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
cc341824
Commit
cc341824
authored
May 11, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(src/components/core/CoreHandlers): do not emit core started until core is not created
parent
e9f59998
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
77 additions
and
18 deletions
+77
-18
App.cpp
linphone-desktop/src/app/App.cpp
+1
-1
CoreHandlers.cpp
linphone-desktop/src/components/core/CoreHandlers.cpp
+53
-16
CoreHandlers.hpp
linphone-desktop/src/components/core/CoreHandlers.hpp
+22
-0
CoreManager.cpp
linphone-desktop/src/components/core/CoreManager.cpp
+1
-1
No files found.
linphone-desktop/src/app/App.cpp
View file @
cc341824
...
...
@@ -442,7 +442,7 @@ QString App::getLocale () const {
void
App
::
openAppAfterInit
()
{
tryToUsePreferredLocale
();
qInfo
()
<<
QStringLiteral
(
"
Linphone core created
."
);
qInfo
()
<<
QStringLiteral
(
"
Open linphone app
."
);
#ifndef __APPLE__
// Enable TrayIconSystem.
...
...
linphone-desktop/src/components/core/CoreHandlers.cpp
View file @
cc341824
...
...
@@ -20,6 +20,7 @@
* Author: Ronan Abhamon
*/
#include <QMutex>
#include <QtDebug>
#include <QThread>
#include <QTimer>
...
...
@@ -34,19 +35,57 @@ using namespace std;
// =============================================================================
// Emit a signal in the app context.
#define emitApp(EMIT) \
do { \
App *app = App::getInstance(); \
if (QThread::currentThread() != app->thread()) { \
QTimer::singleShot( \
0, app, [this]() { \
(EMIT); \
} \
); \
} else \
(EMIT); \
} while (0)
// Schedule a function in app context.
void
scheduleFunctionInApp
(
function
<
void
()
>
func
)
{
App
*
app
=
App
::
getInstance
();
if
(
QThread
::
currentThread
()
!=
app
->
thread
())
{
QTimer
::
singleShot
(
0
,
app
,
func
);
}
else
func
();
}
// -----------------------------------------------------------------------------
CoreHandlers
::
CoreHandlers
(
CoreManager
*
coreManager
)
{
mCoreStartedLock
=
new
QMutex
();
QObject
::
connect
(
coreManager
,
&
CoreManager
::
coreCreated
,
this
,
&
CoreHandlers
::
handleCoreCreated
);
}
CoreHandlers
::~
CoreHandlers
()
{
delete
mCoreStartedLock
;
}
// -----------------------------------------------------------------------------
void
CoreHandlers
::
handleCoreCreated
()
{
mCoreStartedLock
->
lock
();
Q_ASSERT
(
mCoreCreated
==
false
);
mCoreCreated
=
true
;
notifyCoreStarted
();
mCoreStartedLock
->
unlock
();
}
void
CoreHandlers
::
handleCoreStarted
()
{
mCoreStartedLock
->
lock
();
Q_ASSERT
(
mCoreStarted
==
false
);
mCoreStarted
=
true
;
notifyCoreStarted
();
mCoreStartedLock
->
unlock
();
}
void
CoreHandlers
::
notifyCoreStarted
()
{
if
(
mCoreCreated
&&
mCoreStarted
)
scheduleFunctionInApp
(
[
this
]()
{
qInfo
()
<<
QStringLiteral
(
"Core started."
);
emit
coreStarted
();
}
);
}
// -----------------------------------------------------------------------------
...
...
@@ -75,10 +114,8 @@ void CoreHandlers::onGlobalStateChanged (
linphone
::
GlobalState
gstate
,
const
string
&
)
{
qInfo
()
<<
QStringLiteral
(
"Global state: %1."
).
arg
(
gstate
);
if
(
gstate
==
linphone
::
GlobalStateOn
)
emitApp
(
coreStarted
()
);
handleCoreStarted
(
);
}
void
CoreHandlers
::
onCallStatsUpdated
(
...
...
linphone-desktop/src/components/core/CoreHandlers.hpp
View file @
cc341824
...
...
@@ -28,11 +28,18 @@
// =============================================================================
class
CoreManager
;
class
QMutex
;
class
CoreHandlers
:
public
QObject
,
public
linphone
::
CoreListener
{
Q_OBJECT
;
public:
CoreHandlers
(
CoreManager
*
coreManager
);
~
CoreHandlers
();
signals:
void
authenticationRequested
(
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
authInfo
);
void
callStateChanged
(
const
std
::
shared_ptr
<
linphone
::
Call
>
&
call
,
linphone
::
CallState
state
);
...
...
@@ -42,6 +49,14 @@ signals:
void
registrationStateChanged
(
const
std
::
shared_ptr
<
linphone
::
ProxyConfig
>
&
proxyConfig
,
linphone
::
RegistrationState
state
);
private:
void
handleCoreCreated
();
void
handleCoreStarted
();
void
notifyCoreStarted
();
// ---------------------------------------------------------------------------
// Linphone callbacks.
// ---------------------------------------------------------------------------
void
onAuthenticationRequested
(
const
std
::
shared_ptr
<
linphone
::
Core
>
&
core
,
const
std
::
shared_ptr
<
linphone
::
AuthInfo
>
&
authInfo
,
...
...
@@ -91,6 +106,13 @@ private:
linphone
::
RegistrationState
state
,
const
std
::
string
&
message
)
override
;
// ---------------------------------------------------------------------------
bool
mCoreCreated
=
false
;
bool
mCoreStarted
=
false
;
QMutex
*
mCoreStartedLock
=
nullptr
;
};
#endif // CORE_HANDLERS_H_
linphone-desktop/src/components/core/CoreManager.cpp
View file @
cc341824
...
...
@@ -37,7 +37,7 @@ using namespace std;
CoreManager
*
CoreManager
::
mInstance
=
nullptr
;
CoreManager
::
CoreManager
(
QObject
*
parent
,
const
QString
&
configPath
)
:
QObject
(
parent
),
mHandlers
(
make_shared
<
CoreHandlers
>
())
{
CoreManager
::
CoreManager
(
QObject
*
parent
,
const
QString
&
configPath
)
:
QObject
(
parent
),
mHandlers
(
make_shared
<
CoreHandlers
>
(
this
))
{
mPromiseBuild
=
QtConcurrent
::
run
(
this
,
&
CoreManager
::
createLinphoneCore
,
configPath
);
QObject
::
connect
(
...
...
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