From ef1a3f8dd2cb61198337bf86b427188b03604fe5 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 18 Jun 2018 15:43:09 +0200 Subject: [PATCH] feat(MessagesCountNotifier): notify messages count on Windows with sys tray icon --- CMakeLists.txt | 13 ++----- src/components/core/CoreManager.cpp | 10 +++--- .../AbstractMessagesCountNotifier.hpp | 5 +++ .../MessagesCountNotifierMacOs.hpp | 5 +++ ...> MessagesCountNotifierSystemTrayIcon.cpp} | 4 +-- ...> MessagesCountNotifierSystemTrayIcon.hpp} | 7 +++- .../MessagesCountNotifierWindows.cpp | 34 ------------------- .../MessagesCountNotifierWindows.hpp | 33 ------------------ 8 files changed, 25 insertions(+), 86 deletions(-) rename src/components/core/messages-count-notifier/{MessagesCountNotifierLinux.cpp => MessagesCountNotifierSystemTrayIcon.cpp} (97%) rename src/components/core/messages-count-notifier/{MessagesCountNotifierLinux.hpp => MessagesCountNotifierSystemTrayIcon.hpp} (87%) delete mode 100644 src/components/core/messages-count-notifier/MessagesCountNotifierWindows.cpp delete mode 100644 src/components/core/messages-count-notifier/MessagesCountNotifierWindows.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 9ecefa124..142d4f92d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -225,19 +225,12 @@ set(HEADERS set(MAIN_FILE src/app/main.cpp) -if (UNIX AND NOT APPLE) - list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierLinux.cpp) - list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierLinux.hpp) -endif () - -if (WIN32) - list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierWindows.cpp) - list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierWindows.hpp) -endif () - if (APPLE) list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.m) list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp) +else () + list(APPEND SOURCES src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp) + list(APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp) endif () if (ENABLE_DBUS) diff --git a/src/components/core/CoreManager.cpp b/src/components/core/CoreManager.cpp index 813ce18c2..895897d3e 100644 --- a/src/components/core/CoreManager.cpp +++ b/src/components/core/CoreManager.cpp @@ -35,13 +35,11 @@ #include "components/sip-addresses/SipAddressesModel.hpp" #include "utils/Utils.hpp" -#if defined(Q_OS_LINUX) - #include "messages-count-notifier/MessagesCountNotifierLinux.hpp" -#elif defined(Q_OS_MACOS) +#if defined(Q_OS_MACOS) #include "messages-count-notifier/MessagesCountNotifierMacOs.hpp" -#elif defined(Q_OS_WIN) - #include "messages-count-notifier/MessagesCountNotifierWindows.hpp" -#endif // if defined(Q_OS_LINUX) +#else + #include "messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp" +#endif // if defined(Q_OS_MACOS) #include "CoreHandlers.hpp" #include "CoreManager.hpp" diff --git a/src/components/core/messages-count-notifier/AbstractMessagesCountNotifier.hpp b/src/components/core/messages-count-notifier/AbstractMessagesCountNotifier.hpp index a268dfd83..fc623c0c3 100644 --- a/src/components/core/messages-count-notifier/AbstractMessagesCountNotifier.hpp +++ b/src/components/core/messages-count-notifier/AbstractMessagesCountNotifier.hpp @@ -20,6 +20,9 @@ * Author: Ronan Abhamon */ +#ifndef ABSTRACT_MESSAGES_COUNT_NOTIFIER_H_ +#define ABSTRACT_MESSAGES_COUNT_NOTIFIER_H_ + #include #include @@ -51,3 +54,5 @@ private: int mUnreadMessagesCount = 0; }; + +#endif // ABSTRACT_MESSAGES_COUNT_NOTIFIER_H_ diff --git a/src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp b/src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp index 31c009a5d..f8b28e584 100644 --- a/src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp +++ b/src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp @@ -20,6 +20,9 @@ * Author: Ghislain MARY */ +#ifndef MESSAGES_COUNT_NOTIFIER_MAC_OS_H_ +#define MESSAGES_COUNT_NOTIFIER_MAC_OS_H_ + #include "AbstractMessagesCountNotifier.hpp" extern "C" void notifyUnreadMessagesCountMacOS (int n); @@ -34,3 +37,5 @@ public: notifyUnreadMessagesCountMacOS(n); } }; + +#endif // MESSAGES_COUNT_NOTIFIER_MAC_OS_H_ diff --git a/src/components/core/messages-count-notifier/MessagesCountNotifierLinux.cpp b/src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp similarity index 97% rename from src/components/core/messages-count-notifier/MessagesCountNotifierLinux.cpp rename to src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp index 3c33e74fe..d5dcd3dae 100644 --- a/src/components/core/messages-count-notifier/MessagesCountNotifierLinux.cpp +++ b/src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.cpp @@ -1,5 +1,5 @@ /* - * MessagesCountNotifierLinux.hpp + * MessagesCountNotifierSystemTrayIcon.hpp * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * * This program is free software; you can redistribute it and/or @@ -31,7 +31,7 @@ #include "utils/LinphoneUtils.hpp" #include "utils/Utils.hpp" -#include "MessagesCountNotifierLinux.hpp" +#include "MessagesCountNotifierSystemTrayIcon.hpp" // ============================================================================= diff --git a/src/components/core/messages-count-notifier/MessagesCountNotifierLinux.hpp b/src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp similarity index 87% rename from src/components/core/messages-count-notifier/MessagesCountNotifierLinux.hpp rename to src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp index 6c263a659..2ea533d51 100644 --- a/src/components/core/messages-count-notifier/MessagesCountNotifierLinux.hpp +++ b/src/components/core/messages-count-notifier/MessagesCountNotifierSystemTrayIcon.hpp @@ -1,5 +1,5 @@ /* - * MessagesCountNotifierLinux.hpp + * MessagesCountNotifierSystemTrayIcon.hpp * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * * This program is free software; you can redistribute it and/or @@ -20,6 +20,9 @@ * Author: Ronan Abhamon */ +#ifndef MESSAGES_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ +#define MESSAGES_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ + #include "AbstractMessagesCountNotifier.hpp" // ============================================================================= @@ -42,3 +45,5 @@ private: QTimer *mBlinkTimer = nullptr; bool mDisplayCounter = false; }; + +#endif // MESSAGES_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ diff --git a/src/components/core/messages-count-notifier/MessagesCountNotifierWindows.cpp b/src/components/core/messages-count-notifier/MessagesCountNotifierWindows.cpp deleted file mode 100644 index 37dde1bac..000000000 --- a/src/components/core/messages-count-notifier/MessagesCountNotifierWindows.cpp +++ /dev/null @@ -1,34 +0,0 @@ -/* - * MessagesCountNotifierWindows.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: August 7, 2017 - * Author: Ronan Abhamon - */ - -#include "MessagesCountNotifierWindows.hpp" - -// ============================================================================= - -MessagesCountNotifier::MessagesCountNotifier (QObject *parent) : AbstractMessagesCountNotifier(parent) { - // TODO. -} - -void MessagesCountNotifier::notifyUnreadMessagesCount (int n) { - // TODO. - Q_UNUSED(n); -} diff --git a/src/components/core/messages-count-notifier/MessagesCountNotifierWindows.hpp b/src/components/core/messages-count-notifier/MessagesCountNotifierWindows.hpp deleted file mode 100644 index 67c158445..000000000 --- a/src/components/core/messages-count-notifier/MessagesCountNotifierWindows.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * MessagesCountNotifierWindows.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: August 7, 2017 - * Author: Ronan Abhamon - */ - -#include "AbstractMessagesCountNotifier.hpp" - -// ============================================================================= - -class MessagesCountNotifier : public AbstractMessagesCountNotifier { -public: - MessagesCountNotifier (QObject *parent = Q_NULLPTR); - -protected: - void notifyUnreadMessagesCount (int n) override; -};