Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /***************************************************************************
  2. * Copyright (C) 2008 by Oliver Groß *
  3. * z.o.gross@gmx.de *
  4. * *
  5. * This program 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 2 of the License, or *
  8. * (at your option) any later version. *
  9. * *
  10. * This program is distributed in the hope that it will be useful, *
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of *
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
  13. * GNU General Public License for more details. *
  14. * *
  15. * You should have received a copy of the GNU General Public License *
  16. * along with this program; if not, write to the *
  17. * Free Software Foundation, Inc., *
  18. * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
  19. ***************************************************************************/
  20. #ifndef QFTRANSCWORKER_H
  21. #define QFTRANSCWORKER_H
  22. #include <QObject>
  23. #include <QTcpSocket>
  24. #include <QDataStream>
  25. #include <QQueue>
  26. #include "common.h"
  27. namespace qftrans {
  28. /**
  29. @author Oliver Groß <z.o.gross@gmx.de>
  30. */
  31. class CWorker : public QObject {
  32. Q_OBJECT
  33. public:
  34. CWorker(QTcpSocket * socket, QObject * parent = 0);
  35. ~CWorker();
  36. signals:
  37. void uploadAdded(TransferData * transfer);
  38. void uploadRemoved(TransferData * transfer);
  39. void uploadUpdated(TransferData * transfer);
  40. void downloadAdded(TransferData * transfer);
  41. void downloadRemoved(TransferData * transfer);
  42. void downloadUpdated(TransferData * transfer);
  43. public slots:
  44. void addUpload(TransferData * transfer);
  45. void removeUpload(TransferData * transfer);
  46. // void startUpload(TransferData * transfer);
  47. void removeDownload(TransferData * data);
  48. void setDestinationDir(QString & value);
  49. void writePing();
  50. protected slots:
  51. void writeData();
  52. void readData();
  53. void readPing();
  54. protected:
  55. void readHeader(QDataStream & in);
  56. void startUploadData(quint32 id);
  57. void sendAcknowledge(quint32 id);
  58. QTcpSocket * m_Socket;
  59. QString m_DestinationDir;
  60. quint32 m_IdCounter;
  61. QQueue<TransferData *> m_Uploads;
  62. QTransferDataHash m_DownloadDict;
  63. TransferHeader m_LastHeader;
  64. bool m_LastHeaderValid;
  65. private slots:
  66. void error(QAbstractSocket::SocketError socketError);
  67. };
  68. }
  69. #endif