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
98
Issues
98
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
190c4ff1
Commit
190c4ff1
authored
Feb 20, 2014
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QUIT the irc server when the last channel is left
parent
e390b79a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
5 deletions
+17
-5
src/bridge/bridge.cpp
src/bridge/bridge.cpp
+4
-1
src/irc/irc_client.cpp
src/irc/irc_client.cpp
+8
-3
src/irc/irc_client.hpp
src/irc/irc_client.hpp
+5
-1
No files found.
src/bridge/bridge.cpp
View file @
190c4ff1
...
...
@@ -42,7 +42,7 @@ void Bridge::shutdown()
{
for
(
auto
it
=
this
->
irc_clients
.
begin
();
it
!=
this
->
irc_clients
.
end
();
++
it
)
{
it
->
second
->
send_quit_command
();
it
->
second
->
send_quit_command
(
"Gateway shutdown"
);
}
}
...
...
@@ -193,6 +193,9 @@ void Bridge::send_message(const Iid& iid, const std::string& nick, const std::st
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
);
IrcClient
*
irc
=
this
->
get_irc_client
(
iid
.
server
);
if
(
irc
&&
irc
->
number_of_joined_channels
()
==
0
)
irc
->
send_quit_command
(
""
);
}
void
Bridge
::
send_nick_change
(
Iid
&&
iid
,
...
...
src/irc/irc_client.cpp
View file @
190c4ff1
...
...
@@ -134,9 +134,9 @@ void IrcClient::send_topic_command(const std::string& chan_name, const std::stri
this
->
send_message
(
IrcMessage
(
"TOPIC"
,
{
chan_name
,
topic
}));
}
void
IrcClient
::
send_quit_command
()
void
IrcClient
::
send_quit_command
(
const
std
::
string
&
reason
)
{
this
->
send_message
(
IrcMessage
(
"QUIT"
,
{
"gateway shutdown"
}));
this
->
send_message
(
IrcMessage
(
"QUIT"
,
{
reason
}));
}
void
IrcClient
::
send_join_command
(
const
std
::
string
&
chan_name
)
...
...
@@ -403,7 +403,6 @@ void IrcClient::on_part(const IrcMessage& message)
iid
.
chan
=
chan_name
;
iid
.
server
=
this
->
hostname
;
bool
self
=
channel
->
get_self
()
->
nick
==
nick
;
this
->
bridge
->
send_muc_leave
(
std
::
move
(
iid
),
std
::
move
(
nick
),
std
::
move
(
txt
),
self
);
if
(
self
)
{
channel
->
joined
=
false
;
...
...
@@ -411,6 +410,7 @@ void IrcClient::on_part(const IrcMessage& message)
// channel pointer is now invalid
channel
=
nullptr
;
}
this
->
bridge
->
send_muc_leave
(
std
::
move
(
iid
),
std
::
move
(
nick
),
std
::
move
(
txt
),
self
);
}
}
...
...
@@ -608,3 +608,8 @@ void IrcClient::on_user_mode(const IrcMessage& message)
std
::
string
(
"User mode for "
)
+
message
.
arguments
[
0
]
+
" is ["
+
message
.
arguments
[
1
]
+
"]"
);
}
size_t
IrcClient
::
number_of_joined_channels
()
const
{
return
this
->
channels
.
size
();
}
src/irc/irc_client.hpp
View file @
190c4ff1
...
...
@@ -101,7 +101,7 @@ public:
/**
* Send the QUIT irc command
*/
void
send_quit_command
();
void
send_quit_command
(
const
std
::
string
&
reason
);
/**
* Send a message to the gateway user, not generated by the IRC server,
* but that might be useful because we want to be verbose (for example we
...
...
@@ -186,6 +186,10 @@ public:
*/
void
on_channel_mode
(
const
IrcMessage
&
message
);
void
on_quit
(
const
IrcMessage
&
message
);
/**
* Return the number of joined channels
*/
size_t
number_of_joined_channels
()
const
;
private:
/**
...
...
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