song: renamed attribute "url" to "uri"

This commit is contained in:
Max Kellermann 2009-10-13 18:01:06 +02:00
parent 28442cce9f
commit f7ce4f6239
13 changed files with 44 additions and 45 deletions

View File

@ -1559,7 +1559,7 @@ sticker_song_find_print_cb(struct song *song, const char *value,
{
struct sticker_song_find_data *data = user_data;
song_print_url(data->client, song);
song_print_uri(data->client, song);
sticker_print_value(data->client, data->name, value);
}

View File

@ -59,7 +59,7 @@ static int
printSongInDirectory(struct song *song, G_GNUC_UNUSED void *data)
{
struct client *client = data;
song_print_url(client, song);
song_print_uri(client, song);
return 0;
}
@ -258,7 +258,7 @@ visitTag(struct client *client, struct strset *set,
struct tag *tag = song->tag;
if (tagType == LOCATE_TAG_FILE_TYPE) {
song_print_url(client, song);
song_print_uri(client, song);
return;
}

View File

@ -159,9 +159,9 @@ map_song_fs(const struct song *song)
assert(song_is_file(song));
if (song_in_database(song))
return map_directory_child_fs(song->parent, song->url);
return map_directory_child_fs(song->parent, song->uri);
else
return utf8_to_fs_charset(song->url);
return utf8_to_fs_charset(song->uri);
}
char *

View File

@ -136,7 +136,7 @@ player_wait_for_decoder(struct player *player)
dc_command_wait(&pc.notify);
if (decoder_lock_has_failed()) {
assert(dc.next_song == NULL || dc.next_song->url != NULL);
assert(dc.next_song == NULL || dc.next_song->uri != NULL);
pc.errored_song = dc.next_song;
pc.error = PLAYER_ERROR_FILE;
pc.next_song = NULL;
@ -177,7 +177,7 @@ player_check_decoder_startup(struct player *player)
if (decoder_has_failed()) {
/* the decoder failed */
assert(dc.next_song == NULL || dc.next_song->url != NULL);
assert(dc.next_song == NULL || dc.next_song->uri != NULL);
decoder_unlock();
@ -209,7 +209,7 @@ player_check_decoder_startup(struct player *player)
"while playing \"%s\"", uri);
g_free(uri);
assert(dc.next_song == NULL || dc.next_song->url != NULL);
assert(dc.next_song == NULL || dc.next_song->uri != NULL);
pc.errored_song = dc.next_song;
pc.error = PLAYER_ERROR_AUDIO;
@ -375,7 +375,7 @@ static void player_process_command(struct player *player)
} else {
/* the audio device has failed - rollback to
pause mode */
assert(dc.next_song == NULL || dc.next_song->url != NULL);
assert(dc.next_song == NULL || dc.next_song->uri != NULL);
pc.errored_song = dc.next_song;
pc.error = PLAYER_ERROR_AUDIO;

View File

@ -27,18 +27,18 @@
#include <assert.h>
static struct song *
song_alloc(const char *url, struct directory *parent)
song_alloc(const char *uri, struct directory *parent)
{
size_t urllen;
size_t uri_length;
struct song *song;
assert(url);
urllen = strlen(url);
assert(urllen);
song = g_malloc(sizeof(*song) - sizeof(song->url) + urllen + 1);
assert(uri);
uri_length = strlen(uri);
assert(uri_length);
song = g_malloc(sizeof(*song) - sizeof(song->uri) + uri_length + 1);
song->tag = NULL;
memcpy(song->url, url, urllen + 1);
memcpy(song->uri, uri, uri_length + 1);
song->parent = parent;
song->mtime = 0;
@ -46,9 +46,9 @@ song_alloc(const char *url, struct directory *parent)
}
struct song *
song_remote_new(const char *url)
song_remote_new(const char *uri)
{
return song_alloc(url, NULL);
return song_alloc(uri, NULL);
}
struct song *
@ -71,11 +71,11 @@ char *
song_get_uri(const struct song *song)
{
assert(song != NULL);
assert(*song->url);
assert(*song->uri);
if (!song_in_database(song) || directory_is_root(song->parent))
return g_strdup(song->url);
return g_strdup(song->uri);
else
return g_strconcat(directory_get_path(song->parent),
"/", song->url, NULL);
"/", song->uri, NULL);
}

View File

@ -34,12 +34,12 @@ struct song {
struct tag *tag;
struct directory *parent;
time_t mtime;
char url[sizeof(int)];
char uri[sizeof(int)];
};
/** allocate a new song with a remote URL */
struct song *
song_remote_new(const char *url);
song_remote_new(const char *uri);
/** allocate a new song with a local file name */
struct song *
@ -81,7 +81,7 @@ song_in_database(const struct song *song)
static inline bool
song_is_file(const struct song *song)
{
return song_in_database(song) || song->url[0] == '/';
return song_in_database(song) || song->uri[0] == '/';
}
#endif

View File

@ -26,18 +26,18 @@
#include "uri.h"
void
song_print_url(struct client *client, struct song *song)
song_print_uri(struct client *client, struct song *song)
{
if (song_in_database(song) && !directory_is_root(song->parent)) {
client_printf(client, "%s%s/%s\n", SONG_FILE,
directory_get_path(song->parent), song->url);
directory_get_path(song->parent), song->uri);
} else {
char *allocated;
const char *uri;
uri = allocated = uri_remove_auth(song->url);
uri = allocated = uri_remove_auth(song->uri);
if (uri == NULL)
uri = song->url;
uri = song->uri;
client_printf(client, "%s%s\n", SONG_FILE, uri);
@ -48,7 +48,7 @@ song_print_url(struct client *client, struct song *song)
int
song_print_info(struct client *client, struct song *song)
{
song_print_url(client, song);
song_print_uri(client, song);
if (song->mtime > 0) {
#ifndef G_OS_WIN32

View File

@ -30,6 +30,6 @@ song_print_info(struct client *client, struct song *song);
int songvec_print(struct client *client, const struct songvec *sv);
void
song_print_url(struct client *client, struct song *song);
song_print_uri(struct client *client, struct song *song);
#endif

View File

@ -41,14 +41,13 @@ song_save_quark(void)
}
static void
song_save_url(FILE *fp, struct song *song)
song_save_uri(FILE *fp, struct song *song)
{
if (song->parent != NULL && song->parent->path != NULL)
fprintf(fp, SONG_FILE "%s/%s\n",
directory_get_path(song->parent), song->url);
directory_get_path(song->parent), song->uri);
else
fprintf(fp, SONG_FILE "%s\n",
song->url);
fprintf(fp, SONG_FILE "%s\n", song->uri);
}
static int
@ -56,9 +55,9 @@ song_save(struct song *song, void *data)
{
FILE *fp = data;
fprintf(fp, SONG_KEY "%s\n", song->url);
fprintf(fp, SONG_KEY "%s\n", song->uri);
song_save_url(fp, song);
song_save_uri(fp, song);
if (song->tag != NULL)
tag_save(fp, song->tag);
@ -78,7 +77,7 @@ void songvec_save(FILE *fp, struct songvec *sv)
static void
commit_song(struct songvec *sv, struct song *newsong)
{
struct song *existing = songvec_find(sv, newsong->url);
struct song *existing = songvec_find(sv, newsong->uri);
if (!existing) {
songvec_add(sv, newsong);

View File

@ -103,7 +103,7 @@ song_file_update(struct song *song)
/* check if there's a suffix and a plugin */
suffix = uri_get_suffix(song->url);
suffix = uri_get_suffix(song->uri);
if (suffix == NULL)
return false;
@ -152,7 +152,7 @@ song_file_update_inarchive(struct song *song)
/* check if there's a suffix and a plugin */
suffix = uri_get_suffix(song->url);
suffix = uri_get_suffix(song->uri);
if (suffix == NULL)
return false;

View File

@ -79,7 +79,7 @@ static int songvec_cmp(const void *s1, const void *s2)
return ret;
/* still no difference? compare file name */
return g_utf8_collate(a->url, b->url);
return g_utf8_collate(a->uri, b->uri);
}
static size_t sv_size(const struct songvec *sv)
@ -108,14 +108,14 @@ void songvec_sort(struct songvec *sv)
}
struct song *
songvec_find(const struct songvec *sv, const char *url)
songvec_find(const struct songvec *sv, const char *uri)
{
int i;
struct song *ret = NULL;
g_mutex_lock(nr_lock);
for (i = sv->nr; --i >= 0; ) {
if (strcmp(sv->base[i]->url, url))
if (strcmp(sv->base[i]->uri, uri))
continue;
ret = sv->base[i];
break;
@ -182,7 +182,7 @@ songvec_for_each(const struct songvec *sv,
struct song *song = sv->base[i];
assert(song);
assert(*song->url);
assert(*song->uri);
prev_nr = sv->nr;
g_mutex_unlock(nr_lock); /* fn() may block */

View File

@ -34,7 +34,7 @@ void songvec_deinit(void);
void songvec_sort(struct songvec *sv);
struct song *
songvec_find(const struct songvec *sv, const char *url);
songvec_find(const struct songvec *sv, const char *uri);
int
songvec_delete(struct songvec *sv, const struct song *del);

View File

@ -113,7 +113,7 @@ int main(int argc, char **argv)
/* dump the playlist */
while ((song = playlist_plugin_read(playlist)) != NULL) {
g_print("%s\n", song->url);
g_print("%s\n", song->uri);
if (song->tag != NULL)
tag_save(stdout, song->tag);