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
52cba384
Commit
52cba384
authored
Mar 03, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(src/app/App): supports single instance
parent
15b5093b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
27 deletions
+22
-27
CMakeLists.txt
linphone-desktop/CMakeLists.txt
+1
-1
App.cpp
linphone-desktop/src/app/App.cpp
+1
-1
App.hpp
linphone-desktop/src/app/App.hpp
+4
-3
SingleApplication.cpp
...op/src/externals/single-application/SingleApplication.cpp
+12
-12
SingleApplication.hpp
...op/src/externals/single-application/SingleApplication.hpp
+3
-10
main.cpp
linphone-desktop/src/main.cpp
+1
-0
No files found.
linphone-desktop/CMakeLists.txt
View file @
52cba384
...
@@ -62,7 +62,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG -DQT_DECLARAT
...
@@ -62,7 +62,7 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DQT_QML_DEBUG -DQT_DECLARAT
# Define packages, libs, sources, headers, resources and languages.
# Define packages, libs, sources, headers, resources and languages.
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
set
(
QT5_PACKAGES Core Gui Quick Widgets QuickControls2 Svg LinguistTools
)
set
(
QT5_PACKAGES Core Gui Quick Widgets QuickControls2 Svg LinguistTools
Network
)
find_package
(
Linphone REQUIRED
)
find_package
(
Linphone REQUIRED
)
find_package
(
LinphoneCxx REQUIRED
)
find_package
(
LinphoneCxx REQUIRED
)
...
...
linphone-desktop/src/app/App.cpp
View file @
52cba384
...
@@ -60,7 +60,7 @@ inline bool installLocale (App &app, QTranslator &translator, const QLocale &loc
...
@@ -60,7 +60,7 @@ inline bool installLocale (App &app, QTranslator &translator, const QLocale &loc
return
translator
.
load
(
locale
,
LANGUAGES_PATH
)
&&
app
.
installTranslator
(
&
translator
);
return
translator
.
load
(
locale
,
LANGUAGES_PATH
)
&&
app
.
installTranslator
(
&
translator
);
}
}
App
::
App
(
int
&
argc
,
char
*
*
argv
)
:
Q
Application
(
argc
,
argv
)
{
App
::
App
(
int
&
argc
,
char
*
argv
[])
:
Single
Application
(
argc
,
argv
)
{
setApplicationVersion
(
"4.0"
);
setApplicationVersion
(
"4.0"
);
setWindowIcon
(
QIcon
(
WINDOW_ICON_PATH
));
setWindowIcon
(
QIcon
(
WINDOW_ICON_PATH
));
...
...
linphone-desktop/src/app/App.hpp
View file @
52cba384
...
@@ -25,16 +25,17 @@
...
@@ -25,16 +25,17 @@
#include "../components/notifier/Notifier.hpp"
#include "../components/notifier/Notifier.hpp"
#include <QApplication>
#include <QCommandLineParser>
#include <QCommandLineParser>
#include <QQmlApplicationEngine>
#include <QQmlApplicationEngine>
#include <QQuickWindow>
#include <QQuickWindow>
#include "../externals/single-application/SingleApplication.hpp"
// =============================================================================
// =============================================================================
class
DefaultTranslator
;
class
DefaultTranslator
;
class
App
:
public
Q
Application
{
class
App
:
public
Single
Application
{
Q_OBJECT
;
Q_OBJECT
;
Q_PROPERTY
(
QString
configLocale
READ
getConfigLocale
WRITE
setConfigLocale
NOTIFY
configLocaleChanged
);
Q_PROPERTY
(
QString
configLocale
READ
getConfigLocale
WRITE
setConfigLocale
NOTIFY
configLocaleChanged
);
...
@@ -42,7 +43,7 @@ class App : public QApplication {
...
@@ -42,7 +43,7 @@ class App : public QApplication {
Q_PROPERTY
(
QVariantList
availableLocales
READ
getAvailableLocales
CONSTANT
);
Q_PROPERTY
(
QVariantList
availableLocales
READ
getAvailableLocales
CONSTANT
);
public:
public:
App
(
int
&
argc
,
char
*
*
argv
);
App
(
int
&
argc
,
char
*
argv
[]
);
~
App
();
~
App
();
void
initContentApp
();
void
initContentApp
();
...
...
linphone-desktop/src/externals/single-application/SingleApplication.cpp
View file @
52cba384
...
@@ -65,7 +65,7 @@ SingleApplicationPrivate::~SingleApplicationPrivate () {
...
@@ -65,7 +65,7 @@ SingleApplicationPrivate::~SingleApplicationPrivate () {
delete
socket
;
delete
socket
;
}
}
memory
->
lock
();
memory
->
lock
();
InstancesInfo
*
inst
=
(
InstancesInfo
*
)
memory
->
data
(
);
InstancesInfo
*
inst
=
static_cast
<
InstancesInfo
*>
(
memory
->
data
()
);
if
(
server
!=
nullptr
)
{
if
(
server
!=
nullptr
)
{
server
->
close
();
server
->
close
();
delete
server
;
delete
server
;
...
@@ -78,19 +78,19 @@ SingleApplicationPrivate::~SingleApplicationPrivate () {
...
@@ -78,19 +78,19 @@ SingleApplicationPrivate::~SingleApplicationPrivate () {
void
SingleApplicationPrivate
::
genBlockServerName
(
int
timeout
)
{
void
SingleApplicationPrivate
::
genBlockServerName
(
int
timeout
)
{
QCryptographicHash
appData
(
QCryptographicHash
::
Sha256
);
QCryptographicHash
appData
(
QCryptographicHash
::
Sha256
);
appData
.
addData
(
"SingleApplication"
,
17
);
appData
.
addData
(
"SingleApplication"
,
17
);
appData
.
addData
(
SingleApplication
::
app_t
::
applicationName
().
toUtf8
());
appData
.
addData
(
QApplication
::
applicationName
().
toUtf8
());
appData
.
addData
(
SingleApplication
::
app_t
::
organizationName
().
toUtf8
());
appData
.
addData
(
QApplication
::
organizationName
().
toUtf8
());
appData
.
addData
(
SingleApplication
::
app_t
::
organizationDomain
().
toUtf8
());
appData
.
addData
(
QApplication
::
organizationDomain
().
toUtf8
());
if
(
!
(
options
&
SingleApplication
::
Mode
::
ExcludeAppVersion
))
{
if
(
!
(
options
&
SingleApplication
::
Mode
::
ExcludeAppVersion
))
{
appData
.
addData
(
SingleApplication
::
app_t
::
applicationVersion
().
toUtf8
());
appData
.
addData
(
QApplication
::
applicationVersion
().
toUtf8
());
}
}
if
(
!
(
options
&
SingleApplication
::
Mode
::
ExcludeAppPath
))
{
if
(
!
(
options
&
SingleApplication
::
Mode
::
ExcludeAppPath
))
{
#ifdef Q_OS_WIN
#ifdef Q_OS_WIN
appData
.
addData
(
SingleApplication
::
app_t
::
applicationFilePath
().
toLower
().
toUtf8
());
appData
.
addData
(
QApplication
::
applicationFilePath
().
toLower
().
toUtf8
());
#else
#else
appData
.
addData
(
SingleApplication
::
app_t
::
applicationFilePath
().
toUtf8
());
appData
.
addData
(
QApplication
::
applicationFilePath
().
toUtf8
());
#endif // ifdef Q_OS_WIN
#endif // ifdef Q_OS_WIN
}
}
...
@@ -157,7 +157,7 @@ void SingleApplicationPrivate::startPrimary (bool resetMemory) {
...
@@ -157,7 +157,7 @@ void SingleApplicationPrivate::startPrimary (bool resetMemory) {
// Reset the number of connections
// Reset the number of connections
memory
->
lock
();
memory
->
lock
();
InstancesInfo
*
inst
=
(
InstancesInfo
*
)
memory
->
data
(
);
InstancesInfo
*
inst
=
static_cast
<
InstancesInfo
*>
(
memory
->
data
()
);
if
(
resetMemory
)
{
if
(
resetMemory
)
{
inst
->
primary
=
true
;
inst
->
primary
=
true
;
...
@@ -207,7 +207,7 @@ void SingleApplicationPrivate::connectToPrimary (int msecs, char connectionType)
...
@@ -207,7 +207,7 @@ void SingleApplicationPrivate::connectToPrimary (int msecs, char connectionType)
QByteArray
initMsg
=
blockServerName
.
toLatin1
();
QByteArray
initMsg
=
blockServerName
.
toLatin1
();
initMsg
.
append
(
connectionType
);
initMsg
.
append
(
connectionType
);
initMsg
.
append
(
(
const
char
*
)
&
instanceNumber
,
sizeof
(
quint32
));
initMsg
.
append
(
reinterpret_cast
<
const
char
*>
(
&
instanceNumber
)
,
sizeof
(
quint32
));
initMsg
.
append
(
QByteArray
::
number
(
qChecksum
(
initMsg
.
constData
(),
initMsg
.
length
()),
256
));
initMsg
.
append
(
QByteArray
::
number
(
qChecksum
(
initMsg
.
constData
(),
initMsg
.
length
()),
256
));
socket
->
write
(
initMsg
);
socket
->
write
(
initMsg
);
...
@@ -283,7 +283,7 @@ void SingleApplicationPrivate::slotConnectionEstablished () {
...
@@ -283,7 +283,7 @@ void SingleApplicationPrivate::slotConnectionEstablished () {
initMsg
+=
connectionType
;
initMsg
+=
connectionType
;
tmp
=
nextConnSocket
->
read
(
sizeof
(
quint32
));
tmp
=
nextConnSocket
->
read
(
sizeof
(
quint32
));
const
char
*
data
=
tmp
.
constData
();
const
char
*
data
=
tmp
.
constData
();
instanceId
=
(
quint32
)
*
data
;
instanceId
=
static_cast
<
quint32
>
(
*
data
)
;
initMsg
+=
tmp
;
initMsg
+=
tmp
;
// Verify the checksum of the initMsg
// Verify the checksum of the initMsg
QByteArray
checksum
=
QByteArray
::
number
(
QByteArray
checksum
=
QByteArray
::
number
(
...
@@ -356,7 +356,7 @@ void SingleApplicationPrivate::slotClientConnectionClosed (QLocalSocket *closedS
...
@@ -356,7 +356,7 @@ void SingleApplicationPrivate::slotClientConnectionClosed (QLocalSocket *closedS
* @param {bool} allowSecondaryInstances
* @param {bool} allowSecondaryInstances
*/
*/
SingleApplication
::
SingleApplication
(
int
&
argc
,
char
*
argv
[],
bool
allowSecondary
,
Options
options
,
int
timeout
)
SingleApplication
::
SingleApplication
(
int
&
argc
,
char
*
argv
[],
bool
allowSecondary
,
Options
options
,
int
timeout
)
:
app_t
(
argc
,
argv
),
d_ptr
(
new
SingleApplicationPrivate
(
this
))
{
:
QApplication
(
argc
,
argv
),
d_ptr
(
new
SingleApplicationPrivate
(
this
))
{
Q_D
(
SingleApplication
);
Q_D
(
SingleApplication
);
// Store the current mode of the program
// Store the current mode of the program
...
@@ -384,7 +384,7 @@ SingleApplication::SingleApplication (int &argc, char *argv[], bool allowSeconda
...
@@ -384,7 +384,7 @@ SingleApplication::SingleApplication (int &argc, char *argv[], bool allowSeconda
// Attempt to attach to the memory segment
// Attempt to attach to the memory segment
if
(
d
->
memory
->
attach
())
{
if
(
d
->
memory
->
attach
())
{
d
->
memory
->
lock
();
d
->
memory
->
lock
();
InstancesInfo
*
inst
=
(
InstancesInfo
*
)
d
->
memory
->
data
(
);
InstancesInfo
*
inst
=
static_cast
<
InstancesInfo
*>
(
d
->
memory
->
data
()
);
if
(
!
inst
->
primary
)
{
if
(
!
inst
->
primary
)
{
d
->
startPrimary
(
false
);
d
->
startPrimary
(
false
);
...
...
linphone-desktop/src/externals/single-application/SingleApplication.hpp
View file @
52cba384
...
@@ -25,15 +25,10 @@
...
@@ -25,15 +25,10 @@
#ifndef SINGLE_APPLICATION_H
#ifndef SINGLE_APPLICATION_H
#define SINGLE_APPLICATION_H
#define SINGLE_APPLICATION_H
#include <QApplication>
#include <QtCore/QtGlobal>
#include <QtCore/QtGlobal>
#include <QtNetwork/QLocalSocket>
#include <QtNetwork/QLocalSocket>
#ifndef QAPPLICATION_CLASS
#define QAPPLICATION_CLASS QCoreApplication
#endif // ifndef QAPPLICATION_CLASS
#include QT_STRINGIFY(QAPPLICATION_CLASS)
// =============================================================================
// =============================================================================
class
SingleApplicationPrivate
;
class
SingleApplicationPrivate
;
...
@@ -43,11 +38,9 @@ class SingleApplicationPrivate;
...
@@ -43,11 +38,9 @@ class SingleApplicationPrivate;
* Application
* Application
* @see QCoreApplication
* @see QCoreApplication
*/
*/
class
SingleApplication
:
public
QA
PPLICATION_CLASS
{
class
SingleApplication
:
public
QA
pplication
{
Q_OBJECT
Q_OBJECT
typedef
QAPPLICATION_CLASS
app_t
;
public:
public:
/**
/**
* @brief Mode of operation of SingleApplication.
* @brief Mode of operation of SingleApplication.
...
@@ -90,7 +83,7 @@ public:
...
@@ -90,7 +83,7 @@ public:
* @see See the corresponding QAPPLICATION_CLASS constructor for reference
* @see See the corresponding QAPPLICATION_CLASS constructor for reference
*/
*/
explicit
SingleApplication
(
int
&
argc
,
char
*
argv
[],
bool
allowSecondary
=
false
,
Options
options
=
Mode
::
User
,
int
timeout
=
100
);
explicit
SingleApplication
(
int
&
argc
,
char
*
argv
[],
bool
allowSecondary
=
false
,
Options
options
=
Mode
::
User
,
int
timeout
=
100
);
~
SingleApplication
();
virtual
~
SingleApplication
();
/**
/**
* @brief Returns if the instance is the primary instance
* @brief Returns if the instance is the primary instance
...
...
linphone-desktop/src/main.cpp
View file @
52cba384
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
*/
*/
#include <iostream>
#include <iostream>
#include "app/App.hpp"
#include "app/App.hpp"
#include "app/Logger.hpp"
#include "app/Logger.hpp"
...
...
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