propagatorjobs.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * Copyright (C) by Olivier Goffart <ogoffart@owncloud.com>
  3. * Copyright (C) by Klaas Freitag <freitag@owncloud.com>
  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, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  12. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  13. * for more details.
  14. */
  15. #pragma once
  16. #include "owncloudpropagator.h"
  17. #include <QFile>
  18. namespace OCC {
  19. /**
  20. * Tags for checksum header.
  21. * It's here for being shared between Upload- and Download Job
  22. */
  23. static const char checkSumHeaderC[] = "OC-Checksum";
  24. static const char contentMd5HeaderC[] = "Content-MD5";
  25. static const char checksumRecalculateOnServer[] = "X-Recalculate-Hash";
  26. /**
  27. * @brief Declaration of the other propagation jobs
  28. * @ingroup libsync
  29. */
  30. class PropagateLocalRemove : public PropagateItemJob
  31. {
  32. Q_OBJECT
  33. public:
  34. PropagateLocalRemove(OwncloudPropagator *propagator, const SyncFileItemPtr &item)
  35. : PropagateItemJob(propagator, item)
  36. {
  37. }
  38. void start() override;
  39. private:
  40. bool removeRecursively(const QString &path);
  41. QString _error;
  42. bool _moveToTrash;
  43. };
  44. /**
  45. * @brief The PropagateLocalMkdir class
  46. * @ingroup libsync
  47. */
  48. class PropagateLocalMkdir : public PropagateItemJob
  49. {
  50. Q_OBJECT
  51. public:
  52. PropagateLocalMkdir(OwncloudPropagator *propagator, const SyncFileItemPtr &item)
  53. : PropagateItemJob(propagator, item)
  54. , _deleteExistingFile(false)
  55. {
  56. }
  57. void start() override;
  58. /**
  59. * Whether an existing file with the same name may be deleted before
  60. * creating the directory.
  61. *
  62. * Default: false.
  63. */
  64. void setDeleteExistingFile(bool enabled);
  65. private:
  66. void startLocalMkdir();
  67. void startDemanglingName(const QString &parentPath);
  68. bool _deleteExistingFile;
  69. };
  70. /**
  71. * @brief The PropagateLocalRename class
  72. * @ingroup libsync
  73. */
  74. class PropagateLocalRename : public PropagateItemJob
  75. {
  76. Q_OBJECT
  77. public:
  78. PropagateLocalRename(OwncloudPropagator *propagator, const SyncFileItemPtr &item)
  79. : PropagateItemJob(propagator, item)
  80. {
  81. }
  82. void start() override;
  83. JobParallelism parallelism() override { return _item->isDirectory() ? WaitForFinished : FullParallelism; }
  84. };
  85. }