diff --git a/docs/changes.rst b/docs/changes.rst index 8add66e1..e313c540 100644 --- a/docs/changes.rst +++ b/docs/changes.rst @@ -23,6 +23,9 @@ v0.11.0 (in development) - Add support for ``searchaddpl`` command added in MPD 0.17. +- Add empty stubs for channel commands for client to client communication, + which was added in MPD 0.17. + v0.10.0 (2012-12-12) ==================== diff --git a/docs/modules/frontends/mpd.rst b/docs/modules/frontends/mpd.rst index 090ca5cd..f25b90f2 100644 --- a/docs/modules/frontends/mpd.rst +++ b/docs/modules/frontends/mpd.rst @@ -30,6 +30,14 @@ Audio output :members: +Channels +-------- + +.. automodule:: mopidy.frontends.mpd.protocol.channels + :synopsis: MPD protocol: channels -- client to client communication + :members: + + Command list ------------ diff --git a/mopidy/frontends/mpd/protocol/__init__.py b/mopidy/frontends/mpd/protocol/__init__.py index a8bdc2c7..6afde4b9 100644 --- a/mopidy/frontends/mpd/protocol/__init__.py +++ b/mopidy/frontends/mpd/protocol/__init__.py @@ -74,6 +74,7 @@ def load_protocol_modules(): """ # pylint: disable = W0612 from . import ( # noqa - audio_output, command_list, connection, current_playlist, empty, - music_db, playback, reflection, status, stickers, stored_playlists) + audio_output, channels, command_list, connection, current_playlist, + empty, music_db, playback, reflection, status, stickers, + stored_playlists) # pylint: enable = W0612 diff --git a/mopidy/frontends/mpd/protocol/channels.py b/mopidy/frontends/mpd/protocol/channels.py new file mode 100644 index 00000000..11ac6fda --- /dev/null +++ b/mopidy/frontends/mpd/protocol/channels.py @@ -0,0 +1,69 @@ +from __future__ import unicode_literals + +from mopidy.frontends.mpd.protocol import handle_request +from mopidy.frontends.mpd.exceptions import MpdNotImplemented + + +@handle_request(r'^subscribe "(?P[A-Za-z0-9:._-]+)"$') +def subscribe(context, channel): + """ + *musicpd.org, client to client section:* + + ``subscribe {NAME}`` + + Subscribe to a channel. The channel is created if it does not exist + already. The name may consist of alphanumeric ASCII characters plus + underscore, dash, dot and colon. + """ + raise MpdNotImplemented # TODO + + +@handle_request(r'^unsubscribe "(?P[A-Za-z0-9:._-]+)"$') +def unsubscribe(context, channel): + """ + *musicpd.org, client to client section:* + + ``unsubscribe {NAME}`` + + Unsubscribe from a channel. + """ + raise MpdNotImplemented # TODO + + +@handle_request(r'^channels$') +def channels(context): + """ + *musicpd.org, client to client section:* + + ``channels`` + + Obtain a list of all channels. The response is a list of "channel:" + lines. + """ + raise MpdNotImplemented # TODO + + +@handle_request(r'^readmessages$') +def readmessages(context): + """ + *musicpd.org, client to client section:* + + ``readmessages`` + + Reads messages for this client. The response is a list of "channel:" + and "message:" lines. + """ + raise MpdNotImplemented # TODO + + +@handle_request( + r'^sendmessage "(?P[A-Za-z0-9:._-]+)" "(?P[^"]*)"$') +def sendmessage(context, channel, text): + """ + *musicpd.org, client to client section:* + + ``sendmessage {CHANNEL} {TEXT}`` + + Send a message to the specified channel. + """ + raise MpdNotImplemented # TODO diff --git a/tests/frontends/mpd/protocol/channels_test.py b/tests/frontends/mpd/protocol/channels_test.py new file mode 100644 index 00000000..86cf8197 --- /dev/null +++ b/tests/frontends/mpd/protocol/channels_test.py @@ -0,0 +1,25 @@ +from __future__ import unicode_literals + +from tests.frontends.mpd import protocol + + +class ChannelsHandlerTest(protocol.BaseTestCase): + def test_subscribe(self): + self.sendRequest('subscribe "topic"') + self.assertEqualResponse('ACK [0@0] {} Not implemented') + + def test_unsubscribe(self): + self.sendRequest('unsubscribe "topic"') + self.assertEqualResponse('ACK [0@0] {} Not implemented') + + def test_channels(self): + self.sendRequest('channels') + self.assertEqualResponse('ACK [0@0] {} Not implemented') + + def test_readmessages(self): + self.sendRequest('readmessages') + self.assertEqualResponse('ACK [0@0] {} Not implemented') + + def test_sendmessage(self): + self.sendRequest('sendmessage "topic" "a message"') + self.assertEqualResponse('ACK [0@0] {} Not implemented')