Commit 4a43f00e authored by Simon Morlat's avatar Simon Morlat

Merge branch 'feature/update_sdk'

parents 95245907 d8f1eea6
Pipeline #7390 failed with stages
in 14 minutes and 26 seconds
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
- ccache -s - ccache -s
- export Qt5_DIR=/usr/local/opt/qt/lib/cmake - export Qt5_DIR=/usr/local/opt/qt/lib/cmake
- export PATH=$PATH:/usr/local/opt/qt/bin - 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 - cmake --build WORK/desktop/cmake -- $ADDITIONAL_BUILD_OPTIONS
- codesign --verbose -s "$MACOS_SIGNING_IDENTITY" WORK/desktop/Build/linphone_package/Linphone-*.dmg
- ccache -s - ccache -s
artifacts: artifacts:
...@@ -87,4 +88,4 @@ job-macosx-deploy: ...@@ -87,4 +88,4 @@ job-macosx-deploy:
- job-macosx-ninja - job-macosx-ninja
script: script:
- scp WORK/desktop/Build/linphone_package/$PACKAGE_NAME-*-mac.dmg $DEPLOY_SERVER:$MACOSX_UPLOAD_DIRECTORY/ - scp WORK/desktop/Build/linphone_package/$PACKAGE_NAME-*-mac.dmg $DEPLOY_SERVER:$MACOSX_UPLOAD_DIRECTORY/
\ No newline at end of file
...@@ -29,4 +29,4 @@ include: ...@@ -29,4 +29,4 @@ include:
stages: stages:
- build - build
- package - package
- deploy - deploy
\ No newline at end of file
...@@ -142,7 +142,7 @@ set(SOURCES ...@@ -142,7 +142,7 @@ set(SOURCES
src/components/contacts/ContactsListProxyModel.cpp src/components/contacts/ContactsListProxyModel.cpp
src/components/core/CoreHandlers.cpp src/components/core/CoreHandlers.cpp
src/components/core/CoreManager.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/FileDownloader.cpp
src/components/file/FileExtractor.cpp src/components/file/FileExtractor.cpp
src/components/notifier/Notifier.cpp src/components/notifier/Notifier.cpp
...@@ -200,7 +200,7 @@ set(HEADERS ...@@ -200,7 +200,7 @@ set(HEADERS
src/components/contacts/ContactsListProxyModel.hpp src/components/contacts/ContactsListProxyModel.hpp
src/components/core/CoreHandlers.hpp src/components/core/CoreHandlers.hpp
src/components/core/CoreManager.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/FileDownloader.hpp
src/components/file/FileExtractor.hpp src/components/file/FileExtractor.hpp
src/components/notifier/Notifier.hpp src/components/notifier/Notifier.hpp
...@@ -230,37 +230,37 @@ set(MAIN_FILE src/app/main.cpp) ...@@ -230,37 +230,37 @@ set(MAIN_FILE src/app/main.cpp)
if (APPLE) if (APPLE)
list(APPEND SOURCES list(APPEND SOURCES
src/app/single-application/SingleApplication.cpp 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/DesktopToolsMacOs.cpp
src/components/other/desktop-tools/screen-saver/ScreenSaverMacOs.m src/components/other/desktop-tools/screen-saver/ScreenSaverMacOs.m
) )
list(APPEND HEADERS list(APPEND HEADERS
src/app/single-application/SingleApplicationPrivate.hpp 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 src/components/other/desktop-tools/DesktopToolsMacOs.hpp
) )
elseif (WIN32) elseif (WIN32)
list(APPEND SOURCES list(APPEND SOURCES
src/app/single-application/SingleApplication.cpp 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 src/components/other/desktop-tools/DesktopToolsWindows.cpp
) )
list(APPEND HEADERS list(APPEND HEADERS
src/app/single-application/SingleApplicationPrivate.hpp 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 src/components/other/desktop-tools/DesktopToolsWindows.hpp
) )
else () else ()
list(APPEND SOURCES list(APPEND SOURCES
src/app/single-application/SingleApplicationDBus.cpp 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/DesktopToolsLinux.cpp
src/components/other/desktop-tools/screen-saver/ScreenSaverDBus.cpp src/components/other/desktop-tools/screen-saver/ScreenSaverDBus.cpp
src/components/other/desktop-tools/screen-saver/ScreenSaverXdg.cpp src/components/other/desktop-tools/screen-saver/ScreenSaverXdg.cpp
) )
list(APPEND HEADERS list(APPEND HEADERS
src/app/single-application/SingleApplicationDBusPrivate.hpp 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/DesktopToolsLinux.hpp
src/components/other/desktop-tools/screen-saver/ScreenSaverDBus.hpp src/components/other/desktop-tools/screen-saver/ScreenSaverDBus.hpp
src/components/other/desktop-tools/screen-saver/ScreenSaverXdg.hpp src/components/other/desktop-tools/screen-saver/ScreenSaverXdg.hpp
......
set(APPLICATION_DESCRIPTION "A libre SIP client") set(APPLICATION_DESCRIPTION "A libre SIP client")
set(APPLICATION_ID "com.belledonnecommunications.linphone")
set(APPLICATION_NAME Linphone) set(APPLICATION_NAME Linphone)
set(APPLICATION_URL "https://www.linphone.org") set(APPLICATION_URL "https://www.linphone.org")
set(APPLICATION_VENDOR "Belledonne Communications") set(APPLICATION_VENDOR "Belledonne Communications")
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
<array> <array>
<dict> <dict>
<key>CFBundleURLName</key> <key>CFBundleURLName</key>
<string>com.belledonnecommunications.linphone</string> <string>@APPLICATION_ID@</string>
<key>CFBundleURLSchemes</key> <key>CFBundleURLSchemes</key>
<array> <array>
<string>sip</string> <string>sip</string>
......
Subproject commit a46331c82ce16a427bf486f029af34e9c50d7c9c Subproject commit 44380577a36e41c5e9226328dac64e7b27c4d0fc
...@@ -76,13 +76,13 @@ namespace { ...@@ -76,13 +76,13 @@ namespace {
constexpr char AssistantViewName[] = "Assistant"; constexpr char AssistantViewName[] = "Assistant";
#ifdef Q_OS_LINUX #ifdef Q_OS_LINUX
QString AutoStartDirectory( const QString AutoStartDirectory(QDir::homePath().append(QStringLiteral("/.config/autostart/")));
QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).at(0) + QLatin1String("/autostart/")
);
#elif defined(Q_OS_MACOS) #elif defined(Q_OS_MACOS)
QString OsascriptExecutable("osascript"); const QString OsascriptExecutable(QStringLiteral("osascript"));
#else #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 #endif // ifdef Q_OS_LINUX
} }
...@@ -673,7 +673,9 @@ void App::setAutoStart (bool enabled) { ...@@ -673,7 +673,9 @@ void App::setAutoStart (bool enabled) {
return; 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 (!enabled) {
if (file.exists() && !file.remove()) { if (file.exists() && !file.remove()) {
...@@ -691,20 +693,25 @@ void App::setAutoStart (bool enabled) { ...@@ -691,20 +693,25 @@ void App::setAutoStart (bool enabled) {
return; 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" "[Desktop Entry]\n"
"Name=" APPLICATION_NAME "\n" "Name=" APPLICATION_NAME "\n"
"GenericName=SIP Phone\n" "GenericName=SIP Phone\n"
"Comment=" APPLICATION_DESCRIPTION "\n" "Comment=" APPLICATION_DESCRIPTION "\n"
"Type=Application\n" "Type=Application\n"
"Exec=" + applicationFilePath() + "\n" "Exec=" + exec + "\n"
"Icon=\n" "Icon=\n"
"Terminal=false\n" "Terminal=false\n"
"Categories=Network;Telephony;\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" "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; mAutoStart = enabled;
emit autoStartChanged(enabled); emit autoStartChanged(enabled);
......
...@@ -88,11 +88,11 @@ CallModel::~CallModel () { ...@@ -88,11 +88,11 @@ CallModel::~CallModel () {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
QString CallModel::getPeerAddress () const { QString CallModel::getPeerAddress () const {
return Utils::coreStringToAppString(mCall->getRemoteAddress()->asString()); return Utils::coreStringToAppString(mCall->getRemoteAddress()->asStringUriOnly());
} }
QString CallModel::getLocalAddress () const { QString CallModel::getLocalAddress () const {
return Utils::coreStringToAppString(mCall->getCallLog()->getFromAddress()->asString()); return Utils::coreStringToAppString(mCall->getCallLog()->getLocalAddress()->asStringUriOnly());
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -131,7 +131,6 @@ void CallsListModel::launchVideoCall (const QString &sipAddress) const { ...@@ -131,7 +131,6 @@ void CallsListModel::launchVideoCall (const QString &sipAddress) const {
return; return;
shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr); shared_ptr<linphone::CallParams> params = core->createCallParams(nullptr);
params->enableEarlyMediaSending(true);
params->enableVideo(true); params->enableVideo(true);
CallModel::setRecordFile(params, Utils::coreStringToAppString(address->getUsername())); CallModel::setRecordFile(params, Utils::coreStringToAppString(address->getUsername()));
...@@ -192,6 +191,8 @@ void CallsListModel::handleCallStateChanged (const shared_ptr<linphone::Call> &c ...@@ -192,6 +191,8 @@ void CallsListModel::handleCallStateChanged (const shared_ptr<linphone::Call> &c
case linphone::Call::State::End: case linphone::Call::State::End:
case linphone::Call::State::Error: case linphone::Call::State::Error:
if (call->getCallLog()->getStatus() == linphone::Call::Status::Missed)
emit callMissed(&call->getData<CallModel>("call-model"));
removeCall(call); removeCall(call);
break; break;
......
...@@ -55,6 +55,8 @@ signals: ...@@ -55,6 +55,8 @@ signals:
void callRunning (int index, CallModel *callModel); void callRunning (int index, CallModel *callModel);
void callTransferAsked (CallModel *callModel); void callTransferAsked (CallModel *callModel);
void callMissed (CallModel *callModel);
private: private:
bool removeRow (int row, const QModelIndex &parent = QModelIndex()); bool removeRow (int row, const QModelIndex &parent = QModelIndex());
bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override; bool removeRows (int row, int count, const QModelIndex &parent = QModelIndex()) override;
......
...@@ -117,6 +117,8 @@ signals: ...@@ -117,6 +117,8 @@ signals:
void messageCountReset (); void messageCountReset ();
void focused ();
private: private:
typedef QPair<QVariantMap, std::shared_ptr<void>> ChatEntryData; typedef QPair<QVariantMap, std::shared_ptr<void>> ChatEntryData;
......
...@@ -194,6 +194,7 @@ void ChatProxyModel::reload () { ...@@ -194,6 +194,7 @@ void ChatProxyModel::reload () {
if (mChatModel) { if (mChatModel) {
mChatModel->resetMessageCount(); mChatModel->resetMessageCount();
mChatModel->focused();
ChatModel *chatModel = mChatModel.get(); ChatModel *chatModel = mChatModel.get();
QObject::connect(chatModel, &ChatModel::isRemoteComposingChanged, this, &ChatProxyModel::handleIsRemoteComposingChanged); QObject::connect(chatModel, &ChatModel::isRemoteComposingChanged, this, &ChatProxyModel::handleIsRemoteComposingChanged);
...@@ -217,8 +218,10 @@ static inline QWindow *getParentWindow (QObject *object) { ...@@ -217,8 +218,10 @@ static inline QWindow *getParentWindow (QObject *object) {
} }
void ChatProxyModel::handleIsActiveChanged (QWindow *window) { void ChatProxyModel::handleIsActiveChanged (QWindow *window) {
if (mChatModel && window->isActive() && getParentWindow(this) == window) if (mChatModel && window->isActive() && getParentWindow(this) == window) {
mChatModel->resetMessageCount(); mChatModel->resetMessageCount();
mChatModel->focused();
}
} }
void ChatProxyModel::handleIsRemoteComposingChanged (bool status) { void ChatProxyModel::handleIsRemoteComposingChanged (bool status) {
......
...@@ -39,9 +39,9 @@ ...@@ -39,9 +39,9 @@
#include "utils/Utils.hpp" #include "utils/Utils.hpp"
#if defined(Q_OS_MACOS) #if defined(Q_OS_MACOS)
#include "messages-count-notifier/MessageCountNotifierMacOs.hpp" #include "event-count-notifier/EventCountNotifierMacOs.hpp"
#else #else
#include "messages-count-notifier/MessageCountNotifierSystemTrayIcon.hpp" #include "event-count-notifier/EventCountNotifierSystemTrayIcon.hpp"
#endif // if defined(Q_OS_MACOS) #endif // if defined(Q_OS_MACOS)
#include "CoreHandlers.hpp" #include "CoreHandlers.hpp"
...@@ -90,13 +90,13 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) : ...@@ -90,13 +90,13 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) :
mInstance->mSipAddressesModel = new SipAddressesModel(mInstance); mInstance->mSipAddressesModel = new SipAddressesModel(mInstance);
{ {
MessageCountNotifier *messageCountNotifier = new MessageCountNotifier(mInstance); EventCountNotifier *eventCountNotifier = new EventCountNotifier(mInstance);
messageCountNotifier->updateUnreadMessageCount(); eventCountNotifier->updateUnreadMessageCount();
QObject::connect( QObject::connect(
messageCountNotifier, &MessageCountNotifier::unreadMessageCountChanged, eventCountNotifier, &EventCountNotifier::eventCountChanged,
mInstance, &CoreManager::unreadMessageCountChanged mInstance, &CoreManager::eventCountChanged
); );
mInstance->mMessageCountNotifier = messageCountNotifier; mInstance->mEventCountNotifier = eventCountNotifier;
} }
mInstance->migrate(); mInstance->migrate();
...@@ -319,8 +319,8 @@ QString CoreManager::getVersion () const { ...@@ -319,8 +319,8 @@ QString CoreManager::getVersion () const {
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
int CoreManager::getUnreadMessageCount () const { int CoreManager::getEventCount () const {
return mMessageCountNotifier ? mMessageCountNotifier->getUnreadMessageCount() : 0; return mEventCountNotifier ? mEventCountNotifier->getEventCount() : 0;
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
......
...@@ -35,7 +35,7 @@ class CallsListModel; ...@@ -35,7 +35,7 @@ class CallsListModel;
class ChatModel; class ChatModel;
class ContactsListModel; class ContactsListModel;
class CoreHandlers; class CoreHandlers;
class MessageCountNotifier; class EventCountNotifier;
class SettingsModel; class SettingsModel;
class SipAddressesModel; class SipAddressesModel;
class VcardModel; class VcardModel;
...@@ -45,7 +45,7 @@ class CoreManager : public QObject { ...@@ -45,7 +45,7 @@ class CoreManager : public QObject {
Q_PROPERTY(QString version READ getVersion CONSTANT); Q_PROPERTY(QString version READ getVersion CONSTANT);
Q_PROPERTY(QString downloadUrl READ getDownloadUrl 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: public:
bool started () const { bool started () const {
...@@ -137,7 +137,7 @@ signals: ...@@ -137,7 +137,7 @@ signals:
void logsUploaded (const QString &url); void logsUploaded (const QString &url);
void unreadMessageCountChanged (int count); void eventCountChanged (int count);
private: private:
CoreManager (QObject *parent, const QString &configPath); CoreManager (QObject *parent, const QString &configPath);
...@@ -151,7 +151,7 @@ private: ...@@ -151,7 +151,7 @@ private:
QString getVersion () const; QString getVersion () const;
int getUnreadMessageCount () const; int getEventCount () const;
void iterate (); void iterate ();
...@@ -170,7 +170,7 @@ private: ...@@ -170,7 +170,7 @@ private:
SettingsModel *mSettingsModel = nullptr; SettingsModel *mSettingsModel = nullptr;
AccountSettingsModel *mAccountSettingsModel = nullptr; AccountSettingsModel *mAccountSettingsModel = nullptr;
MessageCountNotifier *mMessageCountNotifier = nullptr; EventCountNotifier *mEventCountNotifier = nullptr;
QHash<QPair<QString, QString>, std::weak_ptr<ChatModel>> mChatModels; QHash<QPair<QString, QString>, std::weak_ptr<ChatModel>> mChatModels;
......
/* /*
* AbstractMessageCountNotifier.cpp * AbstractEventCountNotifier.cpp
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -20,53 +20,79 @@ ...@@ -20,53 +20,79 @@
* Author: Ronan Abhamon * Author: Ronan Abhamon
*/ */
#include "components/call/CallModel.hpp"
#include "components/calls/CallsListModel.hpp"
#include "components/chat/ChatModel.hpp" #include "components/chat/ChatModel.hpp"
#include "components/core/CoreHandlers.hpp" #include "components/core/CoreHandlers.hpp"
#include "components/core/CoreManager.hpp" #include "components/core/CoreManager.hpp"
#include "components/settings/SettingsModel.hpp" #include "components/settings/SettingsModel.hpp"
#include "AbstractMessageCountNotifier.hpp" #include "AbstractEventCountNotifier.hpp"
// ============================================================================= // =============================================================================
using namespace std; using namespace std;
AbstractMessageCountNotifier::AbstractMessageCountNotifier (QObject *parent) : QObject(parent) { AbstractEventCountNotifier::AbstractEventCountNotifier (QObject *parent) : QObject(parent) {
CoreManager *coreManager = CoreManager::getInstance(); CoreManager *coreManager = CoreManager::getInstance();
QObject::connect( QObject::connect(
coreManager, &CoreManager::chatModelCreated, coreManager, &CoreManager::chatModelCreated,
this, &AbstractMessageCountNotifier::handleChatModelCreated this, &AbstractEventCountNotifier::handleChatModelCreated
); );
QObject::connect( QObject::connect(
coreManager->getHandlers().get(), &CoreHandlers::messageReceived, coreManager->getHandlers().get(), &CoreHandlers::messageReceived,
this, &AbstractMessageCountNotifier::updateUnreadMessageCount this, &AbstractEventCountNotifier::updateUnreadMessageCount
); );
QObject::connect( QObject::connect(
coreManager->getSettingsModel(), &SettingsModel::chatEnabledChanged, coreManager->getSettingsModel(), &SettingsModel::chatEnabledChanged,
this, &AbstractMessageCountNotifier::internalNotifyUnreadMessageCount this, &AbstractEventCountNotifier::internalnotifyEventCount
);
QObject::connect(
coreManager->getCallsListModel(), &CallsListModel::callMissed,
this, &AbstractEventCountNotifier::handleCallMissed
); );
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AbstractMessageCountNotifier::updateUnreadMessageCount () { void AbstractEventCountNotifier::updateUnreadMessageCount () {
mUnreadMessageCount = CoreManager::getInstance()->getCore()->getUnreadChatMessageCountFromActiveLocals(); mUnreadMessageCount = CoreManager::getInstance()->getCore()->getUnreadChatMessageCountFromActiveLocals();
internalNotifyUnreadMessageCount(); internalnotifyEventCount();
} }
void AbstractMessageCountNotifier::internalNotifyUnreadMessageCount () { void AbstractEventCountNotifier::internalnotifyEventCount () {
qInfo() << QStringLiteral("Notify unread messages count: %1.").arg(mUnreadMessageCount); int n = mUnreadMessageCount + getMissedCallCount();
int n = mUnreadMessageCount > 99 ? 99 : mUnreadMessageCount; qInfo() << QStringLiteral("Notify event count: %1.").arg(n);
n = n > 99 ? 99 : n;
notifyUnreadMessageCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() ? n : 0); notifyEventCount(CoreManager::getInstance()->getSettingsModel()->getChatEnabled() ? n : 0);
unreadMessageCountChanged(mUnreadMessageCount); emit eventCountChanged(mUnreadMessageCount);
} }
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
void AbstractMessageCountNotifier::handleChatModelCreated (const shared_ptr<ChatModel> &chatModel) { void AbstractEventCountNotifier::handleChatModelCreated (const shared_ptr<ChatModel> &chatModel) {
ChatModel *chatModelPtr = chatModel.get();
QObject::connect(
chatModelPtr, &ChatModel::messageCountReset,
this, &AbstractEventCountNotifier::updateUnreadMessageCount
);
QObject::connect( QObject::connect(
chatModel.get(), &ChatModel::messageCountReset, chatModelPtr, &ChatModel::focused,
this, &AbstractMessageCountNotifier::updateUnreadMessageCount 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();
}
/* /*
* AbstractMessageCountNotifier.hpp * AbstractEventCountNotifier.hpp
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -20,12 +20,14 @@ ...@@ -20,12 +20,14 @@
* Author: Ronan Abhamon * Author: Ronan Abhamon
*/ */
#ifndef ABSTRACT_MESSAGE_COUNT_NOTIFIER_H_ #ifndef ABSTRACT_EVENT_COUNT_NOTIFIER_H_
#define ABSTRACT_MESSAGE_COUNT_NOTIFIER_H_ #define ABSTRACT_EVENT_COUNT_NOTIFIER_H_
#include <memory> #include <memory>
#include <QHash>
#include <QObject> #include <QObject>
#include <QPair>
// ============================================================================= // =============================================================================
...@@ -33,32 +35,44 @@ namespace linphone { ...@@ -33,32 +35,44 @@ namespace linphone {
class ChatMessage; class ChatMessage;
} }
class CallModel;
class ChatModel; class ChatModel;
class AbstractMessageCountNotifier : public QObject { class AbstractEventCountNotifier : public QObject {
Q_OBJECT; Q_OBJECT;
public: public:
AbstractMessageCountNotifier (QObject *parent = Q_NULLPTR); AbstractEventCountNotifier (QObject *parent = Q_NULLPTR);
void updateUnreadMessageCount (); void updateUnreadMessageCount ();
int getUnreadMessageCount () const { int getUnreadMessageCount () const { return mUnreadMessageCount; }
return mUnreadMessageCount; int getMissedCallCount () const {
int t = 0;
for (int n : mMissedCalls) t += n;
return t;
} }
int getEventCount () const { return mUnreadMessageCount + getMissedCallCount(); }
signals: signals:
void unreadMessageCountChanged (int count); void eventCountChanged (int count);
protected: protected:
virtual void notifyUnreadMessageCount (int n) = 0; virtual void notifyEventCount (int n) = 0;
private: private:
void internalNotifyUnreadMessageCount (); using ConferenceId = QPair<QString, QString>;
void internalnotifyEventCount ();
void handleChatModelCreated (const std::shared_ptr<ChatModel> &chatModel); void handleChatModelCreated (const std::shared_ptr<ChatModel> &chatModel);
void handleChatModelFocused (ChatModel *chatModel);
void handleCallMissed (CallModel *callModel);
QHash<ConferenceId, int> mMissedCalls;
int mUnreadMessageCount = 0; int mUnreadMessageCount = 0;
}; };
#endif // ABSTRACT_MESSAGE_COUNT_NOTIFIER_H_ #endif // ABSTRACT_EVENT_COUNT_NOTIFIER_H_
/* /*
* MessageCountNotifierMacOs.hpp * EventCountNotifierMacOs.hpp
* Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France * Copyright (C) 2017-2018 Belledonne Communications, Grenoble, France
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
...@@ -20,22 +20,22 @@ ...@@ -20,22 +20,22 @@
* Author: Ghislain MARY