diff options
author | Max Kellermann <max@duempel.org> | 2014-02-04 11:33:53 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-02-04 11:35:23 +0100 |
commit | abc16b919ddb5f1d7d76774691b7d664ca5ef3ea (patch) | |
tree | 1867b4500b0433fe66337360a025a277f081de96 /src/command | |
parent | 2de7cd32eaec778f9630b682edbca3d1430cd27b (diff) |
{Message,Neighbor}Commands: use Client::partition instead of Main.hxx
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/AllCommands.cxx | 8 | ||||
-rw-r--r-- | src/command/MessageCommands.cxx | 6 | ||||
-rw-r--r-- | src/command/NeighborCommands.cxx | 13 | ||||
-rw-r--r-- | src/command/NeighborCommands.hxx | 3 |
4 files changed, 17 insertions, 13 deletions
diff --git a/src/command/AllCommands.cxx b/src/command/AllCommands.cxx index 3bc6ff6a9..2ac55e715 100644 --- a/src/command/AllCommands.cxx +++ b/src/command/AllCommands.cxx @@ -32,6 +32,7 @@ #include "Permission.hxx" #include "tag/TagType.h" #include "protocol/Result.hxx" +#include "Partition.hxx" #include "client/Client.hxx" #include "util/Tokenizer.hxx" #include "util/Error.hxx" @@ -184,7 +185,8 @@ static const struct command commands[] = { static const unsigned num_commands = sizeof(commands) / sizeof(commands[0]); static bool -command_available(gcc_unused const struct command *cmd) +command_available(gcc_unused const Partition &partition, + gcc_unused const struct command *cmd) { #ifdef ENABLE_SQLITE if (strcmp(cmd->cmd, "sticker") == 0) @@ -193,7 +195,7 @@ command_available(gcc_unused const struct command *cmd) #ifdef ENABLE_NEIGHBOR_PLUGINS if (strcmp(cmd->cmd, "listneighbors") == 0) - return neighbor_commands_available(); + return neighbor_commands_available(partition.instance); #endif return true; @@ -211,7 +213,7 @@ handle_commands(Client &client, cmd = &commands[i]; if (cmd->permission == (permission & cmd->permission) && - command_available(cmd)) + command_available(client.partition, cmd)) client_printf(client, "command: %s\n", cmd->cmd); } diff --git a/src/command/MessageCommands.cxx b/src/command/MessageCommands.cxx index b04e72c07..fe7500aaf 100644 --- a/src/command/MessageCommands.cxx +++ b/src/command/MessageCommands.cxx @@ -22,7 +22,7 @@ #include "client/Client.hxx" #include "client/ClientList.hxx" #include "Instance.hxx" -#include "Main.hxx" +#include "Partition.hxx" #include "protocol/Result.hxx" #include <set> @@ -81,7 +81,7 @@ handle_channels(Client &client, assert(argc == 1); std::set<std::string> channels; - for (const auto &c : *instance->client_list) + for (const auto &c : *client.partition.instance.client_list) channels.insert(c->subscriptions.begin(), c->subscriptions.end()); @@ -122,7 +122,7 @@ handle_send_message(Client &client, bool sent = false; const ClientMessage msg(argv[1], argv[2]); - for (const auto &c : *instance->client_list) + for (const auto &c : *client.partition.instance.client_list) if (c->PushMessage(msg)) sent = true; diff --git a/src/command/NeighborCommands.cxx b/src/command/NeighborCommands.cxx index ee88c7935..1171f6424 100644 --- a/src/command/NeighborCommands.cxx +++ b/src/command/NeighborCommands.cxx @@ -21,7 +21,7 @@ #include "NeighborCommands.hxx" #include "client/Client.hxx" #include "Instance.hxx" -#include "Main.hxx" +#include "Partition.hxx" #include "protocol/Result.hxx" #include "neighbor/Glue.hxx" #include "neighbor/Info.hxx" @@ -32,23 +32,24 @@ #include <assert.h> bool -neighbor_commands_available() +neighbor_commands_available(const Instance &instance) { - return instance->neighbors != nullptr; + return instance.neighbors != nullptr; } CommandResult handle_listneighbors(Client &client, gcc_unused int argc, gcc_unused char *argv[]) { - if (instance->neighbors == nullptr) { + const NeighborGlue *const neighbors = + client.partition.instance.neighbors; + if (neighbors == nullptr) { command_error(client, ACK_ERROR_UNKNOWN, "No neighbor plugin configured"); return CommandResult::ERROR; } - const auto neighbors = instance->neighbors->GetList(); - for (const auto &i : neighbors) + for (const auto &i : neighbors->GetList()) client_printf(client, "neighbor: %s\n" "name: %s\n", diff --git a/src/command/NeighborCommands.hxx b/src/command/NeighborCommands.hxx index 7bad946b4..64a7fe120 100644 --- a/src/command/NeighborCommands.hxx +++ b/src/command/NeighborCommands.hxx @@ -23,11 +23,12 @@ #include "CommandResult.hxx" #include "Compiler.h" +struct Instance; class Client; gcc_pure bool -neighbor_commands_available(); +neighbor_commands_available(const Instance &instance); CommandResult handle_listneighbors(Client &client, int argc, char *argv[]); |