dbUtils: pass player_control to findAddIn()

Allow calling findAddIn() without a client object.
This commit is contained in:
Max Kellermann 2011-09-05 23:12:33 +02:00
parent c2c4228722
commit dadf1339b5
3 changed files with 14 additions and 9 deletions

View File

@ -956,7 +956,7 @@ handle_findadd(struct client *client, int argc, char *argv[])
return COMMAND_RETURN_ERROR; return COMMAND_RETURN_ERROR;
} }
ret = findAddIn(client, NULL, list); ret = findAddIn(client->player_control, NULL, list);
if (ret == -1) if (ret == -1)
command_error(client, ACK_ERROR_NO_EXIST, command_error(client, ACK_ERROR_NO_EXIST,
"directory or file not found"); "directory or file not found");

View File

@ -203,25 +203,30 @@ int addAllInToStoredPlaylist(const char *name, const char *utf8file)
return db_walk(name, directoryAddSongToStoredPlaylist, NULL, &data); return db_walk(name, directoryAddSongToStoredPlaylist, NULL, &data);
} }
struct find_add_data {
struct player_control *pc;
const struct locate_item_list *criteria;
};
static int static int
findAddInDirectory(struct song *song, void *_data) findAddInDirectory(struct song *song, void *_data)
{ {
struct search_data *data = _data; struct find_add_data *data = _data;
if (locate_song_match(song, data->criteria)) if (locate_song_match(song, data->criteria))
return playlist_append_song(&g_playlist, return playlist_append_song(&g_playlist,
data->client->player_control, data->pc,
song, NULL); song, NULL);
return 0; return 0;
} }
int findAddIn(struct client *client, const char *name, int
const struct locate_item_list *criteria) findAddIn(struct player_control *pc, const char *name,
const struct locate_item_list *criteria)
{ {
struct search_data data; struct find_add_data data;
data.pc = pc;
data.client = client;
data.criteria = criteria; data.criteria = criteria;
return db_walk(name, findAddInDirectory, NULL, &data); return db_walk(name, findAddInDirectory, NULL, &data);

View File

@ -42,7 +42,7 @@ findSongsIn(struct client *client, const char *name,
const struct locate_item_list *criteria); const struct locate_item_list *criteria);
int int
findAddIn(struct client *client, const char *name, findAddIn(struct player_control *pc, const char *name,
const struct locate_item_list *criteria); const struct locate_item_list *criteria);
int int