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
0106e497
Commit
0106e497
authored
May 09, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/app/App): provide a way to restart core and app
parent
b19b0156
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
32 deletions
+80
-32
App.cpp
linphone-desktop/src/app/App.cpp
+51
-25
App.hpp
linphone-desktop/src/app/App.hpp
+12
-4
CoreManager.cpp
linphone-desktop/src/components/core/CoreManager.cpp
+7
-0
CoreManager.hpp
linphone-desktop/src/components/core/CoreManager.hpp
+1
-0
main.cpp
linphone-desktop/src/main.cpp
+7
-2
FetchRemoteConfiguration.qml
.../ui/views/App/Main/Assistant/FetchRemoteConfiguration.qml
+2
-1
No files found.
linphone-desktop/src/app/App.cpp
View file @
0106e497
...
...
@@ -89,6 +89,7 @@ App::App (int &argc, char *argv[]) : SingleApplication(argc, argv, true) {
App
::~
App
()
{
qInfo
()
<<
QStringLiteral
(
"Destroying app..."
);
delete
mEngine
;
}
// -----------------------------------------------------------------------------
...
...
@@ -120,35 +121,56 @@ inline void activeSplashScreen (App *app) {
}
void
App
::
initContentApp
()
{
// Destroy qml components and linphone core if necessary.
if
(
mEngine
)
{
qInfo
()
<<
QStringLiteral
(
"Restarting app..."
);
delete
mEngine
;
mCallsWindow
=
nullptr
;
mSettingsWindow
=
nullptr
;
CoreManager
::
uninit
();
}
else
{
// Don't quit if last window is closed!!!
setQuitOnLastWindowClosed
(
false
);
QObject
::
connect
(
this
,
&
App
::
receivedMessage
,
this
,
[
this
](
int
,
QByteArray
message
)
{
if
(
message
==
"show"
)
App
::
smartShowWindow
(
getMainWindow
());
}
);
}
// Init core.
CoreManager
::
init
(
this
,
mParser
.
value
(
"config"
));
qInfo
()
<<
"Activated selectors:"
<<
QQmlFileSelector
::
get
(
&
mEngine
)
->
selector
()
->
allSelectors
();
// Init engine content.
mEngine
=
new
QQmlApplicationEngine
();
qInfo
()
<<
QStringLiteral
(
"Activated selectors:"
)
<<
QQmlFileSelector
::
get
(
mEngine
)
->
selector
()
->
allSelectors
();
// Provide `+custom` folders for custom components.
(
new
QQmlFileSelector
(
&
mEngine
,
this
))
->
setExtraSelectors
(
QStringList
(
"custom"
));
(
new
QQmlFileSelector
(
mEngine
,
mEngine
))
->
setExtraSelectors
(
QStringList
(
"custom"
));
// Set modules paths.
mEngine
.
addImportPath
(
":/ui/modules"
);
mEngine
.
addImportPath
(
":/ui/scripts"
);
mEngine
.
addImportPath
(
":/ui/views"
);
mEngine
->
addImportPath
(
":/ui/modules"
);
mEngine
->
addImportPath
(
":/ui/scripts"
);
mEngine
->
addImportPath
(
":/ui/views"
);
// Provide avatars/thumbnails providers.
mEngine
.
addImageProvider
(
AvatarProvider
::
PROVIDER_ID
,
new
AvatarProvider
());
mEngine
.
addImageProvider
(
ThumbnailProvider
::
PROVIDER_ID
,
new
ThumbnailProvider
());
// Don't quit if last window is closed!!!
setQuitOnLastWindowClosed
(
false
);
mEngine
->
addImageProvider
(
AvatarProvider
::
PROVIDER_ID
,
new
AvatarProvider
());
mEngine
->
addImageProvider
(
ThumbnailProvider
::
PROVIDER_ID
,
new
ThumbnailProvider
());
// Register types.
registerTypes
();
registerSharedTypes
();
// Enable notifications.
mNotifier
=
new
Notifier
(
this
);
createNotifier
(
);
// Load main view.
qInfo
()
<<
"Loading main view..."
;
mEngine
.
load
(
QUrl
(
QML_VIEW_MAIN_WINDOW
));
if
(
mEngine
.
rootObjects
().
isEmpty
())
qInfo
()
<<
QStringLiteral
(
"Loading main view..."
)
;
mEngine
->
load
(
QUrl
(
QML_VIEW_MAIN_WINDOW
));
if
(
mEngine
->
rootObjects
().
isEmpty
())
qFatal
(
"Unable to open main window."
);
// Load splashscreen.
...
...
@@ -159,13 +181,6 @@ void App::initContentApp () {
&
CoreManager
::
linphoneCoreCreated
,
this
,
mParser
.
isSet
(
"selftest"
)
?
&
App
::
quit
:
&
App
::
openAppAfterInit
);
QObject
::
connect
(
this
,
&
App
::
receivedMessage
,
this
,
[
this
](
int
,
QByteArray
message
)
{
if
(
message
==
"show"
)
App
::
smartShowWindow
(
getMainWindow
());
}
);
}
// -----------------------------------------------------------------------------
...
...
@@ -228,7 +243,7 @@ QQuickWindow *App::getCallsWindow () {
QQuickWindow
*
App
::
getMainWindow
()
const
{
return
qobject_cast
<
QQuickWindow
*>
(
const_cast
<
QQmlApplicationEngine
*>
(
&
mEngine
)
->
rootObjects
().
at
(
0
)
const_cast
<
QQmlApplicationEngine
*>
(
mEngine
)
->
rootObjects
().
at
(
0
)
);
}
...
...
@@ -238,7 +253,7 @@ QQuickWindow *App::getSettingsWindow () {
QObject
::
connect
(
mSettingsWindow
,
&
QWindow
::
visibilityChanged
,
this
,
[](
QWindow
::
Visibility
visibility
)
{
if
(
visibility
==
QWindow
::
Hidden
)
{
qInfo
()
<<
"Update nat policy."
;
qInfo
()
<<
QStringLiteral
(
"Update nat policy."
)
;
shared_ptr
<
linphone
::
Core
>
core
=
CoreManager
::
getInstance
()
->
getCore
();
core
->
setNatPolicy
(
core
->
getNatPolicy
());
}
...
...
@@ -331,6 +346,10 @@ void App::registerTypes () {
registerUncreatableType
(
ContactModel
,
"ContactModel"
);
registerUncreatableType
(
SipAddressObserver
,
"SipAddressObserver"
);
registerUncreatableType
(
VcardModel
,
"VcardModel"
);
}
void
App
::
registerSharedTypes
()
{
qInfo
()
<<
QStringLiteral
(
"Registering shared types..."
);
registerSharedSingletonType
(
App
,
"App"
,
App
::
getInstance
);
registerSharedSingletonType
(
CoreManager
,
"CoreManager"
,
CoreManager
::
getInstance
);
...
...
@@ -348,7 +367,7 @@ void App::registerTypes () {
void
App
::
setTrayIcon
()
{
QQuickWindow
*
root
=
getMainWindow
();
QSystemTrayIcon
*
systemTrayIcon
=
new
QSystemTrayIcon
(
root
);
QSystemTrayIcon
*
systemTrayIcon
=
new
QSystemTrayIcon
(
mEngine
);
// trayIcon: Right click actions.
QAction
*
quitAction
=
new
QAction
(
"Quit"
,
root
);
...
...
@@ -387,6 +406,13 @@ void App::setTrayIcon () {
// -----------------------------------------------------------------------------
void
App
::
createNotifier
()
{
if
(
!
mNotifier
)
mNotifier
=
new
Notifier
(
this
);
}
// -----------------------------------------------------------------------------
QString
App
::
getConfigLocale
()
const
{
return
::
Utils
::
linphoneStringToQString
(
CoreManager
::
getInstance
()
->
getCore
()
->
getConfig
()
->
getString
(
...
...
linphone-desktop/src/app/App.hpp
View file @
0106e497
...
...
@@ -30,6 +30,8 @@
#include "../components/notifier/Notifier.hpp"
#include "../externals/single-application/SingleApplication.hpp"
#define APP_CODE_RESTART 1000
// =============================================================================
class
DefaultTranslator
;
...
...
@@ -52,7 +54,7 @@ public:
void
tryToUsePreferredLocale
();
QQmlEngine
*
getEngine
()
{
return
&
mEngine
;
return
mEngine
;
}
Notifier
*
getNotifier
()
const
{
...
...
@@ -64,12 +66,16 @@ public:
bool
hasFocus
()
const
;
Q_INVOKABLE
QQuickWindow
*
getSettingsWindow
();
static
App
*
getInstance
()
{
return
static_cast
<
App
*>
(
QApplication
::
instance
());
}
Q_INVOKABLE
void
restart
()
{
exit
(
APP_CODE_RESTART
);
}
Q_INVOKABLE
QQuickWindow
*
getSettingsWindow
();
Q_INVOKABLE
static
void
smartShowWindow
(
QQuickWindow
*
window
);
Q_INVOKABLE
static
QString
convertUrlToLocalPath
(
const
QUrl
&
url
);
...
...
@@ -81,7 +87,9 @@ signals:
private:
void
registerTypes
();
void
registerSharedTypes
();
void
setTrayIcon
();
void
createNotifier
();
QString
getConfigLocale
()
const
;
void
setConfigLocale
(
const
QString
&
locale
);
...
...
@@ -103,7 +111,7 @@ private:
QVariantList
mAvailableLocales
;
QString
mLocale
;
QQmlApplicationEngine
mEngine
;
QQmlApplicationEngine
*
mEngine
=
nullptr
;
DefaultTranslator
*
mTranslator
=
nullptr
;
Notifier
*
mNotifier
=
nullptr
;
...
...
linphone-desktop/src/components/core/CoreManager.cpp
View file @
0106e497
...
...
@@ -73,6 +73,13 @@ void CoreManager::init (QObject *parent, const QString &configPath) {
QObject
::
connect
(
timer
,
&
QTimer
::
timeout
,
mInstance
,
&
CoreManager
::
iterate
);
}
void
CoreManager
::
uninit
()
{
if
(
mInstance
)
{
delete
mInstance
;
mInstance
=
nullptr
;
}
}
// -----------------------------------------------------------------------------
VcardModel
*
CoreManager
::
createDetachedVcardModel
()
{
...
...
linphone-desktop/src/components/core/CoreManager.hpp
View file @
0106e497
...
...
@@ -98,6 +98,7 @@ public:
// ---------------------------------------------------------------------------
static
void
init
(
QObject
*
parent
,
const
QString
&
configPath
);
static
void
uninit
();
static
CoreManager
*
getInstance
()
{
return
mInstance
;
...
...
linphone-desktop/src/main.cpp
View file @
0106e497
...
...
@@ -97,7 +97,12 @@ int main (int argc, char *argv[]) {
// Init and run!
// ---------------------------------------------------------------------------
app
.
initContentApp
();
qInfo
()
<<
QStringLiteral
(
"Running app..."
);
return
app
.
exec
();
int
ret
;
do
{
app
.
initContentApp
();
ret
=
app
.
exec
();
}
while
(
ret
==
APP_CODE_RESTART
);
return
ret
;
}
linphone-desktop/ui/views/App/Main/Assistant/FetchRemoteConfiguration.qml
View file @
0106e497
import
Common
1.0
import
Linphone
1.0
// =============================================================================
AssistantAbstractView
{
mainAction
:
(
function
()
{
console
.
log
(
'
TODO
'
)
App
.
restart
(
)
})
mainActionEnabled
:
url
.
text
.
length
>
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