forked from gnachman/iTerm2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiTermAutomaticProfileSwitcher.h
64 lines (47 loc) · 2.2 KB
/
iTermAutomaticProfileSwitcher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// iTermAutomaticProfileSwitching.h
// iTerm2
//
// Created by George Nachman on 2/28/16.
//
//
#import <Foundation/Foundation.h>
#import "ProfileModel.h"
NS_ASSUME_NONNULL_BEGIN
// Describes all the possible state of a profile needed to restore it.
@interface iTermSavedProfile : NSObject
@property(nonatomic, copy, nullable) Profile *profile;
@property(nonatomic, copy) Profile *originalProfile;
@property(nonatomic, assign) BOOL isDivorced;
@property(nonatomic, retain, nullable) NSMutableSet *overriddenFields;
@end
// The session that uses automatic profile switching should implement this protocol.
@protocol iTermAutomaticProfileSwitcherDelegate<NSObject>
// Make the |savedProfile| into the current profile, respecting overridden fields, etc.
- (void)automaticProfileSwitcherLoadProfile:(iTermSavedProfile *)savedProfile;
// Returns the current profile, including local changes.
- (Profile *)automaticProfileSwitcherCurrentProfile;
// Returns the current profile. Only the name and GUID are needed.
- (iTermSavedProfile *)automaticProfileSwitcherCurrentSavedProfile;
// Returns all profiles in user defaults. Exposed for testing.
- (NSArray<Profile *> *)automaticProfileSwitcherAllProfiles;
// Returns the session's name for logging.
- (NSString *)automaticProfileSwitcherSessionName;
@end
// This class encapsulates the logic needed by automatic profile switching.
@interface iTermAutomaticProfileSwitcher : NSObject
// You should set this or nothing will work.
@property(nonatomic, weak) id<iTermAutomaticProfileSwitcherDelegate> delegate;
@property(nonatomic, readonly) NSString *profileStackString; // For tests
- (instancetype)initWithDelegate:(id<iTermAutomaticProfileSwitcherDelegate>)delegate NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithDelegate:(id<iTermAutomaticProfileSwitcherDelegate>)delegate
savedState:(NSDictionary *)savedState;
- (instancetype)init NS_UNAVAILABLE;
- (NSDictionary *)savedState;
// Call this when the hostname, username, or path changes.
- (void)setHostname:(nullable NSString *)hostname
username:(nullable NSString *)username
path:(nullable NSString *)path
job:(nullable NSString *)job;
@end
NS_ASSUME_NONNULL_END