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
29453ba1
Commit
29453ba1
authored
Feb 07, 2017
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
client: add tag_mask attribute
The "tagtypes" command now has several sub commands which can be used to edit that mask.
parent
599d7764
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
174 additions
and
20 deletions
+174
-20
NEWS
NEWS
+2
-0
protocol.xml
doc/protocol.xml
+89
-12
TagPrint.cxx
src/TagPrint.cxx
+3
-1
Client.hxx
src/client/Client.hxx
+6
-0
Response.cxx
src/client/Response.cxx
+6
-0
Response.hxx
src/client/Response.hxx
+9
-0
AllCommands.cxx
src/command/AllCommands.cxx
+1
-1
ClientCommands.cxx
src/command/ClientCommands.cxx
+54
-4
OtherCommands.cxx
src/command/OtherCommands.cxx
+2
-1
DatabasePrint.cxx
src/db/DatabasePrint.cxx
+2
-1
No files found.
NEWS
View file @
29453ba1
ver 0.21 (not yet released)
* protocol
- "tagtypes" can be used to hide tags
ver 0.20.5 (not yet released)
* tags
...
...
doc/protocol.xml
View file @
29453ba1
...
...
@@ -2252,6 +2252,95 @@ OK
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_tagtypes"
>
<term>
<cmdsynopsis>
<command>
tagtypes
</command>
</cmdsynopsis>
</term>
<listitem>
<para>
Shows a list of available tag types. It is an
intersection of the
<varname>
metadata_to_use
</varname>
setting and this client's tag mask.
</para>
<para>
About the tag mask: each client can decide to disable
any number of tag types, which will be omitted from
responses to this client. That is a good idea, because
it makes responses smaller. The following
<command>
tagtypes
</command>
sub commands configure this
list.
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_tagtypes_disable"
>
<term>
<cmdsynopsis>
<command>
tagtypes
</command>
<arg
choice=
"plain"
>
disable
</arg>
<arg
choice=
"req"
rep=
"repeat"
><replaceable>
NAME
</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Remove one or more tags from the list of tag types the
client is interested in. These will be omitted from
responses to this client.
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_tagtypes_enable"
>
<term>
<cmdsynopsis>
<command>
tagtypes
</command>
<arg
choice=
"plain"
>
enable
</arg>
<arg
choice=
"req"
rep=
"repeat"
><replaceable>
NAME
</replaceable></arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Re-enable one or more tags from the list of tag types
for this client. These will no longer be hidden from
responses to this client.
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_tagtypes_clear"
>
<term>
<cmdsynopsis>
<command>
tagtypes
</command>
<arg
choice=
"plain"
>
clear
</arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Clear the list of tag types this client is interested
in. This means that
<application>
MPD
</application>
will
not send any tags to this client.
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_tagtypes_all"
>
<term>
<cmdsynopsis>
<command>
tagtypes
</command>
<arg
choice=
"plain"
>
all
</arg>
</cmdsynopsis>
</term>
<listitem>
<para>
Announce that this client is interested in all tag
types. This is the default setting for new clients.
</para>
</listitem>
</varlistentry>
</variablelist>
</section>
...
...
@@ -2410,18 +2499,6 @@ OK
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_tagtypes"
>
<term>
<cmdsynopsis>
<command>
tagtypes
</command>
</cmdsynopsis>
</term>
<listitem>
<para>
Shows a list of available song metadata.
</para>
</listitem>
</varlistentry>
<varlistentry
id=
"command_urlhandlers"
>
<term>
<cmdsynopsis>
...
...
src/TagPrint.cxx
View file @
29453ba1
...
...
@@ -40,8 +40,10 @@ tag_print(Response &r, TagType type, const char *value)
void
tag_print_values
(
Response
&
r
,
const
Tag
&
tag
)
{
const
auto
tag_mask
=
r
.
GetTagMask
();
for
(
const
auto
&
i
:
tag
)
tag_print
(
r
,
i
.
type
,
i
.
value
);
if
(
tag_mask
.
Test
(
i
.
type
))
tag_print
(
r
,
i
.
type
,
i
.
value
);
}
void
...
...
src/client/Client.hxx
View file @
29453ba1
...
...
@@ -23,6 +23,7 @@
#include "check.h"
#include "ClientMessage.hxx"
#include "command/CommandListBuilder.hxx"
#include "tag/Mask.hxx"
#include "event/FullyBufferedSocket.hxx"
#include "event/TimeoutMonitor.hxx"
#include "Compiler.h"
...
...
@@ -71,6 +72,11 @@ public:
unsigned
idle_subscriptions
;
/**
* The tags this client is interested in.
*/
TagMask
tag_mask
=
TagMask
::
All
();
/**
* A list of channel names this client is subscribed to.
*/
std
::
set
<
std
::
string
>
subscriptions
;
...
...
src/client/Response.cxx
View file @
29453ba1
...
...
@@ -23,6 +23,12 @@
#include "util/FormatString.hxx"
#include "util/AllocatedString.hxx"
TagMask
Response
::
GetTagMask
()
const
{
return
GetClient
().
tag_mask
;
}
bool
Response
::
Write
(
const
void
*
data
,
size_t
length
)
{
...
...
src/client/Response.hxx
View file @
29453ba1
...
...
@@ -22,11 +22,13 @@
#include "check.h"
#include "protocol/Ack.hxx"
#include "Compiler.h"
#include <stddef.h>
#include <stdarg.h>
class
Client
;
class
TagMask
;
class
Response
{
Client
&
client
;
...
...
@@ -59,6 +61,13 @@ public:
return
client
;
}
/**
* Accessor for Client::tag_mask. Can be used if caller wants
* to avoid including Client.hxx.
*/
gcc_pure
TagMask
GetTagMask
()
const
;
void
SetCommand
(
const
char
*
_command
)
{
command
=
_command
;
}
...
...
src/command/AllCommands.cxx
View file @
29453ba1
...
...
@@ -187,7 +187,7 @@ static constexpr struct command commands[] = {
{
"subscribe"
,
PERMISSION_READ
,
1
,
1
,
handle_subscribe
},
{
"swap"
,
PERMISSION_CONTROL
,
2
,
2
,
handle_swap
},
{
"swapid"
,
PERMISSION_CONTROL
,
2
,
2
,
handle_swapid
},
{
"tagtypes"
,
PERMISSION_READ
,
0
,
0
,
handle_tagtypes
},
{
"tagtypes"
,
PERMISSION_READ
,
0
,
-
1
,
handle_tagtypes
},
{
"toggleoutput"
,
PERMISSION_ADMIN
,
1
,
1
,
handle_toggleoutput
},
#ifdef ENABLE_DATABASE
{
"unmount"
,
PERMISSION_ADMIN
,
1
,
1
,
handle_unmount
},
...
...
src/command/ClientCommands.cxx
View file @
29453ba1
...
...
@@ -24,6 +24,8 @@
#include "client/Client.hxx"
#include "client/Response.hxx"
#include "TagPrint.hxx"
#include "tag/ParseName.hxx"
#include "util/StringAPI.hxx"
CommandResult
handle_close
(
gcc_unused
Client
&
client
,
gcc_unused
Request
args
,
...
...
@@ -53,10 +55,58 @@ handle_password(Client &client, Request args, Response &r)
return
CommandResult
::
OK
;
}
static
TagMask
ParseTagMask
(
Request
request
)
{
if
(
request
.
IsEmpty
())
throw
ProtocolError
(
ACK_ERROR_ARG
,
"Not enough arguments"
);
TagMask
result
=
TagMask
::
None
();
for
(
const
char
*
name
:
request
)
{
auto
type
=
tag_name_parse_i
(
name
);
if
(
type
==
TAG_NUM_OF_ITEM_TYPES
)
throw
ProtocolError
(
ACK_ERROR_ARG
,
"Unknown tag type"
);
result
|=
type
;
}
return
result
;
}
CommandResult
handle_tagtypes
(
gcc_unused
Client
&
client
,
gcc_unused
Request
request
,
Response
&
r
)
handle_tagtypes
(
Client
&
client
,
Request
request
,
Response
&
r
)
{
tag_print_types
(
r
);
return
CommandResult
::
OK
;
if
(
request
.
IsEmpty
())
{
tag_print_types
(
r
);
return
CommandResult
::
OK
;
}
const
char
*
cmd
=
request
.
shift
();
if
(
StringIsEqual
(
cmd
,
"all"
))
{
if
(
!
request
.
IsEmpty
())
{
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
return
CommandResult
::
ERROR
;
}
client
.
tag_mask
=
TagMask
::
All
();
return
CommandResult
::
OK
;
}
else
if
(
StringIsEqual
(
cmd
,
"clear"
))
{
if
(
!
request
.
IsEmpty
())
{
r
.
Error
(
ACK_ERROR_ARG
,
"Too many arguments"
);
return
CommandResult
::
ERROR
;
}
client
.
tag_mask
=
TagMask
::
None
();
return
CommandResult
::
OK
;
}
else
if
(
StringIsEqual
(
cmd
,
"enable"
))
{
client
.
tag_mask
|=
ParseTagMask
(
request
);
return
CommandResult
::
OK
;
}
else
if
(
StringIsEqual
(
cmd
,
"disable"
))
{
client
.
tag_mask
&=
~
ParseTagMask
(
request
);
return
CommandResult
::
OK
;
}
else
{
r
.
Error
(
ACK_ERROR_ARG
,
"Unknown sub command"
);
return
CommandResult
::
ERROR
;
}
}
src/command/OtherCommands.cxx
View file @
29453ba1
...
...
@@ -97,7 +97,8 @@ print_tag(TagType type, const char *value, void *ctx)
{
auto
&
r
=
*
(
Response
*
)
ctx
;
tag_print
(
r
,
type
,
value
);
if
(
r
.
GetClient
().
tag_mask
.
Test
(
type
))
tag_print
(
r
,
type
,
value
);
}
CommandResult
...
...
src/db/DatabasePrint.cxx
View file @
29453ba1
...
...
@@ -196,8 +196,9 @@ PrintUniqueTag(Response &r, TagType tag_type,
assert
(
value
!=
nullptr
);
tag_print
(
r
,
tag_type
,
value
);
const
auto
tag_mask
=
r
.
GetTagMask
();
for
(
const
auto
&
item
:
tag
)
if
(
item
.
type
!=
tag_type
)
if
(
item
.
type
!=
tag_type
&&
tag_mask
.
Test
(
item
.
type
)
)
tag_print
(
r
,
item
.
type
,
item
.
value
);
}
...
...
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