Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
99
Issues
99
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
6c2d03da
Commit
6c2d03da
authored
May 28, 2014
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send an error presence when the connection to the IRC server fails
parent
7b31bea7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
1 deletion
+54
-1
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+5
-0
src/bridge/bridge.hpp
src/bridge/bridge.hpp
+5
-0
src/irc/irc_client.cpp
src/irc/irc_client.cpp
+8
-1
src/xmpp/xmpp_component.cpp
src/xmpp/xmpp_component.cpp
+27
-0
src/xmpp/xmpp_component.hpp
src/xmpp/xmpp_component.hpp
+9
-0
No files found.
src/bridge/bridge.cpp
View file @
6c2d03da
...
...
@@ -241,6 +241,11 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st
this
->
make_xmpp_body
(
body
),
this
->
user_jid
,
"chat"
);
}
void
Bridge
::
send_join_failed
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
text
)
{
this
->
xmpp
->
send_presence_error
(
iid
.
chan
+
"%"
+
iid
.
server
,
nick
,
this
->
user_jid
,
type
,
condition
,
text
);
}
void
Bridge
::
send_muc_leave
(
Iid
&&
iid
,
std
::
string
&&
nick
,
const
std
::
string
&
message
,
const
bool
self
)
{
this
->
xmpp
->
send_muc_leave
(
std
::
move
(
iid
.
chan
)
+
"%"
+
std
::
move
(
iid
.
server
),
std
::
move
(
nick
),
this
->
make_xmpp_body
(
message
),
this
->
user_jid
,
self
);
...
...
src/bridge/bridge.hpp
View file @
6c2d03da
...
...
@@ -80,6 +80,11 @@ public:
* Send a MUC message from some participant
*/
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.
*/
void
send_join_failed
(
const
Iid
&
iid
,
const
std
::
string
&
nick
,
const
std
::
string
&
type
,
const
std
::
string
&
condition
,
const
std
::
string
&
text
);
/**
* Send an unavailable presence from this participant
*/
...
...
src/irc/irc_client.cpp
View file @
6c2d03da
...
...
@@ -50,6 +50,13 @@ void IrcClient::on_connection_failed(const std::string& reason)
{
this
->
bridge
->
send_xmpp_message
(
this
->
hostname
,
""
,
"Connection failed: "
s
+
reason
);
// Send an error message for all room that the user wanted to join
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
);
}
}
void
IrcClient
::
on_connected
()
...
...
@@ -167,11 +174,11 @@ void IrcClient::send_quit_command(const std::string& reason)
void
IrcClient
::
send_join_command
(
const
std
::
string
&
chan_name
)
{
this
->
start
();
if
(
this
->
welcomed
==
false
)
this
->
channels_to_join
.
push_back
(
chan_name
);
else
this
->
send_message
(
IrcMessage
(
"JOIN"
,
{
chan_name
}));
this
->
start
();
}
bool
IrcClient
::
send_channel_message
(
const
std
::
string
&
chan_name
,
const
std
::
string
&
body
)
...
...
src/xmpp/xmpp_component.cpp
View file @
6c2d03da
...
...
@@ -796,6 +796,33 @@ void XmppComponent::send_nickname_conflict_error(const std::string& muc_name,
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
&
)
{
Stanza
presence
(
"presence"
);
presence
[
"from"
]
=
muc_name
+
"@"
+
this
->
served_hostname
+
"/"
+
nickname
;
presence
[
"to"
]
=
jid_to
;
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"
]
=
type
;
XmlNode
subnode
(
condition
);
subnode
[
"xmlns"
]
=
STANZA_NS
;
subnode
.
close
();
error
.
add_child
(
std
::
move
(
subnode
));
error
.
close
();
presence
.
add_child
(
std
::
move
(
error
));
presence
.
close
();
this
->
send_stanza
(
presence
);
}
void
XmppComponent
::
send_affiliation_role_change
(
const
std
::
string
&
muc_name
,
const
std
::
string
&
target
,
const
std
::
string
&
affiliation
,
...
...
src/xmpp/xmpp_component.hpp
View file @
6c2d03da
...
...
@@ -141,6 +141,15 @@ public:
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
);
/**
* Send a presence from the MUC indicating a change in the role and/or
* affiliation of a participant
...
...
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