-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from jcorporation/protocol
Implement new protocol command to toggle features
- Loading branch information
Showing
8 changed files
with
340 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright The Music Player Daemon Project | ||
|
||
#ifndef LIBMPDCLIENT_FEATURE_H | ||
#define LIBMPDCLIENT_FEATURE_H | ||
|
||
/** | ||
* @since libmpdclient 2.23 added support for #MPD_TAG_SHOWMOVEMENT. | ||
*/ | ||
enum mpd_protocol_feature | ||
{ | ||
/** | ||
* Special value returned by mpd_feature_parse() when an | ||
* unknown name was passed. | ||
*/ | ||
MPD_FEATURE_UNKNOWN = -1, | ||
|
||
MPD_FEATURE_HIDE_PLAYLISTS_IN_ROOT, | ||
|
||
/* IMPORTANT: the ordering of tag types above must be | ||
retained, or else the libmpdclient ABI breaks */ | ||
|
||
MPD_FEATURE_COUNT | ||
}; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* Looks up the name of the specified protocol feature. | ||
* | ||
* @return the name, or NULL if the tag type is not valid | ||
*/ | ||
const char * | ||
mpd_feature_name(enum mpd_protocol_feature feature); | ||
|
||
/** | ||
* Parses a protocol feature name, and returns its #mpd_protocol_feature value. | ||
* | ||
* @return a #mpd_protocol_feature value, or MPD_FEATURE_UNKNOWN if the name was | ||
* not recognized | ||
*/ | ||
enum mpd_protocol_feature | ||
mpd_feature_name_parse(const char *name); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// Copyright The Music Player Daemon Project | ||
|
||
#include <mpd/feature.h> | ||
|
||
#include <assert.h> | ||
#include <string.h> | ||
#include <stdbool.h> | ||
|
||
static const char *const mpd_feature_names[MPD_FEATURE_COUNT] = | ||
{ | ||
[MPD_FEATURE_HIDE_PLAYLISTS_IN_ROOT] = "hide_playlists_in_root", | ||
}; | ||
|
||
const char * | ||
mpd_feature_name(enum mpd_protocol_feature feature) | ||
{ | ||
if ((unsigned)feature >= MPD_FEATURE_COUNT) | ||
return NULL; | ||
|
||
return mpd_feature_names[feature]; | ||
} | ||
|
||
enum mpd_protocol_feature | ||
mpd_feature_name_parse(const char *name) | ||
{ | ||
assert(name != NULL); | ||
|
||
for (unsigned i = 0; i < MPD_FEATURE_COUNT; ++i) | ||
if (strcmp(name, mpd_feature_names[i]) == 0) | ||
return (enum mpd_protocol_feature)i; | ||
|
||
return MPD_FEATURE_UNKNOWN; | ||
} |