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
b05e003d
Commit
b05e003d
authored
Mar 14, 2018
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(app): clean some pieces of code and improve build (cli, logger and paths)
parent
41d21d89
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
129 additions
and
116 deletions
+129
-116
CMakeLists.txt
CMakeLists.txt
+2
-0
Cli.cpp
src/app/cli/Cli.cpp
+27
-26
Logger.cpp
src/app/logger/Logger.cpp
+24
-22
Logger.hpp
src/app/logger/Logger.hpp
+7
-1
Paths.cpp
src/app/paths/Paths.cpp
+69
-67
No files found.
CMakeLists.txt
View file @
b05e003d
...
...
@@ -331,6 +331,8 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BIN
# Build.
# ------------------------------------------------------------------------------
include_directories
(
src/
)
find_package
(
Qt5 COMPONENTS
${
QT5_PACKAGES
}
REQUIRED
)
find_package
(
Qt5 COMPONENTS
${
QT5_PACKAGES_OPTIONAL
}
QUIET
)
find_package
(
Qt5 COMPONENTS Test REQUIRED
)
...
...
src/app/cli/Cli.cpp
View file @
b05e003d
...
...
@@ -22,12 +22,13 @@
#include <iostream>
#include "
../../components/core/CoreManager
.hpp"
#include "
../../utils/Utils
.hpp"
#include "
../App
.hpp"
#include "
app/App
.hpp"
#include "
components/core/CoreManager
.hpp"
#include "
utils/Utils
.hpp"
#include "Cli.hpp"
#include "iostream"
// =============================================================================
using
namespace
std
;
...
...
@@ -52,7 +53,7 @@ static void cliJoinConference (QHash<QString, QString> &args) {
{
shared_ptr
<
linphone
::
Address
>
address
=
core
->
getPrimaryContactParsed
();
address
->
setDisplayName
(
::
Utils
::
appStringToCoreString
(
args
.
take
(
"display-name"
)));
address
->
setDisplayName
(
Utils
::
appStringToCoreString
(
args
.
take
(
"display-name"
)));
core
->
setPrimaryContact
(
address
->
asString
());
}
...
...
@@ -73,7 +74,7 @@ static void cliJoinConferenceAs (QHash<QString, QString> &args) {
const
shared_ptr
<
const
linphone
::
Address
>
currentSipAddress
=
proxyConfig
->
getIdentityAddress
();
const
shared_ptr
<
const
linphone
::
Address
>
askedSipAddress
=
linphone
::
Factory
::
get
()
->
createAddress
(
::
Utils
::
appStringToCoreString
(
fromSipAddress
)
Utils
::
appStringToCoreString
(
fromSipAddress
)
);
if
(
!
currentSipAddress
->
weakEqual
(
askedSipAddress
))
{
qWarning
()
<<
QStringLiteral
(
"Guest sip address `%1` doesn't match with default proxy config."
)
...
...
@@ -90,7 +91,7 @@ static void cliInitiateConference (QHash<QString, QString> &args) {
// Check identity.
{
shared_ptr
<
linphone
::
Address
>
address
=
core
->
interpretUrl
(
::
Utils
::
appStringToCoreString
(
args
[
"sip-address"
]));
shared_ptr
<
linphone
::
Address
>
address
=
core
->
interpretUrl
(
Utils
::
appStringToCoreString
(
args
[
"sip-address"
]));
if
(
!
address
||
address
->
getUsername
().
empty
())
{
qWarning
()
<<
QStringLiteral
(
"Unable to parse invalid sip address."
);
return
;
...
...
@@ -107,8 +108,8 @@ static void cliInitiateConference (QHash<QString, QString> &args) {
const
string
identity
=
proxyConfig
->
getIdentityAddress
()
->
asStringUriOnly
();
if
(
sipAddress
!=
identity
)
{
qWarning
()
<<
QStringLiteral
(
"Received different sip address from identity : `%1 != %2`."
)
.
arg
(
::
Utils
::
coreStringToAppString
(
identity
))
.
arg
(
::
Utils
::
coreStringToAppString
(
sipAddress
));
.
arg
(
Utils
::
coreStringToAppString
(
identity
))
.
arg
(
Utils
::
coreStringToAppString
(
sipAddress
));
return
;
}
}
...
...
@@ -119,7 +120,7 @@ static void cliInitiateConference (QHash<QString, QString> &args) {
App
*
app
=
App
::
getInstance
();
if
(
conference
)
{
if
(
conference
->
getId
()
==
::
Utils
::
appStringToCoreString
(
id
))
{
if
(
conference
->
getId
()
==
Utils
::
appStringToCoreString
(
id
))
{
qInfo
()
<<
QStringLiteral
(
"Conference `%1` already exists."
).
arg
(
id
);
// TODO: Set the view to the "waiting call view".
app
->
smartShowWindow
(
app
->
getCallsWindow
());
...
...
@@ -127,13 +128,13 @@ static void cliInitiateConference (QHash<QString, QString> &args) {
}
qInfo
()
<<
QStringLiteral
(
"Remove existing conference with id: `%1`."
)
.
arg
(
::
Utils
::
coreStringToAppString
(
conference
->
getId
()));
.
arg
(
Utils
::
coreStringToAppString
(
conference
->
getId
()));
core
->
terminateConference
();
}
qInfo
()
<<
QStringLiteral
(
"Create conference with id: `%1`."
).
arg
(
id
);
conference
=
core
->
createConferenceWithParams
(
core
->
createConferenceParams
());
conference
->
setId
(
::
Utils
::
appStringToCoreString
(
id
));
conference
->
setId
(
Utils
::
appStringToCoreString
(
id
));
if
(
core
->
enterConference
()
==
-
1
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to join created conference: `%1`."
).
arg
(
id
);
...
...
@@ -221,7 +222,7 @@ static string multilineIndent (const QString &str, int indentationNumber = 0) {
out
+=
indentedWord
(
word
,
indentedTextCurPos
,
lineLength
,
padding
);
out
+=
"
\n
"
;
return
::
Utils
::
appStringToCoreString
(
out
);
return
Utils
::
appStringToCoreString
(
out
);
}
// =============================================================================
...
...
@@ -264,7 +265,7 @@ void Cli::Command::execute (QHash<QString, QString> &args) const {
(
*
mFunction
)(
args
);
else
{
Function
f
=
mFunction
;
::
Utils
::
connectOnce
(
coreManager
->
getHandlers
().
get
(),
&
CoreHandlers
::
coreStarted
,
coreManager
,
[
f
,
args
]
{
Utils
::
connectOnce
(
coreManager
->
getHandlers
().
get
(),
&
CoreHandlers
::
coreStarted
,
coreManager
,
[
f
,
args
]
{
QHash
<
QString
,
QString
>
fuckConst
=
args
;
(
*
f
)(
fuckConst
);
});
...
...
@@ -275,11 +276,11 @@ void Cli::Command::executeUri (const shared_ptr<linphone::Address> &address) con
QHash
<
QString
,
QString
>
args
;
// TODO: check if there is too much headers.
for
(
const
auto
&
argName
:
mArgsScheme
.
keys
())
{
const
string
header
=
address
->
getHeader
(
::
Utils
::
appStringToCoreString
(
argName
));
const
string
header
=
address
->
getHeader
(
Utils
::
appStringToCoreString
(
argName
));
args
[
argName
]
=
QByteArray
::
fromBase64
(
QByteArray
(
header
.
c_str
(),
int
(
header
.
length
())));
}
address
->
clean
();
args
[
"sip-address"
]
=
::
Utils
::
coreStringToAppString
(
address
->
asStringUriOnly
());
args
[
"sip-address"
]
=
Utils
::
coreStringToAppString
(
address
->
asStringUriOnly
());
execute
(
args
);
}
...
...
@@ -315,17 +316,17 @@ QRegExp Cli::mRegExpArgs("(?:(?:([\\w-]+)\\s*)=\\s*(?:\"([^\"\\\\]*(?:\\\\.[^\"\
QRegExp
Cli
::
mRegExpFunctionName
(
"^
\\
s*([a-z-]+)
\\
s*"
);
QMap
<
QString
,
Cli
::
Command
>
Cli
::
mCommands
=
{
createCommand
(
"show"
,
QT_TR_NOOP
(
"showFunctionDescription"
),
::
cliShow
),
createCommand
(
"call"
,
QT_TR_NOOP
(
"callFunctionDescription"
),
::
cliCall
,
{
createCommand
(
"show"
,
QT_TR_NOOP
(
"showFunctionDescription"
),
cliShow
),
createCommand
(
"call"
,
QT_TR_NOOP
(
"callFunctionDescription"
),
cliCall
,
{
{
"sip-address"
,
{}
}
}),
createCommand
(
"initiate-conference"
,
QT_TR_NOOP
(
"initiateConferenceFunctionDescription"
),
::
cliInitiateConference
,
{
createCommand
(
"initiate-conference"
,
QT_TR_NOOP
(
"initiateConferenceFunctionDescription"
),
cliInitiateConference
,
{
{
"sip-address"
,
{}
},
{
"conference-id"
,
{}
}
}),
createCommand
(
"join-conference"
,
QT_TR_NOOP
(
"joinConferenceFunctionDescription"
),
::
cliJoinConference
,
{
createCommand
(
"join-conference"
,
QT_TR_NOOP
(
"joinConferenceFunctionDescription"
),
cliJoinConference
,
{
{
"sip-address"
,
{}
},
{
"conference-id"
,
{}
},
{
"display-name"
,
{}
}
}),
createCommand
(
"join-conference-as"
,
QT_TR_NOOP
(
"joinConferenceAsFunctionDescription"
),
::
cliJoinConferenceAs
,
{
createCommand
(
"join-conference-as"
,
QT_TR_NOOP
(
"joinConferenceAsFunctionDescription"
),
cliJoinConferenceAs
,
{
{
"sip-address"
,
{}
},
{
"conference-id"
,
{}
},
{
"guest-sip-address"
,
{}
}
})
};
...
...
@@ -334,7 +335,7 @@ QMap<QString, Cli::Command> Cli::mCommands = {
void
Cli
::
executeCommand
(
const
QString
&
command
,
CommandFormat
*
format
)
{
shared_ptr
<
linphone
::
Address
>
address
=
linphone
::
Factory
::
get
()
->
createAddress
(
::
Utils
::
appStringToCoreString
(
command
)
Utils
::
appStringToCoreString
(
command
)
);
// Execute cli command.
...
...
@@ -362,13 +363,13 @@ void Cli::executeCommand (const QString &command, CommandFormat *format) {
if
(
scheme
==
validScheme
)
goto
success
;
qWarning
()
<<
QStringLiteral
(
"Not a valid uri: `%1` Unsupported scheme: `%2`."
)
.
arg
(
command
).
arg
(
::
Utils
::
coreStringToAppString
(
scheme
));
.
arg
(
command
).
arg
(
Utils
::
coreStringToAppString
(
scheme
));
return
;
success:
const
QString
functionName
=
::
Utils
::
coreStringToAppString
(
address
->
getHeader
(
"method"
)).
isEmpty
()
const
QString
functionName
=
Utils
::
coreStringToAppString
(
address
->
getHeader
(
"method"
)).
isEmpty
()
?
QStringLiteral
(
"call"
)
:
::
Utils
::
coreStringToAppString
(
address
->
getHeader
(
"method"
));
:
Utils
::
coreStringToAppString
(
address
->
getHeader
(
"method"
));
if
(
!
functionName
.
isEmpty
()
&&
!
mCommands
.
contains
(
functionName
))
{
qWarning
()
<<
QStringLiteral
(
"This command doesn't exist: `%1`."
).
arg
(
functionName
);
...
...
src/app/logger/Logger.cpp
View file @
b05e003d
...
...
@@ -21,11 +21,12 @@
*/
#include <bctoolbox/logging.h>
#include <linphone++/linphone.hh>
#include <QDateTime>
#include <QThread>
#include "
../../
components/settings/SettingsModel.hpp"
#include "
../../
utils/Utils.hpp"
#include "components/settings/SettingsModel.hpp"
#include "utils/Utils.hpp"
#include "Logger.hpp"
...
...
@@ -45,15 +46,15 @@
#define RESET ""
#endif // if defined(__linux__) || defined(__APPLE__)
#define QT_DOMAIN "qt"
#define MAX_LOGS_COLLECTION_SIZE 10485760
/* 10MB. */
#define SRC_PATTERN "/linphone-desktop/src/"
// =============================================================================
using
namespace
std
;
// =============================================================================
namespace
{
constexpr
char
cQtDomain
[]
=
"qt"
;
constexpr
size_t
cMaxLogsCollectionSize
=
10485760
;
// 10MB.
constexpr
char
cSrcPattern
[]
=
"/linphone-desktop/src/"
;
}
QMutex
Logger
::
mMutex
;
...
...
@@ -81,24 +82,25 @@ private:
if
(
!
mLogger
->
isVerbose
())
return
;
using
LogLevel
=
linphone
::
LogLevel
;
const
char
*
format
;
switch
(
level
)
{
case
linphone
:
:
LogLevel
::
LogLevelDebug
:
case
LogLevel
:
:
LogLevelDebug
:
format
=
GREEN
"[%s][Debug]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelTrace
:
case
LogLevel
:
:
LogLevelTrace
:
format
=
BLUE
"[%s][Trace]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelMessage
:
case
LogLevel
:
:
LogLevelMessage
:
format
=
BLUE
"[%s][Info]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelWarning
:
case
LogLevel
:
:
LogLevelWarning
:
format
=
RED
"[%s][Warning]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelError
:
case
LogLevel
:
:
LogLevelError
:
format
=
RED
"[%s][Error]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
case
linphone
:
:
LogLevel
::
LogLevelFatal
:
case
LogLevel
:
:
LogLevelFatal
:
format
=
RED
"[%s][Fatal]"
YELLOW
"Core:%s: "
RESET
"%s
\n
"
;
break
;
}
...
...
@@ -106,12 +108,12 @@ private:
fprintf
(
stderr
,
format
,
::
getFormattedCurrentTime
().
constData
(),
getFormattedCurrentTime
().
constData
(),
domain
.
empty
()
?
domain
.
c_str
()
:
"linphone"
,
message
.
c_str
()
);
if
(
level
==
linphone
::
LogLevel
::
LogLevelFatal
)
if
(
level
==
LogLevel
::
LogLevelFatal
)
terminate
();
};
...
...
@@ -148,10 +150,10 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
QByteArray
contextArr
;
{
const
char
*
file
=
context
.
file
;
const
char
*
pos
=
file
?
::
Utils
::
rstrstr
(
file
,
SRC_PATTERN
)
:
file
;
const
char
*
pos
=
file
?
Utils
::
rstrstr
(
file
,
cSrcPattern
)
:
file
;
contextArr
=
QStringLiteral
(
"%1:%2: "
)
.
arg
(
pos
?
pos
+
sizeof
(
SRC_PATTERN
)
-
1
:
file
)
.
arg
(
pos
?
pos
+
sizeof
(
cSrcPattern
)
-
1
:
file
)
.
arg
(
context
.
line
)
.
toLocal8Bit
();
contextStr
=
contextArr
.
constData
();
...
...
@@ -161,12 +163,12 @@ void Logger::log (QtMsgType type, const QMessageLogContext &context, const QStri
#endif // ifdef QT_MESSAGELOGCONTEXT
QByteArray
localMsg
=
msg
.
toLocal8Bit
();
QByteArray
dateTime
=
::
getFormattedCurrentTime
();
QByteArray
dateTime
=
getFormattedCurrentTime
();
mMutex
.
lock
();
fprintf
(
stderr
,
format
,
dateTime
.
constData
(),
QThread
::
currentThread
(),
contextStr
,
localMsg
.
constData
());
bctbx_log
(
QT_DOMAIN
,
level
,
"QT: %s%s"
,
contextStr
,
localMsg
.
constData
());
bctbx_log
(
cQtDomain
,
level
,
"QT: %s%s"
,
contextStr
,
localMsg
.
constData
());
mMutex
.
unlock
();
...
...
@@ -201,8 +203,8 @@ void Logger::init (const shared_ptr<linphone::Config> &config) {
loggingService
->
setListener
(
make_shared
<
LinphoneLogger
>
(
mInstance
));
}
linphone
::
Core
::
setLogCollectionPath
(
::
Utils
::
appStringToCoreString
(
folder
));
linphone
::
Core
::
setLogCollectionMaxFileSize
(
MAX_LOGS_COLLECTION_SIZE
);
linphone
::
Core
::
setLogCollectionPath
(
Utils
::
appStringToCoreString
(
folder
));
linphone
::
Core
::
setLogCollectionMaxFileSize
(
cMaxLogsCollectionSize
);
mInstance
->
enable
(
SettingsModel
::
getLogsEnabled
(
config
));
}
src/app/logger/Logger.hpp
View file @
b05e003d
...
...
@@ -23,11 +23,17 @@
#ifndef LOGGER_H_
#define LOGGER_H_
#include <linphone++/linphone.hh>
#include <memory>
#include <QMutex>
// =============================================================================
namespace
linphone
{
class
Config
;
class
LoggingService
;
}
class
Logger
{
public:
~
Logger
()
=
default
;
...
...
src/app/paths/Paths.cpp
View file @
b05e003d
...
...
@@ -26,31 +26,33 @@
#include <QStandardPaths>
#include <QtDebug>
#include "
../../
utils/Utils.hpp"
#include "utils/Utils.hpp"
#include "config.h"
#include "Paths.hpp"
#define PATH_ASSISTANT_CONFIG "/linphone/assistant/"
#define PATH_AVATARS "/avatars/"
#define PATH_CAPTURES "/Linphone/captures/"
#define PATH_LOGS "/logs/"
#define PATH_PLUGINS "/plugins/"
#define PATH_THUMBNAILS "/thumbnails/"
#define PATH_USER_CERTIFICATES "/usr-crt/"
#define PATH_CALL_HISTORY_LIST "/call-history.db"
#define PATH_CONFIG "/linphonerc"
#define PATH_FACTORY_CONFIG "/linphone/linphonerc-factory"
#define PATH_ROOT_CA "/linphone/rootca.pem"
#define PATH_FRIENDS_LIST "/friends.db"
#define PATH_MESSAGE_HISTORY_LIST "/message-history.db"
#define PATH_ZRTP_SECRETS "/zidcache"
// =============================================================================
using
namespace
std
;
// =============================================================================
namespace
{
constexpr
char
cPathAssistantConfig
[]
=
"/linphone/assistant/"
;
constexpr
char
cPathAvatars
[]
=
"/avatars/"
;
constexpr
char
cPathCaptures
[]
=
"/Linphone/captures/"
;
constexpr
char
cPathLogs
[]
=
"/logs/"
;
constexpr
char
cPathPlugins
[]
=
"/plugins/"
;
constexpr
char
cPathThumbnails
[]
=
"/thumbnails/"
;
constexpr
char
cPathUserCertificates
[]
=
"/usr-crt/"
;
constexpr
char
cPathCallHistoryList
[]
=
"/call-history.db"
;
constexpr
char
cPathConfig
[]
=
"/linphonerc"
;
constexpr
char
cPathFactoryConfig
[]
=
"/linphone/linphonerc-factory"
;
constexpr
char
cPathRootCa
[]
=
"/linphone/rootca.pem"
;
constexpr
char
cPathFriendsList
[]
=
"/friends.db"
;
constexpr
char
cPathMessageHistoryList
[]
=
"/message-history.db"
;
constexpr
char
cPathZrtpSecrets
[]
=
"/zidcache"
;
}
static
inline
bool
dirPathExists
(
const
QString
&
path
)
{
QDir
dir
(
path
);
...
...
@@ -59,7 +61,7 @@ static inline bool dirPathExists (const QString &path) {
static
inline
bool
filePathExists
(
const
QString
&
path
)
{
QFileInfo
info
(
path
);
if
(
!
::
dirPathExists
(
info
.
path
()))
if
(
!
dirPathExists
(
info
.
path
()))
return
false
;
QFile
file
(
path
);
...
...
@@ -74,7 +76,7 @@ static inline void ensureDirPathExists (const QString &path) {
static
inline
void
ensureFilePathExists
(
const
QString
&
path
)
{
QFileInfo
info
(
path
);
::
ensureDirPathExists
(
info
.
path
());
ensureDirPathExists
(
info
.
path
());
QFile
file
(
path
);
if
(
!
file
.
exists
()
&&
!
file
.
open
(
QIODevice
::
ReadWrite
))
...
...
@@ -82,21 +84,21 @@ static inline void ensureFilePathExists (const QString &path) {
}
static
inline
string
getReadableDirPath
(
const
QString
&
dirname
)
{
return
::
Utils
::
appStringToCoreString
(
QDir
::
toNativeSeparators
(
dirname
));
return
Utils
::
appStringToCoreString
(
QDir
::
toNativeSeparators
(
dirname
));
}
static
inline
string
getWritableDirPath
(
const
QString
&
dirname
)
{
::
ensureDirPathExists
(
dirname
);
return
::
getReadableDirPath
(
dirname
);
ensureDirPathExists
(
dirname
);
return
getReadableDirPath
(
dirname
);
}
static
inline
string
getReadableFilePath
(
const
QString
&
filename
)
{
return
::
Utils
::
appStringToCoreString
(
QDir
::
toNativeSeparators
(
filename
));
return
Utils
::
appStringToCoreString
(
QDir
::
toNativeSeparators
(
filename
));
}
static
inline
string
getWritableFilePath
(
const
QString
&
filename
)
{
::
ensureFilePathExists
(
filename
);
return
::
getReadableFilePath
(
filename
);
ensureFilePathExists
(
filename
);
return
getReadableFilePath
(
filename
);
}
// -----------------------------------------------------------------------------
...
...
@@ -112,134 +114,134 @@ static inline QDir getAppPackageDir () {
}
static
inline
QString
getAppPackageDataDirPath
()
{
QDir
dir
=
::
getAppPackageDir
();
QDir
dir
=
getAppPackageDir
();
dir
.
cd
(
"share"
);
return
dir
.
absolutePath
();
}
static
inline
QString
getAppPackageMsPluginsDirPath
()
{
QDir
dir
=
::
getAppPackageDir
();
QDir
dir
=
getAppPackageDir
();
dir
.
cd
(
MSPLUGINS_DIR
);
return
dir
.
absolutePath
();
}
static
inline
QString
getAppAssistantConfigDirPath
()
{
return
::
getAppPackageDataDirPath
()
+
PATH_ASSISTANT_CONFIG
;
return
getAppPackageDataDirPath
()
+
cPathAssistantConfig
;
}
static
inline
QString
getAppConfigFilePath
()
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppConfigLocation
)
+
PATH_CONFIG
;
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppConfigLocation
)
+
cPathConfig
;
}
static
inline
QString
getAppCallHistoryFilePath
()
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_CALL_HISTORY_LIST
;
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
cPathCallHistoryList
;
}
static
inline
QString
getAppFactoryConfigFilePath
()
{
return
::
getAppPackageDataDirPath
()
+
PATH_FACTORY_CONFIG
;
return
getAppPackageDataDirPath
()
+
cPathFactoryConfig
;
}
static
inline
QString
getAppPluginsDirPath
()
{
return
::
getAppPackageDataDirPath
()
+
PATH_PLUGINS
;
return
getAppPackageDataDirPath
()
+
cPathPlugins
;
}
static
inline
QString
getAppRootCaFilePath
()
{
return
::
getAppPackageDataDirPath
()
+
PATH_ROOT_CA
;
return
getAppPackageDataDirPath
()
+
cPathRootCa
;
}
static
inline
QString
getAppFriendsFilePath
()
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_FRIENDS_LIST
;
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
cPathFriendsList
;
}
static
inline
QString
getAppMessageHistoryFilePath
()
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_MESSAGE_HISTORY_LIST
;
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
cPathMessageHistoryList
;
}
// -----------------------------------------------------------------------------
bool
Paths
::
filePathExists
(
const
string
&
path
)
{
return
::
filePathExists
(
Utils
::
coreStringToAppString
(
path
));
return
filePathExists
(
Utils
::
coreStringToAppString
(
path
));
}
// -----------------------------------------------------------------------------
string
Paths
::
getAssistantConfigDirPath
()
{
return
::
getReadableDirPath
(
::
getAppAssistantConfigDirPath
());
return
getReadableDirPath
(
getAppAssistantConfigDirPath
());
}
string
Paths
::
getAvatarsDirPath
()
{
return
::
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_AVATARS
);
return
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
cPathAvatars
);
}
string
Paths
::
getCallHistoryFilePath
()
{
return
::
getWritableFilePath
(
::
getAppCallHistoryFilePath
());
return
getWritableFilePath
(
getAppCallHistoryFilePath
());
}
string
Paths
::
getCapturesDirPath
()
{
return
::
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
PATH_CAPTURES
);
return
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DocumentsLocation
)
+
cPathCaptures
);
}
string
Paths
::
getConfigFilePath
(
const
QString
&
configPath
,
bool
writable
)
{
const
QString
path
=
configPath
.
isEmpty
()
?
::
getAppConfigFilePath
()
?
getAppConfigFilePath
()
:
QFileInfo
(
configPath
).
absoluteFilePath
();
return
writable
?
::
getWritableFilePath
(
path
)
:
::
getReadableFilePath
(
path
);
}
string
Paths
::
getFactoryConfigFilePath
()
{
return
::
getReadableFilePath
(
::
getAppFactoryConfigFilePath
());
return
getReadableFilePath
(
getAppFactoryConfigFilePath
());
}
string
Paths
::
getFriendsListFilePath
()
{
return
::
getWritableFilePath
(
::
getAppFriendsFilePath
());
return
getWritableFilePath
(
getAppFriendsFilePath
());
}
string
Paths
::
getDownloadDirPath
()
{
return
::
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DownloadLocation
));
return
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
DownloadLocation
));
}
string
Paths
::
getLogsDirPath
()
{
return
::
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_LOGS
);
return
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
cPathLogs
);
}
string
Paths
::
getMessageHistoryFilePath
()
{
return
::
getWritableFilePath
(
::
getAppMessageHistoryFilePath
());
return
getWritableFilePath
(
getAppMessageHistoryFilePath
());
}
string
Paths
::
getPackageDataDirPath
()
{
return
::
getReadableDirPath
(
::
getAppPackageDataDirPath
());
return
getReadableDirPath
(
getAppPackageDataDirPath
());
}
string
Paths
::
getPackageMsPluginsDirPath
()
{
return
::
getReadableDirPath
(
::
getAppPackageMsPluginsDirPath
());
return
getReadableDirPath
(
getAppPackageMsPluginsDirPath
());
}
string
Paths
::
getPluginsDirPath
()
{
return
::
getReadableDirPath
(
::
getAppPluginsDirPath
());
return
getReadableDirPath
(
getAppPluginsDirPath
());
}
string
Paths
::
getRootCaFilePath
()
{
return
::
getReadableFilePath
(
::
getAppRootCaFilePath
());
return
getReadableFilePath
(
getAppRootCaFilePath
());
}
string
Paths
::
getThumbnailsDirPath
()
{
return
::
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_THUMBNAILS
);
return
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
cPathThumbnails
);
}
string
Paths
::
getUserCertificatesDirPath
()
{
return
::
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_USER_CERTIFICATES
);
return
getWritableDirPath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
cPathUserCertificates
);
}
string
Paths
::
getZrtpSecretsFilePath
()
{
return
::
getWritableFilePath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_ZRTP_SECRETS
);
return
getWritableFilePath
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
cPathZrtpSecrets
);
}
// -----------------------------------------------------------------------------
static
void
migrateFile
(
const
QString
&
oldPath
,
const
QString
&
newPath
)
{
QFileInfo
info
(
newPath
);
::
ensureDirPathExists
(
info
.
path
());
ensureDirPathExists
(
info
.
path
());
if
(
QFile
::
copy
(
oldPath
,
newPath
))
{
QFile
::
remove
(
oldPath
);
...
...
@@ -251,7 +253,7 @@ static void migrateFile (const QString &oldPath, const QString &newPath) {
static
void
migrateConfigurationFile
(
const
QString
&
oldPath
,
const
QString
&
newPath
)
{
QFileInfo
info
(
newPath
);
::
ensureDirPathExists
(
info
.
path
());
ensureDirPathExists
(
info
.
path
());
if
(
QFile
::
copy
(
oldPath
,
newPath
))
{
QFile
oldFile
(
oldPath
);
...
...
@@ -268,30 +270,30 @@ static void migrateConfigurationFile (const QString &oldPath, const QString &new
}
void
Paths
::
migrate
()
{
QString
newPath
=
::
getAppConfigFilePath
();
QString
newPath
=
getAppConfigFilePath
();
QString
oldBaseDir
=
QSysInfo
::
productType
()
==
"windows"
?
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
:
QStandardPaths
::
writableLocation
(
QStandardPaths
::
HomeLocation
);
QString
oldPath
=
oldBaseDir
+
"/.linphonerc"
;
if
(
!
::
filePathExists
(
newPath
)
&&
::
filePathExists
(
oldPath
))
::
migrateConfigurationFile
(
oldPath
,
newPath
);
if
(
!
filePathExists
(
newPath
)
&&
filePathExists
(
oldPath
))
migrateConfigurationFile
(
oldPath
,
newPath
);
newPath
=
::
getAppCallHistoryFilePath
();
newPath
=
getAppCallHistoryFilePath
();
oldPath
=
oldBaseDir
+
"/.linphone-call-history.db"
;
if
(
!
::
filePathExists
(
newPath
)
&&
::
filePathExists
(
oldPath
))
::
migrateFile
(
oldPath
,
newPath
);
if
(
!
filePathExists
(
newPath
)
&&
filePathExists
(
oldPath
))
migrateFile
(
oldPath
,
newPath
);
newPath
=
::
getAppFriendsFilePath
();
newPath
=
getAppFriendsFilePath
();
oldPath
=
oldBaseDir
+
"/.linphone-friends.db"
;
if
(
!
::
filePathExists
(
newPath
)
&&
::
filePathExists
(
oldPath
))
::
migrateFile
(
oldPath
,
newPath
);
if
(
!
filePathExists
(
newPath
)
&&
filePathExists
(
oldPath
))
migrateFile
(
oldPath
,
newPath
);
newPath
=
::
getAppMessageHistoryFilePath
();
newPath
=
getAppMessageHistoryFilePath
();
oldPath
=
oldBaseDir
+
"/.linphone-history.db"
;
if
(
!
::
filePathExists
(
newPath
)
&&
::
filePathExists
(
oldPath
))
::
migrateFile
(
oldPath
,
newPath
);
if
(
!
filePathExists
(
newPath
)
&&
filePathExists
(
oldPath
))
migrateFile
(
oldPath
,
newPath
);
}
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