Skip to content

Commit e11d226

Browse files
committed
Add XAttr based plugin for VFS for Linux and later Mac
1 parent 50b9a4c commit e11d226

File tree

8 files changed

+530
-3
lines changed

8 files changed

+530
-3
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ add_feature_info(AppImageUpdate WITH_APPIMAGEUPDATER "Built-in libappimageupdate
103103
option(WITH_EXTERNAL_BRANDING "A URL to an external branding repo" "")
104104

105105
# specify additional vfs plugins
106-
set(VIRTUAL_FILE_SYSTEM_PLUGINS off cfapi CACHE STRING "Name of internal plugin in src/libsync/vfs or the locations of virtual file plugins")
106+
set(VIRTUAL_FILE_SYSTEM_PLUGINS off cfapi xattr CACHE STRING "Name of internal plugin in src/libsync/vfs or the locations of virtual file plugins")
107107

108108
if(APPLE)
109109
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )

src/libsync/common/pinstate.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,26 @@
1919

2020
using namespace OCC;
2121

22+
23+
template <>
24+
QString Utility::enumToDisplayName(PinState pState)
25+
{
26+
switch (pState) {
27+
case PinState::AlwaysLocal:
28+
return QStringLiteral("alwayslocal");
29+
case PinState::Excluded:
30+
return QStringLiteral("excluded");
31+
case PinState::Inherited:
32+
return QStringLiteral("inherited");
33+
case PinState::OnlineOnly:
34+
return QStringLiteral("onlineonly");
35+
case PinState::Unspecified:
36+
return QStringLiteral("unspecified");
37+
}
38+
Q_UNREACHABLE();
39+
}
40+
41+
2242
template <>
2343
QString Utility::enumToDisplayName(VfsItemAvailability availability)
2444
{

src/libsync/common/pinstate.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ using namespace PinStateEnums;
137137

138138
template <>
139139
OPENCLOUD_SYNC_EXPORT QString Utility::enumToDisplayName(VfsItemAvailability availability);
140+
template <>
141+
OPENCLOUD_SYNC_EXPORT QString Utility::enumToDisplayName(PinState pState);
140142
}
141143

142144
#endif

src/libsync/vfs/vfs.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ Optional<Vfs::Mode> Vfs::modeFromString(const QString &str)
5151
return Off;
5252
} else if (str == QLatin1String("cfapi")) {
5353
return WindowsCfApi;
54+
} else if (str == QLatin1String("xattr")) {
55+
return XAttr;
5456
}
5557
return {};
5658
}
@@ -65,6 +67,8 @@ QString Utility::enumToString(Vfs::Mode mode)
6567
return QStringLiteral("cfapi");
6668
case Vfs::Mode::Off:
6769
return QStringLiteral("off");
70+
case Vfs::Mode::XAttr:
71+
return QStringLiteral("xattr");
6872
}
6973
Q_UNREACHABLE();
7074
}
@@ -146,6 +150,7 @@ void Vfs::wipeDehydratedVirtualFiles()
146150

147151
QFuture<Result<void, QString>> Vfs::hydrateFile(const QByteArray &fileId)
148152
{
153+
Q_UNUSED(fileId)
149154
// nothing to do
150155
return QtFuture::makeReadyValueFuture(Result<void, QString>{});
151156
}
@@ -207,6 +212,8 @@ Vfs::Mode OCC::VfsPluginManager::bestAvailableVfsMode() const
207212
{
208213
if (isVfsPluginAvailable(Vfs::WindowsCfApi)) {
209214
return Vfs::WindowsCfApi;
215+
} else if (isVfsPluginAvailable(Vfs::XAttr)) {
216+
return Vfs::XAttr;
210217
} else if (isVfsPluginAvailable(Vfs::Off)) {
211218
return Vfs::Off;
212219
}

src/libsync/vfs/vfs.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class OPENCLOUD_SYNC_EXPORT Vfs : public QObject
9797
* Currently plugins and modes are one-to-one but that's not required.
9898
* The raw integer values are used in Qml
9999
*/
100-
enum Mode : uint8_t { Off = 0, WindowsCfApi = 1 };
100+
enum Mode : uint8_t { Off = 0, WindowsCfApi = 1, XAttr = 2 };
101101
Q_ENUM(Mode)
102102
enum class ConvertToPlaceholderResult : uint8_t { Ok, Locked };
103103
Q_ENUM(ConvertToPlaceholderResult)
@@ -251,9 +251,9 @@ public Q_SLOTS:
251251
*/
252252
virtual void startImpl(const VfsSetupParams &params) = 0;
253253

254-
private:
255254
// the parameters passed to start()
256255
std::unique_ptr<VfsSetupParams> _setupParams;
256+
private:
257257

258258
friend class OwncloudPropagator;
259259
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
add_vfs_plugin(NAME xattr
2+
SRC
3+
vfs_xattr.cpp
4+
)

0 commit comments

Comments
 (0)