Skip to content

Commit

Permalink
Merge pull request #2196 from nextcloud/develop
Browse files Browse the repository at this point in the history
Version 4.5
  • Loading branch information
marinofaggiana authored Oct 17, 2022
2 parents 785041f + f8b9193 commit cc64ac4
Show file tree
Hide file tree
Showing 458 changed files with 7,388 additions and 4,028 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/xcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,15 @@ jobs:
run: |
xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
env:
SCHEME: Notification Service Extension
SCHEME: Notification Service Extension
- name: Build iOS Widget
run: |
xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
env:
SCHEME: Widget
- name: Build iOS Widget Dashboard IntentHandler
run: |
xcodebuild build -project $PROJECT -scheme "$SCHEME" -destination "$DESTINATION"
env:
SCHEME: WidgetDashboardIntentHandler

11 changes: 10 additions & 1 deletion .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ excluded:
- File Provider Extension/FileProviderExtension.swift
- File Provider Extension/FileProviderUtility.swift
- Notification Service Extension/NotificationService.swift
- Widget/Widget.swift
- Widget/Dashboard/DashboardData.swift
- Widget/Dashboard/DashboardWidgetView.swift
- Widget/Files/FilesData.swift
- Widget/Files/FilesWidgetView.swift
- Widget/Lockscreen/LockscreenData.swift
- Widget/Lockscreen/LockscreenWidgetView.swift
- Widget/Lockscreen/LockscreenWidgetProvider.swift
- iOSClient/Activity/NCActivity.swift
- iOSClient/Activity/NCActivityTableViewCell.swift
- iOSClient/AppDelegate.swift
Expand All @@ -56,6 +64,7 @@ excluded:
- iOSClient/Data/NCManageDatabase.swift
- iOSClient/Data/NCManageDatabase+Metadata.swift
- iOSClient/Data/NCManageDatabase+Video.swift
- iOSClient/Data/NCManageDatabase+DashboardWidget.swift
- iOSClient/Diagnostics/NCCapabilitiesViewController.swift
- iOSClient/EmptyView/NCEmptyDataSet.swift
- iOSClient/Extensions/UIColor+Extensions.swift
Expand Down Expand Up @@ -122,6 +131,7 @@ excluded:
- iOSClient/Utility/NCStoreReview.swift
- iOSClient/Utility/NCUtility.swift
- iOSClient/Utility/NCUtilityFileSystem.swift
- iOSClient/Utility/NCUtilityGUI.swift
- iOSClient/Viewer/NCViewer.swift
- iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayer.swift
- iOSClient/Viewer/NCViewerMedia/NCPlayer/NCPlayerToolBar.swift
Expand All @@ -133,5 +143,4 @@ excluded:
- iOSClient/Viewer/NCViewerProviderContextMenu.swift
- iOSClient/Viewer/NCViewerRichdocument/NCViewerRichdocument.swift


reporter: "xcode"
14 changes: 6 additions & 8 deletions File Provider Extension/FileProviderData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
//

import UIKit
import NCCommunication
import NextcloudKit

class fileProviderData: NSObject {
static let shared: fileProviderData = {
Expand Down Expand Up @@ -77,27 +77,26 @@ class fileProviderData: NSObject {

// LOG
if let pathDirectoryGroup = CCUtility.getDirectoryGroup()?.path {
NCCommunicationCommon.shared.pathLog = pathDirectoryGroup
NKCommon.shared.pathLog = pathDirectoryGroup
let levelLog = CCUtility.getLogLevel()
NCCommunicationCommon.shared.levelLog = levelLog
NKCommon.shared.levelLog = levelLog
let version = NSString(format: NCBrandOptions.shared.textCopyrightNextcloudiOS as NSString, NCUtility.shared.getVersionApp()) as String
NCCommunicationCommon.shared.writeLog("Start File Provider session with level \(levelLog) " + version + " (File Provider Extension)")
NKCommon.shared.writeLog("[INFO] Start File Provider session with level \(levelLog) " + version + " (File Provider Extension)")
}

// NO DOMAIN -> Set default account
if domain == nil {

guard let activeAccount = NCManageDatabase.shared.getActiveAccount() else { return nil }
let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: activeAccount.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
let webDav = NCUtilityFileSystem.shared.getWebDAV(account: activeAccount.account)

account = activeAccount.account
user = activeAccount.user
userId = activeAccount.userId
accountUrlBase = activeAccount.urlBase
homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(account: activeAccount.account)

NCCommunicationCommon.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
NKCommon.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate

return tableAccount.init(value: activeAccount)
Expand All @@ -114,15 +113,14 @@ class fileProviderData: NSObject {
if accountDomain == domain!.identifier.rawValue {

let serverVersionMajor = NCManageDatabase.shared.getCapabilitiesServerInt(account: activeAccount.account, elements: NCElementsJSON.shared.capabilitiesVersionMajor)
let webDav = NCUtilityFileSystem.shared.getWebDAV(account: activeAccount.account)

account = activeAccount.account
user = activeAccount.user
userId = activeAccount.userId
accountUrlBase = activeAccount.urlBase
homeServerUrl = NCUtilityFileSystem.shared.getHomeServer(account: activeAccount.account)

NCCommunicationCommon.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), webDav: webDav, nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
NKCommon.shared.setup(account: activeAccount.account, user: activeAccount.user, userId: activeAccount.userId, password: CCUtility.getPassword(activeAccount.account), urlBase: activeAccount.urlBase, userAgent: CCUtility.getUserAgent(), nextcloudVersion: serverVersionMajor, delegate: NCNetworking.shared)
NCNetworking.shared.delegate = providerExtension as? NCNetworkingDelegate

return tableAccount.init(value: activeAccount)
Expand Down
10 changes: 5 additions & 5 deletions File Provider Extension/FileProviderEnumerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import UIKit
import FileProvider
import NCCommunication
import NextcloudKit

class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {

Expand Down Expand Up @@ -203,15 +203,15 @@ class FileProviderEnumerator: NSObject, NSFileProviderEnumerator {
directoryEtag = tableDirectory.etag
}

NCCommunication.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "0", showHiddenFiles: CCUtility.getShowHiddenFiles()) { account, files, _, errorCode, _ in
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "0", showHiddenFiles: CCUtility.getShowHiddenFiles()) { account, files, _, error in

if directoryEtag != files.first?.etag {

NCCommunication.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: CCUtility.getShowHiddenFiles()) { account, files, _, errorCode, _ in
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrl, depth: "1", showHiddenFiles: CCUtility.getShowHiddenFiles()) { account, files, _, error in

if errorCode == 0 {
if error == .success {
DispatchQueue.global().async {
NCManageDatabase.shared.convertNCCommunicationFilesToMetadatas(files, useMetadataFolder: true, account: account) { _, metadatasFolder, metadatas in
NCManageDatabase.shared.convertNKFilesToMetadatas(files, useMetadataFolder: true, account: account) { _, metadatasFolder, metadatas in
let metadatasResult = NCManageDatabase.shared.getMetadatas(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@ AND status == %d", account, serverUrl, NCGlobal.shared.metadataStatusNormal))
NCManageDatabase.shared.updateMetadatas(metadatas, metadatasResult: metadatasResult)
for metadata in metadatasFolder {
Expand Down
26 changes: 13 additions & 13 deletions File Provider Extension/FileProviderExtension+Actions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import UIKit
import FileProvider
import NCCommunication
import NextcloudKit

extension FileProviderExtension {

Expand All @@ -37,13 +37,13 @@ extension FileProviderExtension {
let directoryName = NCUtilityFileSystem.shared.createFileName(directoryName, serverUrl: tableDirectory.serverUrl, account: fileProviderData.shared.account)
let serverUrlFileName = tableDirectory.serverUrl + "/" + directoryName

NCCommunication.shared.createFolder(serverUrlFileName) { account, ocId, _, errorCode, _ in
NextcloudKit.shared.createFolder(serverUrlFileName) { account, ocId, _, error in

if errorCode == 0 {
if error == .success {

NCCommunication.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", showHiddenFiles: CCUtility.getShowHiddenFiles()) { account, files, _, errorCode, _ in
NextcloudKit.shared.readFileOrFolder(serverUrlFileName: serverUrlFileName, depth: "0", showHiddenFiles: CCUtility.getShowHiddenFiles()) { account, files, _, error in

if errorCode == 0 && files.count > 0 {
if error == .success && files.count > 0 {

let file = files.first!
let metadata = NCManageDatabase.shared.convertNCFileToMetadata(file, isEncrypted: false, account: fileProviderData.shared.account)
Expand Down Expand Up @@ -88,9 +88,9 @@ extension FileProviderExtension {
let serverUrl = metadata.serverUrl
let fileName = metadata.fileName

NCCommunication.shared.deleteFileOrFolder(serverUrlFileName) { account, errorCode, _ in
NextcloudKit.shared.deleteFileOrFolder(serverUrlFileName) { account, error in

if errorCode == 0 { // || error == kOCErrorServerPathNotFound {
if error == .success { // || error == kOCErrorServerPathNotFound {

let fileNamePath = CCUtility.getDirectoryProviderStorageOcId(itemIdentifier.rawValue)!
do {
Expand Down Expand Up @@ -138,9 +138,9 @@ extension FileProviderExtension {
let serverUrlTo = tableDirectoryTo.serverUrl
let fileNameTo = serverUrlTo + "/" + itemFrom.filename

NCCommunication.shared.moveFileOrFolder(serverUrlFileNameSource: fileNameFrom, serverUrlFileNameDestination: fileNameTo, overwrite: false) { account, errorCode, _ in
NextcloudKit.shared.moveFileOrFolder(serverUrlFileNameSource: fileNameFrom, serverUrlFileNameDestination: fileNameTo, overwrite: false) { account, error in

if errorCode == 0 {
if error == .success {

if metadataFrom.directory {
NCManageDatabase.shared.deleteDirectoryAndSubDirectory(serverUrl: serverUrlFrom, account: account)
Expand Down Expand Up @@ -180,9 +180,9 @@ extension FileProviderExtension {
let fileNamePathTo = metadata.serverUrl + "/" + itemName
let ocId = metadata.ocId

NCCommunication.shared.moveFileOrFolder(serverUrlFileNameSource: fileNamePathFrom, serverUrlFileNameDestination: fileNamePathTo, overwrite: false) { account, errorCode, _ in
NextcloudKit.shared.moveFileOrFolder(serverUrlFileNameSource: fileNamePathFrom, serverUrlFileNameDestination: fileNamePathTo, overwrite: false) { account, error in

if errorCode == 0 {
if error == .success {

// Rename metadata
NCManageDatabase.shared.renameMetadata(fileNameTo: itemName, ocId: ocId)
Expand Down Expand Up @@ -247,9 +247,9 @@ extension FileProviderExtension {
if (favorite == true && metadata.favorite == false) || (favorite == false && metadata.favorite == true) {
let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, account: metadata.account)!

NCCommunication.shared.setFavorite(fileName: fileNamePath, favorite: favorite) { _, errorCode, _ in
NextcloudKit.shared.setFavorite(fileName: fileNamePath, favorite: favorite) { _, error in

if errorCode == 0 {
if error == .success {

guard let metadataTemp = NCManageDatabase.shared.getMetadataFromOcId(ocId) else {
completionHandler(nil, NSFileProviderError(.noSuchItem))
Expand Down
32 changes: 19 additions & 13 deletions File Provider Extension/FileProviderExtension+Thumbnail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import UIKit
import FileProvider
import NCCommunication
import NextcloudKit

extension FileProviderExtension {

Expand All @@ -45,20 +45,26 @@ extension FileProviderExtension {
let fileNamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: metadata.urlBase, account: metadata.account)!
let fileNameIconLocalPath = CCUtility.getDirectoryProviderStorageIconOcId(metadata.ocId, etag: metadata.etag)!

NCCommunication.shared.getPreview(fileNamePath: fileNamePath, widthPreview: NCGlobal.shared.sizeIcon, heightPreview: NCGlobal.shared.sizeIcon) { _, data, errorCode, _ in
if errorCode == 0 && data != nil {
do {
try data!.write(to: URL(fileURLWithPath: fileNameIconLocalPath), options: .atomic)
} catch { }
perThumbnailCompletionHandler(itemIdentifier, data, nil)
} else {
perThumbnailCompletionHandler(itemIdentifier, nil, NSFileProviderError(.serverUnreachable))
}
counterProgress += 1
if counterProgress == progress.totalUnitCount {
completionHandler(nil)
if let urlBase = metadata.urlBase.urlEncoded,
let fileNamePath = fileNamePath.urlEncoded,
let url = URL(string: "\(urlBase)/index.php/core/preview.png?file=\(fileNamePath)&x=\(size)&y=\(size)&a=1&mode=cover") {

NextcloudKit.shared.getPreview(url: url) { _, data, error in
if error == .success && data != nil {
do {
try data!.write(to: URL(fileURLWithPath: fileNameIconLocalPath), options: .atomic)
} catch { }
perThumbnailCompletionHandler(itemIdentifier, data, nil)
} else {
perThumbnailCompletionHandler(itemIdentifier, nil, NSFileProviderError(.serverUnreachable))
}
counterProgress += 1
if counterProgress == progress.totalUnitCount {
completionHandler(nil)
}
}
}

} else {
counterProgress += 1
if counterProgress == progress.totalUnitCount {
Expand Down
Loading

0 comments on commit cc64ac4

Please sign in to comment.