1 | #ifndef __APPDELEGATE_H__ |
---|
2 | #define __APPDELEGATE_H__ |
---|
3 | |
---|
4 | |
---|
5 | #include <string.h> |
---|
6 | #include <memory.h> |
---|
7 | |
---|
8 | #include <Cocoa/Cocoa.h> |
---|
9 | |
---|
10 | |
---|
11 | #include "RouterTask.h" |
---|
12 | #include "JavaHelper.h" |
---|
13 | |
---|
14 | |
---|
15 | #define DEF_I2P_VERSION "0.9.36" |
---|
16 | #define APPDOMAIN "net.i2p.launcher" |
---|
17 | #define NSAPPDOMAIN @APPDOMAIN |
---|
18 | #define CFAPPDOMAIN CFSTR(APPDOMAIN) |
---|
19 | #define APP_IDSTR @"I2P Launcher" |
---|
20 | |
---|
21 | @class SwiftMainDelegate; |
---|
22 | |
---|
23 | @protocol SwiftMainDelegateProto |
---|
24 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification; |
---|
25 | @end |
---|
26 | |
---|
27 | |
---|
28 | @class ExtractMetaInfo; |
---|
29 | |
---|
30 | |
---|
31 | |
---|
32 | @interface ExtractMetaInfo : NSObject |
---|
33 | @property (copy) NSString* i2pBase; |
---|
34 | @property (copy) NSString* javaBinary; |
---|
35 | @property (copy) NSString* zipFile; |
---|
36 | @property (copy) NSString* jarFile; |
---|
37 | @end |
---|
38 | #ifdef __cplusplus |
---|
39 | #include "JavaHelper.h" |
---|
40 | |
---|
41 | inline void sendUserNotification(NSString* title, NSString* informativeText, NSImage* contentImage = NULL, bool makeSound = false) { |
---|
42 | NSUserNotification *userNotification = [[NSUserNotification alloc] init]; |
---|
43 | |
---|
44 | userNotification.title = title; |
---|
45 | userNotification.informativeText = informativeText; |
---|
46 | NSBundle *launcherBundle = [NSBundle mainBundle]; |
---|
47 | auto resPath = [launcherBundle resourcePath]; |
---|
48 | auto stdResPath = std::string([resPath UTF8String]); |
---|
49 | stdResPath += "/AppImage.png"; |
---|
50 | auto nsString = [[NSString alloc] initWithUTF8String:(const char*)stdResPath.c_str()]; |
---|
51 | NSImage *appImage = [[NSImage alloc] initWithContentsOfFile:nsString]; |
---|
52 | userNotification.contentImage = appImage; |
---|
53 | if (makeSound) userNotification.soundName = NSUserNotificationDefaultSoundName; |
---|
54 | |
---|
55 | [[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:userNotification]; |
---|
56 | }; |
---|
57 | |
---|
58 | using maybeAnRouterRunner = I2PRouterTask*; |
---|
59 | |
---|
60 | std::vector<std::string> buildClassPath(std::string basePath); |
---|
61 | |
---|
62 | extern JvmListSharedPtr gRawJvmList; |
---|
63 | |
---|
64 | // DO NOT ACCESS THIS GLOBAL VARIABLE DIRECTLY. |
---|
65 | static std::mutex globalRouterStatusMutex; |
---|
66 | static maybeAnRouterRunner globalRouterStatus = maybeAnRouterRunner{}; |
---|
67 | static bool isRuterRunning = false; |
---|
68 | |
---|
69 | maybeAnRouterRunner getGlobalRouterObject(); |
---|
70 | void setGlobalRouterObject(I2PRouterTask* newRouter); |
---|
71 | bool getGlobalRouterIsRunning(); |
---|
72 | void setGlobalRouterIsRunning(bool running); |
---|
73 | |
---|
74 | #include "SBridge.h" |
---|
75 | |
---|
76 | #endif |
---|
77 | |
---|
78 | @class MenuBarCtrl; |
---|
79 | |
---|
80 | @interface AppDelegate : NSObject <NSUserNotificationCenterDelegate, NSApplicationDelegate> { |
---|
81 | @public |
---|
82 | //NSImageView *imageCell; |
---|
83 | } |
---|
84 | @property BOOL enableLogging; |
---|
85 | @property BOOL enableVerboseLogging; |
---|
86 | @property (assign) SwiftMainDelegate *swiftRuntime; |
---|
87 | @property (assign) NSUserDefaults *userPreferences; |
---|
88 | @property (assign) ExtractMetaInfo *metaInfo; |
---|
89 | @property (copy) NSImage *contentImage NS_AVAILABLE(10_9, NA); |
---|
90 | |
---|
91 | - (void) extractI2PBaseDir:(void(^)(BOOL success, NSError *error))completion; |
---|
92 | - (void) awakeFromNib; |
---|
93 | - (void) applicationDidFinishLaunching:(NSNotification *)aNotification; |
---|
94 | - (void) applicationWillTerminate:(NSNotification *)aNotification; |
---|
95 | - (void) setApplicationDefaultPreferences; |
---|
96 | - (void) userChooseJavaHome; |
---|
97 | - (AppDelegate *) initWithArgc:(int)argc argv:(const char **)argv; |
---|
98 | #ifdef __cplusplus |
---|
99 | - (void) startupI2PRouter; |
---|
100 | - (NSString *) userSelectJavaHome:(JvmListPtr)rawJvmList; |
---|
101 | #endif |
---|
102 | - (BOOL) userNotificationCenter:(NSUserNotificationCenter *)center |
---|
103 | shouldPresentNotification:(NSUserNotification *)notification; |
---|
104 | @end |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | |
---|
109 | #endif |
---|