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-daemon
Commits
a646cde3
Commit
a646cde3
authored
Oct 15, 2015
by
Adrien Béraud
Committed by
Guillaume Roguez
Oct 23, 2015
Browse files
ring: parse ring:// uri for calls and text messages
Tuleap:
#3
Change-Id: If43ac48729f4f55ba7fa02faa548b69d7f41dc78
parent
65ab34ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/ringdht/ringaccount.cpp
View file @
a646cde3
...
...
@@ -83,6 +83,28 @@ constexpr const char * const RingAccount::ACCOUNT_TYPE;
static
std
::
uniform_int_distribution
<
dht
::
Value
::
Id
>
udist
;
static
const
std
::
string
parseRingUri
(
const
std
::
string
&
toUrl
)
{
auto
dhtf
=
toUrl
.
find
(
"ring:"
);
if
(
dhtf
!=
std
::
string
::
npos
)
{
dhtf
=
dhtf
+
5
;
}
else
{
dhtf
=
toUrl
.
find
(
"sips:"
);
dhtf
=
(
dhtf
==
std
::
string
::
npos
)
?
0
:
dhtf
+
5
;
}
while
(
dhtf
<
toUrl
.
length
()
&&
toUrl
[
dhtf
]
==
'/'
)
dhtf
++
;
if
(
toUrl
.
length
()
-
dhtf
<
40
)
throw
std
::
invalid_argument
(
"id must be a ring infohash"
);
const
std
::
string
toUri
=
toUrl
.
substr
(
dhtf
,
40
);
if
(
std
::
find_if_not
(
toUri
.
cbegin
(),
toUri
.
cend
(),
::
isxdigit
)
!=
toUri
.
cend
())
throw
std
::
invalid_argument
(
"id must be a ring infohash"
);
return
toUri
;
}
/**
* Local ICE Transport factory helper
*
...
...
@@ -152,20 +174,7 @@ template <>
std
::
shared_ptr
<
SIPCall
>
RingAccount
::
newOutgoingCall
(
const
std
::
string
&
toUrl
)
{
auto
dhtf
=
toUrl
.
find
(
RING_URI_PREFIX
);
if
(
dhtf
!=
std
::
string
::
npos
)
{
dhtf
=
dhtf
+
5
;
}
else
{
dhtf
=
toUrl
.
find
(
"sips:"
);
dhtf
=
(
dhtf
==
std
::
string
::
npos
)
?
0
:
dhtf
+
5
;
}
if
(
toUrl
.
length
()
-
dhtf
<
40
)
throw
std
::
invalid_argument
(
"id must be a ring infohash"
);
const
std
::
string
toUri
=
toUrl
.
substr
(
dhtf
,
40
);
if
(
std
::
find_if_not
(
toUri
.
cbegin
(),
toUri
.
cend
(),
::
isxdigit
)
!=
toUri
.
cend
())
throw
std
::
invalid_argument
(
"id must be a ring infohash"
);
const
std
::
string
toUri
=
parseRingUri
(
toUrl
);
RING_DBG
(
"Calling DHT peer %s"
,
toUri
.
c_str
());
auto
&
manager
=
Manager
::
instance
();
...
...
@@ -1273,8 +1282,9 @@ RingAccount::connectivityChanged()
void
RingAccount
::
sendTextMessage
(
const
std
::
string
&
to
,
const
std
::
string
&
message
)
{
dht_
.
putEncrypted
(
dht
::
InfoHash
::
get
(
"inbox:"
+
to
),
dht
::
InfoHash
(
to
),
const
std
::
string
&
toUri
=
parseRingUri
(
to
);
dht_
.
putEncrypted
(
dht
::
InfoHash
::
get
(
"inbox:"
+
toUri
),
dht
::
InfoHash
(
toUri
),
dht
::
ImMessage
(
std
::
string
(
message
)));
}
...
...
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