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
cbc8c720
Commit
cbc8c720
authored
Mar 13, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(src/app/Paths): fix style with uncrustify
parent
3aec3dc4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
59 deletions
+66
-59
Paths.cpp
linphone-desktop/src/app/Paths.cpp
+58
-53
Paths.hpp
linphone-desktop/src/app/Paths.hpp
+7
-5
CoreManager.cpp
linphone-desktop/src/components/core/CoreManager.cpp
+1
-1
No files found.
linphone-desktop/src/app/Paths.cpp
View file @
cbc8c720
...
...
@@ -29,22 +29,19 @@
#include "Paths.hpp"
// =============================================================================
using
namespace
std
;
#define PATH_AVATARS "/avatars/"
#define PATH_CAPTURES "/captures/"
#define PATH_LOGS "/logs/"
#define PATH_THUMBNAILS "/thumbnails/"
#define PATH_USER_CERTIFICATES "/usr-crt/"
#define PATH_CONFIG "/linphonerc"
#define PATH_CALL_HISTORY_LIST "/call-history.db"
#define PATH_CONFIG "/linphonerc"
#define PATH_FRIENDS_LIST "/friends.db"
#define PATH_MESSAGE_HISTORY_LIST "/message-history.db"
#define PATH_ZRTP_SECRETS "/zidcache"
#define PATH_USER_CERTIFICATES "/usr-crt/"
using
namespace
std
;
// =============================================================================
...
...
@@ -55,14 +52,15 @@ inline bool directoryPathExists (const QString &path) {
inline
bool
filePathExists
(
const
QString
&
path
)
{
QFileInfo
info
(
path
);
if
(
!
directoryPathExists
(
info
.
path
()))
return
false
;
if
(
!
directoryPathExists
(
info
.
path
()))
return
false
;
QFile
file
(
path
);
return
file
.
exists
();
}
inline
bool
filePathExists
(
const
string
&
path
)
{
return
filePathExists
(
Utils
::
linphoneStringToQString
(
path
));
return
filePathExists
(
Utils
::
linphoneStringToQString
(
path
));
}
inline
void
ensureDirectoryPathExists
(
const
QString
&
path
)
{
...
...
@@ -91,11 +89,10 @@ inline string getFilePath (const QString &filename) {
}
static
QString
getAppConfigFilepath
()
{
if
(
QSysInfo
::
productType
()
==
"macos"
)
{
if
(
QSysInfo
::
productType
()
==
"macos"
)
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
+
PATH_CONFIG
;
}
else
{
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppConfigLocation
)
+
PATH_CONFIG
;
}
return
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppConfigLocation
)
+
PATH_CONFIG
;
}
static
QString
getAppCallHistoryFilepath
()
{
...
...
@@ -120,10 +117,10 @@ string Paths::getCallHistoryFilepath () {
return
getFilePath
(
getAppCallHistoryFilepath
());
}
string
Paths
::
getConfigFilepath
(
const
QString
&
config
P
ath
)
{
if
(
!
config
Path
.
isEmpty
())
{
return
getFilePath
(
QFileInfo
(
config
P
ath
).
absoluteFilePath
());
}
string
Paths
::
getConfigFilepath
(
const
QString
&
config
_p
ath
)
{
if
(
!
config
_path
.
isEmpty
())
return
getFilePath
(
QFileInfo
(
config
_p
ath
).
absoluteFilePath
());
return
getFilePath
(
getAppConfigFilepath
());
}
...
...
@@ -157,53 +154,61 @@ string Paths::getUserCertificatesDirpath () {
// -----------------------------------------------------------------------------
static
void
migrateFile
(
const
QString
&
old
Path
,
const
QString
&
newP
ath
)
{
QFileInfo
info
(
new
P
ath
);
static
void
migrateFile
(
const
QString
&
old
_path
,
const
QString
&
new_p
ath
)
{
QFileInfo
info
(
new
_p
ath
);
ensureDirectoryPathExists
(
info
.
path
());
if
(
QFile
::
copy
(
oldPath
,
newPath
))
{
QFile
::
remove
(
oldPath
);
qInfo
()
<<
"Migrated"
<<
oldPath
<<
"to"
<<
newPath
;
if
(
QFile
::
copy
(
old_path
,
new_path
))
{
QFile
::
remove
(
old_path
);
qInfo
()
<<
"Migrated"
<<
old_path
<<
"to"
<<
new_path
;
}
else
{
qWarning
()
<<
"Failed migration of"
<<
old
Path
<<
"to"
<<
newP
ath
;
qWarning
()
<<
"Failed migration of"
<<
old
_path
<<
"to"
<<
new_p
ath
;
}
}
static
void
migrateConfigurationFile
(
const
QString
&
old
Path
,
const
QString
&
newP
ath
)
{
QFileInfo
info
(
new
P
ath
);
static
void
migrateConfigurationFile
(
const
QString
&
old
_path
,
const
QString
&
new_p
ath
)
{
QFileInfo
info
(
new
_p
ath
);
ensureDirectoryPathExists
(
info
.
path
());
if
(
QFile
::
copy
(
oldPath
,
newPath
))
{
QFile
oldFile
(
oldPath
);
if
(
oldFile
.
open
(
QIODevice
::
WriteOnly
))
{
QTextStream
stream
(
&
oldFile
);
stream
<<
"This file has been migrated to "
<<
newPath
;
if
(
QFile
::
copy
(
old_path
,
new_path
))
{
QFile
old_file
(
old_path
);
if
(
old_file
.
open
(
QIODevice
::
WriteOnly
))
{
QTextStream
stream
(
&
old_file
);
stream
<<
"This file has been migrated to "
<<
new_path
;
}
QFile
::
setPermissions
(
oldPath
,
QFileDevice
::
ReadOwner
);
qInfo
()
<<
"Migrated"
<<
oldPath
<<
"to"
<<
newPath
;
QFile
::
setPermissions
(
old_path
,
QFileDevice
::
ReadOwner
);
qInfo
()
<<
"Migrated"
<<
old_path
<<
"to"
<<
new_path
;
}
else
{
qWarning
()
<<
"Failed migration of"
<<
old
Path
<<
"to"
<<
newP
ath
;
qWarning
()
<<
"Failed migration of"
<<
old
_path
<<
"to"
<<
new_p
ath
;
}
}
void
Paths
::
migrate
()
{
QString
newPath
;
QString
oldPath
;
QString
oldBaseDir
;
QString
new_path
=
getAppConfigFilepath
();
QString
old_base_dir
=
QSysInfo
::
productType
()
==
"windows"
?
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
)
:
QStandardPaths
::
writableLocation
(
QStandardPaths
::
HomeLocation
);
QString
old_path
=
old_base_dir
+
"/.linphonerc"
;
if
(
QSysInfo
::
productType
()
==
"windows"
)
{
oldBaseDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppLocalDataLocation
);
}
else
{
oldBaseDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
HomeLocation
);
}
newPath
=
getAppConfigFilepath
();
oldPath
=
oldBaseDir
+
"/.linphonerc"
;
if
(
!
filePathExists
(
newPath
)
&&
filePathExists
(
oldPath
))
migrateConfigurationFile
(
oldPath
,
newPath
);
newPath
=
getAppCallHistoryFilepath
();
oldPath
=
oldBaseDir
+
"/.linphone-call-history.db"
;
if
(
!
filePathExists
(
newPath
)
&&
filePathExists
(
oldPath
))
migrateFile
(
oldPath
,
newPath
);
newPath
=
getAppFriendsFilepath
();
oldPath
=
oldBaseDir
+
"/.linphone-friends.db"
;
if
(
!
filePathExists
(
newPath
)
&&
filePathExists
(
oldPath
))
migrateFile
(
oldPath
,
newPath
);
newPath
=
getAppMessageHistoryFilepath
();
oldPath
=
oldBaseDir
+
"/.linphone-history.db"
;
if
(
!
filePathExists
(
newPath
)
&&
filePathExists
(
oldPath
))
migrateFile
(
oldPath
,
newPath
);
if
(
!
filePathExists
(
new_path
)
&&
filePathExists
(
old_path
))
migrateConfigurationFile
(
old_path
,
new_path
);
new_path
=
getAppCallHistoryFilepath
();
old_path
=
old_base_dir
+
"/.linphone-call-history.db"
;
if
(
!
filePathExists
(
new_path
)
&&
filePathExists
(
old_path
))
migrateFile
(
old_path
,
new_path
);
new_path
=
getAppFriendsFilepath
();
old_path
=
old_base_dir
+
"/.linphone-friends.db"
;
if
(
!
filePathExists
(
new_path
)
&&
filePathExists
(
old_path
))
migrateFile
(
old_path
,
new_path
);
new_path
=
getAppMessageHistoryFilepath
();
old_path
=
old_base_dir
+
"/.linphone-history.db"
;
if
(
!
filePathExists
(
new_path
)
&&
filePathExists
(
old_path
))
migrateFile
(
old_path
,
new_path
);
}
linphone-desktop/src/app/Paths.hpp
View file @
cbc8c720
...
...
@@ -24,22 +24,24 @@
#define PATHS_H_
#include <string>
#include <QString>
// =============================================================================
namespace
Paths
{
std
::
string
getAvatarsDirpath
();
std
::
string
getCallHistoryFilepath
();
std
::
string
getConfigFilepath
(
const
QString
&
configPath
=
QString
());
std
::
string
getFriendsListFilepath
();
std
::
string
getCapturesDirpath
();
std
::
string
getLogsDirpath
();
std
::
string
getMessageHistoryFilepath
();
std
::
string
getThumbnailsDirpath
();
std
::
string
getZrtpSecretsFilepath
();
std
::
string
getUserCertificatesDirpath
();
std
::
string
getCallHistoryFilepath
();
std
::
string
getConfigFilepath
(
const
QString
&
config_path
=
QString
());
std
::
string
getFriendsListFilepath
();
std
::
string
getMessageHistoryFilepath
();
std
::
string
getZrtpSecretsFilepath
();
void
migrate
();
}
...
...
linphone-desktop/src/components/core/CoreManager.cpp
View file @
cbc8c720
...
...
@@ -37,7 +37,7 @@ CoreManager *CoreManager::m_instance = nullptr;
CoreManager
::
CoreManager
(
QObject
*
parent
,
const
QString
&
config_path
)
:
QObject
(
parent
),
m_handlers
(
make_shared
<
CoreHandlers
>
())
{
// TODO: activate migration when ready to switch to this new version
//Paths::migrate();
//
Paths::migrate();
setResourcesPaths
();
...
...
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