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
e88d1d09
Commit
e88d1d09
authored
May 05, 2017
by
Ronan Abhamon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(src/components/contact/VcardModel): interpret sip address on add/remove
parent
853f9fa8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
16 deletions
+24
-16
VcardModel.cpp
linphone-desktop/src/components/contact/VcardModel.cpp
+24
-16
No files found.
linphone-desktop/src/components/contact/VcardModel.cpp
View file @
e88d1d09
...
...
@@ -52,17 +52,14 @@ inline shared_ptr<T> findBelCardValue (const list<shared_ptr<T> > &list, const Q
}
);
if
(
it
!=
list
.
cend
())
return
*
it
;
return
nullptr
;
return
it
!=
list
.
cend
()
?
*
it
:
nullptr
;
}
inline
bool
isLinphoneDesktopPhoto
(
const
shared_ptr
<
belcard
::
BelCardPhoto
>
&
photo
)
{
return
!
photo
->
getValue
().
compare
(
0
,
sizeof
(
VCARD_SCHEME
)
-
1
,
VCARD_SCHEME
);
}
inline
shared_ptr
<
belcard
::
BelCardPhoto
>
findBelcardPhoto
(
const
shared_ptr
<
belcard
::
BelCard
>
&
belcard
)
{
static
shared_ptr
<
belcard
::
BelCardPhoto
>
findBelcardPhoto
(
const
shared_ptr
<
belcard
::
BelCard
>
&
belcard
)
{
const
list
<
shared_ptr
<
belcard
::
BelCardPhoto
>
>
&
photos
=
belcard
->
getPhotos
();
auto
it
=
find_if
(
photos
.
cbegin
(),
photos
.
cend
(),
isLinphoneDesktopPhoto
);
if
(
it
!=
photos
.
cend
())
...
...
@@ -71,7 +68,7 @@ inline shared_ptr<belcard::BelCardPhoto> findBelcardPhoto (const shared_ptr<belc
return
nullptr
;
}
inline
void
removeBelcardPhoto
(
const
shared_ptr
<
belcard
::
BelCard
>
&
belcard
,
bool
cleanPathsOnly
=
false
)
{
static
void
removeBelcardPhoto
(
const
shared_ptr
<
belcard
::
BelCard
>
&
belcard
,
bool
cleanPathsOnly
=
false
)
{
list
<
shared_ptr
<
belcard
::
BelCardPhoto
>
>
photos
;
for
(
const
auto
photo
:
belcard
->
getPhotos
())
{
if
(
isLinphoneDesktopPhoto
(
photo
))
...
...
@@ -96,6 +93,21 @@ inline void removeBelcardPhoto (const shared_ptr<belcard::BelCard> &belcard, boo
}
}
static
string
interpretSipAddress
(
const
QString
&
sipAddress
)
{
string
out
;
shared_ptr
<
linphone
::
Address
>
linphoneAddress
=
CoreManager
::
getInstance
()
->
getCore
()
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sipAddress
)
);
if
(
!
linphoneAddress
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to interpret invalid sip address: `%1`."
).
arg
(
sipAddress
);
return
out
;
}
return
linphoneAddress
->
asStringUriOnly
();
}
// -----------------------------------------------------------------------------
VcardModel
::
VcardModel
(
shared_ptr
<
linphone
::
Vcard
>
vcard
,
bool
isReadOnly
)
{
...
...
@@ -277,20 +289,14 @@ QVariantList VcardModel::getSipAddresses () const {
bool
VcardModel
::
addSipAddress
(
const
QString
&
sipAddress
)
{
CHECK_VCARD_IS_WRITABLE
(
this
);
// Check sip address format.
shared_ptr
<
linphone
::
Address
>
linphoneAddress
=
CoreManager
::
getInstance
()
->
getCore
()
->
interpretUrl
(
::
Utils
::
qStringToLinphoneString
(
sipAddress
)
);
if
(
!
linphoneAddress
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to add invalid sip address on vcard: `%1`."
).
arg
(
sipAddress
);
string
interpretedSipAddress
=
interpretSipAddress
(
sipAddress
);
if
(
interpretedSipAddress
.
empty
())
return
false
;
}
// Add sip address in belcard.
shared_ptr
<
belcard
::
BelCard
>
belcard
=
mVcard
->
getVcard
();
shared_ptr
<
belcard
::
BelCardImpp
>
value
=
belcard
::
BelCardGeneric
::
create
<
belcard
::
BelCardImpp
>
();
value
->
setValue
(
linphoneAddress
->
asStringUriOnly
()
);
value
->
setValue
(
interpretedSipAddress
);
if
(
!
belcard
->
addImpp
(
value
))
{
qWarning
()
<<
QStringLiteral
(
"Unable to add sip address on vcard: `%1`."
).
arg
(
sipAddress
);
...
...
@@ -308,7 +314,9 @@ void VcardModel::removeSipAddress (const QString &sipAddress) {
shared_ptr
<
belcard
::
BelCard
>
belcard
=
mVcard
->
getVcard
();
list
<
shared_ptr
<
belcard
::
BelCardImpp
>
>
addresses
=
belcard
->
getImpp
();
shared_ptr
<
belcard
::
BelCardImpp
>
value
=
findBelCardValue
(
addresses
,
sipAddress
);
shared_ptr
<
belcard
::
BelCardImpp
>
value
=
findBelCardValue
(
addresses
,
::
Utils
::
linphoneStringToQString
(
interpretSipAddress
(
sipAddress
))
);
if
(
!
value
)
{
qWarning
()
<<
QStringLiteral
(
"Unable to remove sip address on vcard: `%1`."
).
arg
(
sipAddress
);
...
...
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