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
bd1b7e72
Commit
bd1b7e72
authored
Jan 03, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app):
- supports message received notification - provide a way to test app focus
parent
f181b6d6
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
30 deletions
+82
-30
resources.qrc
tests/resources.qrc
+1
-0
App.cpp
tests/src/app/App.cpp
+8
-1
App.hpp
tests/src/app/App.hpp
+16
-10
CoreHandlers.cpp
tests/src/components/core/CoreHandlers.cpp
+15
-9
CoreHandlers.hpp
tests/src/components/core/CoreHandlers.hpp
+3
-3
Notifier.cpp
tests/src/components/notifier/Notifier.cpp
+15
-2
Notifier.hpp
tests/src/components/notifier/Notifier.hpp
+11
-1
SipAddressesModel.cpp
tests/src/components/sip-addresses/SipAddressesModel.cpp
+0
-2
TimelineModel.cpp
tests/src/components/timeline/TimelineModel.cpp
+1
-2
ReceivedMessageNotification.qml
...es/Linphone/Notifications/ReceivedMessageNotification.qml
+12
-0
No files found.
tests/resources.qrc
View file @
bd1b7e72
...
@@ -210,6 +210,7 @@
...
@@ -210,6 +210,7 @@
<file>
ui/modules/Linphone/Contact/Contact.qml
</file>
<file>
ui/modules/Linphone/Contact/Contact.qml
</file>
<file>
ui/modules/Linphone/Notifications/CallNotification.qml
</file>
<file>
ui/modules/Linphone/Notifications/CallNotification.qml
</file>
<file>
ui/modules/Linphone/Notifications/Notification.qml
</file>
<file>
ui/modules/Linphone/Notifications/Notification.qml
</file>
<file>
ui/modules/Linphone/Notifications/ReceivedMessageNotification.qml
</file>
<file>
ui/modules/Linphone/Presence/PresenceLevel.qml
</file>
<file>
ui/modules/Linphone/Presence/PresenceLevel.qml
</file>
<file>
ui/modules/Linphone/Presence/PresenceString.qml
</file>
<file>
ui/modules/Linphone/Presence/PresenceString.qml
</file>
<file>
ui/modules/Linphone/qmldir
</file>
<file>
ui/modules/Linphone/qmldir
</file>
...
...
tests/src/app/App.cpp
View file @
bd1b7e72
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
#include "../components/chat/ChatProxyModel.hpp"
#include "../components/chat/ChatProxyModel.hpp"
#include "../components/contacts/ContactsListProxyModel.hpp"
#include "../components/contacts/ContactsListProxyModel.hpp"
#include "../components/core/CoreManager.hpp"
#include "../components/core/CoreManager.hpp"
#include "../components/notifier/Notifier.hpp"
#include "../components/settings/AccountSettingsModel.hpp"
#include "../components/settings/AccountSettingsModel.hpp"
#include "../components/timeline/TimelineModel.hpp"
#include "../components/timeline/TimelineModel.hpp"
#include "../components/smart-search-bar/SmartSearchBarModel.hpp"
#include "../components/smart-search-bar/SmartSearchBarModel.hpp"
...
@@ -60,6 +59,14 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
...
@@ -60,6 +59,14 @@ App::App (int &argc, char **argv) : QApplication(argc, argv) {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
bool
App
::
hasFocus
()
const
{
QQmlApplicationEngine
&
engine
=
const_cast
<
QQmlApplicationEngine
&>
(
m_engine
);
const
QQuickWindow
*
root
=
qobject_cast
<
QQuickWindow
*>
(
engine
.
rootObjects
().
at
(
0
));
return
!!
root
->
activeFocusItem
();
}
// -----------------------------------------------------------------------------
void
App
::
initContentApp
()
{
void
App
::
initContentApp
()
{
qInfo
()
<<
"Initializing core manager..."
;
qInfo
()
<<
"Initializing core manager..."
;
...
...
tests/src/app/App.hpp
View file @
bd1b7e72
...
@@ -6,17 +6,31 @@
...
@@ -6,17 +6,31 @@
#include <QQmlFileSelector>
#include <QQmlFileSelector>
#include <QSystemTrayIcon>
#include <QSystemTrayIcon>
#include "../components/notifier/Notifier.hpp"
#include "AvatarProvider.hpp"
#include "AvatarProvider.hpp"
#include "DefaultTranslator.hpp"
#include "DefaultTranslator.hpp"
class
Notifier
;
// =============================================================================
// =============================================================================
class
App
:
public
QApplication
{
class
App
:
public
QApplication
{
Q_OBJECT
;
Q_OBJECT
;
public:
public:
QQmlEngine
*
getEngine
()
{
return
&
m_engine
;
}
Notifier
*
getNotifier
()
const
{
return
m_notifier
;
}
bool
hasFocus
()
const
;
Q_INVOKABLE
QString
locale
()
const
{
return
m_locale
;
}
static
void
init
(
int
&
argc
,
char
**
argv
)
{
static
void
init
(
int
&
argc
,
char
**
argv
)
{
if
(
!
m_instance
)
{
if
(
!
m_instance
)
{
// Instance must be exists before content.
// Instance must be exists before content.
...
@@ -29,14 +43,6 @@ public:
...
@@ -29,14 +43,6 @@ public:
return
m_instance
;
return
m_instance
;
}
}
QQmlEngine
*
getEngine
()
{
return
&
m_engine
;
}
Q_INVOKABLE
QString
locale
()
const
{
return
m_locale
;
}
private:
private:
App
(
int
&
argc
,
char
**
argv
);
App
(
int
&
argc
,
char
**
argv
);
~
App
()
=
default
;
~
App
()
=
default
;
...
...
tests/src/components/core/CoreHandlers.cpp
View file @
bd1b7e72
#include <QtDebug>
#include <QtDebug>
#include "../../app/App.hpp"
#include "CoreManager.hpp"
#include "CoreManager.hpp"
#include "CoreHandlers.hpp"
#include "CoreHandlers.hpp"
...
@@ -9,26 +10,31 @@ using namespace std;
...
@@ -9,26 +10,31 @@ using namespace std;
// =============================================================================
// =============================================================================
void
CoreHandlers
::
onAuthenticationRequested
(
void
CoreHandlers
::
onAuthenticationRequested
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
lc
,
const
std
::
shared_ptr
<
linphone
::
Core
>
&
,
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth_info
,
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
,
linphone
::
AuthMethod
method
linphone
::
AuthMethod
)
{
)
{
qDebug
()
<<
"Auth request"
;
qDebug
()
<<
"Auth request"
;
}
}
void
CoreHandlers
::
onCallStateChanged
(
void
CoreHandlers
::
onCallStateChanged
(
const
shared_ptr
<
linphone
::
Core
>
&
lc
,
const
shared_ptr
<
linphone
::
Core
>
&
,
const
shared_ptr
<
linphone
::
Call
>
&
call
,
const
shared_ptr
<
linphone
::
Call
>
&
,
linphone
::
CallState
cstate
,
linphone
::
CallState
,
const
string
&
message
const
string
&
)
{
)
{
qDebug
()
<<
"call"
;
qDebug
()
<<
"call"
;
}
}
void
CoreHandlers
::
onMessageReceived
(
void
CoreHandlers
::
onMessageReceived
(
const
shared_ptr
<
linphone
::
Core
>
&
lc
,
const
shared_ptr
<
linphone
::
Core
>
&
,
const
shared_ptr
<
linphone
::
ChatRoom
>
&
room
,
const
shared_ptr
<
linphone
::
ChatRoom
>
&
room
,
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
const
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
)
{
CoreManager
::
getInstance
()
->
getSipAddressesModel
()
->
handleReceivedMessage
(
room
,
message
);
CoreManager
*
core
=
CoreManager
::
getInstance
();
core
->
getSipAddressesModel
()
->
handleReceivedMessage
(
room
,
message
);
const
App
*
app
=
App
::
getInstance
();
if
(
!
app
->
hasFocus
())
app
->
getNotifier
()
->
notifyReceivedMessage
(
10000
,
room
,
message
);
}
}
tests/src/components/core/CoreHandlers.hpp
View file @
bd1b7e72
...
@@ -8,20 +8,20 @@
...
@@ -8,20 +8,20 @@
class
CoreHandlers
:
public
linphone
::
CoreListener
{
class
CoreHandlers
:
public
linphone
::
CoreListener
{
public:
public:
void
onAuthenticationRequested
(
void
onAuthenticationRequested
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
lc
,
const
std
::
shared_ptr
<
linphone
::
Core
>
&
core
,
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth_info
,
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
auth_info
,
linphone
::
AuthMethod
method
linphone
::
AuthMethod
method
)
override
;
)
override
;
void
onCallStateChanged
(
void
onCallStateChanged
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
lc
,
const
std
::
shared_ptr
<
linphone
::
Core
>
&
core
,
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
cstate
,
linphone
::
CallState
cstate
,
const
std
::
string
&
message
const
std
::
string
&
message
)
override
;
)
override
;
void
onMessageReceived
(
void
onMessageReceived
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
lc
,
const
std
::
shared_ptr
<
linphone
::
Core
>
&
core
,
const
std
::
shared_ptr
<
linphone
::
ChatRoom
>
&
room
,
const
std
::
shared_ptr
<
linphone
::
ChatRoom
>
&
room
,
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
override
;
)
override
;
...
...
tests/src/components/notifier/Notifier.cpp
View file @
bd1b7e72
...
@@ -13,7 +13,8 @@
...
@@ -13,7 +13,8 @@
#define NOTIFICATION_HEIGHT_PROPERTY "notificationHeight"
#define NOTIFICATION_HEIGHT_PROPERTY "notificationHeight"
#define NOTIFICATION_OFFSET_PROPERTY_NAME "notificationOffset"
#define NOTIFICATION_OFFSET_PROPERTY_NAME "notificationOffset"
#define QML_NOTIFICATION_PATH "qrc:/ui/modules/Linphone/Notifications/CallNotification.qml"
#define QML_CALL_NOTIFICATION_PATH "qrc:/ui/modules/Linphone/Notifications/CallNotification.qml"
#define QML_MESSAGE_RECEIVED_NOTIFICATION_PATH "qrc:/ui/modules/Linphone/Notifications/ReceivedMessageNotification.qml"
// Arbitrary hardcoded values.
// Arbitrary hardcoded values.
#define NOTIFICATION_SPACING 10
#define NOTIFICATION_SPACING 10
...
@@ -54,7 +55,8 @@ Notifier::Notifier (QObject *parent) :
...
@@ -54,7 +55,8 @@ Notifier::Notifier (QObject *parent) :
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
QQmlEngine
*
engine
=
App
::
getInstance
()
->
getEngine
();
// Build components.
// Build components.
m_components
[
Notifier
::
Call
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_NOTIFICATION_PATH
));
m_components
[
Notifier
::
Call
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_CALL_NOTIFICATION_PATH
));
m_components
[
Notifier
::
MessageReceived
]
=
new
QQmlComponent
(
engine
,
QUrl
(
QML_MESSAGE_RECEIVED_NOTIFICATION_PATH
));
// Check errors.
// Check errors.
for
(
int
i
=
0
;
i
<
Notifier
::
MaxNbTypes
;
++
i
)
{
for
(
int
i
=
0
;
i
<
Notifier
::
MaxNbTypes
;
++
i
)
{
...
@@ -148,6 +150,17 @@ void Notifier::showNotification (QObject *notification, int timeout) {
...
@@ -148,6 +150,17 @@ void Notifier::showNotification (QObject *notification, int timeout) {
// -----------------------------------------------------------------------------
// -----------------------------------------------------------------------------
void
Notifier
::
notifyReceivedMessage
(
int
timeout
,
const
std
::
shared_ptr
<
linphone
::
ChatRoom
>
&
room
,
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
)
{
QObject
*
object
=
createNotification
(
Notifier
::
MessageReceived
);
if
(
object
)
showNotification
(
object
,
timeout
);
}
void
Notifier
::
showCallMessage
(
int
timeout
,
const
QString
&
)
{
void
Notifier
::
showCallMessage
(
int
timeout
,
const
QString
&
)
{
QObject
*
object
=
createNotification
(
Notifier
::
Call
);
QObject
*
object
=
createNotification
(
Notifier
::
Call
);
...
...
tests/src/components/notifier/Notifier.hpp
View file @
bd1b7e72
#ifndef NOTIFIER_H_
#ifndef NOTIFIER_H_
#define NOTIFIER_H_
#define NOTIFIER_H_
#include <linphone++/linphone.hh>
#include <QMutex>
#include <QMutex>
#include <QObject>
#include <QObject>
...
@@ -17,10 +19,18 @@ public:
...
@@ -17,10 +19,18 @@ public:
enum
NotificationType
{
enum
NotificationType
{
Call
,
Call
,
MessageReceived
,
MaxNbTypes
MaxNbTypes
};
};
Q_INVOKABLE
void
showCallMessage
(
int
timeout
,
const
QString
&
sip_address
);
void
notifyReceivedMessage
(
int
timeout
,
const
std
::
shared_ptr
<
linphone
::
ChatRoom
>
&
room
,
const
std
::
shared_ptr
<
linphone
::
ChatMessage
>
&
message
);
// TODO
void
showCallMessage
(
int
timeout
,
const
QString
&
);
private:
private:
QObject
*
createNotification
(
NotificationType
type
);
QObject
*
createNotification
(
NotificationType
type
);
...
...
tests/src/components/sip-addresses/SipAddressesModel.cpp
View file @
bd1b7e72
...
@@ -213,8 +213,6 @@ void SipAddressesModel::addOrUpdateSipAddress (const QString &sip_address, Conta
...
@@ -213,8 +213,6 @@ void SipAddressesModel::addOrUpdateSipAddress (const QString &sip_address, Conta
m_refs
<<
&
m_sip_addresses
[
sip_address
];
m_refs
<<
&
m_sip_addresses
[
sip_address
];
endInsertRows
();
endInsertRows
();
emit
dataChanged
(
index
(
row
,
0
),
index
(
row
,
0
));
}
}
void
SipAddressesModel
::
removeContactOfSipAddress
(
const
QString
&
sip_address
)
{
void
SipAddressesModel
::
removeContactOfSipAddress
(
const
QString
&
sip_address
)
{
...
...
tests/src/components/timeline/TimelineModel.cpp
View file @
bd1b7e72
...
@@ -25,6 +25,5 @@ bool TimelineModel::filterAcceptsRow (int source_row, const QModelIndex &source_
...
@@ -25,6 +25,5 @@ bool TimelineModel::filterAcceptsRow (int source_row, const QModelIndex &source_
}
}
bool
TimelineModel
::
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
{
bool
TimelineModel
::
lessThan
(
const
QModelIndex
&
left
,
const
QModelIndex
&
right
)
const
{
return
sourceModel
()
->
data
(
left
).
toMap
()[
"timestamp"
].
toDateTime
().
toMSecsSinceEpoch
()
>
return
sourceModel
()
->
data
(
left
).
toMap
()[
"timestamp"
]
>
sourceModel
()
->
data
(
right
).
toMap
()[
"timestamp"
];
sourceModel
()
->
data
(
right
).
toMap
()[
"timestamp"
].
toDateTime
().
toMSecsSinceEpoch
();
}
}
tests/ui/modules/Linphone/Notifications/ReceivedMessageNotification.qml
0 → 100644
View file @
bd1b7e72
import
QtQuick
2.7
// =============================================================================
Notification
{
Rectangle
{
color
:
'
red
'
width
:
200
height
:
100
}
}
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