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
97a100c7
Commit
97a100c7
authored
Jun 29, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(App): provide a `MessagesCountNotifier` component created by `CoreManager`
parent
15f1d4de
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
147 additions
and
13 deletions
+147
-13
CMakeLists.txt
CMakeLists.txt
+2
-0
ChatModel.cpp
src/components/chat/ChatModel.cpp
+7
-10
ChatModel.hpp
src/components/chat/ChatModel.hpp
+2
-2
ChatProxyModel.cpp
src/components/chat/ChatProxyModel.cpp
+3
-0
CoreManager.cpp
src/components/core/CoreManager.cpp
+3
-0
CoreManager.hpp
src/components/core/CoreManager.hpp
+1
-1
MessagesCountNotifier.cpp
src/components/core/MessagesCountNotifier.cpp
+79
-0
MessagesCountNotifier.hpp
src/components/core/MessagesCountNotifier.hpp
+50
-0
No files found.
CMakeLists.txt
View file @
97a100c7
...
...
@@ -127,6 +127,7 @@ set(SOURCES
src/components/contacts/ContactsListProxyModel.cpp
src/components/core/CoreHandlers.cpp
src/components/core/CoreManager.cpp
src/components/core/MessagesCountNotifier.cpp
src/components/notifier/Notifier.cpp
src/components/other/colors/Colors.cpp
src/components/other/clipboard/Clipboard.cpp
...
...
@@ -181,6 +182,7 @@ set(HEADERS
src/components/contacts/ContactsListProxyModel.hpp
src/components/core/CoreHandlers.hpp
src/components/core/CoreManager.hpp
src/components/core/MessagesCountNotifier.hpp
src/components/notifier/Notifier.hpp
src/components/other/colors/Colors.hpp
src/components/other/clipboard/Clipboard.hpp
...
...
src/components/chat/ChatModel.cpp
View file @
97a100c7
...
...
@@ -272,9 +272,6 @@ void ChatModel::setSipAddress (const QString &sipAddress) {
handleIsComposingChanged
(
mChatRoom
);
if
(
mChatRoom
->
getUnreadMessagesCount
()
>
0
)
resetMessagesCount
();
// Get messages.
for
(
auto
&
message
:
mChatRoom
->
getHistory
(
0
))
{
QVariantMap
map
;
...
...
@@ -461,6 +458,13 @@ void ChatModel::compose () {
mChatRoom
->
compose
();
}
void
ChatModel
::
resetMessagesCount
()
{
if
(
mChatRoom
->
getUnreadMessagesCount
()
>
0
)
{
mChatRoom
->
markAsRead
();
emit
messagesCountReset
();
}
}
// -----------------------------------------------------------------------------
const
ChatModel
::
ChatEntryData
ChatModel
::
getFileMessageEntry
(
int
id
)
{
...
...
@@ -617,11 +621,6 @@ void ChatModel::insertMessageAtEnd (const shared_ptr<linphone::ChatMessage> &mes
endInsertRows
();
}
void
ChatModel
::
resetMessagesCount
()
{
mChatRoom
->
markAsRead
();
emit
messagesCountReset
();
}
// -----------------------------------------------------------------------------
void
ChatModel
::
handleCallStateChanged
(
const
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
)
{
...
...
@@ -645,8 +644,6 @@ void ChatModel::handleIsComposingChanged (const shared_ptr<linphone::ChatRoom> &
void
ChatModel
::
handleMessageReceived
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
if
(
mChatRoom
==
message
->
getChatRoom
())
{
insertMessageAtEnd
(
message
);
resetMessagesCount
();
emit
messageReceived
(
message
);
}
}
src/components/chat/ChatModel.hpp
View file @
97a100c7
...
...
@@ -106,6 +106,8 @@ public:
void
compose
();
void
resetMessagesCount
();
signals:
bool
isRemoteComposingChanged
(
bool
status
);
...
...
@@ -132,8 +134,6 @@ private:
void
insertCall
(
const
std
::
shared_ptr
<
linphone
::
CallLog
>
&
callLog
);
void
insertMessageAtEnd
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
void
resetMessagesCount
();
void
handleCallStateChanged
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
);
void
handleIsComposingChanged
(
const
std
::
shared_ptr
<
linphone
::
ChatRoom
>
&
chatRoom
);
void
handleMessageReceived
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
...
...
src/components/chat/ChatProxyModel.cpp
View file @
97a100c7
...
...
@@ -159,6 +159,8 @@ void ChatProxyModel::setSipAddress (const QString &sipAddress) {
}
mChatModel
=
CoreManager
::
getInstance
()
->
getChatModelFromSipAddress
(
sipAddress
);
mChatModel
->
resetMessagesCount
();
if
(
mChatModel
)
{
ChatModel
*
chatModel
=
mChatModel
.
get
();
QObject
::
connect
(
chatModel
,
&
ChatModel
::
isRemoteComposingChanged
,
this
,
&
ChatProxyModel
::
handleIsRemoteComposingChanged
);
...
...
@@ -181,6 +183,7 @@ void ChatProxyModel::handleIsRemoteComposingChanged (bool status) {
void
ChatProxyModel
::
handleMessageReceived
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
mMaxDisplayedEntries
++
;
mChatModel
->
resetMessagesCount
();
}
void
ChatProxyModel
::
handleMessageSent
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
...
...
src/components/core/CoreManager.cpp
View file @
97a100c7
...
...
@@ -27,6 +27,7 @@
#include "../../app/paths/Paths.hpp"
#include "../../utils/Utils.hpp"
#include "MessagesCountNotifier.hpp"
#include "CoreManager.hpp"
...
...
@@ -54,6 +55,8 @@ CoreManager::CoreManager (QObject *parent, const QString &configPath) :
CoreHandlers
*
coreHandlers
=
mHandlers
.
get
();
QObject
::
connect
(
coreHandlers
,
&
CoreHandlers
::
coreStarted
,
this
,
[]
{
new
MessagesCountNotifier
(
mInstance
);
mInstance
->
mCallsListModel
=
new
CallsListModel
(
mInstance
);
mInstance
->
mContactsListModel
=
new
ContactsListModel
(
mInstance
);
mInstance
->
mSipAddressesModel
=
new
SipAddressesModel
(
mInstance
);
...
...
src/components/core/CoreManager.hpp
View file @
97a100c7
...
...
@@ -127,7 +127,7 @@ signals:
void
coreCreated
();
void
coreStarted
();
void
chatModelCreated
(
const
std
::
shared_ptr
<
ChatModel
>
chatModel
);
void
chatModelCreated
(
const
std
::
shared_ptr
<
ChatModel
>
&
chatModel
);
void
logsUploaded
(
const
QString
&
url
);
...
...
src/components/core/MessagesCountNotifier.cpp
0 → 100644
View file @
97a100c7
/*
* MessagesCountNotifier.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: June 29, 2017
* Author: Ronan Abhamon
*/
#include "../core/CoreManager.hpp"
#include "MessagesCountNotifier.hpp"
using
namespace
std
;
// =============================================================================
MessagesCountNotifier
::
MessagesCountNotifier
(
QObject
*
parent
)
:
QObject
(
parent
)
{
CoreManager
*
coreManager
=
CoreManager
::
getInstance
();
QObject
::
connect
(
coreManager
,
&
CoreManager
::
chatModelCreated
,
this
,
&
MessagesCountNotifier
::
handleChatModelCreated
);
QObject
::
connect
(
coreManager
->
getHandlers
().
get
(),
&
CoreHandlers
::
messageReceived
,
this
,
&
MessagesCountNotifier
::
handleMessageReceived
);
updateUnreadMessagesCount
();
}
// -----------------------------------------------------------------------------
void
MessagesCountNotifier
::
updateUnreadMessagesCount
()
{
mUnreadMessagesCount
=
0
;
for
(
const
auto
&
chatRoom
:
CoreManager
::
getInstance
()
->
getCore
()
->
getChatRooms
())
mUnreadMessagesCount
+=
chatRoom
->
getUnreadMessagesCount
();
notifyUnreadMessagesCount
();
}
void
MessagesCountNotifier
::
notifyUnreadMessagesCount
()
{
qInfo
()
<<
QStringLiteral
(
"Notify unread messages count: %1."
).
arg
(
mUnreadMessagesCount
);
#ifdef Q_OS_LINUX
// TODO.
#elif Q_OS_MACOS
// TODO.
#elif Q_OS_WIN
// TODO.
#endif // ifdef Q_OS_LINUX
}
// -----------------------------------------------------------------------------
void
MessagesCountNotifier
::
handleChatModelCreated
(
const
shared_ptr
<
ChatModel
>
&
chatModel
)
{
QObject
::
connect
(
chatModel
.
get
(),
&
ChatModel
::
messagesCountReset
,
this
,
&
MessagesCountNotifier
::
updateUnreadMessagesCount
);
}
void
MessagesCountNotifier
::
handleMessageReceived
(
const
shared_ptr
<
linphone
::
ChatMessage
>
&
)
{
mUnreadMessagesCount
++
;
notifyUnreadMessagesCount
();
}
src/components/core/MessagesCountNotifier.hpp
0 → 100644
View file @
97a100c7
/*
* MessagesCountNotifier.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 29, 2017
* Author: Ronan Abhamon
*/
#include <memory>
#include <QObject>
// =============================================================================
namespace
linphone
{
class
ChatMessage
;
}
class
ChatModel
;
class
MessagesCountNotifier
:
public
QObject
{
Q_OBJECT
;
public:
MessagesCountNotifier
(
QObject
*
parent
=
Q_NULLPTR
);
~
MessagesCountNotifier
()
=
default
;
private:
void
updateUnreadMessagesCount
();
void
notifyUnreadMessagesCount
();
void
handleChatModelCreated
(
const
std
::
shared_ptr
<
ChatModel
>
&
chatModel
);
void
handleMessageReceived
(
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
int
mUnreadMessagesCount
=
0
;
};
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