Skip to content
Extraits de code Groupes Projets

Queue and playlist interactions with lkt

Affichage du commit 87ef69c4
Suivant
Afficher la dernière version
1 file
+ 58
8
Comparer les modifications
  • Côte à côte
  • En ligne
+ 58
8
@@ -276,6 +276,54 @@ populate__(struct lkt_cmd_args *args)
rescan_or_update__(args, "__rescan");
}
noreturn void
queue_import__(struct lkt_cmd_args *args)
{
if (args->argc != 1)
fail("Invalid argument");
FILE *sock = lkt_connect();
char buff[LKT_MESSAGE_MAX];
write_socket(sock, "load %s\n", args->argv[0]);
exit_with_status(sock, buff);
}
noreturn void
queue_replace__(struct lkt_cmd_args *args)
{
if (args->argc != 1)
fail("Invalid argument");
bool play = false;
char buff[LKT_MESSAGE_MAX];
FILE *sock = lkt_connect();
for (;;) {
memset(buff, 0, LKT_MESSAGE_MAX * sizeof(char));
read_socket(sock, buff, LKT_MESSAGE_MAX - 1);
size_t len = strcspn(buff, LKT_KEY_VALUE_SEP);
if (STR_NMATCH(buff, "state", len)) {
char *it = lkt_skip_key(buff);
play = STR_NMATCH(it, "play", 4);
break;
}
if (STR_NMATCH(buff, "OK", 2))
break;
else if (STR_NMATCH(buff, "ACK", 3))
fail("ACK");
}
fclose(sock);
sock = lkt_connect();
write_socket(sock, "command_list_begin\n");
write_socket(sock, "clear\n");
write_socket(sock, "load %s\n", args->argv[0]);
if (play)
write_socket(sock, "play\n");
write_socket(sock, "command_list_end\n");
exit_with_status(sock, buff);
}
noreturn void
config__(struct lkt_cmd_args *args)
{
@@ -816,14 +864,16 @@ search_with_cmd(search_queue__, playlistfind)
/* Parsing stuff. */
static struct lkt_cmd_opt options_queue[] = {
{ .name = "insert", .call = queue_insert__ },
{ .name = "pos", .call = queue_pos__ },
{ .name = "pop", .call = queue_pop__ },
{ .name = "add", .call = queue_add__ },
{ .name = "seek", .call = queue_seek__ },
{ .name = "delete", .call = queue_delete__ },
{ .name = "clear", .call = queue_clear__ },
{ .name = "crop", .call = queue_crop__ },
{ .name = "insert", .call = queue_insert__ },
{ .name = "pos", .call = queue_pos__ },
{ .name = "pop", .call = queue_pop__ },
{ .name = "add", .call = queue_add__ },
{ .name = "seek", .call = queue_seek__ },
{ .name = "delete", .call = queue_delete__ },
{ .name = "clear", .call = queue_clear__ },
{ .name = "crop", .call = queue_crop__ },
{ .name = "replace", .call = queue_replace__ },
{ .name = "import", .call = queue_import__ },
LKT_OPT_DEFAULT(queue_list__),
};
Chargement en cours