Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
abc16b91
Commit
abc16b91
authored
Feb 04, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
{Message,Neighbor}Commands: use Client::partition instead of Main.hxx
parent
2de7cd32
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
13 deletions
+17
-13
AllCommands.cxx
src/command/AllCommands.cxx
+5
-3
MessageCommands.cxx
src/command/MessageCommands.cxx
+3
-3
NeighborCommands.cxx
src/command/NeighborCommands.cxx
+7
-6
NeighborCommands.hxx
src/command/NeighborCommands.hxx
+2
-1
No files found.
src/command/AllCommands.cxx
View file @
abc16b91
...
...
@@ -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
(
c
lient
.
partition
,
c
md
))
client_printf
(
client
,
"command: %s
\n
"
,
cmd
->
cmd
);
}
...
...
src/command/MessageCommands.cxx
View file @
abc16b91
...
...
@@ -22,7 +22,7 @@
#include "client/Client.hxx"
#include "client/ClientList.hxx"
#include "Instance.hxx"
#include "
Mai
n.hxx"
#include "
Partitio
n.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
;
...
...
src/command/NeighborCommands.cxx
View file @
abc16b91
...
...
@@ -21,7 +21,7 @@
#include "NeighborCommands.hxx"
#include "client/Client.hxx"
#include "Instance.hxx"
#include "
Mai
n.hxx"
#include "
Partitio
n.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
"
,
...
...
src/command/NeighborCommands.hxx
View file @
abc16b91
...
...
@@ -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
[]);
...
...
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