From 25a638d41162fb56ce806b64632eb6c1ed196d6b Mon Sep 17 00:00:00 2001 From: "Bruno G. Albuquerque" Date: Sat, 15 Aug 2009 21:04:00 +0000 Subject: [PATCH] - Implemented handling of partial matches. This must be improved eventually as, right now, we just handle it as normal multiple matches. - Improved error reporting for CDDB query commands. This should fix #4103. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32423 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/servers/cddb_daemon/cddb_server.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/servers/cddb_daemon/cddb_server.cpp b/src/servers/cddb_daemon/cddb_server.cpp index dc70f67b93..4b80b6fb35 100644 --- a/src/servers/cddb_daemon/cddb_server.cpp +++ b/src/servers/cddb_daemon/cddb_server.cpp @@ -90,14 +90,28 @@ CDDBServer::Query(uint32 cddbId, const scsi_toc_toc* toc, BList* queryResponse) // Check status code. BString statusCode; output.MoveInto(statusCode, 0, 3); - if (statusCode == "210") { + if (statusCode == "210" || statusCode == "211") { + // TODO(bga): We can get around with returning the first result + // in case of multiple matches, but we most definitely needs a + // better handling of inexact matches. + if (statusCode == "211") + printf("Warning : Inexact match found.\n"); + // Multiple results, remove the first line and parse the others. output.Remove(0, output.FindFirst("\r\n") + 2); } else if (statusCode == "200") { // Remove the first char which is a left over space. output.Remove(0, 1); + } else if (statusCode == "202") { + // No match found. + printf("Error : CDDB entry for id %s not found.", hexCddbId); + + return B_ENTRY_NOT_FOUND; } else { // Something bad happened. + printf("Error : CDDB server status code is %s.", + statusCode.String()); + return B_ERROR; }