3 * Copyright (C) 2005-2013 Team XBMC
6 * This Program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
11 * This Program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with XBMC; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
22 #include "system.h" // for HAS_DVD_DRIVE
32 #include "storage/cdioSupport.h"
34 #include "utils/AutoPtrHandle.h"
39 //Can be removed if/when removing Xcddb::queryCDinfo(int real_track_count, toc cdtoc[])
40 //#define IN_PROGRESS -1
42 //#define E_INEXACT_MATCH_FOUND 211
43 //#define W_CDDB_already_shook_hands 402
44 //#define E_CDDB_Handshake_not_successful 431
46 #define E_TOC_INCORRECT 2
47 #define E_NETWORK_ERROR_OPEN_SOCKET 3
48 #define E_NETWORK_ERROR_SEND 4
49 #define E_WAIT_FOR_INPUT 5
50 #define E_PARAMETER_WRONG 6
51 #define E_NO_MATCH_FOUND 202
53 #define CDDB_PORT 8880
69 void setCDDBIpAdress(const CStdString& ip_adress);
70 void setCacheDir(const CStdString& pCacheDir );
72 // int queryCDinfo(int real_track_count, toc cdtoc[]);
73 bool queryCDinfo(MEDIA_DETECT::CCdInfo* pInfo, int inexact_list_select);
74 bool queryCDinfo(MEDIA_DETECT::CCdInfo* pInfo);
75 int getLastError() const;
76 const char * getLastErrorText() const;
77 const CStdString& getYear() const;
78 const CStdString& getGenre() const;
79 const CStdString& getTrackArtist(int track) const;
80 const CStdString& getTrackTitle(int track) const;
81 void getDiskArtist(CStdString& strdisk_artist) const;
82 void getDiskTitle(CStdString& strdisk_title) const;
83 const CStdString& getTrackExtended(int track) const;
84 uint32_t calc_disc_id(int nr_of_tracks, toc cdtoc[]);
85 const CStdString& getInexactArtist(int select) const;
86 const CStdString& getInexactTitle(int select) const;
87 bool queryCache( uint32_t discid );
88 bool writeCacheFile( const char* pBuffer, uint32_t discid );
89 bool isCDCached( int nr_of_tracks, toc cdtoc[] );
90 bool isCDCached( MEDIA_DETECT::CCdInfo* pInfo );
94 AUTOPTR::CAutoPtrSocket m_cddb_socket;
95 const static int recv_buffer = 4096;
97 std::map<int, CStdString> m_mapTitles;
98 std::map<int, CStdString> m_mapArtists;
99 std::map<int, CStdString> m_mapExtended_track;
101 std::map<int, CStdString> m_mapInexact_cddb_command_list;
102 std::map<int, CStdString> m_mapInexact_artist_list;
103 std::map<int, CStdString> m_mapInexact_title_list;
106 CStdString m_strDisk_artist;
107 CStdString m_strDisk_title;
108 CStdString m_strYear;
109 CStdString m_strGenre;
111 void addTitle(const char *buffer);
112 void addExtended(const char *buffer);
113 void parseData(const char *buffer);
114 bool Send( const void *buffer, int bytes );
115 bool Send( const char *buffer);
116 std::string Recv(bool wait4point);
119 struct toc cdtoc[100];
121 void addInexactList(const char *list);
122 void addInexactListLine(int line_cnt, const char *line, int len);
123 const CStdString& getInexactCommand(int select) const;
124 CStdString GetCacheFile(uint32_t disc_id) const;
125 /*! \brief Trim and convert some text to UTF8
126 \param untrimmedText original text to trim and convert
127 \return a utf8 version of the trimmed text
129 CStdString TrimToUTF8(const CStdString &untrimmed);
131 CStdString m_cddb_ip_adress;
132 CStdString cCacheDir;