libmusicbrainz4
4.0.1
|
00001 /* -------------------------------------------------------------------------- 00002 00003 libmusicbrainz4 - Client library to access MusicBrainz 00004 00005 Copyright (C) 2011 Andrew Hawkins 00006 00007 This file is part of libmusicbrainz4. 00008 00009 This library is free software; you can redistribute it and/or 00010 modify it under the terms of v2 of the GNU Lesser General Public 00011 License as published by the Free Software Foundation. 00012 00013 libmusicbrainz4 is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 Lesser General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this library. If not, see <http://www.gnu.org/licenses/>. 00020 00021 $Id$ 00022 00023 ----------------------------------------------------------------------------*/ 00024 00025 #ifndef _MUSICBRAINZ4_QUERY_H 00026 #define _MUSICBRAINZ4_QUERY_H 00027 00028 #include "Entity.h" 00029 00030 #include "musicbrainz4/ReleaseList.h" 00031 #include "musicbrainz4/Metadata.h" 00032 00033 #include "musicbrainz4/xmlParser.h" 00034 00035 #include <string> 00036 #include <map> 00037 #include <vector> 00038 00138 namespace MusicBrainz4 00139 { 00140 class CQueryPrivate; 00141 00165 class CQuery 00166 { 00167 public: 00168 typedef std::map<std::string,std::string> tParamMap; 00169 00175 enum tQueryResult 00176 { 00177 eQuery_Success=0, 00178 eQuery_ConnectionError, 00179 eQuery_Timeout, 00180 eQuery_AuthenticationError, 00181 eQuery_FetchError, 00182 eQuery_RequestError, 00183 eQuery_ResourceNotFound 00184 }; 00185 00199 CQuery(const std::string& UserAgent, const std::string& Server="musicbrainz.org", int Port=80); 00200 00201 ~CQuery(); 00202 00211 void SetUserName(const std::string& UserName); 00212 00221 void SetPassword(const std::string& Password); 00222 00233 void SetProxyHost(const std::string& ProxyHost); 00234 00245 void SetProxyPort(int ProxyPort); 00246 00257 void SetProxyUserName(const std::string& ProxyUserName); 00258 00269 void SetProxyPassword(const std::string& ProxyPassword); 00270 00281 CReleaseList LookupDiscID(const std::string& DiscID); 00282 00300 CRelease LookupRelease(const std::string& ReleaseID); 00301 00338 CMetadata Query(const std::string& Entity,const std::string& ID="",const std::string& Resource="",const tParamMap& Params=tParamMap()); 00339 00358 bool AddCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries); 00359 00378 bool DeleteCollectionEntries(const std::string& CollectionID, const std::vector<std::string>& Entries); 00379 00388 CQuery::tQueryResult LastResult() const; 00389 00397 int LastHTTPCode() const; 00398 00406 std::string LastErrorMessage() const; 00407 00415 std::string Version() const; 00416 00417 private: 00418 CQueryPrivate * const m_d; 00419 00420 CMetadata PerformQuery(const std::string& Query); 00421 void WaitRequest() const; 00422 std::string UserAgent() const; 00423 bool EditCollection(const std::string& CollectionID, const std::vector<std::string>& Entries, const std::string& Action); 00424 std::string URIEscape(const std::string& URI); 00425 std::string URLEncode(const std::map<std::string,std::string>& Params); 00426 }; 00427 } 00428 00429 #endif