Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 6808431
Author: Felix Schwarz <[email protected]>
Date:   Thu Jan 31 11:05:17 2019 +0100

    - Single item queries: take into account that if items are moved on the server, and they haven't come into view at their new location yet, they may temporarily appear as removed

commit aaaf9be
Merge: 538c6ac dd45ed0
Author: Felix Schwarz <[email protected]>
Date:   Wed Jan 30 21:30:56 2019 +0100

    Merge remote-tracking branch 'origin/master' into develop

commit 538c6ac
Author: Felix Schwarz <[email protected]>
Date:   Wed Jan 30 21:27:58 2019 +0100

    - OCCoreServerStatusSignalProvider
            - new name for OCCoreMaintenanceModeStatusSignalProvider
            - added handling and automatic recovery from "Connection refused" errors with custom status message
    - OCConnection
            - extension of delegate method for connection request instructions
    - OCCore
            - check for "connection refused" errors, reporting and automatic recovery using OCCoreServerStatusSignalProvider

commit dd45ed0
Author: Javier Gonzalez <[email protected]>
Date:   Wed Jan 30 20:52:41 2019 +0100

    - Added th-TH to the .tx config (#39)

    - Updated the th translations pushed recently to the right folder

commit bf2fdf0
Author: Felix Schwarz <[email protected]>
Date:   Wed Jan 30 17:21:59 2019 +0100

    - OCCore+ItemList
            - preserve LocalID (and local copies) when files are moved on the server by looking up the fileID of supposedly new items (previously would create a new localID for the moved item)
            - new OCDatabase method for retrieving items with a particular fileID, even it is was previously marked as deleted (quite common with certain move operations on the server)
    - OCCore+ItemUpdates
            - fixes for single-item queries
            - single-item queries now also use LocalID in addition to the path
    - Bookmarks
            - OCBookmark: new OCBookmarkUpdatedNotification notification so any part of the SDK can request that a particular bookmark's data be persisted if necessary
            - OCBookmarkManager: now listens for OCBookmarkUpdatedNotification and saves the bookmark if it receives a notification for a bookmark it manages
            - OCConnection: posts OCBookmarkUpdatedNotification if users approve a changed certificate so the changes are persisted

commit 613bf6c
Author: Felix Schwarz <[email protected]>
Date:   Wed Jan 30 13:23:38 2019 +0100

    - Sync Engine
            - changed cancellable flag of NSProgress objects for all actions, so that only up- and downloads are cancellable until the other actions fully support that
            - sync engine now blocks the OCCore queue while running
            - added sync journal dumps before and after entering processing, and after the processing of every journal entry (debug log-level only)
    - Upgraded most table schemas - especially metaData and syncJournal - from "INTEGER PRIMARY KEY" to "INTEGER PRIMARY KEY AUTOINCREMENT" to avoid the reuse of IDs by SQLite (including migrations)

commit 4195955
Author: ownClouders <[email protected]>
Date:   Wed Jan 30 09:48:03 2019 +0000

    [tx] updated from transifex

commit ed2969d
Author: Felix Schwarz <[email protected]>
Date:   Tue Jan 29 11:11:46 2019 +0100

    - OCCore
            - fixed order in which progress is removed and the observers on progress are removed
            - made sure observers aren't removed from inside -observeValueForKeyPath:
    - OCSyncActionDownload and OCSyncActionUpload
            - now registered the sync record's progress instead of the connection's

commit 4617829
Author: ownClouders <[email protected]>
Date:   Tue Jan 29 05:00:38 2019 +0000

    [tx] updated from transifex

commit 36e4ea5
Author: Felix Schwarz <[email protected]>
Date:   Tue Jan 29 00:25:00 2019 +0100

    - Add OCItem.cloudStatus computed property indicating the cloud status of the item
    - Fix OCCore progress tracking bugs

commit ab78777
Author: Felix Schwarz <[email protected]>
Date:   Mon Jan 28 10:30:04 2019 +0100

    - OCActivity
            - fill API gaps
            - implement missing pieces of OCSyncRecordActivity
            - OCCoreItemListTask now is an OCActivitySource, OCCore+ItemList now emits activity updates
    - OCCore
            - use localID instead of fileID to track progress on a per-item basis
            - now posts OCCoreItemBeginsHavingProgress and OCCoreItemStopsHavingProgress notifications when an item starts having progress, and when the last progress has completed for an item
            - add localID property to NSProgress
    - Sync Engine
            - OCSyncAction now properly serialized/deserializes the localizedDescription
            - gated access to OCDatabase for adding, updating and removing SyncRecords, used to emit activity updates

commit 8dcda9c
Author: Felix Schwarz <[email protected]>
Date:   Sat Jan 26 16:48:25 2019 +0100

    - New activity tracking subsystem
            - OCActivityManager
                    - keeps track of activities
                    - coalesces updates for maximum performance
                    - relays activity information to main thread
            - OCActivity
                    - describes an activity with description, status message, progress
                    - provides cancel option
                    - can contain an OCIssue for error resolution
            - OCActivityUpdate
                    - encapsulates activity update information
                    - allows publishing and unpublishing activities
                    - allows update of individual activity properties
            - simplified creation of OCActivity objects and updates via the OCActivitySource protocol
    - OCConnection
            - trying to upload a non-existant file now results in an error
            - extended internal error checks in uploadFileFromURL:
    - OCCore+ItemList
            - experimental supply of activity information for background updates
    - OCCore+LocalImport
            - addition of a import transformations
            - used by the FileProvider to transform select bundle document formats into ZIP archives on the fly
    - OCSyncRecord
            - adding OCActivitySource conformance

commit 5c8ea2d
Author: ownClouders <[email protected]>
Date:   Fri Jan 25 05:00:37 2019 +0000

    [tx] updated from transifex

commit 58d5397
Author: Felix Schwarz <[email protected]>
Date:   Thu Jan 24 17:11:41 2019 +0100

    - Fix duplicate item issue (placeholder + item from server) in case of copying a folder while a query retrieves the copied file briefl before copying returns
    - Switched OCSyncExec / OCSyncExecDone to semaphores for increased efficiency
    - Extended TestTools.databaseSanityCheckFilter with dumping the creation history stacktrace of items raising an error

commit af00e58
Author: Felix Schwarz <[email protected]>
Date:   Thu Jan 24 16:09:13 2019 +0100

    - Make OCBookmarkManager.bookmarks a non-mutable array

commit 84427e9
Author: Javier Gonzalez <[email protected]>
Date:   Thu Jan 24 13:12:07 2019 +0100

    Added the following languages: (#38)

    cs_CZ de de_DE en_GB ko mk nb_NO nn_NO pt_BR pt_PT ru sq th_TH zh_CN

commit 72318f0
Author: ownClouders <[email protected]>
Date:   Thu Jan 24 05:03:17 2019 +0000

    [tx] updated from transifex

commit 8183876
Author: Felix Schwarz <[email protected]>
Date:   Wed Jan 23 17:30:56 2019 +0100

    - Introducing OCLocalID
            - an ID issues locally by the SDK for every item that does not change for the lifetime of the item (including transitions from placeholder to item on the server)
            - added OCItem.localID and OCItem.parentLocalID properties (+ serialization/deserialization)
            - added +[OCItem generateNewLocalID] for the generation of new localIDs
            - updated OCSyncActions
                    - greatly simplified OCSyncActionUpload as files no longer need to be moved when transitioning from placeholder to item on the server
            - updated OCDatabase
                    - updated metadata table schema with localID column
                    - updated syncRecords table schema with localID column
                    - updated methods accordingly
                    - new OCDatabase.itemFilter API to run on all items as they are added, updated and removed from the database
            - updated CoreTests and CoreSyncTests
                    - added localID sanitizer to the OCDatabase of all tests (using new OCDatabase.itemFilter feature)
                    - updated all tests to verify that localIDs stay intact across actions and queries
            - update OCCoreItemList to also offer sets and dictionaries of items by localID
            - drafted new API for OCSyncAction to alllow coalescing of unexecuted sync records using the localID as connecting element
            - upgraded query updates to detect moved files using the localID of an updated item
            - changed FileProvider-related methods to use the localID instead of the fileID as NSFileProviderItemIdentifier
  • Loading branch information
felix-schwarz committed Feb 1, 2019
1 parent dd45ed0 commit 3a0d1db
Show file tree
Hide file tree
Showing 63 changed files with 2,433 additions and 359 deletions.
76 changes: 50 additions & 26 deletions ownCloudSDK.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

91 changes: 91 additions & 0 deletions ownCloudSDK/Activity/OCActivity.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//
// OCActivity.h
// ownCloudSDK
//
// Created by Felix Schwarz on 24.01.19.
// Copyright © 2019 ownCloud GmbH. All rights reserved.
//

/*
* Copyright (C) 2019, ownCloud GmbH.
*
* This code is covered by the GNU Public License Version 3.
*
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*
*/

#import <Foundation/Foundation.h>
#import "OCIssue.h"

typedef NSString* OCActivityIdentifier;

typedef NS_ENUM(NSUInteger, OCActivityState)
{
OCActivityStatePending, //!< Activity is pending
OCActivityStateRunning, //!< Activity is being executed
OCActivityStatePaused, //!< Activity is paused
OCActivityStateFailed //!< Activity has failed (and optionally awaits resolution)
};

NS_ASSUME_NONNULL_BEGIN

@class OCActivity;
@class OCActivityUpdate;

@protocol OCActivitySource

@required
@property(readonly,nonatomic) OCActivityIdentifier activityIdentifier; //!< Returns an identifier uniquely identifying the source's activity.

@optional
- (OCActivity *)provideActivity; //!< Returns a new instance of OCActivity representing the source's activity.

@end

@interface OCActivity : NSObject
{
OCActivityIdentifier _identifier;

OCActivityState _state;

NSInteger _ranking;

NSString *_localizedDescription;
NSString *_localizedStatusMessage;

NSProgress *_progress;

OCIssue *_issue;

BOOL _isCancellable;
}

@property(strong) OCActivityIdentifier identifier; //!< Identifier uniquely identifying an activity

@property(assign,nonatomic) OCActivityState state; //!< State of the activity

@property(assign) NSInteger ranking; //!< Lower numbers for higher prioritized items

@property(strong) NSString *localizedDescription; //!< Localized description of the activity (f.ex. "Copying party.jpg to Photos..")
@property(nullable,strong) NSString *localizedStatusMessage; //!< Localized message describing the status of the activity (f.ex. "Waiting for response..")

@property(nullable,strong) NSProgress *progress; //!< Progress information on the activity

@property(nullable,strong) OCIssue *issue; //!< If .state is failed, an issue that can be used to resolve the failure (optional)

@property(assign) BOOL isCancellable; //!< If YES, the activity can be cancelled

+ (instancetype)withIdentifier:(OCActivityIdentifier)identifier description:(NSString *)description statusMessage:(nullable NSString *)statusMessage ranking:(NSInteger)ranking;

- (instancetype)initWithIdentifier:(OCActivityIdentifier)identifier;

- (NSError *)applyUpdate:(OCActivityUpdate *)update; //!< Applies an update to the activity. Returns nil if the update could be applied, an error otherwise.
- (NSError *)applyValue:(nullable id <NSObject>)value forKeyPath:(NSString *)keyPath; //!< Applies a new value to a keypath (entrypoint for subclassing)

- (void)cancel;

@end

NS_ASSUME_NONNULL_END
103 changes: 103 additions & 0 deletions ownCloudSDK/Activity/OCActivity.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
//
// OCActivity.m
// ownCloudSDK
//
// Created by Felix Schwarz on 24.01.19.
// Copyright © 2019 ownCloud GmbH. All rights reserved.
//

/*
* Copyright (C) 2019, ownCloud GmbH.
*
* This code is covered by the GNU Public License Version 3.
*
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*
*/

#import "OCActivity.h"
#import "OCActivityUpdate.h"
#import "NSError+OCError.h"

@implementation OCActivity

@synthesize identifier = _identifier;

@synthesize ranking = _ranking;

@synthesize localizedDescription = _localizedDescription;
@synthesize localizedStatusMessage = _localizedStatusMessage;

@synthesize progress = _progress;

@synthesize issue = _issue;

@synthesize isCancellable = _isCancellable;

+ (instancetype)withIdentifier:(OCActivityIdentifier)identifier description:(NSString *)description statusMessage:(nullable NSString *)statusMessage ranking:(NSInteger)ranking
{
OCActivity *activity = [OCActivity new];

activity.identifier = identifier;
activity.localizedDescription = description;
activity.localizedStatusMessage = statusMessage;
activity.ranking = ranking;

return (activity);
}

- (instancetype)initWithIdentifier:(OCActivityIdentifier)identifier
{
if ((self = [super init]) != nil)
{
_identifier = identifier;
}

return (self);
}

- (void)cancel
{
if (_isCancellable)
{
[self.progress cancel];
}
}

- (NSError *)applyUpdate:(OCActivityUpdate *)update
{
__block NSError *error = nil;

if (update.type != OCActivityUpdateTypeProperty)
{
return (OCError(OCErrorInsufficientParameters));
}

[update.updatesByKeyPath enumerateKeysAndObjectsUsingBlock:^(NSString * _Nonnull keyPath, id<NSObject> _Nonnull value, BOOL * _Nonnull stop) {
NSError *applicationError = nil;

if ([value isEqual:[NSNull null]])
{
value = nil;
}

if ((applicationError = [self applyValue:value forKeyPath:keyPath]) != nil)
{
error = applicationError;
*stop = YES;
}
}];

return (error);
}

- (NSError *)applyValue:(nullable id <NSObject>)value forKeyPath:(NSString *)keyPath
{
// Entrypoint for subclassing
[self setValue:value forKeyPath:keyPath];

return (nil);
}

@end
47 changes: 47 additions & 0 deletions ownCloudSDK/Activity/OCActivityManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// OCActivityManager.h
// ownCloudSDK
//
// Created by Felix Schwarz on 25.01.19.
// Copyright © 2019 ownCloud GmbH. All rights reserved.
//

/*
* Copyright (C) 2019, ownCloud GmbH.
*
* This code is covered by the GNU Public License Version 3.
*
* For distribution utilizing Apple mechanisms please see https://owncloud.org/contribute/iOS-license-exception/
* You should have received a copy of this license along with this program. If not, see <http://www.gnu.org/licenses/gpl-3.0.en.html>.
*
*/

#import <Foundation/Foundation.h>
#import "OCActivity.h"
#import "OCLogTag.h"

NS_ASSUME_NONNULL_BEGIN

@interface OCActivityManager : NSObject <OCLogTagging>

#pragma mark - Init
- (instancetype)initWithUpdateNotificationName:(NSString *)updateNotificationName;

#pragma mark - Update notifications
@property(readonly,nonatomic) NSNotificationName activityUpdateNotificationName;

#pragma mark - Access
@property(readonly,nonatomic) NSArray <OCActivity *> *activities;
- (nullable OCActivity *)activityForIdentifier:(OCActivityIdentifier)activityIdentifier;

#pragma mark - Updating
- (void)update:(OCActivityUpdate *)update;

@end

extern NSString *OCActivityManagerNotificationUserInfoUpdatesKey; //!< UserInfo key that contains an array of dictionaries providing info on the activity updates:

extern NSString *OCActivityManagerUpdateTypeKey; //!< the type of the update [OCActivityUpdateType]
extern NSString *OCActivityManagerUpdateActivityKey; //!< the updated activity object [OCActivity]

NS_ASSUME_NONNULL_END
Loading

0 comments on commit 3a0d1db

Please sign in to comment.