Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linphone-desktop
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
linphone-desktop
Commits
66a0748f
Commit
66a0748f
authored
Aug 07, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(MessagesCountNotifier): refactoring
parent
6b28a34a
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
219 additions
and
53 deletions
+219
-53
CMakeLists.txt
CMakeLists.txt
+22
-10
App.cpp
src/app/App.cpp
+1
-1
CoreManager.cpp
src/components/core/CoreManager.cpp
+8
-1
AbstractMessagesCountNotifier.cpp
...messages-count-notifier/AbstractMessagesCountNotifier.cpp
+17
-29
AbstractMessagesCountNotifier.hpp
...messages-count-notifier/AbstractMessagesCountNotifier.hpp
+9
-6
MessagesCountNotifierLinux.cpp
...re/messages-count-notifier/MessagesCountNotifierLinux.cpp
+38
-0
MessagesCountNotifierLinux.hpp
...re/messages-count-notifier/MessagesCountNotifierLinux.hpp
+38
-0
MessagesCountNotifierMacOs.hpp
...re/messages-count-notifier/MessagesCountNotifierMacOs.hpp
+36
-0
MessagesCountNotifierMacOs.m
...core/messages-count-notifier/MessagesCountNotifierMacOs.m
+2
-2
MessagesCountNotifierWindows.cpp
.../messages-count-notifier/MessagesCountNotifierWindows.cpp
+34
-0
MessagesCountNotifierWindows.hpp
.../messages-count-notifier/MessagesCountNotifierWindows.hpp
+12
-4
LinphoneUtils.hpp
src/utils/LinphoneUtils.hpp
+2
-0
No files found.
CMakeLists.txt
View file @
66a0748f
...
...
@@ -134,10 +134,10 @@ set(SOURCES
src/components/contacts/ContactsListProxyModel.cpp
src/components/core/CoreHandlers.cpp
src/components/core/CoreManager.cpp
src/components/core/MessagesCountNotifier.cpp
src/components/core/
messages-count-notifier/Abstract
MessagesCountNotifier.cpp
src/components/notifier/Notifier.cpp
src/components/other/colors/Colors.cpp
src/components/other/clipboard/Clipboard.cpp
src/components/other/colors/Colors.cpp
src/components/other/text-to-speech/TextToSpeech.cpp
src/components/other/units/Units.cpp
src/components/presence/OwnPresenceModel.cpp
...
...
@@ -190,10 +190,10 @@ set(HEADERS
src/components/contacts/ContactsListProxyModel.hpp
src/components/core/CoreHandlers.hpp
src/components/core/CoreManager.hpp
src/components/core/MessagesCountNotifier.hpp
src/components/core/
messages-count-notifier/Abstract
MessagesCountNotifier.hpp
src/components/notifier/Notifier.hpp
src/components/other/colors/Colors.hpp
src/components/other/clipboard/Clipboard.hpp
src/components/other/colors/Colors.hpp
src/components/other/text-to-speech/TextToSpeech.hpp
src/components/other/units/Units.hpp
src/components/presence/OwnPresenceModel.hpp
...
...
@@ -226,16 +226,28 @@ set(TESTS
set
(
MAIN_FILE src/app/main.cpp
)
set
(
TESTER_MAIN_FILE src/tests/main.cpp
)
if
(
APPLE
)
list
(
APPEND SOURCES src/components/core/MessagesCountNotifierMacOS.m
)
endif
()
if
(
ENABLE_DBUS
)
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/MessagesCountNotifierWindow.cpp
)
list
(
APPEND HEADERS src/components/core/messages-count-notifier/MessagesCountNotifierWindow.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
)
endif
()
if
(
ENABLE_DBUS
)
list
(
APPEND SOURCES src/app/single-application/SingleApplicationDBus.cpp
)
list
(
APPEND HEADERS src/app/single-application/SingleApplicationDBusPrivate.hpp
)
else
()
else
()
list
(
APPEND SOURCES src/app/single-application/SingleApplication.cpp
)
list
(
APPEND HEADERS src/app/single-application/SingleApplicationPrivate.hpp
)
endif
()
endif
()
set
(
QRC_RESOURCES resources.qrc
)
...
...
src/app/App.cpp
View file @
66a0748f
...
...
@@ -31,6 +31,7 @@
#include "config.h"
#include "../components/Components.hpp"
#include "../utils/LinphoneUtils.hpp"
#include "../utils/Utils.hpp"
#include "cli/Cli.hpp"
...
...
@@ -46,7 +47,6 @@
#define DEFAULT_LOCALE "en"
#define LANGUAGES_PATH ":/languages/"
#define WINDOW_ICON_PATH ":/assets/images/linphone_logo.svg"
// The main windows of Linphone desktop.
#define QML_VIEW_MAIN_WINDOW "qrc:/ui/views/App/Main/MainWindow.qml"
...
...
src/components/core/CoreManager.cpp
View file @
66a0748f
...
...
@@ -27,7 +27,14 @@
#include "../../app/paths/Paths.hpp"
#include "../../utils/Utils.hpp"
#include "MessagesCountNotifier.hpp"
#if defined(Q_OS_LINUX)
#include "messages-count-notifier/MessagesCountNotifierLinux.hpp"
#elif 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)
#include "CoreManager.hpp"
...
...
src/components/core/MessagesCountNotifier.cpp
→
src/components/core/
messages-count-notifier/Abstract
MessagesCountNotifier.cpp
View file @
66a0748f
/*
* MessagesCountNotifier.cpp
*
Abstract
MessagesCountNotifier.cpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
...
...
@@ -20,31 +20,23 @@
* Author: Ronan Abhamon
*/
#include "../
core/
CoreManager.hpp"
#include "../CoreManager.hpp"
#if defined(Q_OS_LINUX)
// TODO.
#elif defined(Q_OS_MACOS)
#include "MessagesCountNotifierMacOS.h"
#elif defined(Q_OS_WIN)
// TODO.
#endif // if defined(Q_OS_LINUX)
#include "MessagesCountNotifier.hpp"
#include "AbstractMessagesCountNotifier.hpp"
using
namespace
std
;
// =============================================================================
MessagesCountNotifier
::
MessagesCountNotifier
(
QObject
*
parent
)
:
QObject
(
parent
)
{
AbstractMessagesCountNotifier
::
Abstract
MessagesCountNotifier
(
QObject
*
parent
)
:
QObject
(
parent
)
{
CoreManager
*
coreManager
=
CoreManager
::
getInstance
();
QObject
::
connect
(
coreManager
,
&
CoreManager
::
chatModelCreated
,
this
,
&
MessagesCountNotifier
::
handleChatModelCreated
this
,
&
Abstract
MessagesCountNotifier
::
handleChatModelCreated
);
QObject
::
connect
(
coreManager
->
getHandlers
().
get
(),
&
CoreHandlers
::
messageReceived
,
this
,
&
MessagesCountNotifier
::
handleMessageReceived
this
,
&
Abstract
MessagesCountNotifier
::
handleMessageReceived
);
updateUnreadMessagesCount
();
...
...
@@ -52,37 +44,33 @@ MessagesCountNotifier::MessagesCountNotifier (QObject *parent) : QObject(parent)
// -----------------------------------------------------------------------------
void
MessagesCountNotifier
::
updateUnreadMessagesCount
()
{
void
AbstractMessagesCountNotifier
::
notifyUnreadMessagesCount
(
int
)
{}
void
AbstractMessagesCountNotifier
::
updateUnreadMessagesCount
()
{
mUnreadMessagesCount
=
0
;
for
(
const
auto
&
chatRoom
:
CoreManager
::
getInstance
()
->
getCore
()
->
getChatRooms
())
mUnreadMessagesCount
+=
chatRoom
->
getUnreadMessagesCount
();
n
otifyUnreadMessagesCount
();
internalN
otifyUnreadMessagesCount
();
}
void
MessagesCountNotifier
::
n
otifyUnreadMessagesCount
()
{
void
AbstractMessagesCountNotifier
::
internalN
otifyUnreadMessagesCount
()
{
qInfo
()
<<
QStringLiteral
(
"Notify unread messages count: %1."
).
arg
(
mUnreadMessagesCount
);
int
count
=
mUnreadMessagesCount
>
99
?
99
:
mUnreadMessagesCount
;
int
n
=
mUnreadMessagesCount
>
99
?
99
:
mUnreadMessagesCount
;
#if defined(Q_OS_LINUX)
(
void
)
count
;
#elif defined(Q_OS_MACOS)
::
notifyUnreadMessagesCountMacOS
(
count
);
#elif defined(Q_OS_WIN)
(
void
)
count
;
#endif // if defined(Q_OS_LINUX)
notifyUnreadMessagesCount
(
n
);
}
// -----------------------------------------------------------------------------
void
MessagesCountNotifier
::
handleChatModelCreated
(
const
shared_ptr
<
ChatModel
>
&
chatModel
)
{
void
Abstract
MessagesCountNotifier
::
handleChatModelCreated
(
const
shared_ptr
<
ChatModel
>
&
chatModel
)
{
QObject
::
connect
(
chatModel
.
get
(),
&
ChatModel
::
messagesCountReset
,
this
,
&
MessagesCountNotifier
::
updateUnreadMessagesCount
this
,
&
Abstract
MessagesCountNotifier
::
updateUnreadMessagesCount
);
}
void
MessagesCountNotifier
::
handleMessageReceived
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
void
Abstract
MessagesCountNotifier
::
handleMessageReceived
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
mUnreadMessagesCount
++
;
n
otifyUnreadMessagesCount
();
internalN
otifyUnreadMessagesCount
();
}
src/components/core/MessagesCountNotifier.hpp
→
src/components/core/
messages-count-notifier/Abstract
MessagesCountNotifier.hpp
View file @
66a0748f
/*
* MessagesCountNotifier.hpp
*
Abstract
MessagesCountNotifier.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
...
...
@@ -27,21 +27,24 @@
// =============================================================================
namespace
linphone
{
class
ChatMessage
;
class
ChatMessage
;
}
class
ChatModel
;
class
MessagesCountNotifier
:
public
QObject
{
class
Abstract
MessagesCountNotifier
:
public
QObject
{
Q_OBJECT
;
public:
MessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
);
~
MessagesCountNotifier
()
=
default
;
AbstractMessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
);
virtual
~
AbstractMessagesCountNotifier
()
=
default
;
protected:
virtual
void
notifyUnreadMessagesCount
(
int
n
)
=
0
;
private:
void
updateUnreadMessagesCount
();
void
n
otifyUnreadMessagesCount
();
void
internalN
otifyUnreadMessagesCount
();
void
handleChatModelCreated
(
const
std
::
shared_ptr
<
ChatModel
>
&
chatModel
);
void
handleMessageReceived
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
...
...
src/components/core/messages-count-notifier/MessagesCountNotifierLinux.cpp
0 → 100644
View file @
66a0748f
/*
* MessagesCountNotifierLinux.hpp
* Copyright (C) 2017 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 <QSvgRenderer>
#include "../../../utils/LinphoneUtils.hpp"
#include "MessagesCountNotifierLinux.hpp"
// =============================================================================
MessagesCountNotifier
::
MessagesCountNotifier
(
QObject
*
parent
)
:
AbstractMessagesCountNotifier
(
parent
)
{
mSvgRenderer
=
new
QSvgRenderer
(
QStringLiteral
(
WINDOW_ICON_PATH
),
this
);
}
void
MessagesCountNotifier
::
notifyUnreadMessagesCount
(
int
n
)
{
// TODO.
(
void
)
n
;
}
src/components/core/messages-count-notifier/MessagesCountNotifierLinux.hpp
0 → 100644
View file @
66a0748f
/*
* MessagesCountNotifierLinux.hpp
* Copyright (C) 2017 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
QSvgRenderer
;
class
MessagesCountNotifier
:
public
AbstractMessagesCountNotifier
{
public:
MessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
);
protected:
void
notifyUnreadMessagesCount
(
int
n
)
override
;
private:
QSvgRenderer
*
mSvgRenderer
=
nullptr
;
};
src/components/core/messages-count-notifier/MessagesCountNotifierMacOs.hpp
0 → 100644
View file @
66a0748f
/*
* MessagesCountNotifierMacOs.hpp
* Copyright (C) 2017 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 30, 2017
* Author: Ghislain MARY
*/
#include "AbstractMessagesCountNotifier.hpp"
extern
"C"
void
notifyUnreadMessagesCountMacOS
(
int
n
);
// =============================================================================
class
MessagesCountNotifier
:
public
AbstractMessagesCountNotifier
{
public:
MessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
)
:
AbstractMessagesCountNotifier
(
parent
)
{}
void
notifyUnreadMessagesCount
(
int
n
)
override
{
::
notifyUnreadMessagesCountMacOS
(
n
);
}
};
src/components/core/
MessagesCountNotifierMacOS
.m
→
src/components/core/
messages-count-notifier/MessagesCountNotifierMacOs
.m
View file @
66a0748f
...
...
@@ -24,7 +24,7 @@
// =============================================================================
void
notifyUnreadMessagesCountMacOS
(
int
count
)
{
NSString
*
badgeStr
=
(
count
>
0
)
?
[
NSString
stringWithFormat
:
@"%d"
,
count
]
:
@""
;
void
notifyUnreadMessagesCountMacOS
(
int
n
)
{
NSString
*
badgeStr
=
(
n
>
0
)
?
[
NSString
stringWithFormat
:
@"%d"
,
n
]
:
@""
;
[[
NSApp
dockTile
]
setBadgeLabel
:
badgeStr
];
}
src/components/core/messages-count-notifier/MessagesCountNotifierWindows.cpp
0 → 100644
View file @
66a0748f
/*
* MessagesCountNotifierWindows.cpp
* Copyright (C) 2017 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.
(
void
)
n
;
}
src/components/core/
MessagesCountNotifierMacOS.h
→
src/components/core/
messages-count-notifier/MessagesCountNotifierWindows.hpp
View file @
66a0748f
/*
* MessagesCountNotifier
MacOS.h
* MessagesCountNotifier
Windows.hpp
* Copyright (C) 2017 Belledonne Communications, Grenoble, France
*
* This program is free software; you can redistribute it and/or
...
...
@@ -16,10 +16,18 @@
* 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 30
, 2017
* Author:
Ghislain MARY
* Created on:
August 7
, 2017
* Author:
Ronan Abhamon
*/
#include "AbstractMessagesCountNotifier.hpp"
// =============================================================================
extern
"C"
void
notifyUnreadMessagesCountMacOS
(
int
count
);
class
MessagesCountNotifier
:
public
AbstractMessagesCountNotifier
{
public:
MessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
);
protected:
void
notifyUnreadMessagesCount
(
int
n
)
override
;
};
src/utils/LinphoneUtils.hpp
View file @
66a0748f
...
...
@@ -28,6 +28,8 @@
// =============================================================================
#define WINDOW_ICON_PATH ":/assets/images/linphone_logo.svg"
#define VU_MIN (-20.f)
#define VU_MAX (4.f)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment