From afe9f743d2b1f9d617352165ed53e81a26d8b16a Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Mon, 9 Jun 2008 09:25:49 +0100 Subject: [PATCH] Proper calculation of scratch/remove rights Organization: Straylight/Edgeware From: Richard Kettlewell --- disobedience/control.c | 3 +-- disobedience/disobedience.h | 2 ++ disobedience/queue.c | 8 +++----- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/disobedience/control.c b/disobedience/control.c index fd37651..31ac48e 100644 --- a/disobedience/control.c +++ b/disobedience/control.c @@ -144,8 +144,7 @@ static int pause_resume_sensitive(void) { static int scratch_sensitive(void) { return !!(last_state & DISORDER_PLAYING) - && (last_rights & RIGHT_SCRATCH__MASK); - /* TODO: it's more complicated than that... */ + && right_scratchable(last_rights, config->username, playing_track); } static int random_sensitive(void) { diff --git a/disobedience/disobedience.h b/disobedience/disobedience.h index 4a9bfe5..938a69e 100644 --- a/disobedience/disobedience.h +++ b/disobedience/disobedience.h @@ -211,6 +211,8 @@ void namepart_update(const char *track, const char *part); /* Called when a namepart might have changed */ +extern struct queue_entry *playing_track; + /* Choose */ GtkWidget *choose_widget(void); diff --git a/disobedience/queue.c b/disobedience/queue.c index 4bf7cc2..48c43fb 100644 --- a/disobedience/queue.c +++ b/disobedience/queue.c @@ -225,7 +225,7 @@ static struct queuelike ql_queue; /**< @brief The main queue */ static struct queuelike ql_recent; /*< @brief Recently-played tracks */ static struct queuelike ql_added; /*< @brief Newly added tracks */ static struct queue_entry *actual_queue; /**< @brief actual queue */ -static struct queue_entry *playing_track; /**< @brief currenty playing */ +struct queue_entry *playing_track; /**< @brief currently playing */ static time_t last_playing = (time_t)-1; /**< @brief when last got playing */ static int namepart_lookups_outstanding; static int namepart_completions_deferred; /* # of completions not processed */ @@ -1203,8 +1203,7 @@ static int scratch_sensitive(struct queuelike attribute((unused)) *ql, return (playing_track && (disorder_eclient_state(client) & DISORDER_CONNECTED) && selection_selected(ql->selection, playing_track->id) - && (last_rights & RIGHT_SCRATCH__MASK)); - /* TODO: rights is more complicated than that */ + && right_scratchable(last_rights, config->username, playing_track)); } /** @brief Called when disorder_eclient_scratch completes */ @@ -1231,8 +1230,7 @@ static int remove_sensitive(struct queuelike *ql, && ((q && q != playing_track) || count_selected_nonplaying(ql)) - && (last_rights & RIGHT_REMOVE__MASK)); - /* TODO: rights is more complicated than that */ + && right_removable(last_rights, config->username, q)); } static void remove_completed(void attribute((unused)) *v, -- [mdw]