Ring Daemon
16.0.0
Loading...
Searching...
No Matches
uri.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3
*
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 3 of the License, or
7
* (at your option) any later version.
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16
*/
17
#include "
uri.h
"
18
19
#include <fmt/format.h>
20
#include <fmt/compile.h>
21
22
namespace
jami
{
23
24
Uri::Uri
(std::string_view uri)
25
{
26
// TODO better handling of Uri, for now it's only used for
27
// setMessageDisplayed to differentiate swarm:xxx
28
scheme_ =
Uri::Scheme::JAMI
;
29
auto
posSep
= uri.find(
':'
);
30
if
(
posSep
!= std::string::npos) {
31
auto
scheme_str
= uri.substr(0,
posSep
);
32
if
(
scheme_str
==
"sip"
)
33
scheme_ =
Uri::Scheme::SIP
;
34
else
if
(
scheme_str
==
"swarm"
)
35
scheme_ =
Uri::Scheme::SWARM
;
36
else
if
(
scheme_str
==
"jami"
)
37
scheme_ =
Uri::Scheme::JAMI
;
38
else
if
(
scheme_str
==
"data-transfer"
)
39
scheme_ =
Uri::Scheme::DATA_TRANSFER
;
40
else
if
(
scheme_str
==
"git"
)
41
scheme_ =
Uri::Scheme::GIT
;
42
else
if
(
scheme_str
==
"rdv"
)
43
scheme_ =
Uri::Scheme::RENDEZVOUS
;
44
else
if
(
scheme_str
==
"sync"
)
45
scheme_ =
Uri::Scheme::SYNC
;
46
else
if
(
scheme_str
==
"msg"
)
47
scheme_ =
Uri::Scheme::MESSAGE
;
48
else
if
(
scheme_str
==
"auth"
)
49
scheme_ =
Uri::Scheme::AUTH
;
50
else
51
scheme_ =
Uri::Scheme::UNRECOGNIZED
;
52
authority_ = uri.substr(
posSep
+ 1);
53
}
else
{
54
authority_ = uri;
55
}
56
auto
posParams
= authority_.find(
';'
);
57
if
(
posParams
!= std::string::npos) {
58
authority_ = authority_.substr(0,
posParams
);
59
}
60
}
61
62
const
std::string&
63
Uri::authority
()
const
64
{
65
return
authority_;
66
}
67
68
Uri::Scheme
69
Uri::scheme
()
const
70
{
71
return
scheme_;
72
}
73
74
std::string
75
Uri::toString
()
const
76
{
77
return
fmt::format(
FMT_COMPILE
(
"{}:{}"
), schemeToString(), authority_);
78
}
79
80
constexpr
std::string_view
81
Uri::schemeToString()
const
82
{
83
switch
(scheme_) {
84
case
Uri::Scheme::SIP
:
85
return
"sip"
sv
;
86
case
Uri::Scheme::SWARM
:
87
return
"swarm"
sv
;
88
case
Uri::Scheme::RENDEZVOUS
:
89
return
"rdv"
sv
;
90
case
Uri::Scheme::GIT
:
91
return
"git"
sv
;
92
case
Uri::Scheme::SYNC
:
93
return
"sync"
sv
;
94
case
Uri::Scheme::MESSAGE
:
95
return
"msg"
sv
;
96
case
Uri::Scheme::AUTH
:
97
return
"auth"
sv
;
98
case
Uri::Scheme::JAMI
:
99
case
Uri::Scheme::UNRECOGNIZED
:
100
default
:
101
return
"jami"
sv
;
102
}
103
}
104
105
}
// namespace jami
jami::Uri::Uri
Uri(std::string_view uri)
Definition
uri.cpp:24
jami::Uri::authority
const std::string & authority() const
Definition
uri.cpp:63
jami::Uri::scheme
Scheme scheme() const
Definition
uri.cpp:69
jami::Uri::toString
std::string toString() const
Definition
uri.cpp:75
jami::Uri::Scheme
Scheme
Definition
uri.h:31
jami::Uri::Scheme::JAMI
@ JAMI
jami::Uri::Scheme::SYNC
@ SYNC
jami::Uri::Scheme::SWARM
@ SWARM
jami::Uri::Scheme::DATA_TRANSFER
@ DATA_TRANSFER
jami::Uri::Scheme::SIP
@ SIP
jami::Uri::Scheme::MESSAGE
@ MESSAGE
jami::Uri::Scheme::RENDEZVOUS
@ RENDEZVOUS
jami::Uri::Scheme::UNRECOGNIZED
@ UNRECOGNIZED
jami::Uri::Scheme::GIT
@ GIT
jami::Uri::Scheme::AUTH
@ AUTH
jami
Definition
account.cpp:61
jami::emitSignal
void emitSignal(Args... args)
Definition
ring_signal.h:64
uri.h
src
uri.cpp
Generated on Thu Jun 19 2025 15:50:38 for Ring Daemon by
1.9.8