Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-libclient
Commits
67d0902c
Commit
67d0902c
authored
Nov 05, 2019
by
Andreas Traczyk
Committed by
Sébastien Blin
Nov 06, 2019
Browse files
profiles: try to open the base64 path first for vcards
Change-Id: I632b4dd891813327fbdaec1d90e3c42e99af9a39
parent
ad56bb86
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/authority/storagehelper.cpp
View file @
67d0902c
...
@@ -232,7 +232,7 @@ setProfile(const std::string& accountId,
...
@@ -232,7 +232,7 @@ setProfile(const std::string& accountId,
file
.
setFileName
(
filePath
);
file
.
setFileName
(
filePath
);
}
}
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
qWarning
().
noquote
()
<<
"Can't open file: "
<<
filePath
;
qWarning
().
noquote
()
<<
"Can't open file
for writing
: "
<<
filePath
;
return
;
return
;
}
}
QTextStream
(
&
file
)
<<
QString
::
fromStdString
(
vcard
);
QTextStream
(
&
file
)
<<
QString
::
fromStdString
(
vcard
);
...
@@ -299,26 +299,28 @@ buildContactFromProfile(const std::string & accountId,
...
@@ -299,26 +299,28 @@ buildContactFromProfile(const std::string & accountId,
profileInfo
.
uri
=
peer_uri
;
profileInfo
.
uri
=
peer_uri
;
profileInfo
.
type
=
type
;
profileInfo
.
type
=
type
;
auto
accountLocalPath
=
getPath
()
+
QString
::
fromStdString
(
accountId
)
+
"/"
;
auto
accountLocalPath
=
getPath
()
+
QString
::
fromStdString
(
accountId
)
+
"/"
;
QString
filePath
;
QString
b64filePath
;
filePath
=
accountLocalPath
+
"profiles/"
+
QString
::
fromStdString
(
peer_uri
)
+
".vcf"
;
b64filePath
=
accountLocalPath
+
"profiles/"
+
QString
(
QByteArray
::
fromStdString
(
peer_uri
).
toBase64
())
+
".vcf"
;
QFile
file
(
filePath
);
QFile
file
(
b64filePath
);
bool
deleteOld
=
false
;
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
qWarning
().
noquote
()
<<
"Can't open file: "
<<
filePath
<<
". Trying B
ase64
file
path
."
;
// try non-b
ase64 path
filePath
=
accountLocalPath
+
"profiles/"
+
QString
(
QByteArray
::
fromStdString
(
peer_uri
)
.
toBase64
())
+
".vcf"
;
QString
filePath
=
accountLocalPath
+
"profiles/"
+
QString
::
fromStdString
(
peer_uri
)
+
".vcf"
;
file
.
setFileName
(
filePath
);
file
.
setFileName
(
filePath
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
qWarning
().
noquote
()
<<
"Can't open file (base64 file path): "
<<
filePath
;
qWarning
().
noquote
()
<<
"Can't open file: "
<<
filePath
;
return
{
profileInfo
,
""
,
true
,
false
};
}
// rename it
qWarning
().
noquote
()
<<
"Renaming profile: "
<<
filePath
;
file
.
rename
(
b64filePath
);
// reopen it
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
))
{
qWarning
().
noquote
()
<<
"Can't open file: "
<<
b64filePath
;
return
{
profileInfo
,
""
,
true
,
false
};
return
{
profileInfo
,
""
,
true
,
false
};
}
}
}
else
{
deleteOld
=
true
;
}
}
QTextStream
in
(
&
file
);
QTextStream
in
(
&
file
);
QByteArray
vcard
=
in
.
readAll
().
toUtf8
();
QByteArray
vcard
=
in
.
readAll
().
toUtf8
();
if
(
deleteOld
)
{
file
.
remove
();
}
const
auto
vCard
=
lrc
::
vCard
::
utils
::
toHashMap
(
vcard
);
const
auto
vCard
=
lrc
::
vCard
::
utils
::
toHashMap
(
vcard
);
const
auto
alias
=
vCard
[
vCard
::
Property
::
FORMATTED_NAME
];
const
auto
alias
=
vCard
[
vCard
::
Property
::
FORMATTED_NAME
];
const
auto
photo
=
(
vCard
.
find
(
vCard
::
Property
::
PHOTO_PNG
)
==
vCard
.
end
())
?
const
auto
photo
=
(
vCard
.
find
(
vCard
::
Property
::
PHOTO_PNG
)
==
vCard
.
end
())
?
...
...
Write
Preview
Supports
Markdown
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