1 // 2 // KBEnvConfig.h 3 // Keybase 4 // 5 // Created by Gabriel on 5/27/15. 6 // Copyright (c) 2015 Gabriel Handford. All rights reserved. 7 // 8 9 #import <Foundation/Foundation.h> 10 11 #import <KBKit/KBPath.h> 12 13 typedef NS_ENUM (NSInteger, KBRunMode) { 14 KBRunModeProd, 15 KBRunModeStaging, 16 KBRunModeDevel, 17 }; 18 19 typedef NS_OPTIONS (NSUInteger, KBInstallOptions) { 20 KBInstallOptionNone = 0, 21 KBInstallOptionService = 1 << 1, 22 KBInstallOptionHelper = 1 << 2, 23 KBInstallOptionFuse = 1 << 3, 24 KBInstallOptionKBFS = 1 << 4, 25 KBInstallOptionUpdater = 1 << 5, 26 KBInstallOptionMountDir = 1 << 6, 27 KBInstallOptionRedirector = 1 << 7, 28 KBInstallOptionCLI = 1 << 10, 29 KBInstallOptionAppBundle = 1 << 11, 30 KBInstallOptionKBNM = 1 << 12, 31 }; 32 33 @interface KBEnvConfig : NSObject 34 35 @property (nonatomic, readonly) NSString *homeDir; 36 @property (readonly, getter=isDebugEnabled) BOOL debugEnabled; 37 @property (readonly) NSString *mountDir; 38 @property (readonly) NSString *title; 39 @property (readonly) NSString *info; 40 @property (readonly) NSImage *image; 41 @property (readonly) KBRunMode runMode; 42 @property (readonly, getter=isInstallDisabled) BOOL installDisabled; 43 @property (readonly) KBInstallOptions installOptions; 44 @property (readonly) NSTimeInterval installTimeout; 45 @property (readonly) NSString *appPath; 46 @property (readonly) NSString *sourcePath; 47 48 - (instancetype)initWithRunMode:(KBRunMode)runMode; 49 50 + (instancetype)envConfigWithHomeDir:(NSString *)homeDir mountDir:(NSString *)mountDir runMode:(KBRunMode)runMode; 51 + (instancetype)envConfigWithRunMode:(KBRunMode)runMode; 52 + (instancetype)envConfigWithRunModeString:(NSString *)runModeString installOptions:(KBInstallOptions)installOptions installTimeout:(NSTimeInterval)installTimeout appPath:(NSString *)appPath sourcePath:(NSString *)sourcePath; 53 + (instancetype)envConfigFromUserDefaults:(NSUserDefaults *)userDefaults; 54 55 - (void)saveToUserDefaults:(NSUserDefaults *)userDefaults; 56 57 - (BOOL)isHomeDirSet; 58 59 - (NSString *)sockFile; 60 61 - (NSString *)logFile:(NSString *)label; 62 63 - (NSString *)homePath:(NSString *)filename options:(KBPathOptions)options; 64 - (NSString *)dataPath:(NSString *)filename options:(KBPathOptions)options; 65 - (NSString *)runtimePath:(NSString *)filename options:(KBPathOptions)options; 66 - (NSString *)cachePath:(NSString *)filename options:(KBPathOptions)options; 67 68 - (NSString *)appName; 69 - (NSString *)serviceBinName; 70 - (NSString *)serviceBinPathWithPathOptions:(KBPathOptions)pathOptions servicePath:(NSString *)servicePath; 71 - (NSString *)kbfsBinPathWithPathOptions:(KBPathOptions)pathOptions servicePath:(NSString *)servicePath; 72 - (NSString *)redirectorBinPathWithPathOptions:(KBPathOptions)pathOptions servicePath:(NSString *)servicePath; 73 - (NSString *)gitRemoteHelperName; 74 - (NSString *)redirectorBinName; 75 - (NSString *)redirectorMount; 76 - (NSString *)volumesRedirectorMount; 77 - (BOOL)redirectorDisabled; 78 79 - (BOOL)validate:(NSError **)error; 80 81 - (NSString *)launchdServiceLabel; 82 - (NSString *)launchdKBFSLabel; 83 - (NSString *)launchdUpdaterLabel; 84 85 - (BOOL)isInApplications:(NSString *)path; 86 - (BOOL)isInUserApplications:(NSString *)path; 87 88 @end 89 90 NSString *NSStringFromKBRunMode(KBRunMode runMode, BOOL isValue); 91 92