Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
louiz’
biboumi
Commits
e3ea0d62
Commit
e3ea0d62
authored
Aug 08, 2014
by
louiz’
Browse files
Use generic send_presence_error() instead of almost identical specializations
parent
7d99ba8d
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/bridge/bridge.cpp
View file @
e3ea0d62
...
...
@@ -331,9 +331,11 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st
}
}
void
Bridge
::
send_join_failed
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
text
)
void
Bridge
::
send_presence_error
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
error_code
,
const
std
::
string
&
text
)
{
this
->
xmpp
->
send_presence_error
(
std
::
to_string
(
iid
),
nick
,
this
->
user_jid
,
type
,
condition
,
text
);
this
->
xmpp
->
send_presence_error
(
std
::
to_string
(
iid
),
nick
,
this
->
user_jid
,
type
,
condition
,
error_code
,
text
);
}
void
Bridge
::
send_muc_leave
(
Iid
&&
iid
,
std
::
string
&&
nick
,
const
std
::
string
&
message
,
const
bool
self
)
...
...
@@ -412,7 +414,7 @@ void Bridge::kick_muc_user(Iid&& iid, const std::string& target, const std::stri
void
Bridge
::
send_nickname_conflict_error
(
const
Iid
&
iid
,
const
std
::
string
&
nickname
)
{
this
->
xmpp
->
send_
nickname_conflict
_error
(
std
::
to_string
(
iid
),
nickname
,
this
->
user_jid
);
this
->
xmpp
->
send_
presence
_error
(
std
::
to_string
(
iid
),
nickname
,
this
->
user_jid
,
"cancel"
,
"conflict"
,
"409"
,
""
);
}
void
Bridge
::
send_affiliation_role_change
(
const
Iid
&
iid
,
const
std
::
string
&
target
,
const
char
mode
)
...
...
src/bridge/bridge.hpp
View file @
e3ea0d62
...
...
@@ -100,10 +100,9 @@ public:
*/
void
send_message
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
body
,
const
bool
muc
);
/**
* Send a presence of type error, from a room. This is used to indicate
* why joining a room failed.
* Send a presence of type error, from a room.
*/
void
send_
join_failed
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
text
);
void
send_
presence_error
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
error_code
,
const
std
::
string
&
text
);
/**
* Send an unavailable presence from this participant
*/
...
...
src/irc/irc_client.cpp
View file @
e3ea0d62
...
...
@@ -77,8 +77,9 @@ void IrcClient::on_connection_failed(const std::string& reason)
for
(
const
std
::
string
&
channel
:
this
->
channels_to_join
)
{
Iid
iid
(
channel
+
"%"
+
this
->
hostname
);
this
->
bridge
->
send_join_failed
(
iid
,
this
->
current_nick
,
"cancel"
,
"item-not-found"
,
reason
);
this
->
bridge
->
send_presence_error
(
iid
,
this
->
current_nick
,
"cancel"
,
"item-not-found"
,
""
,
reason
);
}
}
else
// try the next port
...
...
src/xmpp/xmpp_component.cpp
View file @
e3ea0d62
...
...
@@ -911,38 +911,13 @@ void XmppComponent::kick_user(const std::string& muc_name,
this
->
send_stanza
(
presence
);
}
void
XmppComponent
::
send_nickname_conflict_error
(
const
std
::
string
&
muc_name
,
const
std
::
string
&
nickname
,
const
std
::
string
&
jid_to
)
{
Stanza
presence
(
"presence"
);
presence
[
"from"
]
=
muc_name
+
"@"
+
this
->
served_hostname
+
"/"
+
nickname
;
presence
[
"to"
]
=
jid_to
;
presence
[
"type"
]
=
"error"
;
XmlNode
x
(
"x"
);
x
[
"xmlns"
]
=
MUC_NS
;
x
.
close
();
presence
.
add_child
(
std
::
move
(
x
));
XmlNode
error
(
"error"
);
error
[
"by"
]
=
muc_name
+
"@"
+
this
->
served_hostname
;
error
[
"type"
]
=
"cancel"
;
error
[
"code"
]
=
"409"
;
XmlNode
conflict
(
"conflict"
);
conflict
[
"xmlns"
]
=
STANZA_NS
;
conflict
.
close
();
error
.
add_child
(
std
::
move
(
conflict
));
error
.
close
();
presence
.
add_child
(
std
::
move
(
error
));
presence
.
close
();
this
->
send_stanza
(
presence
);
}
void
XmppComponent
::
send_presence_error
(
const
std
::
string
&
muc_name
,
const
std
::
string
&
nickname
,
const
std
::
string
&
jid_to
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
)
const
std
::
string
&
nickname
,
const
std
::
string
&
jid_to
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
error_code
,
const
std
::
string
&
/* text */
)
{
Stanza
presence
(
"presence"
);
presence
[
"from"
]
=
muc_name
+
"@"
+
this
->
served_hostname
+
"/"
+
nickname
;
...
...
@@ -955,6 +930,8 @@ void XmppComponent::send_presence_error(const std::string& muc_name,
XmlNode
error
(
"error"
);
error
[
"by"
]
=
muc_name
+
"@"
+
this
->
served_hostname
;
error
[
"type"
]
=
type
;
if
(
!
error_code
.
empty
())
error
[
"code"
]
=
error_code
;
XmlNode
subnode
(
condition
);
subnode
[
"xmlns"
]
=
STANZA_NS
;
subnode
.
close
();
...
...
src/xmpp/xmpp_component.hpp
View file @
e3ea0d62
...
...
@@ -171,21 +171,16 @@ public:
const
std
::
string
&
reason
,
const
std
::
string
&
author
,
const
std
::
string
&
jid_to
);
/**
* Send a presence type=error with a conflict element
*/
void
send_nickname_conflict_error
(
const
std
::
string
&
muc_name
,
const
std
::
string
&
nickname
,
const
std
::
string
&
jid_to
);
/**
* Send a generic presence error
*/
void
send_presence_error
(
const
std
::
string
&
muc_name
,
const
std
::
string
&
nickname
,
const
std
::
string
&
jid_to
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
text
);
const
std
::
string
&
nickname
,
const
std
::
string
&
jid_to
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
error_code
,
const
std
::
string
&
text
);
/**
* Send a presence from the MUC indicating a change in the role and/or
* affiliation of a participant
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment