Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Goetz <markus@woboq.com>2018-04-11 14:40:27 +0300
committerMarkus Goetz <markus@woboq.com>2018-04-12 14:12:42 +0300
commitaceff1f8632d159922d49dbcaa1aaf930a4a2fed (patch)
treeacf7cc789a48a34e450237367a31622578112f90 /shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/SyncClientProxy.m
parent113f56fdc5a895cb0893da89904d77374e1a7762 (diff)
macOS: Implement new dynamic Finder menu items #6328
Diffstat (limited to 'shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/SyncClientProxy.m')
-rw-r--r--shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/SyncClientProxy.m38
1 files changed, 25 insertions, 13 deletions
diff --git a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/SyncClientProxy.m b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/SyncClientProxy.m
index b7b64571f..656f77003 100644
--- a/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/SyncClientProxy.m
+++ b/shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/SyncClientProxy.m
@@ -27,7 +27,7 @@
- (instancetype)initWithDelegate:(id)arg1 serverName:(NSString*)serverName
{
self = [super init];
-
+
self.delegate = arg1;
_serverName = serverName;
_remoteEnd = nil;
@@ -41,20 +41,20 @@
{
if (_remoteEnd)
return;
-
+
// Lookup the server connection
NSConnection *conn = [NSConnection connectionWithRegisteredName:_serverName host:nil];
-
+
if (!conn) {
// Could not connect to the sync client
[self scheduleRetry];
return;
}
-
+
[[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(connectionDidDie:)
- name:NSConnectionDidDieNotification
- object:conn];
+ selector:@selector(connectionDidDie:)
+ name:NSConnectionDidDieNotification
+ object:conn];
NSDistantObject <ServerProtocol> *server = (NSDistantObject <ServerProtocol> *)[conn rootProxy];
assert(server);
@@ -71,7 +71,7 @@
// The server replied with the distant object that we will use for tx
_remoteEnd = (NSDistantObject <ChannelProtocol> *)tx;
[_remoteEnd setProtocolForProxy:@protocol(ChannelProtocol)];
-
+
// Everything is set up, start querying
[self askOnSocket:@"" query:@"GET_STRINGS"];
}
@@ -83,7 +83,7 @@
- (void)connectionDidDie:(NSNotification*)notification
{
-#pragma unused(notification)
+#pragma unused(notification)
_remoteEnd = nil;
[_delegate connectionDidDie];
@@ -95,11 +95,11 @@
- (void)sendMessage:(NSData*)msg
{
NSString *answer = [[NSString alloc] initWithData:msg encoding:NSUTF8StringEncoding];
-
- // Cut the trailing newline
+
+ // Cut the trailing newline. We always only receive one line from the client.
answer = [answer substringToIndex:[answer length] - 1];
NSArray *chunks = [answer componentsSeparatedByString: @":"];
-
+
if( [[chunks objectAtIndex:0] isEqualToString:@"STATUS"] ) {
NSString *result = [chunks objectAtIndex:1];
NSString *path = [chunks objectAtIndex:2];
@@ -123,6 +123,18 @@
// BEGIN and END messages, do nothing.
} else if( [[chunks objectAtIndex:0 ] isEqualToString:@"STRING"] ) {
[_delegate setString:[chunks objectAtIndex:1] value:[chunks objectAtIndex:2]];
+ } else if( [[chunks objectAtIndex:0 ] isEqualToString:@"GET_MENU_ITEMS"] ) {
+ if ([[chunks objectAtIndex:1] isEqualToString:@"BEGIN"]) {
+ [_delegate resetMenuItems];
+ } else if ([[chunks objectAtIndex:1] isEqualToString:@"END"]) {
+ // Don't do anything special, the askOnSocket call in FinderSync menuForMenuKind will return after this line
+ }
+ } else if( [[chunks objectAtIndex:0 ] isEqualToString:@"MENU_ITEM"] ) {
+ NSMutableDictionary *item = [[NSMutableDictionary alloc] init];
+ [item setValue:[chunks objectAtIndex:1] forKey:@"command"]; // e.g. "COPY_PRIVATE_LINK"
+ [item setValue:[chunks objectAtIndex:2] forKey:@"flags"]; // e.g. "d"
+ [item setValue:[chunks objectAtIndex:3] forKey:@"text"]; // e.g. "Copy private link to clipboard"
+ [_delegate addMenuItem:item];
} else {
NSLog(@"SyncState: Unknown command %@", [chunks objectAtIndex:0]);
}
@@ -131,7 +143,7 @@
- (void)askOnSocket:(NSString*)path query:(NSString*)verb
{
NSString *query = [NSString stringWithFormat:@"%@:%@\n", verb,path];
-
+
@try {
[_remoteEnd sendMessage:[query dataUsingEncoding:NSUTF8StringEncoding]];
} @catch(NSException* e) {