55e349d643
Reported by: stas
245 lines
7.1 KiB
Text
245 lines
7.1 KiB
Text
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
|
|
@@ -13,11 +13,14 @@
|
|
#endif
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
+#include <wchar.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 +118,10 @@
|
|
|
|
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 +137,9 @@
|
|
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 +157,10 @@
|
|
*hbox,
|
|
*unhbox,
|
|
*pwhbox,
|
|
+ *enhbox,
|
|
*lblun,
|
|
*lblpw,
|
|
+ *lblen,
|
|
*frame;
|
|
|
|
ConfigFile *cfgfile;
|
|
@@ -184,9 +196,16 @@
|
|
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 +221,26 @@
|
|
|
|
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);
|