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.

common.h 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #include <QList>
  21. #include <QHash>
  22. #ifndef QFTRANS_COMMON_H
  23. #define QFTRANS_COMMON_H
  24. #define RAWPACKET_SIZE 9
  25. #define DATA_BLOCK_SIZE (64*1024)
  26. #define DESCRIPTOR_STRING "QFTH"
  27. namespace qftrans {
  28. enum TransferStatus {TS_SUSPENDED = 0, TS_PENDING = 1, TS_ANNOUNCING = 2, TS_WAITING = 3, TS_TRANSFERING = 4, TS_CLOSING = 5, TS_FINISHED = 6};
  29. enum HeaderType {HT_ANNOUNCE = 0, HT_DATA = 1, HT_CLOSE = 2, HT_ACK = 3, HT_CANCEL = 4};
  30. struct TransferData {
  31. QString fileDir;
  32. QString fileName;
  33. TransferStatus status;
  34. bool localFile;
  35. qint64 size;
  36. qint64 transfered;
  37. HeaderType lastHeader;
  38. quint32 id;
  39. };
  40. struct TransferHeader {
  41. char descriptor[5];
  42. quint8 type;
  43. quint32 id;
  44. quint32 length;
  45. TransferHeader() {
  46. descriptor[0] = 'Q';
  47. descriptor[1] = 'F';
  48. descriptor[2] = 'T';
  49. descriptor[3] = 'H';
  50. descriptor[4] = 0;
  51. }
  52. };
  53. typedef QList<TransferData *> QTransferDataList;
  54. typedef QHash<quint32, TransferData *> QTransferDataHash;
  55. typedef QHash<TransferData *, quint32> QTransferIdHash;
  56. }
  57. #endif