pinstate.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (C) by Christian Kamm <mail@ckamm.de>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  11. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  12. * for more details.
  13. */
  14. #ifndef PINSTATE_H
  15. #define PINSTATE_H
  16. #include "ocsynclib.h"
  17. namespace OCC {
  18. /** Determines whether items should be available locally permanently or not
  19. *
  20. * The idea is that files and folders can be marked with the user intent
  21. * on availability.
  22. *
  23. * The Inherited state is used for resetting a pin state to what its
  24. * parent path would do.
  25. *
  26. * The pin state of a directory usually only matters for the initial pin and
  27. * hydration state of new remote files. It's perfectly possible for a
  28. * AlwaysLocal directory to have only OnlineOnly items. (though setting pin
  29. * states is usually done recursively, so one'd need to set the folder to
  30. * pinned and then each contained item to unpinned)
  31. *
  32. * Note: This enum intentionally mimics CF_PIN_STATE of Windows cfapi.
  33. */
  34. enum class PinState {
  35. /** The pin state is derived from the state of the parent folder.
  36. *
  37. * For example new remote files start out in this state, following
  38. * the state of their parent folder.
  39. *
  40. * This state is used purely for resetting pin states to their derived
  41. * value. The effective state for an item will never be "Inherited".
  42. */
  43. Inherited = 0,
  44. /** The file shall be available and up to date locally.
  45. *
  46. * Also known as "pinned". Pinned dehydrated files shall be hydrated
  47. * as soon as possible.
  48. */
  49. AlwaysLocal = 1,
  50. /** File shall be a dehydrated placeholder, filled on demand.
  51. *
  52. * Also known as "unpinned". Unpinned hydrated files shall be dehydrated
  53. * as soon as possible.
  54. *
  55. * If a unpinned file becomes hydrated (such as due to an implicit hydration
  56. * where the user requested access to the file's data) its pin state changes
  57. * to Unspecified.
  58. */
  59. OnlineOnly = 2,
  60. /** The user hasn't made a decision. The client or platform may hydrate or
  61. * dehydrate as they see fit.
  62. *
  63. * New remote files in unspecified directories start unspecified, and
  64. * dehydrated (which is an arbitrary decision).
  65. */
  66. Unspecified = 3,
  67. };
  68. /** A user-facing version of PinState.
  69. *
  70. * PinStates communicate availability intent for an item, but particular
  71. * situations can get complex: An AlwaysLocal folder can have OnlineOnly
  72. * files or directories.
  73. *
  74. * For users this is condensed to a few useful cases.
  75. *
  76. * Note that this is only about *intent*. The file could still be out of date,
  77. * or not have been synced for other reasons, like errors.
  78. *
  79. * NOTE: The numerical values and ordering of this enum are relevant.
  80. */
  81. enum class VfsItemAvailability {
  82. /** The item and all its subitems are hydrated and pinned AlwaysLocal.
  83. *
  84. * This guarantees that all contents will be kept in sync.
  85. */
  86. AlwaysLocal = 0,
  87. /** The item and all its subitems are hydrated.
  88. *
  89. * This may change if the platform or client decide to dehydrate items
  90. * that have Unspecified pin state.
  91. *
  92. * A folder with no file contents will have this availability.
  93. */
  94. AllHydrated = 1,
  95. /** There are dehydrated and hydrated items.
  96. *
  97. * This would happen if a dehydration happens to a Unspecified item that
  98. * used to be hydrated.
  99. */
  100. Mixed = 2,
  101. /** There are only dehydrated items but the pin state isn't all OnlineOnly.
  102. */
  103. AllDehydrated = 3,
  104. /** The item and all its subitems are dehydrated and OnlineOnly.
  105. *
  106. * This guarantees that contents will not take up space.
  107. */
  108. OnlineOnly = 4,
  109. };
  110. }
  111. #endif