Ignore:
Timestamp:
Sep 18, 2018 3:39:32 PM (3 years ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
01a05f7
Parents:
7615b92
Message:

Adding XCode workspace & Xcode project, and some files missing from last commit.

Please note that Xcode project embedds the packing script (meaning it runs "ant" - zip files, and moves it to bundle)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/AppDelegate.h

    r7615b92 rf76874a  
    22#define __APPDELEGATE_H__
    33
    4 #include <algorithm>
    5 #include <string>
    6 #include <memory>
     4
     5#include <string.h>
     6#include <memory.h>
    77
    88#include <Cocoa/Cocoa.h>
    99
     10
    1011#include "RouterTask.h"
    11 #include "StatusItemButton.h"
    1212#include "JavaHelper.h"
    13 #include "neither/maybe.hpp"
    14 #include "optional.hpp"
    15 #include "subprocess.hpp"
    16 #include <glob.h>
    17 #include <vector>
    1813
    1914
    20 #define DEF_I2P_VERSION "0.9.35"
     15#define DEF_I2P_VERSION "0.9.36"
    2116#define APPDOMAIN "net.i2p.launcher"
    2217#define NSAPPDOMAIN @APPDOMAIN
     
    2419#define APP_IDSTR @"I2P Launcher"
    2520
     21@class SwiftMainDelegate;
    2622
    27 using namespace neither;
     23@protocol SwiftMainDelegateProto
     24- (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
     25@end
     26
    2827
    2928@class ExtractMetaInfo;
    30 using maybeAnRouterRunner = std::experimental::optional<I2PRouterTask*>;
     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
     41inline void sendUserNotification(NSString* title, NSString* informativeText, NSImage* contentImage = NULL, bool makeSound = false) {
     42  NSUserNotification *userNotification = [[[NSUserNotification alloc] init] autorelease];
     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
     58using maybeAnRouterRunner = I2PRouterTask*;
    3159
    3260std::vector<std::string> buildClassPath(std::string basePath);
     
    4472void setGlobalRouterIsRunning(bool running);
    4573
    46 @interface ExtractMetaInfo : NSObject
    47 @property (copy) NSString* i2pBase;
    48 @property (copy) NSString* javaBinary;
    49 @property (copy) NSString* zipFile;
    50 @property (copy) NSString* jarFile;
    51 @end
     74#include "SBridge.h"
    5275
    53 @class I2PStatusMenu;
    54 @interface I2PStatusMenu : NSMenu
    55 - (BOOL)validateMenuItem:(NSMenuItem *)menuItem;
    56 @end
     76#endif
    5777
    58 inline void sendUserNotification(NSString* title, NSString* informativeText, NSImage* contentImage = NULL, bool makeSound = false) {
    59   NSUserNotification *userNotification = [[[NSUserNotification alloc] init] autorelease];
    60 
    61   userNotification.title = title;
    62   userNotification.informativeText = informativeText;
    63   if (contentImage != NULL) userNotification.contentImage = contentImage;
    64   if (makeSound) userNotification.soundName = NSUserNotificationDefaultSoundName;
    65 
    66   [[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:userNotification];
    67 };
    68 
    69 inline std::vector<std::string> globVector(const std::string& pattern){
    70     glob_t glob_result;
    71     glob(pattern.c_str(),GLOB_TILDE,NULL,&glob_result);
    72     std::vector<std::string> files;
    73     for(unsigned int i=0;i<glob_result.gl_pathc;++i){
    74         files.push_back(std::string(glob_result.gl_pathv[i]));
    75     }
    76     globfree(&glob_result);
    77     return files;
    78 }
    79 
    80 inline std::string getDefaultBaseDir()
    81 {
    82   // Figure out base directory
    83   const char* pathFromHome = "/Users/%s/Library/I2P";
    84   auto username = getenv("USER");
    85   char buffer[strlen(pathFromHome)+strlen(username)];
    86   sprintf(buffer, pathFromHome, username);
    87   std::string i2pBaseDir(buffer);
    88   return i2pBaseDir;
    89 }
    90 
    91 @interface MenuBarCtrl : NSObject <StatusItemButtonDelegate, NSMenuDelegate>
    92 @property BOOL enableLogging;
    93 @property BOOL enableVerboseLogging;
    94 @property (strong) I2PStatusMenu *menu;
    95 @property (strong) StatusItemButton* statusBarButton;
    96 @property (strong) NSUserDefaults *userPreferences;
    97 @property (strong, nonatomic) NSImage * image;
    98 @property (strong, nonatomic) NSStatusItem *statusItem;
    99 // Event handlers
    100 - (void) statusItemButtonLeftClick: (StatusItemButton *) button;
    101 - (void) statusItemButtonRightClick: (StatusItemButton *) button;
    102 - (void) statusBarImageBtnClicked;
    103 - (void) btnPressedAction:(id)sender;
    104 - (void) menuWillOpen:(I2PStatusMenu *)menu;
    105 
    106 - (void) openRouterConsoleBtnHandler: (NSMenuItem *) menuItem;
    107 - (void) startJavaRouterBtnHandler: (NSMenuItem *) menuItem;
    108 - (void) restartJavaRouterBtnHandler: (NSMenuItem *) menuItem;
    109 - (void) stopJavaRouterBtnHandler: (NSMenuItem *) menuItem;
    110 - (void) quitWrapperBtnHandler: (NSMenuItem *) menuItem;
    111 // Methods
    112 - (MenuBarCtrl *) init;
    113 - (void) dealloc;
    114 - (I2PStatusMenu *) createStatusBarMenu;
    115 @end
    116 
    117 @protocol MenuBarCtrlDelegate
    118 - (void) menuBarCtrlStatusChanged: (BOOL) active;
    119 @end
     78@class MenuBarCtrl;
    12079
    12180@interface AppDelegate : NSObject <NSUserNotificationCenterDelegate, NSApplicationDelegate> {
     
    12382  //NSImageView *imageCell;
    12483}
    125 @property (strong) MenuBarCtrl *menuBarCtrl;
    126 @property (strong) NSUserDefaults *userPreferences;
    12784@property BOOL enableLogging;
    12885@property BOOL enableVerboseLogging;
    129 @property ExtractMetaInfo *metaInfo;
     86@property (assign) NSUserDefaults *userPreferences;
     87@property (assign) ExtractMetaInfo *metaInfo;
    13088@property (copy) NSImage *contentImage NS_AVAILABLE(10_9, NA);
    131 - (void)extractI2PBaseDir:(void(^)(BOOL success, NSError *error))completion;
    132 - (void)startupI2PRouter;
    133 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification;
    134 - (void)applicationWillTerminate:(NSNotification *)aNotification;
    135 - (void)setApplicationDefaultPreferences;
    136 - (void)userChooseJavaHome;
    137 - (AppDelegate *)initWithArgc:(int)argc argv:(const char **)argv;
    138 - (NSString *)userSelectJavaHome:(JvmListPtr)rawJvmList;
    139 - (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center
     89
     90- (void) extractI2PBaseDir:(void(^)(BOOL success, NSError *error))completion;
     91- (void) awakeFromNib;
     92- (void) startupI2PRouter;
     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- (NSString *) userSelectJavaHome:(JvmListPtr)rawJvmList;
     100#endif
     101- (BOOL) userNotificationCenter:(NSUserNotificationCenter *)center
    140102                               shouldPresentNotification:(NSUserNotification *)notification;
    141103@end
    142104
    143105
     106
     107
    144108#endif
Note: See TracChangeset for help on using the changeset viewer.