|
8 | 8 |
|
9 | 9 | #import "KBAppExtension.h" |
10 | 10 |
|
11 | | -#import "KBService.h" |
12 | 11 | #import "KBPGPEncryptActionView.h" |
13 | 12 | #import "KBWorkspace.h" |
14 | 13 | #import "KBPGPEncrypt.h" |
15 | 14 | #import "KBWork.h" |
| 15 | +#import "KBRPClient.h" |
16 | 16 |
|
17 | 17 | #import <CocoaLumberjack/CocoaLumberjack.h> |
18 | 18 |
|
19 | 19 | @interface KBAppExtension () |
20 | | -@property (nonatomic) KBService *service; |
| 20 | +@property (nonatomic) KBRPClient *client; |
21 | 21 | @end |
22 | 22 |
|
23 | 23 | @implementation KBAppExtension |
24 | 24 |
|
25 | | -- (KBService *)service { |
26 | | - if (!_service) { |
27 | | - KBEnvConfig *config = [KBEnvConfig loadFromUserDefaults:[KBWorkspace userDefaults]]; |
28 | | - _service = [[KBService alloc] initWithConfig:config]; |
| 25 | +- (KBRPClient *)client { |
| 26 | + if (!_client) { |
| 27 | + KBEnvConfig *config = [KBEnvConfig envConfigFromUserDefaults:[KBWorkspace userDefaults]]; |
| 28 | + _client = [[KBRPClient alloc] initWithConfig:config]; |
29 | 29 | } |
30 | | - return _service; |
| 30 | + return _client; |
31 | 31 | } |
32 | 32 |
|
33 | 33 | - (NSView *)encryptViewWithExtensionItem:(NSExtensionItem *)extensionItem completion:(KBOnExtension)completion { |
34 | 34 | KBPGPEncryptActionView *encryptView = [[KBPGPEncryptActionView alloc] initWithFrame:CGRectMake(0, 0, 400, 300)]; |
35 | 35 | encryptView.extensionItem = extensionItem; |
36 | | - encryptView.client = self.service.client; |
| 36 | + encryptView.client = self.client; |
37 | 37 | encryptView.completion = completion; |
38 | 38 | return encryptView; |
39 | 39 | } |
40 | 40 |
|
41 | 41 | - (void)encryptExtensionItem:(NSExtensionItem *)extensionItem usernames:(NSArray *)usernames sender:(id)sender completion:(KBOnExtension)completion { |
42 | 42 | KBPGPEncrypt *encrypt = [[KBPGPEncrypt alloc] init]; |
43 | | - KBRPClient *client = self.service.client; |
| 43 | + KBRPClient *client = self.client; |
44 | 44 | NSString *text = extensionItem.attributedContentText.string; |
45 | 45 | [encrypt encryptText:text usernames:usernames client:client sender:sender completion:^(KBWork *work) { |
46 | 46 | //NSError *error = [work error]; |
|
0 commit comments