- Clean up server output. Added more relevant information.
- Added the server to Bootscript. This closes ticket #3446. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30781 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -147,6 +147,11 @@ if [ "$SAFEMODE" != "yes" ]; then
|
|||||||
launch $SERVERS/mail_daemon "" -E
|
launch $SERVERS/mail_daemon "" -E
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Launch CDDB Daemon
|
||||||
|
if [ "$SAFEMODE" != "yes" ]; then
|
||||||
|
launch $SERVERS/cddb_daemon ""
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for daily saving time
|
# Check for daily saving time
|
||||||
launch system/bin/dstcheck
|
launch system/bin/dstcheck
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,13 @@ CDDBDaemon::CDDBDaemon()
|
|||||||
fVolumeRoster->StartWatching();
|
fVolumeRoster->StartWatching();
|
||||||
|
|
||||||
BVolume volume;
|
BVolume volume;
|
||||||
|
printf("Checking currently mounted volumes ...\n");
|
||||||
while (fVolumeRoster->GetNextVolume(&volume) == B_OK) {
|
while (fVolumeRoster->GetNextVolume(&volume) == B_OK) {
|
||||||
if (_Lookup(volume.Device()) != B_OK) {
|
if (_Lookup(volume.Device()) != B_OK) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
printf("Checking complete. Listening for device mounts.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -82,10 +84,11 @@ CDDBDaemon::_Lookup(const dev_t device)
|
|||||||
uint32 cddbId;
|
uint32 cddbId;
|
||||||
if (!_CanLookup(device, &cddbId, toc)) {
|
if (!_CanLookup(device, &cddbId, toc)) {
|
||||||
free(toc);
|
free(toc);
|
||||||
|
printf("Skipping device with id %d.\n", device);
|
||||||
return B_BAD_TYPE;
|
return B_BAD_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("CD can be looked up. CDDB id = %08lx.\n", cddbId);
|
printf("Looking up CD with CDDB Id %08lx.\n", cddbId);
|
||||||
|
|
||||||
CDDBServer cddb_server("freedb.freedb.org:80");
|
CDDBServer cddb_server("freedb.freedb.org:80");
|
||||||
|
|
||||||
@@ -93,6 +96,7 @@ CDDBDaemon::_Lookup(const dev_t device)
|
|||||||
|
|
||||||
BList queryResponse;
|
BList queryResponse;
|
||||||
if ((result = cddb_server.Query(cddbId, toc, &queryResponse)) != B_OK) {
|
if ((result = cddb_server.Query(cddbId, toc, &queryResponse)) != B_OK) {
|
||||||
|
printf("Error when querying CD.\n");
|
||||||
free(toc);
|
free(toc);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -101,6 +105,7 @@ CDDBDaemon::_Lookup(const dev_t device)
|
|||||||
|
|
||||||
QueryResponseData* diskData = _SelectResult(&queryResponse);
|
QueryResponseData* diskData = _SelectResult(&queryResponse);
|
||||||
if (diskData == NULL) {
|
if (diskData == NULL) {
|
||||||
|
printf("Could not find any CD entries in query response.\n");
|
||||||
return B_BAD_INDEX;
|
return B_BAD_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +117,7 @@ CDDBDaemon::_Lookup(const dev_t device)
|
|||||||
if (_WriteCDData(device, diskData, &readResponse) == B_OK) {
|
if (_WriteCDData(device, diskData, &readResponse) == B_OK) {
|
||||||
printf("CD data saved.\n");
|
printf("CD data saved.\n");
|
||||||
} else {
|
} else {
|
||||||
printf("CD data not saved.\n" );
|
printf("Error writting CD data.\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete itens in the query response BList;
|
// Delete itens in the query response BList;
|
||||||
@@ -179,8 +184,23 @@ CDDBDaemon::_SelectResult(BList* response) const
|
|||||||
//
|
//
|
||||||
// TODO(bga):Right now it just picks the first entry on the list but
|
// TODO(bga):Right now it just picks the first entry on the list but
|
||||||
// someday we may want to let the user choose one.
|
// someday we may want to let the user choose one.
|
||||||
if (response->CountItems() != 0)
|
int32 numItems = response->CountItems();
|
||||||
|
if (numItems > 0) {
|
||||||
|
if (numItems > 1) {
|
||||||
|
printf("Multiple matches found :\n");
|
||||||
|
};
|
||||||
|
for (int32 i = 0; i < numItems; i++) {
|
||||||
|
QueryResponseData* data = (QueryResponseData*)response->ItemAt(i);
|
||||||
|
printf("* %s : %s - %s (%s)\n", (data->cddbId).String(),
|
||||||
|
(data->artist).String(), (data->title).String(),
|
||||||
|
(data->category).String());
|
||||||
|
}
|
||||||
|
if (numItems > 1) {
|
||||||
|
printf("Returning first entry.\n");
|
||||||
|
}
|
||||||
|
|
||||||
return (QueryResponseData*)response->ItemAt(0L);
|
return (QueryResponseData*)response->ItemAt(0L);
|
||||||
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -246,6 +266,7 @@ CDDBDaemon::_WriteCDData(dev_t device, QueryResponseData* diskData,
|
|||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
|
printf("CDDB Daemon for Haiku v1.0.0 started.\n");
|
||||||
CDDBDaemon* cddbDaemon = new CDDBDaemon();
|
CDDBDaemon* cddbDaemon = new CDDBDaemon();
|
||||||
cddbDaemon->Run();
|
cddbDaemon->Run();
|
||||||
delete cddbDaemon;
|
delete cddbDaemon;
|
||||||
|
|||||||
@@ -252,8 +252,6 @@ CDDBServer::Read(QueryResponseData* diskData, ReadResponseData* readResponse)
|
|||||||
trackData->title = line;
|
trackData->title = line;
|
||||||
|
|
||||||
(readResponse->tracks).AddItem(trackData);
|
(readResponse->tracks).AddItem(trackData);
|
||||||
} else {
|
|
||||||
printf("Unhandled or unknown prefix: %s\n", prefix.String());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (output == "" || output == ".\r\n") {
|
if (output == "" || output == ".\r\n") {
|
||||||
|
|||||||
Reference in New Issue
Block a user