From b8405e24bddc381b10043f62c9dc72820300fe2b Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 7 Jan 2019 14:28:35 +0100 Subject: [PATCH 1/5] chore(.gitlab-ci.yml): sign mac os package --- .gitlab-ci-files/job-macosx.yml | 5 +++-- .gitlab-ci.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci-files/job-macosx.yml b/.gitlab-ci-files/job-macosx.yml index 5da3bac75..0289a5600 100644 --- a/.gitlab-ci-files/job-macosx.yml +++ b/.gitlab-ci-files/job-macosx.yml @@ -9,8 +9,9 @@ - ccache -s - export Qt5_DIR=/usr/local/opt/qt/lib/cmake - export PATH=$PATH:/usr/local/opt/qt/bin - - python prepare.py -G "$CMAKE_GENERATOR" -cc --package $DEFAULT_MACOS_CMAKE_OPTIONS $CMAKE_OPTIONS + - python prepare.py -G "$CMAKE_GENERATOR" -cc --package -DLINPHONE_BUILDER_SIGNING_IDENTITY="$MACOS_SIGNING_IDENTITY" $DEFAULT_MACOS_CMAKE_OPTIONS $CMAKE_OPTIONS - cmake --build WORK/desktop/cmake -- $ADDITIONAL_BUILD_OPTIONS + - codesign --verbose -s "$MACOS_SIGNING_IDENTITY" WORK/desktop/Build/linphone_package/Linphone-*.dmg - ccache -s artifacts: @@ -72,4 +73,4 @@ job-macosx-xcode: - WORK/desktop/Build/linphone_package/Linphone-*.dmg - WORK/desktop/Build/linphone_package/linphone-sdk-*-mac.zip when: always - expire_in: 1 week \ No newline at end of file + expire_in: 1 week diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2bbfd2f80..2384efd4c 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -29,4 +29,4 @@ include: stages: - build - package - - deploy \ No newline at end of file + - deploy From 7d9ead5b7f53d0d9d04f0809ca6df75e791ea0e7 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Mon, 21 Jan 2019 15:06:19 +0100 Subject: [PATCH 2/5] feat(app): deal with autostart on flatpak --- application_info.cmake | 1 + .../linphone_package/macos/Info.plist.in | 2 +- src/app/App.cpp | 27 ++++++++++++------- src/config.h.cmake | 3 ++- 4 files changed, 21 insertions(+), 12 deletions(-) diff --git a/application_info.cmake b/application_info.cmake index 617e2a8ad..9d7375c39 100644 --- a/application_info.cmake +++ b/application_info.cmake @@ -1,4 +1,5 @@ set(APPLICATION_DESCRIPTION "A libre SIP client") +set(APPLICATION_ID "com.belledonnecommunications.linphone") set(APPLICATION_NAME Linphone) set(APPLICATION_URL "https://www.linphone.org") set(APPLICATION_VENDOR "Belledonne Communications") diff --git a/cmake_builder/linphone_package/macos/Info.plist.in b/cmake_builder/linphone_package/macos/Info.plist.in index ee84b69f1..6e4b7c817 100644 --- a/cmake_builder/linphone_package/macos/Info.plist.in +++ b/cmake_builder/linphone_package/macos/Info.plist.in @@ -36,7 +36,7 @@ CFBundleURLName - com.belledonnecommunications.linphone + @APPLICATION_ID@ CFBundleURLSchemes sip diff --git a/src/app/App.cpp b/src/app/App.cpp index 681f4315d..72886dbbe 100644 --- a/src/app/App.cpp +++ b/src/app/App.cpp @@ -76,13 +76,13 @@ namespace { constexpr char AssistantViewName[] = "Assistant"; #ifdef Q_OS_LINUX - QString AutoStartDirectory( - QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).at(0) + QLatin1String("/autostart/") - ); + const QString AutoStartDirectory(QDir::homePath().append(QStringLiteral("/.config/autostart/"))); #elif defined(Q_OS_MACOS) - QString OsascriptExecutable("osascript"); + const QString OsascriptExecutable(QStringLiteral("osascript")); #else - QString AutoStartSettingsFilePath("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); + const QString AutoStartSettingsFilePath( + QStringLiteral("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run") + ); #endif // ifdef Q_OS_LINUX } @@ -673,7 +673,9 @@ void App::setAutoStart (bool enabled) { return; } - QFile file(AutoStartDirectory + EXECUTABLE_NAME ".desktop"); + const QString confPath(AutoStartDirectory + EXECUTABLE_NAME ".desktop"); + qInfo() << QStringLiteral("Updating `%1`...").arg(confPath); + QFile file(confPath); if (!enabled) { if (file.exists() && !file.remove()) { @@ -691,20 +693,25 @@ void App::setAutoStart (bool enabled) { return; } - QString fileContent( + const QString binPath(applicationFilePath()); + const QString exec( + binPath.startsWith("/app") + ? QStringLiteral("flatpak run " APPLICATION_ID) + : binPath + ); + + QTextStream(&file) << QString( "[Desktop Entry]\n" "Name=" APPLICATION_NAME "\n" "GenericName=SIP Phone\n" "Comment=" APPLICATION_DESCRIPTION "\n" "Type=Application\n" - "Exec=" + applicationFilePath() + "\n" + "Exec=" + exec + "\n" "Icon=\n" "Terminal=false\n" "Categories=Network;Telephony;\n" "MimeType=x-scheme-handler/sip-linphone;x-scheme-handler/sip;x-scheme-handler/sips-linphone;x-scheme-handler/sips;\n" ); - QTextStream out(&file); - out << fileContent; mAutoStart = enabled; emit autoStartChanged(enabled); diff --git a/src/config.h.cmake b/src/config.h.cmake index 7c64f7c94..02462415f 100644 --- a/src/config.h.cmake +++ b/src/config.h.cmake @@ -20,8 +20,9 @@ * *******************************************************************************/ -#cmakedefine APPLICATION_NAME "${APPLICATION_NAME}" #cmakedefine APPLICATION_DESCRIPTION "${APPLICATION_DESCRIPTION}" +#cmakedefine APPLICATION_ID "${APPLICATION_ID}" +#cmakedefine APPLICATION_NAME "${APPLICATION_NAME}" #cmakedefine ENABLE_UPDATE_CHECK 1 #cmakedefine EXECUTABLE_NAME "${EXECUTABLE_NAME}" #cmakedefine MSPLUGINS_DIR "${MSPLUGINS_DIR}" From 39c096fb47b4d54f9b554c8b91a7668c39c5d6d7 Mon Sep 17 00:00:00 2001 From: Anon Date: Fri, 11 Jan 2019 11:51:40 +0100 Subject: [PATCH 3/5] feat(call): display the missed call count in the tray icon + in the account status --- CMakeLists.txt | 16 +-- src/components/call/CallModel.cpp | 4 +- src/components/calls/CallsListModel.cpp | 2 + src/components/calls/CallsListModel.hpp | 2 + src/components/chat/ChatModel.hpp | 2 + src/components/chat/ChatProxyModel.cpp | 5 +- src/components/core/CoreManager.cpp | 18 ++-- src/components/core/CoreManager.hpp | 10 +- .../AbstractEventCountNotifier.cpp | 98 +++++++++++++++++++ .../AbstractEventCountNotifier.hpp} | 36 ++++--- .../EventCountNotifierMacOs.hpp} | 20 ++-- .../EventCountNotifierMacOs.m} | 4 +- .../EventCountNotifierSystemTrayIcon.cpp} | 16 +-- .../EventCountNotifierSystemTrayIcon.hpp} | 18 ++-- .../AbstractMessageCountNotifier.cpp | 72 -------------- .../settings/AccountSettingsModel.cpp | 2 +- ui/modules/Linphone/Account/AccountStatus.qml | 2 +- 17 files changed, 188 insertions(+), 139 deletions(-) create mode 100644 src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp rename src/components/core/{messages-count-notifier/AbstractMessageCountNotifier.hpp => event-count-notifier/AbstractEventCountNotifier.hpp} (58%) rename src/components/core/{messages-count-notifier/MessageCountNotifierMacOs.hpp => event-count-notifier/EventCountNotifierMacOs.hpp} (65%) rename src/components/core/{messages-count-notifier/MessageCountNotifierMacOs.m => event-count-notifier/EventCountNotifierMacOs.m} (93%) rename src/components/core/{messages-count-notifier/MessageCountNotifierSystemTrayIcon.cpp => event-count-notifier/EventCountNotifierSystemTrayIcon.cpp} (86%) rename src/components/core/{messages-count-notifier/MessageCountNotifierSystemTrayIcon.hpp => event-count-notifier/EventCountNotifierSystemTrayIcon.hpp} (72%) delete mode 100644 src/components/core/messages-count-notifier/AbstractMessageCountNotifier.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b9d0501d2..0d27b0fbf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,7 +142,7 @@ set(SOURCES src/components/contacts/ContactsListProxyModel.cpp src/components/core/CoreHandlers.cpp src/components/core/CoreManager.cpp - src/components/core/messages-count-notifier/AbstractMessageCountNotifier.cpp + src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp src/components/file/FileDownloader.cpp src/components/file/FileExtractor.cpp src/components/notifier/Notifier.cpp @@ -200,7 +200,7 @@ set(HEADERS src/components/contacts/ContactsListProxyModel.hpp src/components/core/CoreHandlers.hpp src/components/core/CoreManager.hpp - src/components/core/messages-count-notifier/AbstractMessageCountNotifier.hpp + src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp src/components/file/FileDownloader.hpp src/components/file/FileExtractor.hpp src/components/notifier/Notifier.hpp @@ -230,37 +230,37 @@ set(MAIN_FILE src/app/main.cpp) if (APPLE) list(APPEND SOURCES src/app/single-application/SingleApplication.cpp - src/components/core/messages-count-notifier/MessageCountNotifierMacOs.m + src/components/core/event-count-notifier/EventCountNotifierMacOs.m src/components/other/desktop-tools/DesktopToolsMacOs.cpp src/components/other/desktop-tools/screen-saver/ScreenSaverMacOs.m ) list(APPEND HEADERS src/app/single-application/SingleApplicationPrivate.hpp - src/components/core/messages-count-notifier/MessageCountNotifierMacOs.hpp + src/components/core/event-count-notifier/EventCountNotifierMacOs.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/MessageCountNotifierSystemTrayIcon.cpp + src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp src/components/other/desktop-tools/DesktopToolsWindows.cpp ) list(APPEND HEADERS src/app/single-application/SingleApplicationPrivate.hpp - src/components/core/messages-count-notifier/MessageCountNotifierSystemTrayIcon.hpp + src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp src/components/other/desktop-tools/DesktopToolsWindows.hpp ) else () list(APPEND SOURCES src/app/single-application/SingleApplicationDBus.cpp - src/components/core/messages-count-notifier/MessageCountNotifierSystemTrayIcon.cpp + src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.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/MessageCountNotifierSystemTrayIcon.hpp + src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.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 diff --git a/src/components/call/CallModel.cpp b/src/components/call/CallModel.cpp index 6effeff1a..6fba9a6d6 100644 --- a/src/components/call/CallModel.cpp +++ b/src/components/call/CallModel.cpp @@ -88,11 +88,11 @@ CallModel::~CallModel () { // ----------------------------------------------------------------------------- QString CallModel::getPeerAddress () const { - return Utils::coreStringToAppString(mCall->getRemoteAddress()->asString()); + return Utils::coreStringToAppString(mCall->getRemoteAddress()->asStringUriOnly()); } QString CallModel::getLocalAddress () const { - return Utils::coreStringToAppString(mCall->getCallLog()->getFromAddress()->asString()); + return Utils::coreStringToAppString(mCall->getCallLog()->getLocalAddress()->asStringUriOnly()); } // ----------------------------------------------------------------------------- diff --git a/src/components/calls/CallsListModel.cpp b/src/components/calls/CallsListModel.cpp index b5aba1b59..212fb863f 100644 --- a/src/components/calls/CallsListModel.cpp +++ b/src/components/calls/CallsListModel.cpp @@ -192,6 +192,8 @@ void CallsListModel::handleCallStateChanged (const shared_ptr &c case linphone::Call::State::End: case linphone::Call::State::Error: + if (call->getCallLog()->getStatus() == linphone::Call::Status::Missed) + emit callMissed(&call->getData("call-model")); removeCall(call); break; diff --git a/src/components/calls/CallsListModel.hpp b/src/components/calls/CallsListModel.hpp index 1676108b2..8b61d7f35 100644 --- a/src/components/calls/CallsListModel.hpp +++ b/src/components/calls/CallsListModel.hpp @@ -55,6 +55,8 @@ signals: void callRunning (int index, CallModel *callModel); void callTransferAsked (CallModel *callModel); + void callMissed (CallModel *callModel); + private: bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; diff --git a/src/components/chat/ChatModel.hpp b/src/components/chat/ChatModel.hpp index 1eccd3295..b7e312ed7 100644 --- a/src/components/chat/ChatModel.hpp +++ b/src/components/chat/ChatModel.hpp @@ -117,6 +117,8 @@ signals: void messageCountReset (); + void focused (); + private: typedef QPair> ChatEntryData; diff --git a/src/components/chat/ChatProxyModel.cpp b/src/components/chat/ChatProxyModel.cpp index ee45ecf1b..0a90c4430 100644 --- a/src/components/chat/ChatProxyModel.cpp +++ b/src/components/chat/ChatProxyModel.cpp @@ -194,6 +194,7 @@ void ChatProxyModel::reload () { if (mChatModel) { mChatModel->resetMessageCount(); + mChatModel->focused(); ChatModel *chatModel = mChatModel.get(); QObject::connect(chatModel, &ChatModel::isRemoteComposingChanged, this, &ChatProxyModel::handleIsRemoteComposingChanged); @@ -217,8 +218,10 @@ static inline QWindow *getParentWindow (QObject *object) { } void ChatProxyModel::handleIsActiveChanged (QWindow *window) { - if (mChatModel && window->isActive() && getParentWindow(this) == window) + if (mChatModel && window->isActive() && getParentWindow(this) == window) { mChatModel->resetMessageCount(); + mChatModel->focused(); + } } void ChatProxyModel::handleIsRemoteComposingChanged (bool status) { diff --git a/src/components/core/CoreManager.cpp b/src/components/core/CoreManager.cpp index f68d6ce23..5df6e8db1 100644 --- a/src/components/core/CoreManager.cpp +++ b/src/components/core/CoreManager.cpp @@ -39,9 +39,9 @@ #include "utils/Utils.hpp" #if defined(Q_OS_MACOS) - #include "messages-count-notifier/MessageCountNotifierMacOs.hpp" + #include "event-count-notifier/EventCountNotifierMacOs.hpp" #else - #include "messages-count-notifier/MessageCountNotifierSystemTrayIcon.hpp" + #include "event-count-notifier/EventCountNotifierSystemTrayIcon.hpp" #endif // if defined(Q_OS_MACOS) #include "CoreHandlers.hpp" @@ -90,13 +90,13 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : mInstance->mSipAddressesModel = new SipAddressesModel(mInstance); { - MessageCountNotifier *messageCountNotifier = new MessageCountNotifier(mInstance); - messageCountNotifier->updateUnreadMessageCount(); + EventCountNotifier *eventCountNotifier = new EventCountNotifier(mInstance); + eventCountNotifier->updateUnreadMessageCount(); QObject::connect( - messageCountNotifier, &MessageCountNotifier::unreadMessageCountChanged, - mInstance, &CoreManager::unreadMessageCountChanged + eventCountNotifier, &EventCountNotifier::eventCountChanged, + mInstance, &CoreManager::eventCountChanged ); - mInstance->mMessageCountNotifier = messageCountNotifier; + mInstance->mEventCountNotifier = eventCountNotifier; } mInstance->migrate(); @@ -319,8 +319,8 @@ QString CoreManager::getVersion () const { // ----------------------------------------------------------------------------- -int CoreManager::getUnreadMessageCount () const { - return mMessageCountNotifier ? mMessageCountNotifier->getUnreadMessageCount() : 0; +int CoreManager::getEventCount () const { + return mEventCountNotifier ? mEventCountNotifier->getEventCount() : 0; } // ----------------------------------------------------------------------------- diff --git a/src/components/core/CoreManager.hpp b/src/components/core/CoreManager.hpp index 114a452ea..5c29a28b1 100644 --- a/src/components/core/CoreManager.hpp +++ b/src/components/core/CoreManager.hpp @@ -35,7 +35,7 @@ class CallsListModel; class ChatModel; class ContactsListModel; class CoreHandlers; -class MessageCountNotifier; +class EventCountNotifier; class SettingsModel; class SipAddressesModel; class VcardModel; @@ -45,7 +45,7 @@ class CoreManager : public QObject { Q_PROPERTY(QString version READ getVersion CONSTANT); Q_PROPERTY(QString downloadUrl READ getDownloadUrl CONSTANT); - Q_PROPERTY(int unreadMessageCount READ getUnreadMessageCount NOTIFY unreadMessageCountChanged); + Q_PROPERTY(int eventCount READ getEventCount NOTIFY eventCountChanged); public: bool started () const { @@ -137,7 +137,7 @@ signals: void logsUploaded (const QString &url); - void unreadMessageCountChanged (int count); + void eventCountChanged (int count); private: CoreManager (QObject *parent, const QString &configPath); @@ -151,7 +151,7 @@ private: QString getVersion () const; - int getUnreadMessageCount () const; + int getEventCount () const; void iterate (); @@ -170,7 +170,7 @@ private: SettingsModel *mSettingsModel = nullptr; AccountSettingsModel *mAccountSettingsModel = nullptr; - MessageCountNotifier *mMessageCountNotifier = nullptr; + EventCountNotifier *mEventCountNotifier = nullptr; QHash, std::weak_ptr> mChatModels; diff --git a/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp b/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp new file mode 100644 index 000000000..e03fa5d3d --- /dev/null +++ b/src/components/core/event-count-notifier/AbstractEventCountNotifier.cpp @@ -0,0 +1,98 @@ +/* + * AbstractEventCountNotifier.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 29, 2017 + * Author: Ronan Abhamon + */ + +#include "components/call/CallModel.hpp" +#include "components/calls/CallsListModel.hpp" +#include "components/chat/ChatModel.hpp" +#include "components/core/CoreHandlers.hpp" +#include "components/core/CoreManager.hpp" +#include "components/settings/SettingsModel.hpp" + +#include "AbstractEventCountNotifier.hpp" + +// ============================================================================= + +using namespace std; + +AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObject(parent) { + CoreManager *coreManager = CoreManager::getInstance(); + QObject::connect( + coreManager, &CoreManager::chatModelCreated, + this, &AbstractEventCountNotifier::handleChatModelCreated + ); + QObject::connect( + coreManager->getHandlers().get(), &CoreHandlers::messageReceived, + this, &AbstractEventCountNotifier::updateUnreadMessageCount + ); + QObject::connect( + coreManager->getSettingsModel(), &SettingsModel::chatEnabledChanged, + this, &AbstractEventCountNotifier::internalnotifyEventCount + ); + QObject::connect( + coreManager->getCallsListModel(), &CallsListModel::callMissed, + this, &AbstractEventCountNotifier::handleCallMissed + ); +} + +// ----------------------------------------------------------------------------- + +void AbstractEventCountNotifier::updateUnreadMessageCount () { + mUnreadMessageCount = CoreManager::getInstance()->getCore()->getUnreadChatMessageCountFromActiveLocals(); + internalnotifyEventCount(); +} + +void AbstractEventCountNotifier::internalnotifyEventCount () { + int n = mUnreadMessageCount + getMissedCallCount(); + qInfo() << QStringLiteral("Notify event count: %1.").arg(n); + n = n > 99 ? 99 : n; + + notifyEventCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() ? n : 0); + emit eventCountChanged(mUnreadMessageCount); +} + +// ----------------------------------------------------------------------------- + +void AbstractEventCountNotifier::handleChatModelCreated (const shared_ptr &chatModel) { + ChatModel *chatModelPtr = chatModel.get(); + QObject::connect( + chatModelPtr, &ChatModel::messageCountReset, + this, &AbstractEventCountNotifier::updateUnreadMessageCount + ); + QObject::connect( + chatModelPtr, &ChatModel::focused, + this, [this, chatModelPtr]() { handleChatModelFocused(chatModelPtr); } + ); +} + +void AbstractEventCountNotifier::handleChatModelFocused (ChatModel *chatModel) { + auto it = mMissedCalls.find({ chatModel->getPeerAddress(), chatModel->getLocalAddress() }); + if (it != mMissedCalls.cend()) { + mMissedCalls.erase(it); + internalnotifyEventCount(); + } +} + +void AbstractEventCountNotifier::handleCallMissed (CallModel *callModel) { + Q_UNUSED(callModel); + ++mMissedCalls[{ callModel->getPeerAddress(), callModel->getLocalAddress() }]; + internalnotifyEventCount(); +} diff --git a/src/components/core/messages-count-notifier/AbstractMessageCountNotifier.hpp b/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp similarity index 58% rename from src/components/core/messages-count-notifier/AbstractMessageCountNotifier.hpp rename to src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp index 550d084fa..5ed3d5349 100644 --- a/src/components/core/messages-count-notifier/AbstractMessageCountNotifier.hpp +++ b/src/components/core/event-count-notifier/AbstractEventCountNotifier.hpp @@ -1,5 +1,5 @@ /* - * AbstractMessageCountNotifier.hpp + * AbstractEventCountNotifier.hpp * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * * This program is free software; you can redistribute it and/or @@ -20,12 +20,14 @@ * Author: Ronan Abhamon */ -#ifndef ABSTRACT_MESSAGE_COUNT_NOTIFIER_H_ -#define ABSTRACT_MESSAGE_COUNT_NOTIFIER_H_ +#ifndef ABSTRACT_EVENT_COUNT_NOTIFIER_H_ +#define ABSTRACT_EVENT_COUNT_NOTIFIER_H_ #include +#include #include +#include // ============================================================================= @@ -33,32 +35,44 @@ namespace linphone { class ChatMessage; } +class CallModel; class ChatModel; -class AbstractMessageCountNotifier : public QObject { +class AbstractEventCountNotifier : public QObject { Q_OBJECT; public: - AbstractMessageCountNotifier (QObject *parent = Q_NULLPTR); + AbstractEventCountNotifier (QObject *parent = Q_NULLPTR); void updateUnreadMessageCount (); - int getUnreadMessageCount () const { - return mUnreadMessageCount; + int getUnreadMessageCount () const { return mUnreadMessageCount; } + int getMissedCallCount () const { + int t = 0; + for (int n : mMissedCalls) t += n; + return t; } + int getEventCount () const { return mUnreadMessageCount + getMissedCallCount(); } + signals: - void unreadMessageCountChanged (int count); + void eventCountChanged (int count); protected: - virtual void notifyUnreadMessageCount (int n) = 0; + virtual void notifyEventCount (int n) = 0; private: - void internalNotifyUnreadMessageCount (); + using ConferenceId = QPair; + + void internalnotifyEventCount (); void handleChatModelCreated (const std::shared_ptr &chatModel); + void handleChatModelFocused (ChatModel *chatModel); + void handleCallMissed (CallModel *callModel); + + QHash mMissedCalls; int mUnreadMessageCount = 0; }; -#endif // ABSTRACT_MESSAGE_COUNT_NOTIFIER_H_ +#endif // ABSTRACT_EVENT_COUNT_NOTIFIER_H_ diff --git a/src/components/core/messages-count-notifier/MessageCountNotifierMacOs.hpp b/src/components/core/event-count-notifier/EventCountNotifierMacOs.hpp similarity index 65% rename from src/components/core/messages-count-notifier/MessageCountNotifierMacOs.hpp rename to src/components/core/event-count-notifier/EventCountNotifierMacOs.hpp index 6f21856f9..48e5f126e 100644 --- a/src/components/core/messages-count-notifier/MessageCountNotifierMacOs.hpp +++ b/src/components/core/event-count-notifier/EventCountNotifierMacOs.hpp @@ -1,5 +1,5 @@ /* - * MessageCountNotifierMacOs.hpp + * EventCountNotifierMacOs.hpp * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * * This program is free software; you can redistribute it and/or @@ -20,22 +20,22 @@ * Author: Ghislain MARY */ -#ifndef MESSAGE_COUNT_NOTIFIER_MAC_OS_H_ -#define MESSAGE_COUNT_NOTIFIER_MAC_OS_H_ +#ifndef EVENT_COUNT_NOTIFIER_MAC_OS_H_ +#define EVENT_COUNT_NOTIFIER_MAC_OS_H_ -#include "AbstractMessageCountNotifier.hpp" +#include "AbstractEventCountNotifier.hpp" // ============================================================================= -extern "C" void notifyUnreadMessageCountMacOs (int n); +extern "C" void notifyEventCountMacOs (int n); -class MessageCountNotifier : public AbstractMessageCountNotifier { +class EventCountNotifier : public AbstractEventCountNotifier { public: - MessageCountNotifier (QObject *parent = Q_NULLPTR) : AbstractMessageCountNotifier(parent) {} + EventCountNotifier (QObject *parent = Q_NULLPTR) : AbstractEventCountNotifier(parent) {} - void notifyUnreadMessageCount (int n) override { - notifyUnreadMessageCountMacOs(n); + void notifyEventCount (int n) override { + notifyEventCountMacOs(n); } }; -#endif // MESSAGE_COUNT_NOTIFIER_MAC_OS_H_ +#endif // EVENT_COUNT_NOTIFIER_MAC_OS_H_ diff --git a/src/components/core/messages-count-notifier/MessageCountNotifierMacOs.m b/src/components/core/event-count-notifier/EventCountNotifierMacOs.m similarity index 93% rename from src/components/core/messages-count-notifier/MessageCountNotifierMacOs.m rename to src/components/core/event-count-notifier/EventCountNotifierMacOs.m index 9ecd692d0..7d5d777b1 100644 --- a/src/components/core/messages-count-notifier/MessageCountNotifierMacOs.m +++ b/src/components/core/event-count-notifier/EventCountNotifierMacOs.m @@ -1,5 +1,5 @@ /* - * MessageCountNotifierMacOS.m + * EventCountNotifierMacOs.m * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * * This program is free software; you can redistribute it and/or @@ -24,7 +24,7 @@ // ============================================================================= -void notifyUnreadMessageCountMacOs (int n) { +void notifyEventCountMacOs (int n) { NSString *badgeStr = (n > 0) ? [NSString stringWithFormat:@"%d", n] : @""; [[NSApp dockTile] setBadgeLabel:badgeStr]; } diff --git a/src/components/core/messages-count-notifier/MessageCountNotifierSystemTrayIcon.cpp b/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp similarity index 86% rename from src/components/core/messages-count-notifier/MessageCountNotifierSystemTrayIcon.cpp rename to src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp index 06ebac3ac..345916fb7 100644 --- a/src/components/core/messages-count-notifier/MessageCountNotifierSystemTrayIcon.cpp +++ b/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.cpp @@ -1,5 +1,5 @@ /* - * MessageCountNotifierSystemTrayIcon.hpp + * EventCountNotifierSystemTrayIcon.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 "MessageCountNotifierSystemTrayIcon.hpp" +#include "EventCountNotifierSystemTrayIcon.hpp" // ============================================================================= @@ -46,7 +46,7 @@ namespace { constexpr int IconCounterTextPixelSize = 144; } -MessageCountNotifier::MessageCountNotifier (QObject *parent) : AbstractMessageCountNotifier(parent) { +EventCountNotifier::EventCountNotifier (QObject *parent) : AbstractEventCountNotifier(parent) { QSvgRenderer renderer((QString(LinphoneUtils::WindowIconPath))); if (!renderer.isValid()) qFatal("Invalid SVG Image."); @@ -62,20 +62,20 @@ MessageCountNotifier::MessageCountNotifier (QObject *parent) : AbstractMessageCo mBlinkTimer = new QTimer(this); mBlinkTimer->setInterval(IconCounterBlinkInterval); - QObject::connect(mBlinkTimer, &QTimer::timeout, this, &MessageCountNotifier::update); + QObject::connect(mBlinkTimer, &QTimer::timeout, this, &EventCountNotifier::update); Utils::connectOnce( App::getInstance(), &App::focusWindowChanged, - this, &MessageCountNotifier::updateUnreadMessageCount + this, &EventCountNotifier::updateUnreadMessageCount ); } -MessageCountNotifier::~MessageCountNotifier () { +EventCountNotifier::~EventCountNotifier () { delete mBuf; delete mBufWithCounter; } -void MessageCountNotifier::notifyUnreadMessageCount (int n) { +void EventCountNotifier::notifyEventCount (int n) { QSystemTrayIcon *sysTrayIcon = App::getInstance()->getSystemTrayIcon(); if (!sysTrayIcon) return; @@ -115,7 +115,7 @@ void MessageCountNotifier::notifyUnreadMessageCount (int n) { update(); } -void MessageCountNotifier::update () { +void EventCountNotifier::update () { QSystemTrayIcon *sysTrayIcon = App::getInstance()->getSystemTrayIcon(); Q_CHECK_PTR(sysTrayIcon); sysTrayIcon->setIcon(QIcon(mDisplayCounter ? *mBufWithCounter : *mBuf)); diff --git a/src/components/core/messages-count-notifier/MessageCountNotifierSystemTrayIcon.hpp b/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp similarity index 72% rename from src/components/core/messages-count-notifier/MessageCountNotifierSystemTrayIcon.hpp rename to src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp index 3b1e171a1..61cfcf7f1 100644 --- a/src/components/core/messages-count-notifier/MessageCountNotifierSystemTrayIcon.hpp +++ b/src/components/core/event-count-notifier/EventCountNotifierSystemTrayIcon.hpp @@ -1,5 +1,5 @@ /* - * MessageCountNotifierSystemTrayIcon.hpp + * EventCountNotifierSystemTrayIcon.hpp * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * * This program is free software; you can redistribute it and/or @@ -20,22 +20,22 @@ * Author: Ronan Abhamon */ -#ifndef MESSAGE_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ -#define MESSAGE_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ +#ifndef EVENT_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ +#define EVENT_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ -#include "AbstractMessageCountNotifier.hpp" +#include "AbstractEventCountNotifier.hpp" // ============================================================================= class QTimer; -class MessageCountNotifier : public AbstractMessageCountNotifier { +class EventCountNotifier : public AbstractEventCountNotifier { public: - MessageCountNotifier (QObject *parent = Q_NULLPTR); - ~MessageCountNotifier (); + EventCountNotifier (QObject *parent = Q_NULLPTR); + ~EventCountNotifier (); protected: - void notifyUnreadMessageCount (int n) override; + void notifyEventCount (int n) override; private: void update (); @@ -46,4 +46,4 @@ private: bool mDisplayCounter = false; }; -#endif // MESSAGE_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ +#endif // EVENT_COUNT_NOTIFIER_SYSTEM_TRAY_ICON_H_ diff --git a/src/components/core/messages-count-notifier/AbstractMessageCountNotifier.cpp b/src/components/core/messages-count-notifier/AbstractMessageCountNotifier.cpp deleted file mode 100644 index 2b7fc674b..000000000 --- a/src/components/core/messages-count-notifier/AbstractMessageCountNotifier.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * AbstractMessageCountNotifier.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 29, 2017 - * Author: Ronan Abhamon - */ - -#include "components/chat/ChatModel.hpp" -#include "components/core/CoreHandlers.hpp" -#include "components/core/CoreManager.hpp" -#include "components/settings/SettingsModel.hpp" - -#include "AbstractMessageCountNotifier.hpp" - -// ============================================================================= - -using namespace std; - -AbstractMessageCountNotifier::AbstractMessageCountNotifier (QObject *parent) : QObject(parent) { - CoreManager *coreManager = CoreManager::getInstance(); - QObject::connect( - coreManager, &CoreManager::chatModelCreated, - this, &AbstractMessageCountNotifier::handleChatModelCreated - ); - QObject::connect( - coreManager->getHandlers().get(), &CoreHandlers::messageReceived, - this, &AbstractMessageCountNotifier::updateUnreadMessageCount - ); - QObject::connect( - coreManager->getSettingsModel(), &SettingsModel::chatEnabledChanged, - this, &AbstractMessageCountNotifier::internalNotifyUnreadMessageCount - ); -} - -// ----------------------------------------------------------------------------- - -void AbstractMessageCountNotifier::updateUnreadMessageCount () { - mUnreadMessageCount = CoreManager::getInstance()->getCore()->getUnreadChatMessageCountFromActiveLocals(); - internalNotifyUnreadMessageCount(); -} - -void AbstractMessageCountNotifier::internalNotifyUnreadMessageCount () { - qInfo() << QStringLiteral("Notify unread messages count: %1.").arg(mUnreadMessageCount); - int n = mUnreadMessageCount > 99 ? 99 : mUnreadMessageCount; - - notifyUnreadMessageCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() ? n : 0); - unreadMessageCountChanged(mUnreadMessageCount); -} - -// ----------------------------------------------------------------------------- - -void AbstractMessageCountNotifier::handleChatModelCreated (const shared_ptr &chatModel) { - QObject::connect( - chatModel.get(), &ChatModel::messageCountReset, - this, &AbstractMessageCountNotifier::updateUnreadMessageCount - ); -} diff --git a/src/components/settings/AccountSettingsModel.cpp b/src/components/settings/AccountSettingsModel.cpp index 4843b83f2..276864e1a 100644 --- a/src/components/settings/AccountSettingsModel.cpp +++ b/src/components/settings/AccountSettingsModel.cpp @@ -59,7 +59,7 @@ AccountSettingsModel::AccountSettingsModel (QObject *parent) : QObject(parent) { coreManager->getHandlers().get(), &CoreHandlers::registrationStateChanged, this, &AccountSettingsModel::handleRegistrationStateChanged ); - QObject::connect(coreManager, &CoreManager::unreadMessageCountChanged, this, [this]() { emit accountSettingsUpdated(); }); + QObject::connect(coreManager, &CoreManager::eventCountChanged, this, [this]() { emit accountSettingsUpdated(); }); } // ----------------------------------------------------------------------------- diff --git a/ui/modules/Linphone/Account/AccountStatus.qml b/ui/modules/Linphone/Account/AccountStatus.qml index b273651d0..6d0233642 100644 --- a/ui/modules/Linphone/Account/AccountStatus.qml +++ b/ui/modules/Linphone/Account/AccountStatus.qml @@ -83,7 +83,7 @@ Item { id: messageCounter anchors.fill: parent - count: CoreManager.unreadMessageCount + count: CoreManager.eventCount } } } From 4de95455c30e81326468d126a2f698f3421974b9 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Wed, 23 Jan 2019 17:00:34 +0100 Subject: [PATCH 4/5] fix(calls): disable early media (video) --- src/components/calls/CallsListModel.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/calls/CallsListModel.cpp b/src/components/calls/CallsListModel.cpp index 212fb863f..c3b2d5cea 100644 --- a/src/components/calls/CallsListModel.cpp +++ b/src/components/calls/CallsListModel.cpp @@ -131,7 +131,6 @@ void CallsListModel::launchVideoCall (const QString &sipAddress) const { return; shared_ptr params = core->createCallParams(nullptr); - params->enableEarlyMediaSending(true); params->enableVideo(true); CallModel::setRecordFile(params, Utils::coreStringToAppString(address->getUsername())); From b2764a6de383b78881bac016a09303d67e0ee1dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 13 Feb 2019 16:48:59 +0100 Subject: [PATCH 5/5] Update linphone-sdk (Echo cancelation improvement) --- linphone-sdk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linphone-sdk b/linphone-sdk index a46331c82..44380577a 160000 --- a/linphone-sdk +++ b/linphone-sdk @@ -1 +1 @@ -Subproject commit a46331c82ce16a427bf486f029af34e9c50d7c9c +Subproject commit 44380577a36e41c5e9226328dac64e7b27c4d0fc