Skip to content

Commit

Permalink
[feature/infinite-propfind] Infinite PROPFIND support (#1002)
Browse files Browse the repository at this point in the history
* - ProgressIndicatorViewController : extend with Progress object and cancellation support / monitoring
- BookmarkViewController: add infinite PROPFIND prepopulation step after account creation
- update SDK to provide infinite PROPFIND support

* Configuration documentation updated

* - update SDK to gain access to streaming infinite PROPFIND
- switch from receive+parse to stream+parse for infinite PROPFIND

* - update SDK to gain access to new supportsInfinitePropfind capability
- BookmarkViewController: make prepopulation configurable, using new capability and new class setting
- ProgressIndicatorViewController: add support for new title label view

* - BookmarkViewController: fix property name typo
- scheme: add new options to test streaming and split bookmark prepopulation

* Configuration documentation updated

* added additional build information to the Branding.plist file:
- ios-app and ios-sdk commit hash
- copy the Branding.plist with additional app and build information as file name

* [feature/biometrical-mdm-setting ]Suggest Biometrical Unlock (#1046)

* Suggest biometrical unlock, after setting up passcode

* - do not show Cancel button, if password is enforced
- update biometrical UI switch value in settings view
- fixed bug, dismissing the view, if biometrical is not available

* moved extension into ownCloudAppShared folder

* Branding: (#1045)

- add new `branding.user-defaults-default-values` class settings key to allow registration of alternative defaults for user defaults

* - fix bug where a quick access entry showed no items when selected a second time. (#1044)

* used better wording for "Cellular transfers"

* - adjust to final capabilities naming for infinite PROPFIND support

* upgraded app version numbers

Co-authored-by: felix-schwarz <[email protected]>
Co-authored-by: Matthias Hühne <[email protected]>
Co-authored-by: Matthias Hühne <[email protected]>
  • Loading branch information
4 people authored Jan 18, 2022
1 parent 8fbe2a8 commit 69eeaf2
Show file tree
Hide file tree
Showing 8 changed files with 312 additions and 67 deletions.
27 changes: 27 additions & 0 deletions doc/CONFIGURATION.json
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,33 @@
"status" : "supported",
"type" : "string"
},
{
"autoExpansion" : "none",
"category" : "Bookmarks",
"categoryTag" : "bookmarks",
"classIdentifier" : "bookmark",
"className" : "ownCloud.BookmarkViewController",
"description" : "Controls prepopulation of the local database with the full item set during account setup.",
"flatIdentifier" : "bookmark.prepopulation",
"key" : "prepopulation",
"label" : "bookmark.prepopulation",
"possibleValues" : [
{
"description" : "No prepopulation. Request the contents of every folder individually.",
"value" : "doNot"
},
{
"description" : "Parse the prepopulation metadata after receiving it as a whole.",
"value" : "split"
},
{
"description" : "Parse the prepopulation metadata while receiving it.",
"value" : "streaming"
}
],
"status" : "supported",
"type" : "string"
},
{
"autoExpansion" : "none",
"category" : "Bookmarks",
Expand Down
21 changes: 21 additions & 0 deletions docs/modules/ROOT/pages/ios_mdm_tables.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,27 @@ tag::bookmarks[]
|The default URL for the creation of new bookmarks.
|supported `candidate`

|bookmark.prepopulation
|string
|
|Controls prepopulation of the local database with the full item set during account setup.
[cols="1,2"]
!===
! Value
! Description
! `doNot`
! No prepopulation. Request the contents of every folder individually.

! `split`
! Parse the prepopulation metadata after receiving it as a whole.

! `streaming`
! Parse the prepopulation metadata while receiving it.

!===

|supported `candidate`

|bookmark.url-editable
|bool
|`true`
Expand Down
2 changes: 1 addition & 1 deletion ios-sdk
2 changes: 1 addition & 1 deletion ownCloud Share Extension/ShareViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ class ShareViewController: MoreStaticTableViewController {
OnMainThread {
self.navigationController?.popToViewController(self, animated: false)

let progressViewController = ProgressIndicatorViewController(initialProgressLabel: "Preparing…".localized, cancelHandler: {})
let progressViewController = ProgressIndicatorViewController(initialProgressLabel: "Preparing…".localized, progress: nil, cancelHandler: {})

self.present(progressViewController, animated: false)

Expand Down
12 changes: 11 additions & 1 deletion ownCloud.xcodeproj/xcshareddata/xcschemes/ownCloud.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
<EnvironmentVariable
key = "oc:log.enabled-components"
value = "[writer.stderr,writer.file,option.log-requests-and-responses]"
isEnabled = "YES">
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:log.colored"
Expand Down Expand Up @@ -335,6 +335,16 @@
value = "[com.owncloud.action.copy,com.owncloud.action.move]"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:bookmark.prepopulation"
value = "string:streaming"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:bookmark.prepopulation"
value = "string:split"
isEnabled = "NO">
</EnvironmentVariable>
<EnvironmentVariable
key = "oc:branding.disabled-import-methods"
value = "[share-extension,open-with,file-provider]"
Expand Down
216 changes: 157 additions & 59 deletions ownCloud/Bookmarks/BookmarkViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -554,77 +554,147 @@ class BookmarkViewController: StaticTableViewController {
}

func save(hudCompletion: @escaping (((() -> Void)?) -> Void)) {
guard let bookmark = self.bookmark else { return }

if isBookmarkComplete(bookmark: bookmark) {
bookmark.authenticationDataStorage = .keychain // Commit auth changes to keychain

let connection = instantiateConnection(for: bookmark)

connection.connect { [weak self] (error, issue) in
if let strongSelf = self {
if error == nil {
bookmark.displayName = connection.loggedInUser?.displayName
connection.disconnect(completionHandler: {
switch strongSelf.mode {
case .create:
// Add bookmark
OCBookmarkManager.shared.addBookmark(bookmark)

case .edit:
// Update original bookmark
self?.originalBookmark?.setValuesFrom(bookmark)
if let originalBookmark = self?.originalBookmark, !OCBookmarkManager.shared.updateBookmark(originalBookmark) {
Log.error("Changes to \(originalBookmark) not saved as it's not tracked by OCBookmarkManager!")
}
}
guard let bookmark = self.bookmark else { return }

let userActionCompletionHandler = strongSelf.userActionCompletionHandler
strongSelf.userActionCompletionHandler = nil
if isBookmarkComplete(bookmark: bookmark) {
bookmark.authenticationDataStorage = .keychain // Commit auth changes to keychain
let connection = instantiateConnection(for: bookmark)

OnMainThread {
hudCompletion({
OnMainThread {
userActionCompletionHandler?(bookmark, true)
}
strongSelf.presentingViewController?.dismiss(animated: true, completion: nil)
})
}
connection.connect { [weak self] (error, issue) in

})
} else {
OnMainThread {
hudCompletion({
if let issue = issue {
self?.bookmark?.authenticationData = nil
if let strongSelf = self {
if error == nil {
let serverSupportsInfinitePropfind = connection.capabilities?.davPropfindSupportsDepthInfinity

IssuesCardViewController.present(on: strongSelf, issue: issue, completion: { [weak self, weak issue] (response) in
switch response {
case .cancel:
issue?.reject()
bookmark.displayName = connection.loggedInUser?.displayName
connection.disconnect(completionHandler: {

case .approve:
issue?.approve()
self?.handleContinue()
let done = {
let userActionCompletionHandler = strongSelf.userActionCompletionHandler
strongSelf.userActionCompletionHandler = nil

case .dismiss: break
OnMainThread {
hudCompletion({
OnMainThread {
userActionCompletionHandler?(bookmark, true)
}
})
} else {
strongSelf.presentingViewController?.dismiss(animated: true, completion: nil)
}
})
strongSelf.presentingViewController?.dismiss(animated: true, completion: nil)
})
}
}

switch strongSelf.mode {
case .create:
// Add bookmark
OnMainThread {
var prepopulationMethod : BookmarkPrepopulationMethod?

// Determine prepopulation method
if prepopulationMethod == nil, let prepopulationMethodClassSetting = BookmarkViewController.classSetting(forOCClassSettingsKey: .prepopulation) as? String {
prepopulationMethod = BookmarkPrepopulationMethod(rawValue: prepopulationMethodClassSetting)
}

if prepopulationMethod == nil, serverSupportsInfinitePropfind?.boolValue == true {
prepopulationMethod = .streaming
}

if prepopulationMethod == nil {
prepopulationMethod = .doNot
}

// Prepopulation y/n?
if let prepopulationMethod = prepopulationMethod, prepopulationMethod != .doNot {
// Perform prepopulation
var progressViewController : ProgressIndicatorViewController?
var prepopulateProgress : Progress?
let prepopulateCompletionHandler = {
// Wrap up
OCBookmarkManager.shared.addBookmark(bookmark)

OnMainThread {
progressViewController?.dismiss(animated: true, completion: {
done()
})
}
}

// Perform prepopulation method
switch prepopulationMethod {
case .streaming:
prepopulateProgress = bookmark.prepopulate(streamCompletionHandler: { _ in
prepopulateCompletionHandler()
})

case .split:
prepopulateProgress = bookmark.prepopulate(completionHandler: { _ in
prepopulateCompletionHandler()
})

default:
done()
}

// Present progress
if let prepopulateProgress = prepopulateProgress {

progressViewController = ProgressIndicatorViewController(initialTitleLabel: "Preparing account".localized, initialProgressLabel: "Please wait…".localized, progress: nil, cancelLabel: "Skip".localized, cancelHandler: {
prepopulateProgress.cancel()
})
progressViewController?.progress = prepopulateProgress // work around compiler bug (https://forums.swift.org/t/didset-is-not-triggered-while-called-after-super-init/45226/10)
if let progressViewController = progressViewController {
self?.topMostViewController.present(progressViewController, animated: true, completion: nil)
}
}

} else {
// No prepopulation
done()
}
}

case .edit:
// Update original bookmark
self?.originalBookmark?.setValuesFrom(bookmark)
if let originalBookmark = self?.originalBookmark, !OCBookmarkManager.shared.updateBookmark(originalBookmark) {
Log.error("Changes to \(originalBookmark) not saved as it's not tracked by OCBookmarkManager!")
}

done()
}
})
} else {
OnMainThread {
hudCompletion({
if let issue = issue {
self?.bookmark?.authenticationData = nil

IssuesCardViewController.present(on: strongSelf, issue: issue, completion: { [weak self, weak issue] (response) in
switch response {
case .cancel:
issue?.reject()

case .approve:
issue?.approve()
self?.handleContinue()

case .dismiss: break
}
})
} else {
strongSelf.presentingViewController?.dismiss(animated: true, completion: nil)
}
})
}
}
} else {
hudCompletion({ [weak self] in
if let strongSelf = self {
strongSelf.handleContinue()
}
})
}
}
} else {
hudCompletion({ [weak self] in
if let strongSelf = self {
strongSelf.handleContinue()
}
})
}
}

// MARK: - Update section and row composition
Expand Down Expand Up @@ -917,6 +987,13 @@ extension OCClassSettingsIdentifier {
extension OCClassSettingsKey {
static let bookmarkDefaultURL = OCClassSettingsKey("default-url")
static let bookmarkURLEditable = OCClassSettingsKey("url-editable")
static let prepopulation = OCClassSettingsKey("prepopulation")
}

enum BookmarkPrepopulationMethod : String {
case doNot
case streaming
case split
}

extension BookmarkViewController : OCClassSettingsSupport {
Expand Down Expand Up @@ -946,6 +1023,27 @@ extension BookmarkViewController : OCClassSettingsSupport {
.description : "Controls whether the server URL in the text field during the creation of new bookmarks can be changed.",
.category : "Bookmarks",
.status : OCClassSettingsKeyStatus.supported
],

.prepopulation : [
.type : OCClassSettingsMetadataType.string,
.description : "Controls prepopulation of the local database with the full item set during account setup.",
.category : "Bookmarks",
.status : OCClassSettingsKeyStatus.supported,
.possibleValues : [
[
OCClassSettingsMetadataKey.description : "No prepopulation. Request the contents of every folder individually.",
OCClassSettingsMetadataKey.value : BookmarkPrepopulationMethod.doNot.rawValue
],
[
OCClassSettingsMetadataKey.description : "Parse the prepopulation metadata while receiving it.",
OCClassSettingsMetadataKey.value : BookmarkPrepopulationMethod.streaming.rawValue
],
[
OCClassSettingsMetadataKey.description : "Parse the prepopulation metadata after receiving it as a whole.",
OCClassSettingsMetadataKey.value : BookmarkPrepopulationMethod.split.rawValue
]
]
]
]
}
Expand Down
4 changes: 4 additions & 0 deletions ownCloud/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@
"Fetching user information…" = "Fetching user information…";
"Updating connection…" = "Updating connection…";

"Preparing account" = "Preparing account";
"Please wait…" = "Please wait…";
"Skip" = "Skip";

"Missing hostname" = "Missing hostname";
"The entered URL does not include a hostname." = "The entered URL does not include a hostname.";
"Add account" = "Add account";
Expand Down
Loading

0 comments on commit 69eeaf2

Please sign in to comment.