aboutsummaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authornovel <novel@FreeBSD.org>2006-01-27 04:42:32 +0800
committernovel <novel@FreeBSD.org>2006-01-27 04:42:32 +0800
commit956f4db4b758255d95f333df83dadcedfd815f6a (patch)
treef995ea58947190c6610511f0748108c7bd985031 /audio
parent885140656516a65fa248843555f6d8f1df81d76b (diff)
downloadfreebsd-ports-graphics-956f4db4b758255d95f333df83dadcedfd815f6a.tar.gz
freebsd-ports-graphics-956f4db4b758255d95f333df83dadcedfd815f6a.tar.zst
freebsd-ports-graphics-956f4db4b758255d95f333df83dadcedfd815f6a.zip
- Add an optional ID3 tags encoding conversion support [1]
- Pet portlint Obtained from: http://www.last.fm/forum/4/_/68497 [1]
Diffstat (limited to 'audio')
-rw-r--r--audio/scrobbler/Makefile21
-rw-r--r--audio/scrobbler/files/extra-encodings-patch242
2 files changed, 261 insertions, 2 deletions
diff --git a/audio/scrobbler/Makefile b/audio/scrobbler/Makefile
index 0c984f7b73d..89d1f1f6080 100644
--- a/audio/scrobbler/Makefile
+++ b/audio/scrobbler/Makefile
@@ -18,8 +18,8 @@ COMMENT?= XMMS/BMP plugin for Audioscrobbler.com
LIB_DEPENDS= musicbrainz.4:${PORTSDIR}/audio/libmusicbrainz \
curl.3:${PORTSDIR}/ftp/curl
-CONFLICTS= bmp-scrobbler-* \
- xmms-scrobbler-*
+CONFLICTS= bmp-scrobbler-[0-9]* \
+ xmms-scrobbler-[0-9]*
USE_BZIP2= yes
USE_X_PREFIX= yes
@@ -56,4 +56,21 @@ CONFIGURE_ARGS+= --enable-debug
CONFIGURE_ARGS+= --enable-prefer-ape
.endif
+.if defined(WITH_ENCODINGS_PATCH)
+USE_ICONV= yes
+
+post-patch::
+ @${PATCH} ${PATCH_ARGS} -p1 < ${FILESDIR}/extra-encodings-patch
+.endif
+
+pre-everything::
+ @${ECHO_MSG} "You may specify the following on the command line:"
+ @${ECHO_MSG} " "
+ @${ECHO_MSG} "WITH_XMMS=yes to enable xmms support"
+ @${ECHO_MSG} "WITH_BMP=yes to enable beep-media-player support"
+ @${ECHO_MSG} "WITH_DEBUG=yes to turn on debug mode"
+ @${ECHO_MSG} "WITH_APE=yes to enable ape"
+ @${ECHO_MSG} "WITH_ENCODINGS_PATCH=yes to enable ID3 tags recoding support"
+ @${ECHO_MSG} " "
+
.include <bsd.port.mk>
diff --git a/audio/scrobbler/files/extra-encodings-patch b/audio/scrobbler/files/extra-encodings-patch
new file mode 100644
index 00000000000..19170a7df00
--- /dev/null
+++ b/audio/scrobbler/files/extra-encodings-patch
@@ -0,0 +1,242 @@
+diff -urp xmms-scrobbler-0.3.8.1/gtkstuff.c xmms-scrobbler-0.3.8.1-enc/gtkstuff.c
+--- xmms-scrobbler-0.3.8.1/gtkstuff.c 2005-02-20 05:26:08.000000000 +0100
++++ xmms-scrobbler-0.3.8.1-enc/gtkstuff.c 2005-12-13 22:02:56.000000000 +0100
+@@ -15,9 +15,11 @@
+ #include <string.h>
+ #include "config.h"
+ #include "md5.h"
++#include "tags/include/unicode.h"
+
+ static GtkWidget *eduname,
+- *edpwd;
++ *edpwd,
++ *edenc;
+ static int errorbox_done;
+ void about_show(void)
+ {
+@@ -115,6 +117,10 @@ static void saveconfig(GtkWidget *wid, g
+
+ const char *pwd = gtk_entry_get_text(GTK_ENTRY(edpwd));
+ const char *uid = gtk_entry_get_text(GTK_ENTRY(eduname));
++ const char *enc = gtk_entry_get_text(GTK_ENTRY(edenc));
++
++ g_free(tags_encoding);
++ tags_encoding = g_strdup(enc);
+
+ if ((cfgfile = xmms_cfg_open_default_file())) {
+
+@@ -130,6 +136,9 @@ static void saveconfig(GtkWidget *wid, g
+ xmms_cfg_write_string(cfgfile, "audioscrobbler", "password",
+ (char *)hexify(md5pword, sizeof(md5pword)));
+ }
++
++ xmms_cfg_write_string(cfgfile, "audioscrobbler", "encoding", (char *)enc);
++
+ #ifdef MAKE_XMMS
+ xmms_cfg_write_default_file(cfgfile);
+ #endif
+@@ -147,8 +156,10 @@ void configure_dialog(void)
+ *hbox,
+ *unhbox,
+ *pwhbox,
++ *enhbox,
+ *lblun,
+ *lblpw,
++ *lblen,
+ *frame;
+
+ ConfigFile *cfgfile;
+@@ -184,9 +195,16 @@ void configure_dialog(void)
+ gtk_entry_set_visibility(GTK_ENTRY(edpwd), FALSE);
+ gtk_box_pack_start(GTK_BOX(pwhbox), lblpw, FALSE, FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(pwhbox), edpwd, FALSE, FALSE, 3);
++
++ enhbox = gtk_hbox_new(FALSE, 0);
++ edenc = gtk_entry_new();
++ lblen = gtk_label_new("Tags encoding");
++ gtk_box_pack_start(GTK_BOX(enhbox), lblen, FALSE, FALSE, 3);
++ gtk_box_pack_start(GTK_BOX(enhbox), edenc, FALSE, FALSE, 3);
+
+ gtk_box_pack_start(GTK_BOX(vbox), unhbox, FALSE, FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(vbox), pwhbox, FALSE, FALSE, 3);
++ gtk_box_pack_start(GTK_BOX(vbox), enhbox, FALSE, FALSE, 3);
+
+ hbox = gtk_hbox_new(FALSE, 0);
+
+@@ -202,17 +220,26 @@ void configure_dialog(void)
+
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
+
+- frame = gtk_frame_new(" The plugin will have to be restarted for changes to take effect! ");
++ frame = gtk_frame_new(" The plugin will have to be restarted for username/password changes to take effect! ");
+ gtk_container_add(GTK_CONTAINER(frame), vbox);
+ gtk_container_add(GTK_CONTAINER(cnfdlg), frame);
+ if ((cfgfile = xmms_cfg_open_default_file())) {
+- gchar *username = NULL;
+- xmms_cfg_read_string(cfgfile, "audioscrobbler", "username",
+- &username);
+- if (username) {
+- gtk_entry_set_text(GTK_ENTRY(eduname), username);
+- g_free(username);
++ gchar *entry;
++
++ entry = NULL;
++ xmms_cfg_read_string(cfgfile, "audioscrobbler", "username", &entry);
++ if (entry) {
++ gtk_entry_set_text(GTK_ENTRY(eduname), entry);
++ g_free(entry);
++ }
++
++ entry = NULL;
++ xmms_cfg_read_string(cfgfile, "audioscrobbler", "encoding", &entry);
++ if (entry) {
++ gtk_entry_set_text(GTK_ENTRY(edenc), entry);
++ g_free(entry);
+ }
++
+ xmms_cfg_free(cfgfile);
+ }
+
+diff -urp xmms-scrobbler-0.3.8.1/tags/include/unicode.h xmms-scrobbler-0.3.8.1-enc/tags/include/unicode.h
+--- xmms-scrobbler-0.3.8.1/tags/include/unicode.h 2004-03-28 19:34:56.000000000 +0200
++++ xmms-scrobbler-0.3.8.1-enc/tags/include/unicode.h 2005-12-13 22:00:35.000000000 +0100
+@@ -26,4 +26,6 @@ void iso88591_to_utf8(unsigned char *, s
+ void utf16bom_to_utf8(unsigned char *, size_t, unsigned char **);
+ void utf16be_to_utf8(unsigned char *, size_t, unsigned char **);
+ void utf16le_to_utf8(unsigned char *, size_t, unsigned char **);
++
++extern char *tags_encoding;
+ #endif
+diff -urp xmms-scrobbler-0.3.8.1/tags/unicode.c xmms-scrobbler-0.3.8.1-enc/tags/unicode.c
+--- xmms-scrobbler-0.3.8.1/tags/unicode.c 2004-03-28 20:15:37.000000000 +0200
++++ xmms-scrobbler-0.3.8.1-enc/tags/unicode.c 2005-12-13 22:31:34.000000000 +0100
+@@ -21,9 +21,84 @@
+ #include <stdlib.h>
+ #include <wchar.h>
+ #include <string.h>
++#include <iconv.h>
++#include <glib.h>
++#include <errno.h>
+ #include "include/endian.h"
+ #include "include/unicode.h"
+
++char *tags_encoding = NULL;
++
++/*
++ * generic iconv function
++ * taken from gentoo libxmms - looks nice and works
++ *
++ * Tue Dec 13 22:15:06 CET 2005 - Kosma Moczek <kosmam@op.pl>
++ */
++static char* generic_iconv(const unsigned char *string, size_t insize, char *from, char *to)
++{
++ size_t outleft, outsize;
++ iconv_t cd;
++ char *out, *outptr;
++ char *input = (char *) string;
++
++ if (!string) return NULL;
++
++// g_message("converting %s from %s to %s (%u)", string, from, to, insize);
++
++ /* check if the conversion is needed */
++ if (!strcmp(from,to)) return g_strdup(string);
++
++ 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 = ((insize + 3) & ~3) + 1;
++ out = g_malloc(outsize);
++ outleft = outsize - 1;
++ outptr = out;
++
++ retry:
++ if (iconv(cd, &input, &insize, &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:
++ /* incomplete multibyte sequence (at the end of string)
++ * - just quit, nothing to do here */
++ break;
++ case EILSEQ:
++ /* Invalid sequence, try to get the
++ rest of the string */
++ input++;
++ insize--;
++ goto retry;
++ default:
++ g_warning("convert_string(): Conversion failed. "
++ "Inputstring: %s; Error: %s",
++ string, strerror(errno));
++ break;
++ }
++ }
++ *outptr = '\0';
++
++ iconv_close(cd);
++ return out;
++}
++
+ wchar_t *utf8_to_wchar(unsigned char *utf, size_t memsize)
+ {
+ int i, j = 0;
+@@ -141,6 +216,12 @@ unsigned char *wchar_to_utf8(wchar_t *wc
+ void iso88591_to_utf8(unsigned char *iso, size_t memsize,
+ unsigned char **utf)
+ {
++ /* don't run recoder of setting is incomplete */
++ if (tags_encoding && *tags_encoding) {
++ *utf = generic_iconv(iso, memsize, tags_encoding, "UTF-8");
++ return;
++ }
++
+ int i;
+ wchar_t *wchar;
+
+diff -urp xmms-scrobbler-0.3.8.1/xmms_scrobbler.c xmms-scrobbler-0.3.8.1-enc/xmms_scrobbler.c
+--- xmms-scrobbler-0.3.8.1/xmms_scrobbler.c 2005-02-21 02:25:47.000000000 +0100
++++ xmms-scrobbler-0.3.8.1-enc/xmms_scrobbler.c 2005-12-13 22:53:29.000000000 +0100
+@@ -59,7 +59,7 @@ static GeneralPlugin xmms_scrobbler =
+
+ static void init(void)
+ {
+- char *username = NULL, *password = NULL;
++ char *username = NULL, *password = NULL, *encoding = NULL;
+ ConfigFile *cfgfile;
+ going = 1;
+
+@@ -68,6 +68,8 @@ static void init(void)
+ &username);
+ xmms_cfg_read_string(cfgfile, "audioscrobbler", "password",
+ &password);
++ xmms_cfg_read_string(cfgfile, "audioscrobbler", "encoding",
++ &encoding);
+ xmms_cfg_free(cfgfile);
+ }
+ if ((!username || !password) || (!*username || !*password)) {
+@@ -76,6 +78,10 @@ static void init(void)
+ going = 0;
+ return;
+ }
++ if (encoding) {
++ tags_encoding = g_strdup(encoding);
++ g_free(encoding);
++ }
+ sc_init(username, password);
+ g_free(username);
+ g_free(password);