Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jami-libclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
savoirfairelinux
jami-libclient
Commits
9470ab5f
Commit
9470ab5f
authored
6 years ago
by
Hugo Lefeuvre
Committed by
Adrien Béraud
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
uri: fix broken ring infoHash support
Change-Id: I0d1ce3db21ebb3e13b8fc0c6df01564fea281c0d Gitlab:
#391
parent
24f35997
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/contactmodel.cpp
+26
-18
26 additions, 18 deletions
src/contactmodel.cpp
with
26 additions
and
18 deletions
src/contactmodel.cpp
+
26
−
18
View file @
9470ab5f
...
...
@@ -85,8 +85,8 @@ public:
/**
* Helpers for searchContact. Search for a given RING or SIP contact.
*/
void
searchRingContact
(
const
std
::
string
&
query
);
void
searchSipContact
(
const
std
::
string
&
query
);
void
searchRingContact
(
const
URI
&
query
);
void
searchSipContact
(
const
URI
&
query
);
/**
* Update temporary item to display a given message about a given uri.
*/
...
...
@@ -339,8 +339,6 @@ ContactModel::searchContact(const std::string& query)
auto
uri
=
URI
(
QString
(
query
.
c_str
()));
std
::
string
uriID
=
uri
.
format
(
URI
::
Section
::
USER_INFO
|
URI
::
Section
::
HOSTNAME
|
URI
::
Section
::
PORT
).
toStdString
();
auto
uriScheme
=
uri
.
schemeType
();
if
(
uri
.
schemeType
()
==
URI
::
SchemeType
::
NONE
)
{
// uri has no scheme, default to current account scheme
...
...
@@ -352,9 +350,9 @@ ContactModel::searchContact(const std::string& query)
}
if
(
uriScheme
==
URI
::
SchemeType
::
SIP
&&
owner
.
profileInfo
.
type
==
profile
::
Type
::
SIP
)
{
pimpl_
->
searchSipContact
(
uri
ID
);
pimpl_
->
searchSipContact
(
uri
);
}
else
if
(
uriScheme
==
URI
::
SchemeType
::
RING
&&
owner
.
profileInfo
.
type
==
profile
::
Type
::
RING
)
{
pimpl_
->
searchRingContact
(
uri
ID
);
pimpl_
->
searchRingContact
(
uri
);
}
else
{
pimpl_
->
updateTemporaryMessage
(
tr
(
"Bad URI scheme"
).
toStdString
(),
uri
.
full
().
toStdString
());
}
...
...
@@ -371,38 +369,48 @@ ContactModelPimpl::updateTemporaryMessage(const std::string& mes, const std::str
}
void
ContactModelPimpl
::
searchRingContact
(
const
std
::
string
&
query
)
ContactModelPimpl
::
searchRingContact
(
const
URI
&
query
)
{
if
(
query
.
e
mpty
())
{
if
(
query
.
isE
mpty
())
{
return
;
}
updateTemporaryMessage
(
tr
(
"Searching…"
).
toStdString
(),
query
);
std
::
string
uriID
=
query
.
format
(
URI
::
Section
::
USER_INFO
|
URI
::
Section
::
HOSTNAME
|
URI
::
Section
::
PORT
).
toStdString
();
if
(
query
.
protocolHint
()
==
URI
::
ProtocolHint
::
RING
)
{
// no lookup, this is a ring infoHash
auto
&
temporaryContact
=
contacts
[
""
];
temporaryContact
.
profileInfo
.
uri
=
uriID
;
temporaryContact
.
profileInfo
.
alias
=
uriID
;
temporaryContact
.
profileInfo
.
type
=
profile
::
Type
::
TEMPORARY
;
}
else
{
updateTemporaryMessage
(
tr
(
"Searching…"
).
toStdString
(),
uriID
);
// Default searching
if
(
auto
*
account
=
AccountModel
::
instance
().
getById
(
linked
.
owner
.
id
.
c_str
()))
{
account
->
lookupName
(
QString
(
query
.
c_str
()));
account
->
lookupName
(
QString
(
uriID
.
c_str
()));
}
}
}
void
ContactModelPimpl
::
searchSipContact
(
const
std
::
string
&
query
)
ContactModelPimpl
::
searchSipContact
(
const
URI
&
query
)
{
if
(
query
.
e
mpty
())
{
if
(
query
.
isE
mpty
())
{
return
;
}
std
::
string
uriID
=
query
.
format
(
URI
::
Section
::
USER_INFO
|
URI
::
Section
::
HOSTNAME
|
URI
::
Section
::
PORT
).
toStdString
();
auto
&
temporaryContact
=
contacts
[
""
];
{
std
::
lock_guard
<
std
::
mutex
>
lk
(
contactsMtx_
);
if
(
contacts
.
find
(
query
)
==
contacts
.
end
())
{
temporaryContact
.
profileInfo
.
uri
=
query
;
temporaryContact
.
profileInfo
.
alias
=
query
;
if
(
contacts
.
find
(
uriID
)
==
contacts
.
end
())
{
temporaryContact
.
profileInfo
.
uri
=
uriID
;
temporaryContact
.
profileInfo
.
alias
=
uriID
;
temporaryContact
.
profileInfo
.
type
=
profile
::
Type
::
TEMPORARY
;
}
}
emit
linked
.
modelUpdated
(
query
);
emit
linked
.
modelUpdated
(
uriID
);
}
uint64_t
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment