Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Work/macos use local socket #9214

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ option(BUILD_GUI "BUILD_GUI" ON)
set(VIRTUAL_FILE_SYSTEM_PLUGINS suffix win CACHE STRING "Name of internal plugin in src/libsync/vfs or the locations of virtual file plugins")

if(APPLE)
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (including a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
set( SOCKETAPI_TEAM_IDENTIFIER_PREFIX "" CACHE STRING "SocketApi prefix (without a following dot) that must match the codesign key's TeamIdentifier/Organizational Unit" )
endif()

if(BUILD_CLIENT)
Expand Down
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>
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@

#import <Cocoa/Cocoa.h>
#import <FinderSync/FinderSync.h>
#import "SyncClientProxy.h"

@interface FinderSync : FIFinderSync <SyncClientProxyDelegate>
{
SyncClientProxy *_syncClientProxy;
NSMutableSet *_registeredDirectories;
NSString *_shareMenuTitle;
NSMutableDictionary *_strings;
NSMutableArray *_menuItems;
#import "FinderSyncExt-Swift.h"
#import "SyncClient.h"

@interface FinderSync : FIFinderSync <SyncClientDelegate> {
NSMutableSet *_registeredDirectories;
NSString *_shareMenuTitle;
NSMutableDictionary *_strings;
NSMutableArray *_menuItems;
NSCondition *_menuIsComplete;
}

@property LineProcessorV1 *v1LineProcessor;
@property LocalSocketClient *localSocketClient;

@end
311 changes: 170 additions & 141 deletions shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//
// Use this file to import your target's public headers that you would like to expose to Swift.
//

#import "SyncClient.h"
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<true/>
<key>com.apple.security.application-groups</key>
<array>
<string>$(OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX)$(OC_APPLICATION_REV_DOMAIN)</string>
<string>$(OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX).$(OC_APPLICATION_REV_DOMAIN)</string>
</array>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>SocketApiPrefix</key>
<string>$(OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX)$(OC_APPLICATION_REV_DOMAIN)</string>
<string>$(OC_SOCKETAPI_TEAM_IDENTIFIER_PREFIX).$(OC_APPLICATION_REV_DOMAIN)</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// LineProcessorV1.swift
// FinderSyncExt
//
// Created by Erik Verbruggen <[email protected]> on 06-11-21.
//

import Foundation
import OSLog

class LineProcessorV1: NSObject, LineProcessor {
let delegate: SyncClientDelegate

@objc init(withDelegate delegate: SyncClientDelegate) {
self.delegate = delegate
}

private func log(_ str: String, type logType: OSLogType) {
// We cannot use OSLog's Logger class, because a lot of methods are only available in macOS 11.0 or higher.
os_log("%@", type: logType, str)
}

/// Processes a line, where the trailing \n has already been stripped
func process(line: String) {

self.log("Processing line '\(line)'", type: .debug)
let chunks = line.components(separatedBy: ":")
let command = chunks[0]

switch command {
case "STATUS":
let result = chunks[1]
let path = chunks.suffix(from: 2).joined(separator: ":")
DispatchQueue.main.async { self.delegate.setResultForPath(path, result: result) }
case "UPDATE_VIEW":
let path = chunks[1]
DispatchQueue.main.async { self.delegate.reFetchFileNameCache(forPath: path) }
case "REGISTER_PATH":
let path = chunks[1]
DispatchQueue.main.async { self.delegate.registerPath(path) }
case "UNREGISTER_PATH":
let path = chunks[1]
DispatchQueue.main.async { self.delegate.unregisterPath(path) }
case "GET_STRINGS":
// BEGIN and END messages, do nothing.
break
case "STRING":
DispatchQueue.main.async { self.delegate.setString(chunks[1], value: chunks[2]) }
case "GET_MENU_ITEMS":
if chunks[1] == "BEGIN" {
DispatchQueue.main.async { self.delegate.resetMenuItems() }
} else {
// Do NOT run this on the main queue! It might be blocked waiting for the menu to be completed.
delegate.menuHasCompleted()
}
case "MENU_ITEM":
let item = [
"command" : chunks[1],
"flags" : chunks[2],
"text" : chunks[3]
]
DispatchQueue.main.async { self.delegate.addMenuItem(item) }
default:
self.log("Unknown command '\(command)'", type: .error)
}
}
}
Loading