-
Notifications
You must be signed in to change notification settings - Fork 668
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
macOS: Use local socket to communicate with finder extension
- Loading branch information
Showing
16 changed files
with
627 additions
and
737 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
311 changes: 170 additions & 141 deletions
311
shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSync.m
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/FinderSyncExt-Bridging-Header.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,5 @@ | ||
// | ||
// Use this file to import your target's public headers that you would like to expose to Swift. | ||
// | ||
|
||
#import "SyncClient.h" |
67 changes: 67 additions & 0 deletions
67
shell_integration/MacOSX/OwnCloudFinderSync/FinderSyncExt/LineProcessorV1.swift
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,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) | ||
} | ||
} | ||
} |
Oops, something went wrong.