Ejemplo n.º 1
0
/*
 * et_wavpack_append_or_delete_tag_item:
 * @wpc: the #WavpackContext of which to modify tags
 * @tag: the tag item name
 * @value: the tag value to write, or %NULL to delete
 *
 * Appends @value to the @tag item of @wpc, or removes the tag item if @value
 * is %NULL.
 *
 * Returns: %TRUE on success, %FALSE otherwise
 */
static gboolean
et_wavpack_append_or_delete_tag_item (WavpackContext *wpc,
                                      const gchar *tag,
                                      const gchar *value)
{
    if (value)
    {
        return WavpackAppendTagItem (wpc, tag, value, strlen (value));
    }
    else
    {
        WavpackDeleteTagItem (wpc, tag);

        /* It is not an error if there was no tag item to delete. */
        return TRUE;
    }
}
Ejemplo n.º 2
0
gboolean Wavpack_Tag_Write_File_Tag (ET_File *ETFile)
{
    WavpackContext *wpc;

    gchar    *filename = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value;
    File_Tag *FileTag  = (File_Tag *)ETFile->FileTag->data;
    gchar    *buffer;

    int open_flags = OPEN_EDIT_TAGS;

    g_return_val_if_fail (ETFile != NULL && ETFile->FileTag != NULL, FALSE);

    wpc = WavpackOpenFileInput(filename, NULL, open_flags, 0);

    if ( wpc == NULL ) {
        return FALSE;
    }

    /*
     * Title
     */
    if (FileTag->title && WavpackAppendTagItem(wpc, "title", FileTag->title, strlen(FileTag->title)) == 0) {
        return FALSE;
    }

    /*
     * Artist
     */
    if (FileTag->artist && WavpackAppendTagItem(wpc, "artist", FileTag->artist, strlen(FileTag->artist)) == 0) {
        return FALSE;
    }

    /*
     * Album
     */
    if (FileTag->album && WavpackAppendTagItem(wpc, "album", FileTag->album, strlen(FileTag->album)) == 0) {
        return FALSE;
    }

    /*
     * Discnumber
    */
    if (FileTag->disc_number && FileTag->disc_total)
    {
        buffer = g_strdup_printf ("%s/%s", FileTag->disc_number,
                                  FileTag->disc_total);

        if (WavpackAppendTagItem (wpc, "part", buffer, strlen (buffer)) == 0)
        {
            g_free (buffer);
            return FALSE;
        }
        else
        {
            g_free (buffer);
        }
    }
    else
    {
        if (FileTag->disc_number && WavpackAppendTagItem (wpc, "part",
                                                          FileTag->disc_number,
                                                          strlen (FileTag->disc_number)) == 0)
        {
            return FALSE;
        }
    }

    /*
     * Year
     */
    if (FileTag->year && WavpackAppendTagItem(wpc, "year", FileTag->year, strlen(FileTag->year)) == 0) {
        return FALSE;
    }

    /*
     * Tracknumber + tracktotal
     */
    if (FileTag->track_total) {
        buffer = g_strdup_printf("%s/%s", FileTag->track, FileTag->track_total);
        if (FileTag->track && WavpackAppendTagItem(wpc, "track", buffer, strlen(buffer)) == 0) {
            g_free(buffer);
            return FALSE;
        } else {
            g_free(buffer);
        }
    } else {
        if (FileTag->track && WavpackAppendTagItem(wpc, "track", FileTag->track, strlen(FileTag->track)) == 0) {
            return FALSE;
        }
    }

    /*
     * Genre
     */
    if (FileTag->genre && WavpackAppendTagItem(wpc, "genre", FileTag->genre, strlen(FileTag->genre)) == 0) {
        return FALSE;
    }

    /*
     * Comment
     */
    if (FileTag->comment && WavpackAppendTagItem(wpc, "comment", FileTag->comment, strlen(FileTag->comment)) == 0) {
        return FALSE;
    }

    /*
     * Composer
     */
    if (FileTag->composer && WavpackAppendTagItem(wpc, "composer", FileTag->composer, strlen(FileTag->composer)) == 0) {
        return FALSE;
    }

    /*
     * Original artist
     */
    if (FileTag->orig_artist && WavpackAppendTagItem(wpc, "original artist", FileTag->orig_artist, strlen(FileTag->orig_artist)) == 0) {
        return FALSE;
    }

    /*
     * Copyright
     */
    if (FileTag->copyright && WavpackAppendTagItem(wpc, "copyright", FileTag->copyright, strlen(FileTag->copyright)) == 0) {
        return FALSE;
    }

    /*
     * URL
     */
    if (FileTag->url && WavpackAppendTagItem(wpc, "copyright url", FileTag->url, strlen(FileTag->url)) == 0) {
        return FALSE;
    }

    /*
     * Encoded by
     */
    if (FileTag->encoded_by && WavpackAppendTagItem(wpc, "encoded by", FileTag->encoded_by, strlen(FileTag->encoded_by)) == 0) {
        return FALSE;
    }

    WavpackWriteTag(wpc);

    WavpackCloseFile(wpc);

    return TRUE;
}
Ejemplo n.º 3
0
void
update_tag(ape_tag *tag, char *filename)
{
    WavpackContext *ctx;
    char error_buff [80];

    ctx = WavpackOpenFileInput (filename, error_buff, OPEN_TAGS | OPEN_EDIT_TAGS, 0);

    if (!ctx) {
        char text[256];

        sprintf(text, "File \"%s\" not found or is read protected!\n",
                filename);
        xmms_show_message("File-Error", (gchar *) text, "Ok", FALSE, NULL,
                          NULL);
        return;
    }

    if (strlen (tag->album))
        WavpackAppendTagItem (ctx, "Album", tag->album, strlen (tag->album));
    else
        WavpackDeleteTagItem (ctx, "Album");

    if (strlen (tag->artist))
        WavpackAppendTagItem (ctx, "Artist", tag->artist, strlen (tag->artist));
    else
        WavpackDeleteTagItem (ctx, "Artist");

    if (strlen (tag->comment))
        WavpackAppendTagItem (ctx, "Comment", tag->comment, strlen (tag->comment));
    else
        WavpackDeleteTagItem (ctx, "Comment");

    if (strlen (tag->genre))
        WavpackAppendTagItem (ctx, "Genre", tag->genre, strlen (tag->genre));
    else
        WavpackDeleteTagItem (ctx, "Genre");

    if (strlen (tag->title))
        WavpackAppendTagItem (ctx, "Title", tag->title, strlen (tag->title));
    else
        WavpackDeleteTagItem (ctx, "Title");

    if (strlen (tag->track))
        WavpackAppendTagItem (ctx, "Track", tag->track, strlen (tag->track));
    else
        WavpackDeleteTagItem (ctx, "Track");

    if (strlen (tag->year))
        WavpackAppendTagItem (ctx, "Year", tag->year, strlen (tag->year));
    else
        WavpackDeleteTagItem (ctx, "Year");

    if (!WavpackWriteTag (ctx)) {
        char text[256];

        sprintf(text, "Couldn't write tag to \"%s\"!\n",
                filename);
        xmms_show_message("File-Error", (gchar *) text, "Ok", FALSE, NULL,
                          NULL);
    }

    WavpackCloseFile (ctx);
}