diff --git a/src/gui/macOS/fileprovideritemmetadata.h b/src/gui/macOS/fileprovideritemmetadata.h index 82b91bf5f580e..6ec4c0aca7f74 100644 --- a/src/gui/macOS/fileprovideritemmetadata.h +++ b/src/gui/macOS/fileprovideritemmetadata.h @@ -56,6 +56,8 @@ class FileProviderItemMetadata Q_PROPERTY(bool sharedByCurrentUser READ sharedByCurrentUser CONSTANT) public: + static FileProviderItemMetadata fromNSFileProviderItem(const void *const nsFileProviderItem); + QString identifier() const; QString parentItemIdentifier() const; QString filename() const; diff --git a/src/gui/macOS/fileprovideritemmetadata_mac.mm b/src/gui/macOS/fileprovideritemmetadata_mac.mm index 5521baa463d16..9248873ffbc96 100644 --- a/src/gui/macOS/fileprovideritemmetadata_mac.mm +++ b/src/gui/macOS/fileprovideritemmetadata_mac.mm @@ -41,3 +41,52 @@ QString nsNameComponentsToLocalisedQString(NSPersonNameComponents *const nameCom } } + +namespace OCC { + +namespace Mac { + +FileProviderItemMetadata FileProviderItemMetadata::fromNSFileProviderItem(const void *const nsFileProviderItem) +{ + FileProviderItemMetadata metadata; + const id bridgedNsFileProviderItem = (__bridge id)nsFileProviderItem; + if (bridgedNsFileProviderItem == nil) { + return {}; + } + + metadata._identifier = QString::fromNSString(bridgedNsFileProviderItem.itemIdentifier); + metadata._parentItemIdentifier = QString::fromNSString(bridgedNsFileProviderItem.parentItemIdentifier); + metadata._filename = QString::fromNSString(bridgedNsFileProviderItem.filename); + metadata._typeIdentifier = QString::fromNSString(bridgedNsFileProviderItem.contentType.identifier); + metadata._symlinkTargetPath = QString::fromNSString(bridgedNsFileProviderItem.symlinkTargetPath); + metadata._uploadingError = QString::fromNSString(bridgedNsFileProviderItem.uploadingError.localizedDescription); + metadata._downloadingError = QString::fromNSString(bridgedNsFileProviderItem.downloadingError.localizedDescription); + metadata._mostRecentEditorName = nsNameComponentsToLocalisedQString(bridgedNsFileProviderItem.mostRecentEditorNameComponents); + metadata._ownerName = nsNameComponentsToLocalisedQString(bridgedNsFileProviderItem.ownerNameComponents); + metadata._contentModificationDate = QDateTime::fromNSDate(bridgedNsFileProviderItem.contentModificationDate); + metadata._creationDate = QDateTime::fromNSDate(bridgedNsFileProviderItem.creationDate); + metadata._lastUsedDate = QDateTime::fromNSDate(bridgedNsFileProviderItem.lastUsedDate); + metadata._contentVersion = QByteArray::fromNSData(bridgedNsFileProviderItem.itemVersion.contentVersion); + metadata._metadataVersion = QByteArray::fromNSData(bridgedNsFileProviderItem.itemVersion.metadataVersion); + metadata._tagData = QByteArray::fromNSData(bridgedNsFileProviderItem.tagData); + metadata._extendedAttributes = extendedAttributesToHash(bridgedNsFileProviderItem.extendedAttributes); + metadata._capabilities = bridgedNsFileProviderItem.capabilities; + metadata._fileSystemFlags = bridgedNsFileProviderItem.fileSystemFlags; + metadata._childItemCount = bridgedNsFileProviderItem.childItemCount.unsignedIntegerValue; + metadata._typeOsCode = bridgedNsFileProviderItem.typeAndCreator.type; + metadata._creatorOsCode = bridgedNsFileProviderItem.typeAndCreator.creator; + metadata._documentSize = bridgedNsFileProviderItem.documentSize.unsignedLongLongValue; + metadata._mostRecentVersionDownloaded = bridgedNsFileProviderItem.mostRecentVersionDownloaded; + metadata._uploading = bridgedNsFileProviderItem.uploading; + metadata._uploaded = bridgedNsFileProviderItem.uploaded; + metadata._downloading = bridgedNsFileProviderItem.downloading; + metadata._downloaded = bridgedNsFileProviderItem.downloaded; + metadata._shared = bridgedNsFileProviderItem.shared; + metadata._sharedByCurrentUser = bridgedNsFileProviderItem.sharedByCurrentUser; + + return metadata; +} + +} + +}