• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

webservice.h

Go to the documentation of this file.
00001 /*
00002  * MusicBrainz -- The Internet music metadatabase
00003  *
00004  * Copyright (C) 2006 Lukas Lalinsky
00005  *  
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  * 
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
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

Generated on Mon Oct 18 2010 for libmusicbrainz3 by  doxygen 1.7.1