Commit 412fa3b7 authored by Josh Coalson's avatar Josh Coalson
Browse files

Daisuke Shimamura's id3 v1/v2 + i18n patches

parent d8ab3468
......@@ -104,6 +104,49 @@ AM_CONDITIONAL(FLaC__HAS_XMMS, test x$XMMS_INPUT_PLUGIN_DIR != x)
SHARE_LIBS='$(top_builddir)/src/share/libutf8.a $(top_builddir)/src/share/libgetopt.a'
dnl check for i18n(internationalization)
AM_WITH_NLS
AM_ICONV
AM_LANGINFO_CODESET
dnl check id3lib librairies
LIBS_save_blah_blah_blah=$LIBS
LIBS=""
AC_SEARCH_LIBS(ID3Tag_Link,"id3" "id3 -lstdc++" "id3 -lz" "id3 -lz -lstdc++",
[have_id3lib=yes],
[AC_MSG_WARN([id3lib not found - ID3v2 will not be supported, internal function support only id3v1])])
AM_CONDITIONAL(FLaC__HAS_ID3LIB, [test x$have_id3lib = xyes])
if test x$have_id3lib = xyes ; then
AC_DEFINE(FLAC__HAS_ID3LIB)
ID3LIBS=$LIBS
fi
AC_SUBST(ID3LIBS)
dnl expected version for cross compiling
ID3LIB_MAJOR=3
ID3LIB_MINOR=8
ID3LIB_PATCH=0
AC_MSG_CHECKING(for id3lib version)
AC_TRY_RUN([
#include <id3.h>
#include <stdio.h>
int
main ()
{
FILE *output;
output=fopen("conftest.id3","w");
fprintf(output,"ID3LIB_MAJOR=%d\nID3LIB_MINOR=%d\nID3LIB_PATCH=%d\n",ID3LIB_MAJOR_VERSION,ID3LIB_MINOR_VERSION,ID3LIB_PATCH_VERSION);
fclose(output);
exit(0);
}
], . conftest.id3; echo "${ID3LIB_MAJOR}.${ID3LIB_MINOR}.${ID3LIB_PATCH}", AC_MSG_WARN(could not determine id3lib version),[echo $ac_n "cross compiling; assuming ${ID3LIB_MAJOR}.${ID3LIB_MINOR}.${ID3LIB_PATCH} $ac_c"])
AC_DEFINE_UNQUOTED(ID3LIB_MAJOR, $ID3LIB_MAJOR)
AC_DEFINE_UNQUOTED(ID3LIB_MINOR, $ID3LIB_MINOR)
AC_DEFINE_UNQUOTED(ID3LIB_PATCH, $ID3LIB_PATCH)
LIBS=$LIBS_save_blah_blah_blah
AC_CHECK_PROGS(NASM, nasm)
AM_CONDITIONAL(FLaC__HAS_NASM, test -n "$NASM")
if test -n "$NASM" ; then
......
......@@ -20,15 +20,26 @@
#
EXTRA_DIST = \
Makefile.lite
Makefile.lite \
id3_tag.c
CFLAGS = @CFLAGS@ @XMMS_CFLAGS@
xmmsinputplugindir = @XMMS_INPUT_PLUGIN_DIR@
# Don't build a static library
LIBTOOL = $(top_builddir)/libtool-disable-static
xmmsinputplugin_LTLIBRARIES = libxmms-flac.la
libxmms_flac_la_SOURCES = plugin.c
plugin_sources = plugin.c wrap_id3.c configure.c charset.c
id3v2_sources = id3_tag.c
if FLaC__HAS_ID3LIB
libxmms_flac_la_SOURCES = $(plugin_sources) $(id3v2_sources)
else
libxmms_flac_la_SOURCES = $(plugin_sources)
endif
# work around the bug in libtool where its relinking fails with a different DESTDIR
# for libtool bug info see:
# http://mail.gnu.org/pipermail/bug-libtool/2002-February/003018.html
......@@ -37,5 +48,5 @@ libxmms_flac_la_SOURCES = plugin.c
# for fix info see:
# http://lists.freshrpms.net/pipermail/rpm-list/2002-April/000746.html
# the workaround is the extra '-L$(top_builddir)/src/libFLAC/.libs'
libxmms_flac_la_LIBADD = $(top_builddir)/src/libFLAC/libFLAC.la -L$(top_builddir)/src/libFLAC/.libs @XMMS_LIBS@
libxmms_flac_la_LIBADD = $(top_builddir)/src/libFLAC/libFLAC.la -L$(top_builddir)/src/libFLAC/.libs @XMMS_LIBS@ @ID3LIBS@
libxmms_flac_la_LDFLAGS = -module -avoid-version
......@@ -24,7 +24,11 @@ INCLUDES = $(shell xmms-config --cflags) -I./include -I../../include
LIBS = ../../obj/lib/libFLAC.a
OBJS = \
plugin.o
plugin.o \
configure.o \
wrap_id3.o \
charset.o
include ../../build/lib.mk
......
/* libxmms-flac - XMMS FLAC input plugin
* Copyright (C) 2002 Daisuke Shimamura
*
* Almost from charset.c
* EasyTAG - Tag editor for MP3 and OGG files
* Copyright (C) 1999-2001 Hvard Kvlen <havardk@xmms.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <glib.h>
#include <string.h>
#include <errno.h>
#ifdef HAVE_ICONV
#include <iconv.h>
#endif
#ifdef HAVE_LANGINFO_CODESET
#include <langinfo.h>
#endif
#include "charset.h"
#include "mylocale.h"
#include "configure.h"
/****************
* Declarations *
****************/
#define CHARSET_TRANS_ARRAY_LEN ( sizeof(charset_trans_array) / sizeof((charset_trans_array)[0]) )
const CharsetInfo charset_trans_array[] = {
{N_("Arabic (IBM-864)"), "IBM864" },
{N_("Arabic (ISO-8859-6)"), "ISO-8859-6" },
{N_("Arabic (Windows-1256)"), "windows-1256" },
{N_("Baltic (ISO-8859-13)"), "ISO-8859-13" },
{N_("Baltic (ISO-8859-4)"), "ISO-8859-4" },
{N_("Baltic (Windows-1257)"), "windows-1257" },
{N_("Celtic (ISO-8859-14)"), "ISO-8859-14" },
{N_("Central European (IBM-852)"), "IBM852" },
{N_("Central European (ISO-8859-2)"), "ISO-8859-2" },
{N_("Central European (Windows-1250)"), "windows-1250" },
{N_("Chinese Simplified (GB18030)"), "gb18030" },
{N_("Chinese Simplified (GB2312)"), "GB2312" },
{N_("Chinese Traditional (Big5)"), "Big5" },
{N_("Chinese Traditional (Big5-HKSCS)"), "Big5-HKSCS" },
{N_("Cyrillic (IBM-855)"), "IBM855" },
{N_("Cyrillic (ISO-8859-5)"), "ISO-8859-5" },
{N_("Cyrillic (ISO-IR-111)"), "ISO-IR-111" },
{N_("Cyrillic (KOI8-R)"), "KOI8-R" },
{N_("Cyrillic (Windows-1251)"), "windows-1251" },
{N_("Cyrillic/Russian (CP-866)"), "IBM866" },
{N_("Cyrillic/Ukrainian (KOI8-U)"), "KOI8-U" },
{N_("English (US-ASCII)"), "us-ascii" },
{N_("Greek (ISO-8859-7)"), "ISO-8859-7" },
{N_("Greek (Windows-1253)"), "windows-1253" },
{N_("Hebrew (IBM-862)"), "IBM862" },
{N_("Hebrew (Windows-1255)"), "windows-1255" },
{N_("Japanese (EUC-JP)"), "EUC-JP" },
{N_("Japanese (ISO-2022-JP)"), "ISO-2022-JP" },
{N_("Japanese (Shift_JIS)"), "Shift_JIS" },
{N_("Korean (EUC-KR)"), "EUC-KR" },
{N_("Nordic (ISO-8859-10)"), "ISO-8859-10" },
{N_("South European (ISO-8859-3)"), "ISO-8859-3" },
{N_("Thai (TIS-620)"), "TIS-620" },
{N_("Turkish (IBM-857)"), "IBM857" },
{N_("Turkish (ISO-8859-9)"), "ISO-8859-9" },
{N_("Turkish (Windows-1254)"), "windows-1254" },
{N_("Unicode (UTF-7)"), "UTF-7" },
{N_("Unicode (UTF-8)"), "UTF-8" },
{N_("Unicode (UTF-16BE)"), "UTF-16BE" },
{N_("Unicode (UTF-16LE)"), "UTF-16LE" },
{N_("Unicode (UTF-32BE)"), "UTF-32BE" },
{N_("Unicode (UTF-32LE)"), "UTF-32LE" },
{N_("Vietnamese (VISCII)"), "VISCII" },
{N_("Vietnamese (Windows-1258)"), "windows-1258" },
{N_("Visual Hebrew (ISO-8859-8)"), "ISO-8859-8" },
{N_("Western (IBM-850)"), "IBM850" },
{N_("Western (ISO-8859-1)"), "ISO-8859-1" },
{N_("Western (ISO-8859-15)"), "ISO-8859-15" },
{N_("Western (Windows-1252)"), "windows-1252" }
/*
* From this point, character sets aren't supported by iconv
*/
/* {N_("Arabic (IBM-864-I)"), "IBM864i" },
{N_("Arabic (ISO-8859-6-E)"), "ISO-8859-6-E" },
{N_("Arabic (ISO-8859-6-I)"), "ISO-8859-6-I" },
{N_("Arabic (MacArabic)"), "x-mac-arabic" },
{N_("Armenian (ARMSCII-8)"), "armscii-8" },
{N_("Central European (MacCE)"), "x-mac-ce" },
{N_("Chinese Simplified (GBK)"), "x-gbk" },
{N_("Chinese Simplified (HZ)"), "HZ-GB-2312" },
{N_("Chinese Traditional (EUC-TW)"), "x-euc-tw" },
{N_("Croatian (MacCroatian)"), "x-mac-croatian" },
{N_("Cyrillic (MacCyrillic)"), "x-mac-cyrillic" },
{N_("Cyrillic/Ukrainian (MacUkrainian)"), "x-mac-ukrainian" },
{N_("Farsi (MacFarsi)"), "x-mac-farsi"},
{N_("Greek (MacGreek)"), "x-mac-greek" },
{N_("Gujarati (MacGujarati)"), "x-mac-gujarati" },
{N_("Gurmukhi (MacGurmukhi)"), "x-mac-gurmukhi" },
{N_("Hebrew (ISO-8859-8-E)"), "ISO-8859-8-E" },
{N_("Hebrew (ISO-8859-8-I)"), "ISO-8859-8-I" },
{N_("Hebrew (MacHebrew)"), "x-mac-hebrew" },
{N_("Hindi (MacDevanagari)"), "x-mac-devanagari" },
{N_("Icelandic (MacIcelandic)"), "x-mac-icelandic" },
{N_("Korean (JOHAB)"), "x-johab" },
{N_("Korean (UHC)"), "x-windows-949" },
{N_("Romanian (MacRomanian)"), "x-mac-romanian" },
{N_("Turkish (MacTurkish)"), "x-mac-turkish" },
{N_("User Defined"), "x-user-defined" },
{N_("Vietnamese (TCVN)"), "x-viet-tcvn5712" },
{N_("Vietnamese (VPS)"), "x-viet-vps" },
{N_("Western (MacRoman)"), "x-mac-roman" },
// charsets whithout posibly translatable names
{"T61.8bit", "T61.8bit" },
{"x-imap4-modified-utf7", "x-imap4-modified-utf7"},
{"x-u-escaped", "x-u-escaped" },
{"windows-936", "windows-936" }
*/
};
/*************
* Functions *
*************/
char* get_current_charset (void)
{
char *charset = getenv("CHARSET");
#ifdef HAVE_LANGINFO_CODESET
if (!charset)
charset = nl_langinfo(CODESET);
#endif
if (!charset)
charset = "ISO-8859-1";
return charset;
}
#ifdef HAVE_ICONV
static char* convert_string (const char *string, char *from, char *to)
{
size_t outleft, outsize, length;
iconv_t cd;
char *out, *outptr;
const char *input = string;
if (!string)
return NULL;
length = strlen(string);
/* g_message("converting %s from %s to %s", string, from, to); */
if ((cd = iconv_open(to, from)) == (iconv_t)-1)
{
g_warning("convert_string(): Conversion not supported. Charsets: %s -> %s", from, to);
return g_strdup(string);
}
/* Due to a GLIBC bug, round outbuf_size up to a multiple of 4 */
/* + 1 for nul in case len == 1 */
outsize = ((length + 3) & ~3) + 1;
out = g_malloc(outsize);
outleft = outsize - 1;
outptr = out;
retry:
if (iconv(cd, &input, &length, &outptr, &outleft) == -1)
{
int used;
switch (errno)
{
case E2BIG:
used = outptr - out;
outsize = (outsize - 1) * 2 + 1;
out = g_realloc(out, outsize);
outptr = out + used;
outleft = outsize - 1 - used;
goto retry;
case EINVAL:
break;
case EILSEQ:
/* Invalid sequence, try to get the
rest of the string */
input++;
length = strlen(input);
goto retry;
default:
g_warning("convert_string(): Conversion failed. Inputstring: %s; Error: %s", string, strerror(errno));
break;
}
}
*outptr = '\0';
iconv_close(cd);
return out;
}
#else
static char* convert_string (const char *string, char *from, char *to)
{
if (!string)
return NULL;
return g_strdup(string);
}
#endif
/*
* Commons conversion functions
*/
char* convert_from_file_to_user (const char *string)
{
char *file_charset = flac_cfg.file_char_set;
char *user_charset = flac_cfg.user_char_set;
return convert_string(string,file_charset,user_charset);
}
char* convert_from_user_to_file (const char *string)
{
char *file_charset = flac_cfg.file_char_set;
char *user_charset = flac_cfg.user_char_set;
return convert_string(string,user_charset,file_charset);
}
GList *Charset_Create_List (void)
{
GList *list = NULL;
guint i;
for (i=0; i<CHARSET_TRANS_ARRAY_LEN; i++)
list = g_list_append(list,_(charset_trans_array[i].charset_title));
return list;
}
/*
* Return charset_name from charset_title
*/
gchar *Charset_Get_Name_From_Title (gchar *charset_title)
{
guint i;
if (charset_title)
for (i=0; i<CHARSET_TRANS_ARRAY_LEN; i++)
if ( strcasecmp(_(charset_title),_(charset_trans_array[i].charset_title)) == 0 )
return charset_trans_array[i].charset_name;
return "";
}
/*
* Return charset_title from charset_name
*/
gchar *Charset_Get_Title_From_Name (gchar *charset_name)
{
guint i;
if (charset_name)
for (i=0; i<CHARSET_TRANS_ARRAY_LEN; i++)
if ( strcasecmp(charset_name,charset_trans_array[i].charset_name) == 0 )
return _(charset_trans_array[i].charset_title);
return "";
}
/*
* Test if the conversion is supported between two character sets ('from' and 'to)
*/
#ifdef HAVE_ICONV
gboolean test_conversion_charset (char *from, char *to)
{
iconv_t cd;
if ((cd=iconv_open(to,from)) == (iconv_t)-1)
{
/* Conversion not supported */
return FALSE;
}
iconv_close(cd);
return TRUE;
}
#else
gboolean test_conversion_charset (char *from, char *to)
{
return TRUE;
}
#endif
/* libxmms-flac - XMMS FLAC input plugin
* Copyright (C) 2002 Daisuke Shimamura
*
* Almost from charset.h - 2001/12/04
* EasyTAG - Tag editor for MP3 and OGG files
* Copyright (C) 1999-2001 H蛆ard Kv虱en <havardk@xmms.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __CHARSET_H__
#define __CHARSET_H__
/***************
* Declaration *
***************/
typedef struct {
gchar *charset_title;
gchar *charset_name;
} CharsetInfo;
/* translated charset titles */
extern const CharsetInfo charset_trans_array[];
/**************
* Prototypes *
**************/
gchar* get_current_charset (void);
gchar* convert_from_file_to_user (const gchar *string);
gchar* convert_from_user_to_file (const gchar *string);
GList *Charset_Create_List (void);
gchar *Charset_Get_Name_From_Title (gchar *charset_title);
gchar *Charset_Get_Title_From_Name (gchar *charset_name);
gboolean test_conversion_charset (char *from, char *to);
#endif /* __CHARSET_H__ */
/* libxmms-flac - XMMS FLAC input plugin
* Copyright (C) 2002 Daisuke Shimamura
*
* Based on mpg123 plugin
* and prefs.c - 2000/05/06
* EasyTAG - Tag editor for MP3 and OGG files
* Copyright (C) 2000-2002 Jerome Couderc <j.couderc@ifrance.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include <pthread.h>
#include <xmms/configfile.h>
#include <xmms/dirbrowser.h>
#include <xmms/titlestring.h>
#include <xmms/util.h>
#include <xmms/plugin.h>
#include "mylocale.h"
#include "charset.h"
#include "configure.h"
/*
* Initialize Global Valueable
*/
flac_config_t flac_cfg = {
FALSE,
NULL,
FALSE,
NULL,
NULL
};
static GtkWidget *flac_configurewin = NULL;
static GtkWidget *vbox, *notebook;
static GtkWidget *title_tag_override, *title_tag_box, *title_tag_entry, *title_desc;
static GtkWidget *convert_char_set, *fileCharacterSetEntry, *userCharacterSetEntry;
static gchar *gtk_entry_get_text_1 (GtkWidget *widget);
static void flac_configurewin_ok(GtkWidget * widget, gpointer data);
static void configure_destroy(GtkWidget * w, gpointer data);
static void title_tag_override_cb(GtkWidget * w, gpointer data);
static void convert_char_set_cb(GtkWidget * w, gpointer data);
static void flac_configurewin_ok(GtkWidget * widget, gpointer data)
{
ConfigFile *cfg;
gchar *filename;
g_free(flac_cfg.tag_format);
flac_cfg.tag_format = g_strdup(gtk_entry_get_text(GTK_ENTRY(title_tag_entry)));
flac_cfg.file_char_set = Charset_Get_Name_From_Title(gtk_entry_get_text_1(fileCharacterSetEntry));
flac_cfg.user_char_set = Charset_Get_Name_From_Title(gtk_entry_get_text_1(userCharacterSetEntry));
filename = g_strconcat(g_get_home_dir(), "/.xmms/config", NULL);
cfg = xmms_cfg_open_file(filename);
if (!cfg)
cfg = xmms_cfg_new();
xmms_cfg_write_boolean(cfg, "flac", "tag_override", flac_cfg.tag_override);
xmms_cfg_write_string(cfg, "flac", "tag_format", flac_cfg.tag_format);
xmms_cfg_write_boolean(cfg, "flac", "convert_char_set", flac_cfg.convert_char_set);
xmms_cfg_write_string(cfg, "flac", "file_char_set", flac_cfg.file_char_set);
xmms_cfg_write_string(cfg, "flac", "user_char_set", flac_cfg.user_char_set);
xmms_cfg_write_file(cfg, filename);
xmms_cfg_free(cfg);
g_free(filename);
gtk_widget_destroy(flac_configurewin);
}
static void configure_destroy(GtkWidget * w, gpointer data)
{
}
static void title_tag_override_cb(GtkWidget * w, gpointer data)
{
flac_cfg.tag_override = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(title_tag_override));
gtk_widget_set_sensitive(title_tag_box, flac_cfg.tag_override);
gtk_widget_set_sensitive(title_desc, flac_cfg.tag_override);
}
static void convert_char_set_cb(GtkWidget * w, gpointer data)
{
flac_cfg.convert_char_set = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(convert_char_set));
gtk_widget_set_sensitive(fileCharacterSetEntry, flac_cfg.convert_char_set);
gtk_widget_set_sensitive(userCharacterSetEntry, flac_cfg.convert_char_set);
}
void FLAC_XMMS__configure(void)
{
GtkWidget *title_frame, *title_tag_vbox, *title_tag_label;
GtkWidget *label, *hbox;
GtkWidget *bbox, *ok, *cancel;
GList *list;
if (flac_configurewin != NULL) {
gdk_window_raise(flac_configurewin->window);
return;
}
flac_configurewin = gtk_window_new(GTK_WINDOW_DIALOG);
gtk_signal_connect(GTK_OBJECT(flac_configurewin), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &flac_configurewin);
gtk_signal_connect(GTK_OBJECT(flac_configurewin), "destroy", GTK_SIGNAL_FUNC(configure_destroy), &flac_configurewin);
gtk_window_set_title(GTK_WINDOW(flac_configurewin), _("Flac Configuration"));
gtk_window_set_policy(GTK_WINDOW(flac_configurewin), FALSE, FALSE, FALSE);
gtk_container_border_width(GTK_CONTAINER(flac_configurewin), 10);
vbox = gtk_vbox_new(FALSE, 10);
gtk_container_add(GTK_CONTAINER(flac_configurewin), vbox);
notebook = gtk_notebook_new();
gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
/* Title config.. */
title_frame = gtk_frame_new(_("ID3 Tags:"));
gtk_container_border_width(GTK_CONTAINER(title_frame), 5);
title_tag_vbox = gtk_vbox_new(FALSE, 10);
gtk_container_border_width(GTK_CONTAINER(title_tag_vbox), 5);
gtk_container_add(GTK_CONTAINER(title_frame), title_tag_vbox);
/* Convert Char Set */
convert_char_set = gtk_check_button_new_with_label(_("Convert Character Set"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(convert_char_set), flac_cfg.convert_char_set);
gtk_signal_connect(GTK_OBJECT(convert_char_set), "clicked", convert_char_set_cb, NULL);
gtk_box_pack_start(GTK_BOX(title_tag_vbox), convert_char_set, FALSE, FALSE, 0);
// Combo boxes...
hbox = gtk_hbox_new(FALSE,4);
gtk_container_add(GTK_CONTAINER(title_tag_vbox),hbox);
label = gtk_label_new(_("Convert character set from :"));
gtk_box_pack_start(GTK_BOX(hbox),label,FALSE,FALSE,0);
fileCharacterSetEntry = gtk_combo_new();
gtk_box_pack_start(GTK_BOX(hbox),fileCharacterSetEntry,TRUE,TRUE,0);
label = gtk_label_new (_("to :"));