-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into updateSubmodule
- Loading branch information
Showing
44 changed files
with
1,566 additions
and
841 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
shell_integration/MacOSX/OwnCloud.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/LineProcessor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#import "SyncClient.h" | ||
|
||
#ifndef LineProcessor_h | ||
#define LineProcessor_h | ||
|
||
/// This class is in charge of dispatching all work that must be done on the UI side of the extension. | ||
/// Tasks are dispatched on the main UI thread for this reason. | ||
/// | ||
/// These tasks are parsed from byte data (UTF9 strings) acquired from the socket; look at the | ||
/// LocalSocketClient for more detail on how data is read from and written to the socket. | ||
|
||
@interface LineProcessor : NSObject | ||
@property(nonatomic, weak)id<SyncClientDelegate> delegate; | ||
|
||
- (instancetype)initWithDelegate:(id<SyncClientDelegate>)delegate; | ||
- (void)process:(NSString*)line; | ||
|
||
@end | ||
#endif /* LineProcessor_h */ |
99 changes: 99 additions & 0 deletions
99
shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/LineProcessor.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "LineProcessor.h" | ||
|
||
@implementation LineProcessor | ||
|
||
-(instancetype)initWithDelegate:(id<SyncClientDelegate>)delegate | ||
{ | ||
NSLog(@"Init line processor with delegate."); | ||
self.delegate = delegate; | ||
return self; | ||
} | ||
|
||
-(void)process:(NSString*)line | ||
{ | ||
NSLog(@"Processing line: %@", line); | ||
NSArray *split = [line componentsSeparatedByString:@":"]; | ||
NSString *command = [split objectAtIndex:0]; | ||
|
||
NSLog(@"Command: %@", command); | ||
|
||
if([command isEqualToString:@"STATUS"]) { | ||
NSString *result = [split objectAtIndex:1]; | ||
NSArray *pathSplit = [split subarrayWithRange:NSMakeRange(2, [split count] - 2)]; // Get everything after location 2 | ||
NSString *path = [pathSplit componentsJoinedByString:@":"]; | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
NSLog(@"Setting result %@ for path %@", result, path); | ||
[self.delegate setResultForPath:path result:result]; | ||
}); | ||
} else if([command isEqualToString:@"UPDATE_VIEW"]) { | ||
NSString *path = [split objectAtIndex:1]; | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
NSLog(@"Re-fetching filename cache for path %@", path); | ||
[self.delegate reFetchFileNameCacheForPath:path]; | ||
}); | ||
} else if([command isEqualToString:@"REGISTER_PATH"]) { | ||
NSString *path = [split objectAtIndex:1]; | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
NSLog(@"Registering path %@", path); | ||
[self.delegate registerPath:path]; | ||
}); | ||
} else if([command isEqualToString:@"UNREGISTER_PATH"]) { | ||
NSString *path = [split objectAtIndex:1]; | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
NSLog(@"Unregistering path %@", path); | ||
[self.delegate unregisterPath:path]; | ||
}); | ||
} else if([command isEqualToString:@"GET_STRINGS"]) { | ||
// BEGIN and END messages, do nothing. | ||
return; | ||
} else if([command isEqualToString:@"STRING"]) { | ||
NSString *key = [split objectAtIndex:1]; | ||
NSString *value = [split objectAtIndex:2]; | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
NSLog(@"Setting string %@ to value %@", key, value); | ||
[self.delegate setString:key value:value]; | ||
}); | ||
} else if([command isEqualToString:@"GET_MENU_ITEMS"]) { | ||
if([[split objectAtIndex:1] isEqualToString:@"BEGIN"]) { | ||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
NSLog(@"Resetting menu items."); | ||
[self.delegate resetMenuItems]; | ||
}); | ||
} else { | ||
NSLog(@"Emitting menu has completed signal."); | ||
[self.delegate menuHasCompleted]; | ||
} | ||
} else if([command isEqualToString:@"MENU_ITEM"]) { | ||
NSDictionary *item = @{@"command": [split objectAtIndex:1], @"flags": [split objectAtIndex:2], @"text": [split objectAtIndex:3]}; | ||
|
||
dispatch_async(dispatch_get_main_queue(), ^{ | ||
NSLog(@"Adding menu item with command %@, flags %@, and text %@", [split objectAtIndex:1], [split objectAtIndex:2], [split objectAtIndex:3]); | ||
[self.delegate addMenuItem:item]; | ||
}); | ||
} else { | ||
// LOG UNKOWN COMMAND | ||
NSLog(@"Unkown command: %@", command); | ||
} | ||
} | ||
|
||
@end |
62 changes: 62 additions & 0 deletions
62
shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/LocalSocketClient.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#import "LineProcessor.h" | ||
|
||
#ifndef LocalSocketClient_h | ||
#define LocalSocketClient_h | ||
#define BUF_SIZE 4096 | ||
|
||
/// Class handling asynchronous communication with a server over a local UNIX socket. | ||
/// | ||
/// The implementation uses a `DispatchQueue` and `DispatchSource`s to handle asynchronous communication and thread | ||
/// safety. The delegate that handles the line-decoding is **not invoked on the UI thread**, but the (random) thread associated | ||
/// with the `DispatchQueue`. | ||
/// | ||
/// If any UI work needs to be done, the `LineProcessor` class dispatches this work on the main queue (so the UI thread) itself. | ||
/// | ||
/// Other than the `init(withSocketPath:, lineProcessor)` and the `start()` method, all work is done "on the dispatch | ||
/// queue". The `localSocketQueue` is a serial dispatch queue (so a maximum of 1, and only 1, task is run at any | ||
/// moment), which guarantees safe access to instance variables. Both `askOnSocket(_:, query:)` and | ||
/// `askForIcon(_:, isDirectory:)` will internally dispatch the work on the `DispatchQueue`. | ||
/// | ||
/// Sending and receiving data to and from the socket, is handled by two `DispatchSource`s. These will run an event | ||
/// handler when data can be read from resp. written to the socket. These handlers will also be run on the | ||
/// `DispatchQueue`. | ||
|
||
@interface LocalSocketClient : NSObject | ||
|
||
@property NSString* socketPath; | ||
@property LineProcessor* lineProcessor; | ||
@property int sock; | ||
@property dispatch_queue_t localSocketQueue; | ||
@property dispatch_source_t readSource; | ||
@property dispatch_source_t writeSource; | ||
@property NSMutableData* inBuffer; | ||
@property NSMutableData* outBuffer; | ||
|
||
- (instancetype)init:(NSString*)socketPath lineProcessor:(LineProcessor*)lineProcessor; | ||
- (BOOL)isConnected; | ||
- (void)start; | ||
- (void)restart; | ||
- (void)closeConnection; | ||
- (NSString*)strErr; | ||
- (void)askOnSocket:(NSString*)path query:(NSString*)verb; | ||
- (void)askForIcon:(NSString*)path isDirectory:(BOOL)isDirectory; | ||
- (void)readFromSocket; | ||
- (void)writeToSocket; | ||
- (void)processInBuffer; | ||
|
||
@end | ||
#endif /* LocalSocketClient_h */ |
Oops, something went wrong.