aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-01-07 10:59:56 +0100
committerMax Kellermann <max@duempel.org>2013-01-07 10:59:56 +0100
commitd360f17a59fe6ed52ffa74c48c63164cf203d1e0 (patch)
treedea0df6cb96909f083f89e4d89a48ee82aef9f13 /src
parenta6ee6be9602f64599b40e01321bd771b17d94f39 (diff)
downloadmpd-d360f17a59fe6ed52ffa74c48c63164cf203d1e0.tar.gz
mpd-d360f17a59fe6ed52ffa74c48c63164cf203d1e0.tar.xz
mpd-d360f17a59fe6ed52ffa74c48c63164cf203d1e0.zip
Client: add Partition reference attribute
playlist and player_control are deprecated.
Diffstat (limited to 'src')
-rw-r--r--src/Client.hxx5
-rw-r--r--src/ClientInternal.hxx6
-rw-r--r--src/ClientNew.cxx12
-rw-r--r--src/DatabaseCommands.cxx4
-rw-r--r--src/DatabaseQueue.cxx16
-rw-r--r--src/DatabaseQueue.hxx11
-rw-r--r--src/Listen.cxx3
-rw-r--r--src/QueueCommands.cxx4
8 files changed, 30 insertions, 31 deletions
diff --git a/src/Client.hxx b/src/Client.hxx
index d442d89b2..37bf69409 100644
--- a/src/Client.hxx
+++ b/src/Client.hxx
@@ -27,15 +27,14 @@
#include <stdarg.h>
struct sockaddr;
-struct playlist;
-struct player_control;
+struct Partition;
class Client;
void client_manager_init(void);
void client_manager_deinit(void);
void
-client_new(struct playlist &playlist, struct player_control *player_control,
+client_new(Partition &partition,
int fd, const struct sockaddr *sa, size_t sa_length, int uid);
gcc_pure
diff --git a/src/ClientInternal.hxx b/src/ClientInternal.hxx
index 6f3035671..9d508fa11 100644
--- a/src/ClientInternal.hxx
+++ b/src/ClientInternal.hxx
@@ -44,8 +44,11 @@ struct deferred_buffer {
char data[sizeof(long)];
};
+struct Partition;
+
class Client {
public:
+ Partition &partition;
struct playlist &playlist;
struct player_control *player_control;
@@ -100,8 +103,7 @@ public:
*/
std::list<ClientMessage> messages;
- Client(struct playlist &playlist,
- struct player_control *player_control,
+ Client(Partition &partition,
int fd, int uid, int num);
~Client();
diff --git a/src/ClientNew.cxx b/src/ClientNew.cxx
index 1579b9a53..489af8c31 100644
--- a/src/ClientNew.cxx
+++ b/src/ClientNew.cxx
@@ -19,6 +19,7 @@
#include "config.h"
#include "ClientInternal.hxx"
+#include "Partition.hxx"
#include "fd_util.h"
extern "C" {
#include "fifo_buffer.h"
@@ -45,10 +46,10 @@ extern "C" {
static const char GREETING[] = "OK MPD " PROTOCOL_VERSION "\n";
-Client::Client(struct playlist &_playlist,
- struct player_control *_player_control,
+Client::Client(Partition &_partition,
int fd, int _uid, int _num)
- :playlist(_playlist), player_control(_player_control),
+ :partition(_partition),
+ playlist(partition.playlist), player_control(&partition.pc),
input(fifo_buffer_new(4096)),
permission(getDefaultPermissions()),
uid(_uid),
@@ -94,13 +95,12 @@ Client::~Client()
}
void
-client_new(struct playlist &playlist, struct player_control *player_control,
+client_new(Partition &partition,
int fd, const struct sockaddr *sa, size_t sa_length, int uid)
{
static unsigned int next_client_num;
char *remote;
- assert(player_control != NULL);
assert(fd >= 0);
#ifdef HAVE_LIBWRAP
@@ -134,7 +134,7 @@ client_new(struct playlist &playlist, struct player_control *player_control,
return;
}
- Client *client = new Client(playlist, player_control, fd, uid,
+ Client *client = new Client(partition, fd, uid,
next_client_num++);
(void)send(fd, GREETING, sizeof(GREETING) - 1, 0);
diff --git a/src/DatabaseCommands.cxx b/src/DatabaseCommands.cxx
index b52d72f39..116aa840a 100644
--- a/src/DatabaseCommands.cxx
+++ b/src/DatabaseCommands.cxx
@@ -92,8 +92,8 @@ handle_match_add(Client *client, int argc, char *argv[], bool fold_case)
}
GError *error = NULL;
- return findAddIn(client->playlist, client->player_control,
- "", &filter, &error)
+ return AddFromDatabase(client->partition,
+ "", &filter, &error)
? COMMAND_RETURN_OK
: print_error(client, error);
}
diff --git a/src/DatabaseQueue.cxx b/src/DatabaseQueue.cxx
index 21103fe37..d7bc97f56 100644
--- a/src/DatabaseQueue.cxx
+++ b/src/DatabaseQueue.cxx
@@ -22,16 +22,16 @@
#include "DatabaseSelection.hxx"
#include "DatabaseGlue.hxx"
#include "DatabasePlugin.hxx"
-#include "Playlist.hxx"
+#include "Partition.hxx"
#include <functional>
static bool
-AddToQueue(struct playlist &playlist, struct player_control *pc,
- song &song, GError **error_r)
+AddToQueue(Partition &partition, song &song, GError **error_r)
{
enum playlist_result result =
- playlist_append_song(&playlist, pc, &song, NULL);
+ playlist_append_song(&partition.playlist, &partition.pc,
+ &song, NULL);
if (result != PLAYLIST_RESULT_SUCCESS) {
g_set_error(error_r, playlist_quark(), result,
"Playlist error");
@@ -42,9 +42,9 @@ AddToQueue(struct playlist &playlist, struct player_control *pc,
}
bool
-findAddIn(struct playlist &playlist, struct player_control *pc,
- const char *uri,
- const SongFilter *filter, GError **error_r)
+AddFromDatabase(Partition &partition,
+ const char *uri,
+ const SongFilter *filter, GError **error_r)
{
const Database *db = GetDatabase(error_r);
if (db == nullptr)
@@ -53,6 +53,6 @@ findAddIn(struct playlist &playlist, struct player_control *pc,
const DatabaseSelection selection(uri, true, filter);
using namespace std::placeholders;
- const auto f = std::bind(AddToQueue, std::ref(playlist), pc, _1, _2);
+ const auto f = std::bind(AddToQueue, std::ref(partition), _1, _2);
return db->Visit(selection, f, error_r);
}
diff --git a/src/DatabaseQueue.hxx b/src/DatabaseQueue.hxx
index 50ed7d03a..14947d5d5 100644
--- a/src/DatabaseQueue.hxx
+++ b/src/DatabaseQueue.hxx
@@ -24,13 +24,12 @@
#include "gerror.h"
class SongFilter;
-struct playlist;
-struct player_control;
+struct Partition;
-gcc_nonnull(2,3)
+gcc_nonnull(2)
bool
-findAddIn(struct playlist &playlist, struct player_control *pc,
- const char *name,
- const SongFilter *filter, GError **error_r);
+AddFromDatabase(Partition &partition,
+ const char *name,
+ const SongFilter *filter, GError **error_r);
#endif
diff --git a/src/Listen.cxx b/src/Listen.cxx
index 3b439f8f4..1e6333504 100644
--- a/src/Listen.cxx
+++ b/src/Listen.cxx
@@ -20,7 +20,6 @@
#include "config.h"
#include "Listen.hxx"
#include "Main.hxx"
-#include "Partition.hxx"
#include "Client.hxx"
#include "conf.h"
@@ -47,7 +46,7 @@ static void
listen_callback(int fd, const struct sockaddr *address,
size_t address_length, int uid, G_GNUC_UNUSED void *ctx)
{
- client_new(global_partition->playlist, &global_partition->pc,
+ client_new(*global_partition,
fd, address, address_length, uid);
}
diff --git a/src/QueueCommands.cxx b/src/QueueCommands.cxx
index 3e24f0c92..58792fd1a 100644
--- a/src/QueueCommands.cxx
+++ b/src/QueueCommands.cxx
@@ -70,8 +70,8 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
}
GError *error = NULL;
- return findAddIn(client->playlist, client->player_control,
- uri, nullptr, &error)
+ return AddFromDatabase(client->partition,
+ uri, nullptr, &error)
? COMMAND_RETURN_OK
: print_error(client, error);
}