View | Details | Raw Unified | Return to bug 105220 | Differences between
and this patch

Collapse All | Expand All

(-)/home/makc/porting/ports/audio/kid3/Makefile (-11 / +11 lines)
Lines 7-12 Link Here
7
7
8
PORTNAME=	kid3
8
PORTNAME=	kid3
9
PORTVERSION=	0.7
9
PORTVERSION=	0.7
10
PORTREVISION=	1
10
CATEGORIES=	audio kde
11
CATEGORIES=	audio kde
11
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITE_SUBDIR=	${PORTNAME}
13
MASTER_SITE_SUBDIR=	${PORTNAME}
Lines 18-39 Link Here
18
		FLAC.7:${PORTSDIR}/audio/flac \
19
		FLAC.7:${PORTSDIR}/audio/flac \
19
		ogg.5:${PORTSDIR}/audio/libogg \
20
		ogg.5:${PORTSDIR}/audio/libogg \
20
		vorbis.3:${PORTSDIR}/audio/libvorbis \
21
		vorbis.3:${PORTSDIR}/audio/libvorbis \
21
		tunepimp-0.4.3:${PORTSDIR}/audio/libtunepimp-old
22
		tunepimp.5:${PORTSDIR}/audio/libtunepimp
22
23
23
USE_KDELIBS_VER=3
24
USE_KDELIBS_VER=3
24
USE_GMAKE=	yes
25
USE_GMAKE=	yes
25
USE_AUTOTOOLS=	libtool:15
26
USE_AUTOTOOLS=	automake:19:env autoconf:259:env libtool:15
27
USE_PERL5_BUILD=yes
26
USE_GETTEXT=	yes
28
USE_GETTEXT=	yes
27
GNU_CONFIGURE=	yes
29
GNU_CONFIGURE=	yes
28
INSTALLS_ICONS=	yes
30
INSTALLS_ICONS=	yes
29
CONFIGURE_ARGS+=CFLAGS=-I${LOCALBASE}/include/tunepimp-0.4 \
30
		LDFLAGS=-L${LOCALBASE}/lib/tunepimp-0.4
31
32
post-patch:
33
	@${REINPLACE_CMD} -e 's|-ltunepimp|-ltunepimp-0.4|g' \
34
		-e 's|<tunepimp/tp_c.h>|<tunepimp-0.4/tunepimp/tp_c.h>|g' \
35
	${WRKSRC}/configure ${WRKSRC}/kid3/musicbrainzclient.h \
36
		${WRKSRC}/admin/Makefile
37
31
38
.include <bsd.port.pre.mk>
32
.include <bsd.port.pre.mk>
39
33
Lines 41-45 Link Here
41
IGNORE=	does not compile on FreeBSD 4.x
35
IGNORE=	does not compile on FreeBSD 4.x
42
.endif
36
.endif
43
37
44
.include <bsd.port.post.mk>
38
pre-configure:
39
	@cd ${CONFIGURE_WRKSRC} \
40
		&& ${SETENV} ${AUTOTOOLS_ENV} ${ACLOCAL} -I ${ACLOCAL_DIR} \
41
		&& ${SETENV} ${AUTOTOOLS_ENV} ${AUTOMAKE} ${AUTOMAKE_ARGS} \
42
		&& ${PERL} admin/am_edit \
43
		&& ${SETENV} ${AUTOTOOLS_ENV} ${AUTOCONF} ${AUTOCONF_ARGS}
45
44
45
.include <bsd.port.post.mk>
(-)/home/makc/porting/ports/audio/kid3/files/patch-configure.in (+18 lines)
Line 0 Link Here
1
diff -ru configure.in configure.in
2
--- configure.in	Tue Jun 27 22:54:46 2006
3
+++ configure.in	Sun Nov 12 00:18:44 2006
4
@@ -133,10 +133,12 @@
5
   with_musicbrainz=yes
6
 )
7
 if test "$with_musicbrainz" != "no"; then
8
-  KDE_CHECK_HEADER(tunepimp/tp_c.h, [build_musicbrainz="yes"], [build_musicbrainz="no"])
9
+  AC_CHECK_HEADER(tunepimp-0.5/tp_c.h, [build_musicbrainz="yes"],
10
+    [AC_CHECK_HEADER(tunepimp/tp_c.h, [build_musicbrainz="yes"],
11
+      [build_musicbrainz="no"])])
12
 fi
13
 if test "$build_musicbrainz" = "yes"; then
14
-  AC_CHECK_LIB(tunepimp, tp_SetPUIDCollisionThreshold,
15
+  AC_CHECK_LIB(tunepimp, tr_GetPUID,
16
     AC_DEFINE(HAVE_TUNEPIMP, 5, [have TunePimp 0.5.x]),
17
     AC_CHECK_LIB(tunepimp, tp_SetFileNameEncoding,
18
       AC_DEFINE(HAVE_TUNEPIMP, 4, [have TunePimp 0.4.x]),
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3-oggfile.cpp (-11 lines)
Lines 1-11 Link Here
1
--- kid3/oggfile.cpp.orig	Sat Jan 28 02:15:27 2006
2
+++ kid3/oggfile.cpp	Mon Aug  7 16:13:25 2006
3
@@ -143,7 +143,7 @@
4
 			bool setUtime = false;
5
 			struct utimbuf times;
6
 			if (preserve) {
7
-				int fd = ::fileno(fpIn);
8
+				int fd = fileno(fpIn);
9
 				if (fd >= 0) {
10
 					struct stat fileStat;
11
 					if (::fstat(fd, &fileStat) == 0) {
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_Makefile.am (+41 lines)
Line 0 Link Here
1
diff -ru kid3/Makefile.am kid3/Makefile.am
2
--- kid3/Makefile.am	Thu May 25 17:31:52 2006
3
+++ kid3/Makefile.am	Sun Nov 12 00:25:16 2006
4
@@ -36,22 +36,6 @@
5
 # additional files in distribution
6
 EXTRA_DIST = kid3.desktop kid3ui.rc hi16-app-kid3.png hi32-app-kid3.png hi48-app-kid3.png de_qt.po ru_qt.po kid3.dsp kid3.dsw kid3win.rc kid3.ico kid3.mak config.mk
7
 
8
-install-data-local:
9
-	$(mkinstalldirs) $(kde_datadir)/kid3/
10
-	$(INSTALL_DATA) $(srcdir)/kid3ui.rc $(kde_datadir)/kid3/kid3ui.rc
11
-	$(mkinstalldirs) $(kde_icondir)/hicolor/16x16/apps/
12
-	$(INSTALL_DATA) $(srcdir)/hi16-app-kid3.png $(kde_icondir)/hicolor/16x16/apps/kid3.png
13
-	$(mkinstalldirs) $(kde_icondir)/hicolor/32x32/apps/
14
-	$(INSTALL_DATA) $(srcdir)/hi32-app-kid3.png $(kde_icondir)/hicolor/32x32/apps/kid3.png
15
-	$(mkinstalldirs) $(kde_icondir)/hicolor/48x48/apps/
16
-	$(INSTALL_DATA) $(srcdir)/hi48-app-kid3.png $(kde_icondir)/hicolor/48x48/apps/kid3.png
17
-
18
-uninstall-local:
19
-	-rm -f $(kde_datadir)/kid3/kid3ui.rc
20
-	-rm -f $(kde_icondir)/hicolor/16x16/apps/kid3.png
21
-	-rm -f $(kde_icondir)/hicolor/32x32/apps/kid3.png
22
-	-rm -f $(kde_icondir)/hicolor/48x48/apps/kid3.png
23
-
24
 # generate precompiled header allsys.h.gch for GCC 3.4
25
 pch:
26
 	echo "/* automatically generated by Makefile */" >allsys.h
27
@@ -72,6 +56,11 @@
28
 messages: rc.cpp
29
 	$(XGETTEXT) *.cpp -o $(podir)/kid3.pot
30
 
31
-# this is where the desktop file will go 
32
-desktopdir   = $(kde_appsdir)/Multimedia
33
-desktop_DATA = kid3.desktop
34
+KDE_ICON = kid3
35
+
36
+# this is where the kdelnk file will go 
37
+xdg_apps_DATA = kid3.desktop
38
+
39
+# this is where the XML-GUI resource file goes
40
+rcdir = $(kde_datadir)/kid3
41
+rc_DATA = kid3ui.rc
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_freedbclient.cpp (+101 lines)
Line 0 Link Here
1
+++ ./kid3/freedbclient.cpp	2006-05-28 15:05:28.000000000 +0200
2
+++ ./kid3/freedbclient.cpp	2006-10-07 21:32:21.000000000 +0200
3
@@ -21,6 +21,7 @@
4
 #include <qregexp.h>
5
 #include <qsocket.h>
6
 #include <qstatusbar.h>
7
+#include <qurl.h>
8
 #include "freedbconfig.h"
9
 #include "freedbclient.h"
10
 
11
@@ -34,7 +35,8 @@
12
  *
13
  * @param sb status bar to display progress information.
14
  */
15
-FreedbClient::FreedbClient(QStatusBar *sb) : statusBar(sb)
16
+FreedbClient::FreedbClient(QStatusBar *sb) :
17
+ statusBar(sb), m_requestType(RT_None)
18
 {
19
 	sock = new QSocket();
20
 	connect(sock, SIGNAL(hostFound()),
21
@@ -158,7 +160,39 @@
22
 	}
23
 #endif
24
 	sock->connectToHost(dest, destPort);
25
-	isAlbumRequest = false;
26
+	m_requestType = RT_FindFreedbSearch;
27
+
28
+	statusBar->message(i18n("Connecting..."));
29
+}
30
+
31
+/**
32
+ * Find keyword in freedb with "cddb album" command of freedb2.org.
33
+ *
34
+ * @param cfg  freedb configuration
35
+ * @param what string with words to search
36
+ */
37
+void FreedbClient::findCddbAlbum(const FreedbConfig *cfg, QString what)
38
+{
39
+	QString destNamePort(getProxyOrDest(cfg, cfg->server));
40
+	QString dest;
41
+	int destPort;
42
+	splitNamePort(destNamePort, dest, destPort);
43
+	what.replace(QRegExp(" +"), " "); // collapse spaces
44
+	QUrl::encode(what);
45
+	what.replace("%20", "+"); // replace spaces by '+'
46
+	request = "GET http://" + cfg->server + cfg->cgiPath +
47
+		"?cmd=cddb+album+" + what + "&hello=noname+localhost+" +
48
+		"Kid3+" VERSION "&proto=1 HTTP/1.1\r\nHost: " + cfg->server +
49
+		"\r\nConnection: close\r\n\r\n";
50
+#if defined WIN32 && QT_VERSION < 300
51
+	int err = hostnameToAddress(dest);
52
+	if (err) {
53
+		statusBar->message(QString("WinSock error %1").arg(err));
54
+		return;
55
+	}
56
+#endif
57
+	sock->connectToHost(dest, destPort);
58
+	m_requestType = RT_FindCddbAlbum;
59
 
60
 	statusBar->message(i18n("Connecting..."));
61
 }
62
@@ -186,14 +220,23 @@
63
  */
64
 void FreedbClient::slotConnectionClosed()
65
 {
66
-	rcvStr = "";
67
-	while (sock->canReadLine()) {
68
-		rcvStr += sock->readLine();
69
-	}
70
-	if (isAlbumRequest) {
71
-		emit albumFinished(rcvStr);
72
-	} else {
73
-		emit findFinished(rcvStr);
74
+	Q_ULONG len = sock->bytesAvailable();
75
+	QCString s;
76
+	s.resize(len + 1);
77
+	sock->readBlock(s.data(), len);
78
+	rcvStr = QString::fromUtf8(s.data());
79
+	switch (m_requestType) {
80
+		case RT_Album:
81
+			emit albumFinished(rcvStr);
82
+			break;
83
+		case RT_FindFreedbSearch:
84
+			emit findFinished(rcvStr);
85
+			break;
86
+		case RT_FindCddbAlbum:
87
+			emit findCddbAlbumFinished(rcvStr);
88
+			break;
89
+		default:
90
+			qWarning("Unknown freedb request type");
91
 	}
92
 	sock->close();
93
 	statusBar->message(i18n("Ready."));
94
@@ -256,6 +299,6 @@
95
 	}
96
 #endif
97
 	sock->connectToHost(dest, destPort);
98
-	isAlbumRequest = true;
99
+	m_requestType = RT_Album;
100
 	statusBar->message(i18n("Connecting..."));
101
 }
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_freedbclient.h (+44 lines)
Line 0 Link Here
1
+++ ./kid3/freedbclient.h	2006-01-05 19:15:21.000000000 +0100
2
+++ ./kid3/freedbclient.h	2006-10-07 16:06:53.000000000 +0200
3
@@ -44,6 +44,13 @@
4
 	 */
5
 	void find(const FreedbConfig *cfg, QString what);
6
 	/**
7
+	 * Find keyword in freedb with "cddb album" command of freedb2.org.
8
+	 *
9
+	 * @param cfg  freedb configuration
10
+	 * @param what string with words to search
11
+	 */
12
+	void findCddbAlbum(const FreedbConfig *cfg, QString what);
13
+	/**
14
 	 * Request track list from freedb server.
15
 	 *
16
 	 * @param cfg freedb configuration
17
@@ -92,6 +99,11 @@
18
 	 */
19
 	void findFinished(QString);
20
 	/**
21
+	 * Emitted when findCddbAlbum request finished.
22
+	 * Parameter: text containing result of findCddbAlbum request
23
+	 */
24
+	void findCddbAlbumFinished(QString);
25
+	/**
26
 	 * Emitted when album track data request finished.
27
 	 * Parameter: text containing result of album request
28
 	 */
29
@@ -105,8 +117,13 @@
30
 	QString request;
31
 	/** buffer for received data */
32
 	QString rcvStr;
33
-	/** true if last request was album track data request */
34
-	bool isAlbumRequest;
35
+	/** type of current request */
36
+	enum RequestType {
37
+		RT_None,
38
+		RT_FindFreedbSearch,
39
+		RT_FindCddbAlbum,
40
+		RT_Album
41
+	} m_requestType;
42
 };
43
 
44
 #endif
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_freedbdialog.cpp (+96 lines)
Line 0 Link Here
1
+++ ./kid3/freedbdialog.cpp	2006-02-23 22:48:14.000000000 +0100
2
+++ ./kid3/freedbdialog.cpp	2006-10-07 21:31:43.000000000 +0200
3
@@ -24,6 +24,7 @@
4
 #include <qlistbox.h>
5
 #include <qlabel.h>
6
 #include <qstatusbar.h>
7
+#include <qregexp.h>
8
 #include "freedbconfig.h"
9
 #include "freedbclient.h"
10
 #include "freedbdialog.h"
11
@@ -109,6 +110,7 @@
12
 	if (serverLayout && serverLabel && serverComboBox &&
13
 		cgiLabel && cgiLineEdit) {
14
 		static const char *serverList[] = {
15
+			"freedb2.org:80",
16
 			"freedb.freedb.org:80",
17
 			"at.freedb.org:80",
18
 			"au.freedb.org:80",
19
@@ -155,6 +157,8 @@
20
 		client = new FreedbClient(statusBar);
21
 		connect(client, SIGNAL(findFinished(QString)),
22
 				this, SLOT(slotFindFinished(QString)));
23
+		connect(client, SIGNAL(findCddbAlbumFinished(QString)),
24
+				this, SLOT(slotFindCddbAlbumFinished(QString)));
25
 		connect(client, SIGNAL(albumFinished(QString)),
26
 				this, SLOT(slotAlbumFinished(QString)));
27
 	}
28
@@ -315,7 +319,8 @@
29
 {
30
 	FreedbConfig cfg;
31
 	getFreedbConfig(&cfg);
32
-	client->find(&cfg, findLineEdit->currentText());
33
+//	client->find(&cfg, findLineEdit->currentText());
34
+	client->findCddbAlbum(&cfg, findLineEdit->currentText());
35
 }
36
 
37
 /**
38
@@ -364,6 +369,58 @@
39
 }
40
 
41
 /**
42
+ * Process finished findCddbAlbum request.
43
+ *
44
+ * @param searchStr search data received
45
+ */
46
+void FreedbDialog::slotFindCddbAlbumFinished(QString searchStr)
47
+{
48
+/*
49
+210 exact matches found
50
+categ discid dtitle
51
+(more matches...)
52
+.
53
+or
54
+211 close matches found
55
+rock 920b810c Catharsis / Imago
56
+.
57
+theoretically, but never seen
58
+200	categ discid dtitle
59
+*/
60
+	QRegExp catIdTitleRe("([a-z]+)\\s+([0-9a-f]+)\\s+([^/]+ / .+)");
61
+	QStringList lines = QStringList::split(QRegExp("[\\r\\n]+"), searchStr);
62
+	bool inEntries = false;
63
+	albumListBox->clear();
64
+	for (QStringList::const_iterator it = lines.begin(); it != lines.end(); ++it) {
65
+		if (*it == ".") {
66
+			break;
67
+		}
68
+		if (inEntries) {
69
+			if (catIdTitleRe.exactMatch(*it)) {
70
+				new AlbumListItem(
71
+					albumListBox,
72
+					catIdTitleRe.cap(3),
73
+					catIdTitleRe.cap(1),
74
+					catIdTitleRe.cap(2));
75
+			}
76
+		} else {
77
+			if ((*it).startsWith("21") && (*it).find(" match") != -1) {
78
+				inEntries = true;
79
+			} else if ((*it).startsWith("200 ")) {
80
+				if (catIdTitleRe.exactMatch((*it).mid(4))) {
81
+					new AlbumListItem(
82
+						albumListBox,
83
+						catIdTitleRe.cap(3),
84
+						catIdTitleRe.cap(1),
85
+						catIdTitleRe.cap(2));
86
+				}
87
+			}
88
+		}
89
+	}
90
+	albumListBox->setFocus();
91
+}
92
+
93
+/**
94
  * Process finished album data.
95
  *
96
  * @param albumStr album track data received
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_freedbdialog.h (+15 lines)
Line 0 Link Here
1
+++ ./kid3/freedbdialog.h	2006-02-23 22:39:28.000000000 +0100
2
+++ ./kid3/freedbdialog.h	2006-10-07 17:19:08.000000000 +0200
3
@@ -117,6 +117,12 @@
4
 	 */
5
 	void slotFindFinished(QString searchStr);
6
 	/**
7
+	 * Process finished findCddbAlbum request.
8
+	 *
9
+	 * @param searchStr search data received
10
+	 */
11
+	void slotFindCddbAlbumFinished(QString searchStr);
12
+	/**
13
 	 * Process finished album data.
14
 	 *
15
 	 * @param albumStr album track data received
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_genres.cpp (+12 lines)
Line 0 Link Here
1
diff -ru kid3/genres.cpp kid3/genres.cpp
2
--- kid3/genres.cpp	Thu May 25 19:58:19 2006
3
+++ kid3/genres.cpp	Sun Nov 12 00:13:00 2006
4
@@ -385,7 +385,7 @@
5
  * @return genre number, 255 for unknown index.
6
  */
7
 
8
-int Genres::getNumber(QString &str)
9
+int Genres::getNumber(const QString &str)
10
 {
11
 	for (int i = 0; i < Genres::count + 1; i++) {
12
 		if (QString(genre[i]) == str) {
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_genres.h (+12 lines)
Line 0 Link Here
1
diff -ru kid3/genres.h kid3/genres.h
2
--- kid3/genres.h	Thu Jan  5 21:15:20 2006
3
+++ kid3/genres.h	Sun Nov 12 00:13:00 2006
4
@@ -46,7 +46,7 @@
5
 	 *
6
 	 * @return genre number, 255 for unknown index.
7
 	 */
8
-	static int getNumber(QString &str);
9
+	static int getNumber(const QString &str);
10
 	/** Number of genres */
11
 #if defined _WIN32 || defined WIN32
12
 	enum { count = 148 };
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_id3form.cpp (+12 lines)
Line 0 Link Here
1
diff -ru kid3/id3form.cpp kid3/id3form.cpp
2
--- kid3/id3form.cpp	Sat Jun 17 14:46:00 2006
3
+++ kid3/id3form.cpp	Sun Nov 12 00:13:00 2006
4
@@ -588,7 +588,7 @@
5
 	st->track   = trackV2CheckBox->isChecked()   ? trackV2SpinBox->value()
6
 		: -1;
7
 	st->genre   = genreV2CheckBox->isChecked()   ?
8
-		Genres::getNumber(genreV2ComboBox->currentItem()) : -1;
9
+		Genres::getNumber(genreV2ComboBox->currentText()) : -1;
10
 	st->genreStr = st->genre == 0xff ? genreV2ComboBox->currentText()
11
 		: QString::null;
12
 }
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_mp3file.cpp (+15 lines)
Line 0 Link Here
1
diff -ru kid3/mp3file.cpp kid3/mp3file.cpp
2
--- kid3/mp3file.cpp	Thu Jan  5 21:15:21 2006
3
+++ kid3/mp3file.cpp	Sun Nov 12 00:13:00 2006
4
@@ -365,6 +365,11 @@
5
 		if (!ok || n > 0xff) {
6
 			n = 0xff;
7
 		}
8
+	} else {
9
+		// ID3v2 genres can be stored as "(9)", "(9)Metal" or "Metal".
10
+		// If the string does not start with '(', try to get the genre number
11
+		// from a string containing a genre text.
12
+		n = Genres::getNumber(str);
13
 	}
14
 	return n;
15
 }
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_musicbrainzclient.cpp (+357 lines)
Line 0 Link Here
1
diff -ru kid3/musicbrainzclient.cpp kid3/musicbrainzclient.cpp
2
--- kid3/musicbrainzclient.cpp	Tue Jun  6 00:18:36 2006
3
+++ kid3/musicbrainzclient.cpp	Sun Nov 12 00:18:44 2006
4
@@ -17,10 +17,161 @@
5
 #define I18N_NOOP(s) QT_TR_NOOP(s)
6
 #endif
7
 #include <qfile.h>
8
+#if HAVE_TUNEPIMP >= 5
9
+#include <qsocket.h>
10
+#include <qdom.h>
11
+#endif
12
 #include "musicbrainzconfig.h"
13
 #include "freedbclient.h"
14
 #include "importtrackdata.h"
15
 
16
+#if HAVE_TUNEPIMP >= 5
17
+/**
18
+ * Constructor.
19
+ *
20
+ * @param numFiles   number of files to be queried
21
+ * @param serverName server name
22
+ * @param serverPort server port
23
+ * @param proxyName  proxy name, empty if no proxy
24
+ * @param proxyPort  proxy port
25
+ */
26
+LookupQuery::LookupQuery(int numFiles,
27
+												 const QString& serverName, Q_UINT16 serverPort,
28
+												 const QString& proxyName, Q_UINT16 proxyPort) :
29
+	m_numFiles(numFiles), m_serverName(serverName), m_serverPort(serverPort),
30
+	m_proxyName(proxyName), m_proxyPort(proxyPort),
31
+	m_currentFile(-1), m_fileQueries(new FileQuery[numFiles]),
32
+	m_sock(new QSocket)
33
+{
34
+	for (int i = 0; i < m_numFiles; ++i) {
35
+		m_fileQueries[i].requested = false;
36
+		m_fileQueries[i].puid = "";
37
+	}
38
+	connect(m_sock, SIGNAL(connected()),
39
+			this, SLOT(socketConnected()));
40
+	connect(m_sock, SIGNAL(error(int)),
41
+			this, SLOT(socketError()));
42
+	connect(m_sock, SIGNAL(connectionClosed()),
43
+			this, SLOT(socketConnectionClosed()));
44
+}
45
+
46
+/**
47
+ * Destructor.
48
+ */
49
+LookupQuery::~LookupQuery()
50
+{
51
+	m_sock->close();
52
+	m_sock->disconnect();
53
+	delete m_sock;
54
+	delete [] m_fileQueries;
55
+}
56
+
57
+/**
58
+ * Connect to server to query information about the current file.
59
+ */
60
+void LookupQuery::socketQuery()
61
+{
62
+	if (m_currentFile >= 0 && m_currentFile < m_numFiles) {
63
+		QString  destName = m_proxyName.isEmpty() ? m_serverName : m_proxyName;
64
+		Q_UINT16 destPort = m_proxyName.isEmpty() ? m_serverPort : m_proxyPort;
65
+		m_request = "GET http://";
66
+		m_request += m_serverName;
67
+		if (m_serverPort != 80) {
68
+			m_request += ':';
69
+			m_request += QString::number(m_serverPort);
70
+		}
71
+		m_request += "/ws/1/track/?type=xml&puid=";
72
+		m_request += m_fileQueries[m_currentFile].puid;
73
+		m_request += " HTTP/1.0\r\nHost: ";
74
+		m_request += m_serverName;
75
+		m_request += "\r\nUser-agent: Kid3/" VERSION "\r\n\r\n";
76
+		m_sock->connectToHost(destName, destPort);
77
+		m_fileQueries[m_currentFile].requested = true;
78
+	}
79
+}
80
+
81
+/**
82
+ * Query the next file.
83
+ */
84
+void LookupQuery::queryNext()
85
+{
86
+	// handle the first pending query
87
+	for (int i = 0; i < m_numFiles; ++i) {
88
+		if (!m_fileQueries[i].requested &&
89
+				!m_fileQueries[i].puid.isEmpty()) {
90
+			m_currentFile = i;
91
+			socketQuery();
92
+			return;
93
+		}
94
+	}
95
+	// no pending query => socketQuery() will be done in next query()
96
+	m_currentFile = -1;
97
+}
98
+
99
+/**
100
+ * Query a PUID from the server.
101
+ *
102
+ * @param puid  PUID
103
+ * @param index index of file
104
+ */
105
+void LookupQuery::query(const char* puid, int index)
106
+{
107
+	m_fileQueries[index].puid = QString(puid);
108
+	// if no request is being executed, start the current request
109
+	if (m_currentFile < 0 || m_currentFile >= m_numFiles ||
110
+			!m_fileQueries[m_currentFile].requested) {
111
+		m_currentFile = index;
112
+		socketQuery();
113
+	}
114
+}
115
+
116
+/**
117
+ * Send query when the socket is connected.
118
+ */
119
+void LookupQuery::socketConnected()
120
+{
121
+	m_sock->writeBlock(m_request.latin1(), m_request.length());
122
+}
123
+
124
+/**
125
+ * Error on socket connection.
126
+ */
127
+void LookupQuery::socketError()
128
+{
129
+	queryNext();
130
+}
131
+
132
+/**
133
+ * Read received data when the server has closed the connection.
134
+ */
135
+void LookupQuery::socketConnectionClosed()
136
+{
137
+	Q_ULONG len = m_sock->bytesAvailable();
138
+	QCString buf;
139
+	buf.resize(len + 1 );
140
+	m_sock->readBlock(buf.data(), len);
141
+	m_sock->close();
142
+
143
+	int xmlStart = buf.find("<?xml");
144
+	if (xmlStart >= 0 &&
145
+			m_currentFile >= 0 && m_currentFile < m_numFiles &&
146
+			m_fileQueries[m_currentFile].requested) {
147
+		emit queryResponseReceived(m_currentFile, buf.mid(xmlStart, len - xmlStart));
148
+	}
149
+	queryNext();
150
+}
151
+
152
+#else
153
+
154
+LookupQuery::LookupQuery(int, const QString&, Q_UINT16, const QString&, Q_UINT16) {}
155
+LookupQuery::~LookupQuery() {}
156
+void LookupQuery::socketConnected() {}
157
+void LookupQuery::socketError() {}
158
+void LookupQuery::socketConnectionClosed() {}
159
+
160
+#endif
161
+
162
+
163
 /**
164
  * Constructor.
165
  *
166
@@ -29,6 +180,9 @@
167
  */
168
 MusicBrainzClient::MusicBrainzClient(ImportTrackDataVector& trackDataList) :
169
 	m_trackDataVector(trackDataList), m_tp(0), m_ids(0), m_numFiles(0)
170
+#if HAVE_TUNEPIMP >= 5
171
+	, m_lookupQuery(0)
172
+#endif
173
 {
174
 	m_tp = tp_New("kid3", VERSION);
175
 #ifdef WIN32
176
@@ -39,7 +193,11 @@
177
 #else
178
 	tp_SetUseUTF8(m_tp, 1);
179
 #endif
180
+#if HAVE_TUNEPIMP >= 5
181
+	tp_SetMusicDNSClientId(m_tp, "a95f5c7cd37fd4bce12dc86d196fb4fe");
182
+#else
183
 	tp_SetAutoFileLookup(m_tp, 1);
184
+#endif
185
 	tp_SetRenameFiles(m_tp, 0);
186
 	tp_SetMoveFiles(m_tp, 0);
187
 	tp_SetWriteID3v1(m_tp, 0);
188
@@ -110,8 +268,13 @@
189
     { eUnrecognized,  I18N_NOOP("Unrecognized") },
190
     { eRecognized,    I18N_NOOP("Recognized") },
191
     { ePending,       I18N_NOOP("Pending") },
192
+#if HAVE_TUNEPIMP >= 5
193
+    { ePUIDLookup,     I18N_NOOP("PUID Lookup") },
194
+    { ePUIDCollision,  I18N_NOOP("PUID Collision") },
195
+#else
196
     { eTRMLookup,     I18N_NOOP("TRM Lookup") },
197
     { eTRMCollision,  I18N_NOOP("TRM Collision") },
198
+#endif
199
     { eFileLookup,    I18N_NOOP("File Lookup") },
200
     { eUserSelection, I18N_NOOP("User Selection") },
201
     { eVerified,      I18N_NOOP("Verified") },
202
@@ -163,7 +326,11 @@
203
 					track_t track = tp_GetTrack(m_tp, id);
204
 					if (track) {
205
 						tr_Lock(track);
206
+#if HAVE_TUNEPIMP >= 5
207
+						tr_GetPUID(track, trm, sizeof(trm));
208
+#else
209
 						tr_GetTRM(track, trm, sizeof(trm));
210
+#endif
211
 						if (trm[0] == '\0') {
212
 							tr_SetStatus(track, ePending);
213
 							tp_Wake(m_tp, track);
214
@@ -189,13 +356,33 @@
215
 						ImportTrackData trackData;
216
 						getMetaData(id, trackData);
217
 						emit metaDataReceived(index, trackData);
218
-					} else if (statusCode == eTRMCollision ||
219
-										 statusCode == eUserSelection) {
220
+					}
221
+#if HAVE_TUNEPIMP >= 5
222
+					else if (statusCode == ePUIDLookup ||
223
+									 statusCode == ePUIDCollision ||
224
+									 statusCode == eFileLookup) {
225
+						char puid[255];
226
+						puid[0] = '\0';
227
+						track_t track = tp_GetTrack(m_tp, id);
228
+						if (track) {
229
+							tr_Lock(track);
230
+							tr_GetPUID(track, puid, sizeof(puid));
231
+							tr_Unlock(track);
232
+							tp_ReleaseTrack(m_tp, track);
233
+						}
234
+						if (m_lookupQuery) {
235
+							m_lookupQuery->query(puid, index);
236
+						}
237
+					}
238
+#else
239
+					else if (statusCode == eTRMCollision ||
240
+									 statusCode == eUserSelection) {
241
 						ImportTrackDataVector trackDataList;
242
 						if (getResults(id, trackDataList)) {
243
 							emit resultsReceived(index, trackDataList);
244
 						}
245
 					}
246
+#endif
247
 				}
248
 				break;
249
 			}
250
@@ -242,6 +429,16 @@
251
 	m_numFiles = m_trackDataVector.count();
252
 #endif
253
 	m_ids = new int[m_numFiles];
254
+#if HAVE_TUNEPIMP >= 5
255
+	char serverName[80], proxyName[80];
256
+	short serverPort, proxyPort;
257
+	tp_GetServer(m_tp, serverName, sizeof(serverName) - 1, &serverPort);
258
+	tp_GetProxy(m_tp, proxyName, sizeof(proxyName) - 1, &proxyPort);
259
+	m_lookupQuery = new LookupQuery(m_numFiles, serverName, serverPort,
260
+																	proxyName, proxyPort);
261
+	connect(m_lookupQuery, SIGNAL(queryResponseReceived(int, const QCString&)),
262
+					this, SLOT(parseLookupResponse(int, const QCString&)));
263
+#endif
264
 	int i = 0;
265
 	for (
266
 #if QT_VERSION >= 300
267
@@ -271,6 +468,10 @@
268
 		}
269
 		delete [] m_ids;
270
 		m_ids = 0;
271
+#if HAVE_TUNEPIMP >= 5
272
+		delete m_lookupQuery;
273
+		m_lookupQuery = 0;
274
+#endif
275
 		m_numFiles = 0;
276
 	}
277
 }
278
@@ -308,6 +509,68 @@
279
 	}
280
 }
281
 
282
+#if HAVE_TUNEPIMP >= 5
283
+
284
+bool MusicBrainzClient::getResults(int, ImportTrackDataVector&) {
285
+	return false;
286
+}
287
+
288
+/**
289
+ * Process server response with lookup data.
290
+ *
291
+ * @param index    index of file
292
+ * @param response response from server
293
+ */
294
+void MusicBrainzClient::parseLookupResponse(int index, const QCString& response)
295
+{
296
+	ImportTrackDataVector trackDataList;
297
+	QDomDocument doc;
298
+	if (doc.setContent(response)) {
299
+		QDomElement trackList =
300
+			doc.namedItem("metadata").toElement().namedItem("track-list").toElement();
301
+
302
+		for (QDomNode trackNode = trackList.namedItem("track");
303
+				 !trackNode.isNull();
304
+				 trackNode = trackNode.nextSibling()) {
305
+			QDomElement track = trackNode.toElement();
306
+
307
+			ImportTrackData trackData;
308
+			trackData.artist =
309
+				track.namedItem("artist").toElement().namedItem("name").toElement().text();
310
+			trackData.title = track.namedItem("title").toElement().text();
311
+
312
+			for (QDomNode releaseNode =
313
+						 track.namedItem("release-list").toElement().namedItem("release");
314
+					 !releaseNode.isNull();
315
+					 releaseNode = releaseNode.nextSibling() ) {
316
+				QDomElement release = releaseNode.toElement();
317
+
318
+				trackData.album = release.namedItem("title").toElement().text();
319
+				trackData.track = -1;
320
+				QDomNode releaseTrackNode = release.namedItem("track-list");
321
+				if (!releaseTrackNode.isNull()) {
322
+					QDomElement releaseTrack = releaseTrackNode.toElement();
323
+					if (!releaseTrack.attribute("offset").isEmpty())
324
+						trackData.track = releaseTrack.attribute("offset").toInt() + 1;
325
+				}
326
+			}
327
+			trackDataList.append(trackData);
328
+		}
329
+	}
330
+
331
+	if (trackDataList.size() > 1) {
332
+		emit resultsReceived(index, trackDataList);
333
+		emit statusChanged(index, i18n("User Selection"));
334
+	} else if (trackDataList.size() == 1) {
335
+		emit metaDataReceived(index, *trackDataList.begin());
336
+		emit statusChanged(index, i18n("Recognized"));
337
+	} else {
338
+		emit statusChanged(index, i18n("Unrecognized"));
339
+	}
340
+}
341
+
342
+#else
343
+
344
 /**
345
  * Get results for an ambiguous file.
346
  *
347
@@ -387,6 +650,10 @@
348
 	}
349
 	return resultsAvailable;
350
 }
351
+
352
+void MusicBrainzClient::parseLookupResponse(int, const QCString&) {}
353
+
354
+#endif
355
 
356
 #else // HAVE_TUNEPIMP
357
 
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_musicbrainzclient.h (+147 lines)
Line 0 Link Here
1
diff -ru kid3/musicbrainzclient.h kid3/musicbrainzclient.h
2
--- kid3/musicbrainzclient.h	Thu Feb 23 22:48:34 2006
3
+++ kid3/musicbrainzclient.h	Sun Nov 12 00:18:44 2006
4
@@ -15,7 +15,13 @@
5
 #include <qobject.h>
6
 
7
 #ifdef HAVE_TUNEPIMP
8
+#if HAVE_TUNEPIMP >= 5
9
+#include <qbuffer.h>
10
+#include <tunepimp-0.5/tp_c.h>
11
+class QSocket;
12
+#else
13
 #include <tunepimp/tp_c.h>
14
+#endif
15
 #endif // HAVE_TUNEPIMP
16
 
17
 class MusicBrainzConfig;
18
@@ -23,6 +29,103 @@
19
 class ImportTrackDataVector;
20
 
21
 /**
22
+ * A HTTP query to a musicbrainz server for HAVE_TUNEPIMP >= 5.
23
+ */
24
+class LookupQuery : public QObject {
25
+Q_OBJECT
26
+
27
+public:
28
+	/**
29
+	 * Constructor.
30
+	 *
31
+	 * @param numFiles   number of files to be queried
32
+	 * @param serverName server name
33
+	 * @param serverPort server port
34
+	 * @param proxyName  proxy name, empty if no proxy
35
+	 * @param proxyPort  proxy port
36
+	 */
37
+	LookupQuery(int numFiles,
38
+							const QString& serverName, Q_UINT16 serverPort = 80,
39
+							const QString& proxyName = "", Q_UINT16 proxyPort = 80);
40
+
41
+	/**
42
+	 * Destructor.
43
+	 */
44
+	virtual ~LookupQuery();
45
+
46
+#if HAVE_TUNEPIMP >= 5
47
+	/**
48
+	 * Query a PUID from the server.
49
+	 *
50
+	 * @param puid     PUID
51
+	 * @param index    index of file
52
+	 */
53
+	void query(const char* puid, int index);
54
+#endif
55
+
56
+signals:
57
+	/**
58
+	 * Emitted when the query response is received
59
+	 */
60
+	void queryResponseReceived(int, const QCString&);
61
+
62
+private slots:
63
+	/**
64
+	 * Send query when the socket is connected.
65
+	 */
66
+	void socketConnected();
67
+
68
+	/**
69
+	 * Error on socket connection.
70
+	 */
71
+	void socketError();
72
+
73
+	/**
74
+	 * Read received data when the server has closed the connection.
75
+	 */
76
+	void socketConnectionClosed();
77
+
78
+#if HAVE_TUNEPIMP >= 5
79
+private:
80
+	/**
81
+	 * Connect to server to query information about the current file.
82
+	 */
83
+	void socketQuery();
84
+
85
+	/**
86
+	 * Query the next file.
87
+	 */
88
+	void queryNext();
89
+
90
+	struct FileQuery {
91
+		bool requested;
92
+		QString puid;
93
+	};
94
+
95
+	/** Number of files to be queried. */
96
+	int m_numFiles;
97
+	/** MusicBrainz server */
98
+	QString m_serverName;
99
+	/** Port of MusicBrainz server */
100
+	Q_UINT16 m_serverPort;
101
+	/** Proxy */
102
+	QString m_proxyName;
103
+	/** Port of proxy */
104
+	Q_UINT16 m_proxyPort;
105
+	/**
106
+	 * -1 if not yet started,
107
+	 * 0..m_numFiles-1 if a file is currently processed,
108
+	 * >=m_numFiles if all files processed.
109
+	 */ 
110
+	int m_currentFile;
111
+	FileQuery* m_fileQueries;
112
+	QSocket* m_sock;
113
+	QString m_request;
114
+#endif
115
+};
116
+
117
+
118
+/**
119
  * MusicBrainz client.
120
  */
121
 class MusicBrainzClient : public QObject
122
@@ -85,6 +188,15 @@
123
 	 */
124
 	void resultsReceived(int, ImportTrackDataVector&);
125
 
126
+private slots:
127
+	/**
128
+	 * Process server response with lookup data.
129
+	 *
130
+	 * @param index    index of file
131
+	 * @param response response from server
132
+	 */
133
+	void parseLookupResponse(int index, const QCString& response);
134
+
135
 #ifdef HAVE_TUNEPIMP
136
 private:
137
 	/**
138
@@ -126,6 +238,9 @@
139
 	tunepimp_t m_tp;
140
 	int* m_ids;
141
 	int m_numFiles;
142
+#if HAVE_TUNEPIMP >= 5
143
+	LookupQuery* m_lookupQuery;
144
+#endif
145
 #endif // HAVE_TUNEPIMP
146
 };
147
 
(-)/home/makc/porting/ports/audio/kid3/files/patch-kid3_oggfile.cpp (+12 lines)
Line 0 Link Here
1
diff -ru kid3/oggfile.cpp kid3/oggfile.cpp
2
--- kid3/oggfile.cpp	Fri Jan 27 21:15:27 2006
3
+++ kid3/oggfile.cpp	Sun Nov 12 00:12:20 2006
4
@@ -143,7 +143,7 @@
5
 			bool setUtime = false;
6
 			struct utimbuf times;
7
 			if (preserve) {
8
-				int fd = ::fileno(fpIn);
9
+				int fd = fileno(fpIn);
10
 				if (fd >= 0) {
11
 					struct stat fileStat;
12
 					if (::fstat(fd, &fileStat) == 0) {
(-)/home/makc/porting/ports/audio/kid3/pkg-plist (-1 / +2 lines)
Lines 1-5 Link Here
1
bin/kid3
1
bin/kid3
2
share/applnk/Multimedia/kid3.desktop
2
share/applications/kde/kid3.desktop
3
share/apps/kid3/kid3ui.rc
3
share/apps/kid3/kid3ui.rc
4
share/doc/HTML/de/kid3/common
4
share/doc/HTML/de/kid3/common
5
share/doc/HTML/de/kid3/index.cache.bz2
5
share/doc/HTML/de/kid3/index.cache.bz2
Lines 16-18 Link Here
16
@dirrm share/doc/HTML/en/kid3
16
@dirrm share/doc/HTML/en/kid3
17
@dirrm share/doc/HTML/de/kid3
17
@dirrm share/doc/HTML/de/kid3
18
@dirrm share/apps/kid3
18
@dirrm share/apps/kid3
19
@dirrmtry share/applications/kde

Return to bug 105220