Commit dadf1339 authored by Max Kellermann's avatar Max Kellermann

dbUtils: pass player_control to findAddIn()

Allow calling findAddIn() without a client object.
parent c2c42287
......@@ -956,7 +956,7 @@ handle_findadd(struct client *client, int argc, char *argv[])
return COMMAND_RETURN_ERROR;
}
ret = findAddIn(client, NULL, list);
ret = findAddIn(client->player_control, NULL, list);
if (ret == -1)
command_error(client, ACK_ERROR_NO_EXIST,
"directory or file not found");
......
......@@ -203,25 +203,30 @@ int addAllInToStoredPlaylist(const char *name, const char *utf8file)
return db_walk(name, directoryAddSongToStoredPlaylist, NULL, &data);
}
struct find_add_data {
struct player_control *pc;
const struct locate_item_list *criteria;
};
static int
findAddInDirectory(struct song *song, void *_data)
{
struct search_data *data = _data;
struct find_add_data *data = _data;
if (locate_song_match(song, data->criteria))
return playlist_append_song(&g_playlist,
data->client->player_control,
data->pc,
song, NULL);
return 0;
}
int findAddIn(struct client *client, const char *name,
const struct locate_item_list *criteria)
int
findAddIn(struct player_control *pc, const char *name,
const struct locate_item_list *criteria)
{
struct search_data data;
data.client = client;
struct find_add_data data;
data.pc = pc;
data.criteria = criteria;
return db_walk(name, findAddInDirectory, NULL, &data);
......
......@@ -42,7 +42,7 @@ findSongsIn(struct client *client, const char *name,
const struct locate_item_list *criteria);
int
findAddIn(struct client *client, const char *name,
findAddIn(struct player_control *pc, const char *name,
const struct locate_item_list *criteria);
int
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment