You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.7 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. *
  3. * This file is part of QMapControl,
  4. * an open-source cross-platform map widget
  5. *
  6. * Copyright (C) 2007 - 2008 Kai Winter
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Lesser General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with QMapControl. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. * Contact e-mail: kaiwinter@gmx.de
  22. * Program URL : http://qmapcontrol.sourceforge.net/
  23. *
  24. */
  25. #ifndef MAPNETWORK_H
  26. #define MAPNETWORK_H
  27. #include "qmapcontrol_global.h"
  28. #include <QtCore/QObject>
  29. #include <QtCore/QDebug>
  30. #include <QtNetwork/QNetworkAccessManager>
  31. #include <QtNetwork/QNetworkReply>
  32. #include <QtNetwork/QNetworkProxy>
  33. #include <QtNetwork/QAuthenticator>
  34. #include <QtCore/QVector>
  35. #include <QtGui/QPixmap>
  36. #include <QtCore/QMutex>
  37. #include "imagemanager.h"
  38. #include "../../../data/curl/curlRequestsManager.h"
  39. class MapNetwork {
  40. private:
  41. ImageManager* m_pImageManager;
  42. curlRequestsManager* m_pHttpAccessManager;
  43. QNetworkDiskCache *m_pDiskCache;
  44. //QList<curlRequest*> m_lRequestsList;
  45. QMap<QString, QString> m_mLoadingMap;
  46. qreal loaded;
  47. mutable QMutex vectorMutex;
  48. bool m_bNetworkActive;
  49. bool m_bCacheEnabled;
  50. public:
  51. explicit MapNetwork(ImageManager* parent);
  52. ~MapNetwork();
  53. void loadImage(const QString& host, const QString& url);
  54. /*!
  55. * checks if the given url is already loading
  56. * @param url the url of the image
  57. * @return boolean, if the image is already loading
  58. */
  59. bool imageIsLoading(QString url);
  60. /*!
  61. * Aborts all current loading threads.
  62. * This is useful when changing the zoom-factor, though newly needed images loads faster
  63. */
  64. void abortLoading();
  65. void setProxy(QString host, int port, const QString username = QString(), const QString password = QString());
  66. /*!
  67. *
  68. * @return number of elements in the load queue
  69. */
  70. int loadQueueSize() const;
  71. /*!
  72. *
  73. * @return next free http downloader thread
  74. */
  75. QNetworkAccessManager* nextFreeHttp();
  76. /*!
  77. * sets the disk cache for each network manager
  78. * @param qCache the disk cache object to set
  79. */
  80. void setDiskCache( QNetworkDiskCache* qCache );
  81. //void requestFinished(QNetworkReply *reply);
  82. static void *requestFinished(void *, void *);
  83. };
  84. #endif