/thirdparty/liblastfm2/src/ws/NetworkAccessManager.h

http://github.com/tomahawk-player/tomahawk · C Header · 66 lines · 27 code · 12 blank · 27 comment · 0 complexity · d0b721e95d26146272bca5400894bf6f MD5 · raw file

  1. /*
  2. Copyright 2009 Last.fm Ltd.
  3. - Primarily authored by Max Howell, Jono Cole and Doug Mansell
  4. This file is part of liblastfm.
  5. liblastfm is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 3 of the License, or
  8. (at your option) any later version.
  9. liblastfm is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with liblastfm. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #ifndef LASTFM_WS_ACCESS_MANAGER_H
  17. #define LASTFM_WS_ACCESS_MANAGER_H
  18. #include <lastfm/global.h>
  19. #include <QtNetwork/QNetworkAccessManager>
  20. #include <QNetworkRequest>
  21. #include <QNetworkProxy>
  22. namespace lastfm {
  23. /** Sets useragent and proxy. Auto detecting the proxy where possible. */
  24. class LASTFM_DLLEXPORT NetworkAccessManager : public QNetworkAccessManager
  25. {
  26. Q_OBJECT
  27. #ifdef Q_WS_WIN
  28. class Pac *m_pac;
  29. class InternetConnectionMonitor* m_monitor;
  30. #endif
  31. public:
  32. NetworkAccessManager( QObject *parent = 0 );
  33. ~NetworkAccessManager();
  34. /** PAC allows different proxy configurations depending on the request
  35. * URL and even UserAgent! Thus we allow you to pass that in, we
  36. * automatically configure the proxy for every request through
  37. * WsAccessManager */
  38. QNetworkProxy proxy( const QNetworkRequest& = QNetworkRequest() );
  39. protected:
  40. virtual QNetworkReply* createRequest( Operation, const QNetworkRequest&, QIODevice* outgoingdata = 0 );
  41. private slots:
  42. void onConnectivityChanged( bool );
  43. private:
  44. /** this function calls QNetworkAccessManager::setProxy, and thus
  45. * configures the proxy correctly for the next request created by
  46. * createRequest. This is necessary due */
  47. void applyProxy( const QNetworkRequest& );
  48. };
  49. } //namespace lastfm
  50. #endif