請益一下與軟體 License 標記有關的問題。
Closed this issue · 2 comments
ShikiSuen commented
ShikiSuen commented
扣貼一份在這邊,不是最終版本:
// (c) 2021 and onwards The vChewing Project (MIT-NTL License).
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// Additional licenses may apply by Yahoo Kimo.
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol KimoUserDataReaderService
- (BOOL)userPhraseDBCanProvideService;
- (int)userPhraseDBNumberOfRow;
- (NSDictionary *)userPhraseDBDictionaryAtRow:(int)row;
- (NSArray *)userPhraseDBReadingsForPhrase:(NSString *)phrase;
- (bool)exportUserPhraseDBToFile:(NSString *)path;
@end
/// 不要理會 Xcode 對 NSDistantObject 的過期狗吠。
/// 奇摩輸入法是用 NSConnection 寫的,
/// 換用 NSXPCConnection 只會製造更多的問題。
@interface KimoCommunicator : NSObject
/// 嘗試連線。
- (bool)connect;
/// 偵測連線是否有效。
- (bool)hasValidConnection;
/// 斷開連線。
- (void)disconnect;
// Conforming KimoUserDataReaderService protocol.
- (BOOL)userPhraseDBCanProvideService;
- (int)userPhraseDBNumberOfRow;
- (NSDictionary *)userPhraseDBDictionaryAtRow:(int)row;
- (NSArray *)userPhraseDBReadingsForPhrase:(NSString *)phrase;
- (bool)exportUserPhraseDBToFile:(NSString *)path;
@end
NS_ASSUME_NONNULL_END
// (c) 2021 and onwards The vChewing Project (MIT-NTL License).
// ====================
// This code is released under the MIT license (SPDX-License-Identifier: MIT)
// Additional licenses may apply by Yahoo Kimo.
#import "KimoCommunicator.h"
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
#define kYahooKimoDataObjectConnectionName @"YahooKeyKeyService"
@implementation KimoCommunicator {
id _xpcConnection;
}
/// 解構。
- (void)dealloc {
[self disconnect];
}
/// 斷開連線。
- (void)disconnect {
_xpcConnection = nil;
}
/// 嘗試連線。
- (bool)connect {
_xpcConnection = [NSConnection rootProxyForConnectionWithRegisteredName:kYahooKimoDataObjectConnectionName host:nil];
BOOL result = false;
if (_xpcConnection) {
result = true;
}
if (result) [_xpcConnection setProtocolForProxy:@protocol(KimoUserDataReaderService)];
NSLog(@"vChewingDebug: Connection successful. Available data amount: %d.\n", [_xpcConnection userPhraseDBNumberOfRow]);
return result;
}
/// 偵測連線是否有效。
- (bool)hasValidConnection {
BOOL result = false;
if (_xpcConnection) {
result = true;
}
return result;
}
- (BOOL)userPhraseDBCanProvideService {
return [self hasValidConnection] ? [_xpcConnection userPhraseDBCanProvideService] : NO;
}
- (int)userPhraseDBNumberOfRow {
return [self hasValidConnection] ? [_xpcConnection userPhraseDBNumberOfRow] : 0;
}
- (NSDictionary *)userPhraseDBDictionaryAtRow:(int)row {
return [self hasValidConnection] ? [_xpcConnection userPhraseDBDictionaryAtRow:row] : [NSDictionary alloc];
}
- (NSArray *)userPhraseDBReadingsForPhrase:(NSString *)phrase {
return [self hasValidConnection] ? [_xpcConnection userPhraseDBReadingsForPhrase:phrase] : [NSArray alloc];
}
- (bool)exportUserPhraseDBToFile:(NSString *)path {
return [self hasValidConnection] ? [_xpcConnection exportUserPhraseDBToFile:path] : NO;
}
@end
ShikiSuen commented
因為這個問題不是什麼發生在奇摩這邊必須要解決的軟體問題,所以我先把工單關掉了。