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
86eb025c
Commit
86eb025c
authored
Mar 02, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/components/call/CallModel): handle auto answer
parent
1e83bd74
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
10 deletions
+55
-10
CallModel.cpp
linphone-desktop/src/components/call/CallModel.cpp
+35
-1
CallModel.hpp
linphone-desktop/src/components/call/CallModel.hpp
+2
-0
Notifier.cpp
linphone-desktop/src/components/notifier/Notifier.cpp
+17
-6
Notifier.hpp
linphone-desktop/src/components/notifier/Notifier.hpp
+1
-1
SettingsModel.cpp
linphone-desktop/src/components/settings/SettingsModel.cpp
+0
-2
No files found.
linphone-desktop/src/components/call/CallModel.cpp
View file @
86eb025c
...
...
@@ -22,6 +22,7 @@
#include <QDateTime>
#include <QtDebug>
#include <QTimer>
#include "../../app/App.hpp"
#include "../../utils.hpp"
...
...
@@ -29,11 +30,28 @@
#include "CallModel.hpp"
#define AUTO_ANSWER_OBJECT_NAME "auto-answer-timer"
// =============================================================================
CallModel
::
CallModel
(
shared_ptr
<
linphone
::
Call
>
linphone_call
)
{
m_linphone_call
=
linphone_call
;
// Deal with auto-answer.
{
SettingsModel
*
settings
=
CoreManager
::
getInstance
()
->
getSettingsModel
();
if
(
settings
->
getAutoAnswerStatus
())
{
QTimer
*
timer
=
new
QTimer
(
this
);
timer
->
setInterval
(
settings
->
getAutoAnswerDelay
());
timer
->
setSingleShot
(
true
);
timer
->
setObjectName
(
AUTO_ANSWER_OBJECT_NAME
);
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
this
,
&
CallModel
::
accept
);
timer
->
start
();
}
}
QObject
::
connect
(
&
(
*
CoreManager
::
getInstance
()
->
getHandlers
()),
&
CoreHandlers
::
callStateChanged
,
this
,
[
this
](
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
)
{
...
...
@@ -41,9 +59,13 @@ CallModel::CallModel (shared_ptr<linphone::Call> linphone_call) {
return
;
switch
(
state
)
{
case
linphone
:
:
CallStateConnected
:
case
linphone
:
:
CallStateEnd
:
case
linphone
:
:
CallStateError
:
stopAutoAnswerTimer
();
m_paused_by_remote
=
false
;
break
;
case
linphone
:
:
CallStateConnected
:
case
linphone
:
:
CallStateRefered
:
case
linphone
:
:
CallStateReleased
:
case
linphone
:
:
CallStateStreamsRunning
:
...
...
@@ -96,6 +118,8 @@ void CallModel::setRecordFile (shared_ptr<linphone::CallParams> &call_params) {
// -----------------------------------------------------------------------------
void
CallModel
::
accept
()
{
stopAutoAnswerTimer
();
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m_linphone_call
);
params
->
enableVideo
(
false
);
...
...
@@ -106,6 +130,8 @@ void CallModel::accept () {
}
void
CallModel
::
acceptWithVideo
()
{
stopAutoAnswerTimer
();
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
shared_ptr
<
linphone
::
CallParams
>
params
=
core
->
createCallParams
(
m_linphone_call
);
params
->
enableVideo
(
true
);
...
...
@@ -180,6 +206,14 @@ void CallModel::stopRecording () {
// -----------------------------------------------------------------------------
void
CallModel
::
stopAutoAnswerTimer
()
const
{
QTimer
*
timer
=
findChild
<
QTimer
*>
(
AUTO_ANSWER_OBJECT_NAME
,
Qt
::
FindDirectChildrenOnly
);
if
(
timer
)
{
timer
->
stop
();
timer
->
deleteLater
();
}
}
QString
CallModel
::
getSipAddress
()
const
{
return
::
Utils
::
linphoneStringToQString
(
m_linphone_call
->
getRemoteAddress
()
->
asStringUriOnly
());
}
...
...
linphone-desktop/src/components/call/CallModel.hpp
View file @
86eb025c
...
...
@@ -86,6 +86,8 @@ signals:
void
recordingChanged
(
bool
status
);
private:
void
stopAutoAnswerTimer
()
const
;
QString
getSipAddress
()
const
;
CallStatus
getStatus
()
const
;
...
...
linphone-desktop/src/components/notifier/Notifier.cpp
View file @
86eb025c
...
...
@@ -111,8 +111,10 @@ Notifier::~Notifier () {
QObject
*
Notifier
::
createNotification
(
Notifier
::
NotificationType
type
)
{
m_mutex
.
lock
();
Q_ASSERT
(
m_n_instances
<=
N_MAX_NOTIFICATIONS
);
// Check existing instances.
if
(
m_n_instances
>
=
N_MAX_NOTIFICATIONS
)
{
if
(
m_n_instances
=
=
N_MAX_NOTIFICATIONS
)
{
qWarning
()
<<
"Unable to create another notification"
;
m_mutex
.
unlock
();
return
nullptr
;
...
...
@@ -148,12 +150,12 @@ void Notifier::showNotification (QObject *notification, int timeout) {
// Destroy it after timeout.
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
this
,
[
this
,
notification
]()
{
qDebug
()
<<
"toto"
;
deleteNotification
(
QVariant
::
fromValue
(
notification
));
}
);
// Called explicitly (by a click on notification for example)
// or when single shot happen and if notification is visible.
QObject
::
connect
(
notification
,
SIGNAL
(
deleteNotification
(
QVariant
)),
this
,
SLOT
(
deleteNotification
(
QVariant
)));
timer
->
start
();
...
...
@@ -162,18 +164,27 @@ void Notifier::showNotification (QObject *notification, int timeout) {
// -----------------------------------------------------------------------------
void
Notifier
::
deleteNotification
(
QVariant
notification
)
{
m_mutex
.
lock
();
QObject
*
instance
=
notification
.
value
<
QObject
*>
();
instance
->
property
(
NOTIFICATION_PROPERTY_TIMER
).
value
<
QTimer
*>
()
->
stop
();
// Notification marked destroyed.
if
(
instance
->
property
(
"__valid"
).
isValid
())
{
m_mutex
.
unlock
();
return
;
}
qDebug
()
<<
"Delete notification."
;
m_mutex
.
lock
();
instance
->
setProperty
(
"__valid"
,
true
);
instance
->
property
(
NOTIFICATION_PROPERTY_TIMER
).
value
<
QTimer
*>
()
->
stop
();
m_n_instances
--
;
if
(
m_n_instances
==
0
)
m_offset
=
0
;
Q_ASSERT
(
m_n_instances
>=
0
);
m_mutex
.
unlock
();
instance
->
deleteLater
();
...
...
@@ -217,7 +228,7 @@ void Notifier::notifyReceivedCall (const shared_ptr<linphone::Call> &call) {
QObject
::
connect
(
model
,
&
CallModel
::
statusChanged
,
notification
,
[
this
,
notification
](
CallModel
::
CallStatus
status
)
{
if
(
status
==
CallModel
::
CallStatusEnded
)
if
(
status
==
CallModel
::
CallStatusEnded
||
status
==
CallModel
::
CallStatusConnected
)
deleteNotification
(
QVariant
::
fromValue
(
notification
));
}
);
...
...
linphone-desktop/src/components/notifier/Notifier.hpp
View file @
86eb025c
...
...
@@ -60,7 +60,7 @@ private:
QQmlComponent
*
m_components
[
MaxNbTypes
];
int
m_offset
=
0
;
unsigned
int
m_n_instances
=
0
;
int
m_n_instances
=
0
;
QMutex
m_mutex
;
};
...
...
linphone-desktop/src/components/settings/SettingsModel.cpp
View file @
86eb025c
...
...
@@ -42,8 +42,6 @@ SettingsModel::SettingsModel (QObject *parent) : QObject(parent) {
// Chat & calls.
// =============================================================================
// -----------------------------------------------------------------------------
int
SettingsModel
::
getAutoAnswerDelay
()
const
{
return
m_config
->
getInt
(
UI_SECTION
,
"auto_answer_delay"
,
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