summaryrefslogtreecommitdiffstats
path: root/fixes/zinf-fixes/zinf-ds.patch
blob: 4e4b8397112127c7577b5c590c661b57e6ba21f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
diff -dPNur zinf-2.2.5/plm/metadata/id3lib/id3lib.cpp zinf-2.2.5-new/plm/metadata/id3lib/id3lib.cpp
--- zinf-2.2.5/plm/metadata/id3lib/id3lib.cpp	2004-01-30 13:06:02.000000000 +0100
+++ zinf-2.2.5-new/plm/metadata/id3lib/id3lib.cpp	2005-07-19 23:37:11.000000000 +0200
@@ -304,10 +304,45 @@
 }
 
 
+static int rccGetCurrentEncoding(char *result, unsigned int n) {
+    unsigned int i;
+    char *l;
+
+    if ((!result)||(!n)) return -1;
+
+	l = getenv("CHARSET");
+#ifdef HAVE_CODESET
+	if (!l) l = nl_langinfo(CODESET);
+#endif
+	if (l) {
+	    if (strlen(l)>=n) return -1;
+	    strcpy(result, l);
+	    return 0;
+	}
+
+	l = setlocale(LC_CTYPE, NULL);
+	if (!l) return -1;
+    
+    for (i=0;((l[i])&&(l[i]!='.')&&(l[i]!='_'));i++);
+    if (i>=n) return -1;
+    
+    l = strrchr(l, '.');
+    if (!l) return -1;
+
+    for (i=0;((l[i])&&(l[i]!='@'));i++);
+    if (i>=n) return -1;
+
+    strncpy(result,l+1,i-1);
+    result[i]=0;
+
+    return 0;
+}
+
 static
 bool getTag(ID3_Tag&tag, ID3_FrameID frameid, string &result)
 {
-    static char buffer[1024];
+    int err;
+    static char buffer[1024], locale[64];
 #ifdef HAVE_GLIB
     gchar *utfbuffer;
 #endif
@@ -326,7 +361,8 @@
 	    return true;
 	  }
 	  else {
-	    utfbuffer=g_convert(buffer, sizeof buffer, "UTF-8", charset.c_str(), NULL, NULL, NULL);
+	    err = rccGetCurrentEncoding(locale, 64);
+	    utfbuffer=g_convert(buffer, sizeof buffer, "UTF-8", err?charset.c_str():locale, NULL, NULL, NULL);
 	    result=utfbuffer;
 	    g_free(utfbuffer);
 	    return true;
diff -dPNur zinf-2.2.5/ui/ncurses/Makefile.am zinf-2.2.5-new/ui/ncurses/Makefile.am
--- zinf-2.2.5/ui/ncurses/Makefile.am	2003-09-16 19:35:31.000000000 +0200
+++ zinf-2.2.5-new/ui/ncurses/Makefile.am	2005-07-19 23:51:02.000000000 +0200
@@ -3,11 +3,11 @@
 plugin_LTLIBRARIES = ncurses-ui.la
 
 ncurses_ui_la_SOURCES = ncursesUI.cpp
-ncurses_ui_la_LIBADD = $(NCURSES_LIBS)
+ncurses_ui_la_LIBADD = $(NCURSES_LIBS) $(GLIB_LIBS)
 ncurses_ui_la_LDFLAGS = $(plugin_ldflags)
 
 noinst_HEADERS = ncursesUI.h
 
-AM_CPPFLAGS = $(THREAD_CFLAGS) $(base_includes)
+AM_CPPFLAGS = $(THREAD_CFLAGS) $(base_includes) $(GLIB_CFLAGS)
 
 # arch-tag: 19b44c0b-0802-4cfc-9d47-519f9049c888
diff -dPNur zinf-2.2.5/ui/ncurses/Makefile.in zinf-2.2.5-new/ui/ncurses/Makefile.in
--- zinf-2.2.5/ui/ncurses/Makefile.in	2004-02-09 01:48:25.000000000 +0100
+++ zinf-2.2.5-new/ui/ncurses/Makefile.in	2005-07-20 00:23:03.823574339 +0200
@@ -231,7 +231,7 @@
 
 noinst_HEADERS = ncursesUI.h
 
-AM_CPPFLAGS = $(THREAD_CFLAGS) $(base_includes)
+AM_CPPFLAGS = $(THREAD_CFLAGS) $(base_includes) $(GLIB_CFLAGS)
 subdir = ui/ncurses
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 mkinstalldirs = $(SHELL) $(top_srcdir)/config/mkinstalldirs
diff -dPNur zinf-2.2.5/ui/ncurses/ncursesUI.cpp zinf-2.2.5-new/ui/ncurses/ncursesUI.cpp
--- zinf-2.2.5/ui/ncurses/ncursesUI.cpp	2003-09-16 19:35:31.000000000 +0200
+++ zinf-2.2.5-new/ui/ncurses/ncursesUI.cpp	2005-07-20 00:03:31.000000000 +0200
@@ -32,6 +32,7 @@
 #include <termios.h>
 #include <signal.h>
 
+
 using namespace std;
 #include "config.h"
 #include "i18n.h"
@@ -41,6 +42,10 @@
 #include "thread.h"
 #include "eventdata.h"
 
+#ifdef HAVE_GLIB
+#include <glib.h>
+#endif
+
 #define stdinfd 0
 
 extern "C" {
@@ -262,6 +267,40 @@
 
 }
 
+static int rccGetCurrentEncoding(char *result, unsigned int n) {
+    unsigned int i;
+    char *l;
+
+    if ((!result)||(!n)) return -1;
+
+	l = getenv("CHARSET");
+#ifdef HAVE_CODESET
+	if (!l) l = nl_langinfo(CODESET);
+#endif
+	if (l) {
+	    if (strlen(l)>=n) return -1;
+	    strcpy(result, l);
+	    return 0;
+	}
+
+	l = setlocale(LC_CTYPE, NULL);
+	if (!l) return -1;
+    
+    for (i=0;((l[i])&&(l[i]!='.')&&(l[i]!='_'));i++);
+    if (i>=n) return -1;
+    
+    l = strrchr(l, '.');
+    if (!l) return -1;
+
+    for (i=0;((l[i])&&(l[i]!='@'));i++);
+    if (i>=n) return -1;
+
+    strncpy(result,l+1,i-1);
+    result[i]=0;
+
+    return 0;
+}
+
 Error ncursesUI::AcceptEvent(Event *e) {
     if (e) {
         switch (e->Type()) {
@@ -342,36 +381,69 @@
                     break;
                 md = pItem->GetMetaData();
 
+		char *recoded;
+		char locale[64];
+#ifdef HAVE_GLIB
+		if (rccGetCurrentEncoding(locale, 64)) strcpy(locale, "UTF-8");
+#else
+		recoded = NULL;
+#endif		
+
+
                 clear();
                 move(0,0);
                 showInfo();
                 move(2, 0);
                 addstr(_("Title  : "));
-                if (md.Title().c_str()[0] != '\0')
-                    addstr((char *)md.Title().c_str());
-                else
+                if (md.Title().c_str()[0] != '\0') {
+#ifdef HAVE_GLIB
+		    recoded = g_convert(md.Title().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL);
+#endif
+                    addstr(recoded?recoded:(char *)md.Title().c_str());
+                } else
                     addstr(pmvi->m_filename.c_str());
+
+#ifdef HAVE_GLIB
+		if (recoded) free(recoded);
+		recoded = g_convert(md.Artist().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL);
+#endif
                 addstr(_("\nArtist : "));
-                addstr((char *)md.Artist().c_str());
+                addstr(recoded?recoded:(char *)md.Artist().c_str());
+#ifdef HAVE_GLIB
+		if (recoded) free(recoded);
+		recoded = g_convert(md.Album().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL);
+#endif
                 addstr(_("\nAlbum  : "));
-                addstr((char *)md.Album().c_str());
+                addstr(recoded?recoded:(char *)md.Album().c_str());
                 addstr(_("\nYear   : "));
                 if (md.Year() != 0)
                 {
                     sprintf(buf, "%d", md.Year());
                     addstr(buf);
                 }
+#ifdef HAVE_GLIB
+		if (recoded) free(recoded);
+		recoded = g_convert(md.Genre().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL);
+#endif
                 addstr(_("\nGenre  : "));
-                addstr((char *)md.Genre().c_str());
+                addstr(recoded?recoded:(char *)md.Genre().c_str());
                 addstr(_("\nTrack  : "));
                 if (md.Track() != 0)
                 {
                     sprintf(buf, "%d", md.Track());
                     addstr(buf);
                 }
+#ifdef HAVE_GLIB
+		if (recoded) free(recoded);
+		recoded = g_convert(md.Comment().c_str(), -1, locale, "UTF-8", NULL, NULL, NULL);
+#endif
                 addstr(_("\nComment: "));
-                addstr((char *)md.Comment().c_str());
+                addstr(recoded?recoded:(char *)md.Comment().c_str());
                 addstr("\n");
+
+#ifdef HAVE_GLIB
+		if (recoded) free(recoded);
+#endif
                 refresh();
 
                 counter = 0;