QBreakpadHttpUploader.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (C) 2009 Aleksey Palazhchenko
  3. * Copyright (C) 2014 Sergey Shambir
  4. * Copyright (C) 2016 Alexander Makarov
  5. *
  6. * This file is a part of Breakpad-qt library.
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 2.1 of the License, or (at your option) any later version.
  12. *
  13. * This library 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 GNU
  16. * Lesser General Public License for more details.
  17. *
  18. */
  19. #ifndef QBREAKPAD_HTTP_SENDER_H
  20. #define QBREAKPAD_HTTP_SENDER_H
  21. #include <QObject>
  22. #include <QPointer>
  23. #include <QNetworkAccessManager>
  24. #include <QNetworkRequest>
  25. #include <QNetworkReply>
  26. class QString;
  27. class QUrl;
  28. class QFile;
  29. class QBreakpadHttpUploader : public QObject
  30. {
  31. Q_OBJECT
  32. public:
  33. QBreakpadHttpUploader(QObject *parent=0);
  34. QBreakpadHttpUploader(const QUrl& url, QObject *parent=0);
  35. ~QBreakpadHttpUploader();
  36. //TODO: proxy, ssl
  37. QString remoteUrl() const;
  38. void setUrl(const QUrl& url);
  39. signals:
  40. void finished(QString answer);
  41. public slots:
  42. void uploadDump(const QString& abs_file_path);
  43. private slots:
  44. void onUploadProgress(qint64 sent, qint64 total);
  45. void onError(QNetworkReply::NetworkError err);
  46. void onUploadFinished();
  47. private:
  48. QNetworkAccessManager m_manager;
  49. QNetworkRequest m_request;
  50. QPointer<QNetworkReply> m_reply;
  51. QFile* m_file;
  52. };
  53. #endif // QBREAKPAD_HTTP_SENDER_H