From efa3e10776be1eb906228ee0effadbf055f6d233 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 21 Jun 2018 16:55:41 +0200 Subject: [PATCH] feat(DesktopTools): add skeletions for MacOs and GNU/Linux --- CMakeLists.txt | 30 ++++++++++-- .../other/desktop-tools/DesktopTools.hpp | 29 ++++------- .../other/desktop-tools/DesktopToolsLinux.cpp | 43 ++++++++++++++++ .../other/desktop-tools/DesktopToolsLinux.hpp | 49 +++++++++++++++++++ .../other/desktop-tools/DesktopToolsMacOs.cpp | 43 ++++++++++++++++ .../other/desktop-tools/DesktopToolsMacOs.hpp | 49 +++++++++++++++++++ ...sktopTools.cpp => DesktopToolsWindows.cpp} | 27 ++-------- .../desktop-tools/DesktopToolsWindows.hpp | 49 +++++++++++++++++++ submodules/linphone | 2 +- 9 files changed, 273 insertions(+), 48 deletions(-) create mode 100644 src/components/other/desktop-tools/DesktopToolsLinux.cpp create mode 100644 src/components/other/desktop-tools/DesktopToolsLinux.hpp create mode 100644 src/components/other/desktop-tools/DesktopToolsMacOs.cpp create mode 100644 src/components/other/desktop-tools/DesktopToolsMacOs.hpp rename src/components/other/desktop-tools/{DesktopTools.cpp => DesktopToolsWindows.cpp} (78%) create mode 100644 src/components/other/desktop-tools/DesktopToolsWindows.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dee234b81..561e8e449 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,7 +147,6 @@ set(SOURCES src/components/notifier/Notifier.cpp src/components/other/clipboard/Clipboard.cpp src/components/other/colors/Colors.cpp - src/components/other/desktop-tools/DesktopTools.cpp src/components/other/text-to-speech/TextToSpeech.cpp src/components/other/units/Units.cpp src/components/presence/OwnPresenceModel.cpp @@ -228,11 +227,32 @@ set(HEADERS set(MAIN_FILE src/app/main.cpp) if (APPLE) - list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.m) - list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp) + list(APPEND SOURCES + src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.m + src/components/other/desktop-tools/DesktopToolsMacOs.cpp + ) + list(APPEND HEADERS + src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp + src/components/other/desktop-tools/DesktopToolsMacOs.hpp + ) +elseif (WIN32) + list(APPEND SOURCES + src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp + src/components/other/desktop-tools/DesktopToolsWindows.cpp + ) + list(APPEND HEADERS + src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp + src/components/other/desktop-tools/DesktopToolsWindows.hpp + ) else () - list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp) - list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp) + list(APPEND SOURCES + src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp + src/components/other/desktop-tools/DesktopToolsLinux.cpp + ) + list(APPEND HEADERS + src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp + src/components/other/desktop-tools/DesktopToolsLinux.hpp + ) endif () if (ENABLE_DBUS) diff --git a/src/components/other/desktop-tools/DesktopTools.hpp b/src/components/other/desktop-tools/DesktopTools.hpp index 101cabd85..ca04d11ec 100644 --- a/src/components/other/desktop-tools/DesktopTools.hpp +++ b/src/components/other/desktop-tools/DesktopTools.hpp @@ -23,27 +23,16 @@ #ifndef DESKTOP_TOOLS_H_ #define DESKTOP_TOOLS_H_ -#include +#include + +#ifdef Q_OS_LINUX + #include "DesktopToolsLinux.hpp" +#elif defined(Q_OS_WIN) + #include "DesktopToolsWindows.hpp" +#else + #include "DesktopToolsMacOs.hpp" +#endif // ifdef Q_OS_LINUX // ============================================================================= -class DesktopTools : public QObject { - Q_OBJECT; - - Q_PROPERTY(bool screenSaverStatus READ getScreenSaverStatus WRITE setScreenSaverStatus NOTIFY screenSaverStatusChanged); - -public: - DesktopTools (QObject *parent = Q_NULLPTR); - ~DesktopTools (); - - bool getScreenSaverStatus () const; - void setScreenSaverStatus (bool status); - -signals: - void screenSaverStatusChanged (bool status); - -private: - bool mScreenSaverStatus = true; -}; - #endif // DESKTOP_TOOLS_H_ diff --git a/src/components/other/desktop-tools/DesktopToolsLinux.cpp b/src/components/other/desktop-tools/DesktopToolsLinux.cpp new file mode 100644 index 000000000..614879d92 --- /dev/null +++ b/src/components/other/desktop-tools/DesktopToolsLinux.cpp @@ -0,0 +1,43 @@ +/* + * DesktopToolsLinux.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 "DesktopToolsLinux.hpp" + +// ============================================================================= + +DesktopTools::DesktopTools (QObject *parent) : QObject(parent) {} + +DesktopTools::~DesktopTools () { + setScreenSaverStatus(true); +} + +bool DesktopTools::getScreenSaverStatus () const { + return mScreenSaverStatus; +} + +void DesktopTools::setScreenSaverStatus (bool status) { + if (status == mScreenSaverStatus) + return; + + // TODO: Deal with me. + emit screenSaverStatusChanged(status); +} diff --git a/src/components/other/desktop-tools/DesktopToolsLinux.hpp b/src/components/other/desktop-tools/DesktopToolsLinux.hpp new file mode 100644 index 000000000..65f7ae2e7 --- /dev/null +++ b/src/components/other/desktop-tools/DesktopToolsLinux.hpp @@ -0,0 +1,49 @@ +/* + * DesktopToolsLinux.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: June 21, 2018 + * Author: Ronan Abhamon + */ + +#ifndef DESKTOP_TOOLS_LINUX_H_ +#define DESKTOP_TOOLS_LINUX_H_ + +#include + +// ============================================================================= + +class DesktopTools : public QObject { + Q_OBJECT; + + Q_PROPERTY(bool screenSaverStatus READ getScreenSaverStatus WRITE setScreenSaverStatus NOTIFY screenSaverStatusChanged); + +public: + DesktopTools (QObject *parent = Q_NULLPTR); + ~DesktopTools (); + + bool getScreenSaverStatus () const; + void setScreenSaverStatus (bool status); + +signals: + void screenSaverStatusChanged (bool status); + +private: + bool mScreenSaverStatus = true; +}; + +#endif // DESKTOP_TOOLS_LINUX_H_ diff --git a/src/components/other/desktop-tools/DesktopToolsMacOs.cpp b/src/components/other/desktop-tools/DesktopToolsMacOs.cpp new file mode 100644 index 000000000..4a85e1dbe --- /dev/null +++ b/src/components/other/desktop-tools/DesktopToolsMacOs.cpp @@ -0,0 +1,43 @@ +/* + * DesktopToolsMacOs.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 "DesktopToolsMacOs.hpp" + +// ============================================================================= + +DesktopTools::DesktopTools (QObject *parent) : QObject(parent) {} + +DesktopTools::~DesktopTools () { + setScreenSaverStatus(true); +} + +bool DesktopTools::getScreenSaverStatus () const { + return mScreenSaverStatus; +} + +void DesktopTools::setScreenSaverStatus (bool status) { + if (status == mScreenSaverStatus) + return; + + // TODO: Deal with me. + emit screenSaverStatusChanged(status); +} diff --git a/src/components/other/desktop-tools/DesktopToolsMacOs.hpp b/src/components/other/desktop-tools/DesktopToolsMacOs.hpp new file mode 100644 index 000000000..a61655d4c --- /dev/null +++ b/src/components/other/desktop-tools/DesktopToolsMacOs.hpp @@ -0,0 +1,49 @@ +/* + * DesktopToolsMacOs.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: June 21, 2018 + * Author: Ronan Abhamon + */ + +#ifndef DESKTOP_TOOLS_MAC_OS_H_ +#define DESKTOP_TOOLS_MAC_OS_H_ + +#include + +// ============================================================================= + +class DesktopTools : public QObject { + Q_OBJECT; + + Q_PROPERTY(bool screenSaverStatus READ getScreenSaverStatus WRITE setScreenSaverStatus NOTIFY screenSaverStatusChanged); + +public: + DesktopTools (QObject *parent = Q_NULLPTR); + ~DesktopTools (); + + bool getScreenSaverStatus () const; + void setScreenSaverStatus (bool status); + +signals: + void screenSaverStatusChanged (bool status); + +private: + bool mScreenSaverStatus = true; +}; + +#endif // DESKTOP_TOOLS_MAC_OS_H_ diff --git a/src/components/other/desktop-tools/DesktopTools.cpp b/src/components/other/desktop-tools/DesktopToolsWindows.cpp similarity index 78% rename from src/components/other/desktop-tools/DesktopTools.cpp rename to src/components/other/desktop-tools/DesktopToolsWindows.cpp index fe59113ad..4c9b6930d 100644 --- a/src/components/other/desktop-tools/DesktopTools.cpp +++ b/src/components/other/desktop-tools/DesktopToolsWindows.cpp @@ -1,5 +1,5 @@ /* - * DesktopTools.cpp + * DesktopToolsWindows.cpp * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * * This program is free software; you can redistribute it and/or @@ -20,14 +20,9 @@ * Author: Ronan Abhamon */ -#include -#include +#include -#ifdef Q_OS_WIN - #include -#endif // ifdef Q_OS_WIN - -#include "DesktopTools.hpp" +#include "DesktopToolsWindows.hpp" // ============================================================================= @@ -41,27 +36,15 @@ bool DesktopTools::getScreenSaverStatus () const { return mScreenSaverStatus; } -#ifdef Q_OS_WIN - void DesktopTools::setScreenSaverStatus (bool status) { if (status == mScreenSaverStatus) return; - if (!status) { - qInfo() << "Disable screen saver."; + if (!status) SetThreadExecutionState(ES_CONTINUOUS | ES_DISPLAY_REQUIRED); - } else { - qInfo() << "Enable screen saver."; + else { SetThreadExecutionState(ES_CONTINUOUS); } emit screenSaverStatusChanged(status); } - -#else - -void DesktopTools::setScreenSaverStatus (bool) { - emit screenSaverStatusChanged(true); -} - -#endif // ifdef Q_OS_WIN diff --git a/src/components/other/desktop-tools/DesktopToolsWindows.hpp b/src/components/other/desktop-tools/DesktopToolsWindows.hpp new file mode 100644 index 000000000..7f5fe28cc --- /dev/null +++ b/src/components/other/desktop-tools/DesktopToolsWindows.hpp @@ -0,0 +1,49 @@ +/* + * DesktopToolsWindows.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: June 21, 2018 + * Author: Ronan Abhamon + */ + +#ifndef DESKTOP_TOOLS_WINDOWS_H_ +#define DESKTOP_TOOLS_WINDOWS_H_ + +#include + +// ============================================================================= + +class DesktopTools : public QObject { + Q_OBJECT; + + Q_PROPERTY(bool screenSaverStatus READ getScreenSaverStatus WRITE setScreenSaverStatus NOTIFY screenSaverStatusChanged); + +public: + DesktopTools (QObject *parent = Q_NULLPTR); + ~DesktopTools (); + + bool getScreenSaverStatus () const; + void setScreenSaverStatus (bool status); + +signals: + void screenSaverStatusChanged (bool status); + +private: + bool mScreenSaverStatus = true; +}; + +#endif // DESKTOP_TOOLS_WINDOWS_H_ diff --git a/submodules/linphone b/submodules/linphone index 64cb3ebcf..bb8c1866b 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 64cb3ebcf69a0d0dfea196cfa14b3627c9112d9b +Subproject commit bb8c1866bb8bdb792b7a4483ad90456781f3ad15