DatabaseQueue: pass DatabaseSelection to Add...()
This commit is contained in:
parent
d360f17a59
commit
400ff1c812
@ -91,9 +91,9 @@ handle_match_add(Client *client, int argc, char *argv[], bool fold_case)
|
|||||||
return COMMAND_RETURN_ERROR;
|
return COMMAND_RETURN_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DatabaseSelection selection("", true, &filter);
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
return AddFromDatabase(client->partition,
|
return AddFromDatabase(client->partition, selection, &error)
|
||||||
"", &filter, &error)
|
|
||||||
? COMMAND_RETURN_OK
|
? COMMAND_RETURN_OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
}
|
}
|
||||||
|
@ -42,16 +42,13 @@ AddToQueue(Partition &partition, song &song, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
AddFromDatabase(Partition &partition,
|
AddFromDatabase(Partition &partition, const DatabaseSelection &selection,
|
||||||
const char *uri,
|
GError **error_r)
|
||||||
const SongFilter *filter, GError **error_r)
|
|
||||||
{
|
{
|
||||||
const Database *db = GetDatabase(error_r);
|
const Database *db = GetDatabase(error_r);
|
||||||
if (db == nullptr)
|
if (db == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const DatabaseSelection selection(uri, true, filter);
|
|
||||||
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
const auto f = std::bind(AddToQueue, std::ref(partition), _1, _2);
|
const auto f = std::bind(AddToQueue, std::ref(partition), _1, _2);
|
||||||
return db->Visit(selection, f, error_r);
|
return db->Visit(selection, f, error_r);
|
||||||
|
@ -20,16 +20,13 @@
|
|||||||
#ifndef MPD_DATABASE_QUEUE_HXX
|
#ifndef MPD_DATABASE_QUEUE_HXX
|
||||||
#define MPD_DATABASE_QUEUE_HXX
|
#define MPD_DATABASE_QUEUE_HXX
|
||||||
|
|
||||||
#include "gcc.h"
|
|
||||||
#include "gerror.h"
|
#include "gerror.h"
|
||||||
|
|
||||||
class SongFilter;
|
|
||||||
struct Partition;
|
struct Partition;
|
||||||
|
struct DatabaseSelection;
|
||||||
|
|
||||||
gcc_nonnull(2)
|
|
||||||
bool
|
bool
|
||||||
AddFromDatabase(Partition &partition,
|
AddFromDatabase(Partition &partition, const DatabaseSelection &selection,
|
||||||
const char *name,
|
GError **error_r);
|
||||||
const SongFilter *filter, GError **error_r);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "CommandError.hxx"
|
#include "CommandError.hxx"
|
||||||
#include "DatabaseQueue.hxx"
|
#include "DatabaseQueue.hxx"
|
||||||
#include "SongFilter.hxx"
|
#include "SongFilter.hxx"
|
||||||
|
#include "DatabaseSelection.hxx"
|
||||||
#include "Playlist.hxx"
|
#include "Playlist.hxx"
|
||||||
#include "PlaylistPrint.hxx"
|
#include "PlaylistPrint.hxx"
|
||||||
#include "ClientFile.hxx"
|
#include "ClientFile.hxx"
|
||||||
@ -69,9 +70,9 @@ handle_add(Client *client, G_GNUC_UNUSED int argc, char *argv[])
|
|||||||
return print_playlist_result(client, result);
|
return print_playlist_result(client, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DatabaseSelection selection(uri, true);
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
return AddFromDatabase(client->partition,
|
return AddFromDatabase(client->partition, selection, &error)
|
||||||
uri, nullptr, &error)
|
|
||||||
? COMMAND_RETURN_OK
|
? COMMAND_RETURN_OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user