Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MUSICBRAINZ3_WEBSERVICE_H__
00024 #define __MUSICBRAINZ3_WEBSERVICE_H__
00025
00026 #include <string>
00027 #include <musicbrainz3/musicbrainz.h>
00028 #include <musicbrainz3/iwebservice.h>
00029
00030 namespace MusicBrainz
00031 {
00032
00039 class MB_API WebServiceError : public Exception
00040 {
00041 public:
00042 WebServiceError(const std::string &msg = std::string()) : Exception(msg) {}
00043 };
00044
00052 class MB_API ConnectionError : public WebServiceError
00053 {
00054 public:
00055 ConnectionError(const std::string &msg = std::string()) : WebServiceError(msg) {}
00056 };
00057
00062 class MB_API TimeOutError : public WebServiceError
00063 {
00064 public:
00065 TimeOutError(const std::string &msg = std::string()) : WebServiceError(msg) {}
00066 };
00067
00071 class MB_API ResourceNotFoundError : public WebServiceError
00072 {
00073 public:
00074 ResourceNotFoundError(const std::string &msg = std::string()) : WebServiceError(msg) {}
00075 };
00076
00083 class MB_API AuthenticationError : public WebServiceError
00084 {
00085 public:
00086 AuthenticationError(const std::string &msg = std::string()) : WebServiceError(msg) {}
00087 };
00088
00096 class MB_API ResponseError : public WebServiceError
00097 {
00098 public:
00099 ResponseError(const std::string &msg = std::string()) : WebServiceError(msg) {}
00100 };
00101
00109 class MB_API RequestError : public WebServiceError
00110 {
00111 public:
00112 RequestError(const std::string &msg = std::string()) : WebServiceError(msg) {}
00113 };
00114
00124 class MB_API WebService : public IWebService
00125 {
00126 public:
00127
00141 WebService(const std::string &host = "musicbrainz.org",
00142 const int port = 80,
00143 const std::string &pathPrefix = "/ws",
00144 const std::string &username = std::string(),
00145 const std::string &password = std::string(),
00146 const std::string &realm = "musicbrainz.org");
00147
00151 virtual ~WebService();
00152
00158 void setHost(const std::string &host);
00159
00165 std::string getHost() const;
00166
00172 void setPort(const int port);
00173
00179 int getPort() const;
00180
00186 void setPathPrefix(const std::string &pathPrefix);
00187
00193 std::string getPathPrefix() const;
00194
00200 void setUserName(const std::string &username);
00201
00207 std::string getUserName() const;
00208
00214 void setPassword(const std::string &password);
00215
00221 std::string getPassword() const;
00222
00228 void setRealm(const std::string &realm);
00229
00235 std::string getRealm() const;
00236
00242 void setProxyHost(const std::string &host);
00243
00249 std::string getProxyHost() const;
00250
00256 void setProxyPort(const int port);
00257
00263 int getProxyPort() const;
00264
00270 void setProxyUserName(const std::string &username);
00271
00277 std::string getProxyUserName() const;
00278
00284 void setProxyPassword(const std::string &password);
00285
00291 std::string getProxyPassword() const;
00292
00308 std::string get(const std::string &entity,
00309 const std::string &id,
00310 const IIncludes::IncludeList &include,
00311 const IFilter::ParameterList &filter,
00312 const std::string &version = "1");
00313
00328 void post(const std::string &entity,
00329 const std::string &id,
00330 const std::string &data,
00331 const std::string &version = "1");
00332
00333 private:
00334
00335 static int httpAuth(void *userdata, const char *realm, int attempts,
00336 char *username, char *password);
00337 static int proxyAuth(void *userdata, const char *realm, int attempts,
00338 char *username, char *password);
00339 static int httpResponseReader(void *userdata, const char *buf, size_t len);
00340
00341 class WebServicePrivate;
00342 WebServicePrivate *d;
00343 };
00344
00345 }
00346
00347 #endif