1/*
2 * Copyright 2008-2009, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *              Bruno Albuquerque, bga@bug-br.org.br
7 */
8
9#ifndef _CDDB_SERVER_H
10#define _CDDB_SERVER_H
11
12#include <List.h>
13#include <NetAddress.h>
14#include <NetEndpoint.h>
15#include <String.h>
16
17#include <scsi_cmds.h>
18
19
20// CD track specific data.
21struct TrackData {
22	uint32 trackNumber;
23	BString title;
24	BString artist;
25};
26
27
28// Query command response.
29struct QueryResponseData {
30	BString category;
31	BString cddbId;
32	BString artist;
33	BString title;
34};
35
36
37// Read command response.
38struct ReadResponseData {
39	BString title;
40	BString artist;
41	BString genre;
42	uint32 year;
43	BList tracks; // TrackData items.
44};
45
46
47class CDDBServer {
48public:
49				CDDBServer(const BString& cddbServer);
50
51	// CDDB commands interface.
52	status_t	Query(uint32 cddbId, const scsi_toc_toc* toc,
53		BList* queryResponse);
54	status_t	Read(QueryResponseData* diskData,
55		ReadResponseData* readResponse);
56
57private:
58	status_t 		_ParseAddress(const BString& cddbServer);
59
60	status_t		_OpenConnection();
61	void			_CloseConnection();
62
63	status_t		_SendCddbCommand(const BString& command, BString* output);
64
65	BString			fLocalHostName;
66	BString			fLocalUserName;
67	BNetAddress		fCddbServerAddr;
68	BNetEndpoint	fConnection;
69	bool			fInitialized;
70	bool			fConnected;
71};
72
73#endif  // _CDDB_SERVER_H
74