Changeset e3ab9f8e for launchers/macosx


Ignore:
Timestamp:
Oct 11, 2018 5:02:42 PM (21 months ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
8e988c39
Parents:
96d31995
Message:

OSX Launcher: Swift GUI code updates, most related to the new launch method.

Location:
launchers/macosx
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • launchers/macosx/I2PLauncher.xcodeproj/project.pbxproj

    r96d31995 re3ab9f8e  
    1919                BF1EFA48215141640014EB07 /* ItoopieTransparent.png in Resources */ = {isa = PBXBuildFile; fileRef = BF1EFA45215141640014EB07 /* ItoopieTransparent.png */; };
    2020                BF3143FE2160C1BD0014EB07 /* DownloadJavaViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF3143FD2160C1BD0014EB07 /* DownloadJavaViewController.swift */; };
    21                 BF4AA39F215AA58B0014EB07 /* NetworkExtension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF4AA39E215AA58B0014EB07 /* NetworkExtension.framework */; };
    2221                BF5061702113C48E0014EB07 /* I2PLauncher.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = BF50616E2113C48E0014EB07 /* I2PLauncher.xcdatamodeld */; };
    2322                BF5061722113C4900014EB07 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = BF5061712113C4900014EB07 /* Assets.xcassets */; };
     
    2524                BF5061962113C84E0014EB07 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF5061952113C84E0014EB07 /* Cocoa.framework */; };
    2625                BF5315072150C55B0014EB07 /* RouterRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF5315062150C55B0014EB07 /* RouterRunner.swift */; };
    27                 BF53150B2150C6E80014EB07 /* I2PSubprocess.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF53150A2150C6E80014EB07 /* I2PSubprocess.swift */; };
    2826                BF53150D2150CE310014EB07 /* DateTimeUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF53150C2150CE310014EB07 /* DateTimeUtils.swift */; };
    2927                BF5315132150EB510014EB07 /* RouterProcessStatus+ObjectiveC.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF5315122150EB510014EB07 /* RouterProcessStatus+ObjectiveC.swift */; };
    3028                BF531515215105B40014EB07 /* LogViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF531514215105B40014EB07 /* LogViewController.swift */; };
    3129                BF650CA92152AC7D0014EB07 /* bumpInfoPlist.sh in Resources */ = {isa = PBXBuildFile; fileRef = BF650CA52152AC7D0014EB07 /* bumpInfoPlist.sh */; };
    32                 BF650CAB2152AC7D0014EB07 /* Deployer.m in Sources */ = {isa = PBXBuildFile; fileRef = BF650CA72152AC7D0014EB07 /* Deployer.m */; };
     30                BF650CAB2152AC7D0014EB07 /* Deployer.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF650CA72152AC7D0014EB07 /* Deployer.mm */; };
    3331                BF7506CB21509CFD0014EB07 /* RouterProcessStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF7506CA21509CFD0014EB07 /* RouterProcessStatus.swift */; };
    3432                BF86541321515CA00014EB07 /* launcher.jar in Resources */ = {isa = PBXBuildFile; fileRef = BF1EFA46215141640014EB07 /* launcher.jar */; };
     
    4745                BFBDCB02215060190014EB07 /* DetectJava.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBDCB01215060190014EB07 /* DetectJava.swift */; };
    4846                BFBDCB04215060970014EB07 /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFBDCB03215060970014EB07 /* StatusBarController.swift */; };
     47                BFD899432169EE9F0014EB07 /* LaunchAgent.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFD899422169EE9F0014EB07 /* LaunchAgent.swift */; };
     48                BFD899452169EFE90014EB07 /* LaunchAgent+Status.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFD899442169EFE90014EB07 /* LaunchAgent+Status.swift */; };
     49                BFD899472169F01B0014EB07 /* LaunchAgentManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFD899462169F01B0014EB07 /* LaunchAgentManager.swift */; };
    4950                BFDD81DA2156B3E30014EB07 /* RouterManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFDD81D92156B3E30014EB07 /* RouterManager.swift */; };
    5051                BFE16BF82156C61E0014EB07 /* RouterStatusView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFE16BF72156C61E0014EB07 /* RouterStatusView.swift */; };
    5152                BFE16BFA2156DAED0014EB07 /* EventManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFE16BF92156DAED0014EB07 /* EventManager.swift */; };
    52                 BFE16BFE2156FD2A0014EB07 /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE16BFD2156FD290014EB07 /* Sparkle.framework */; };
    53                 BFE16C002156FD9E0014EB07 /* Sparkle.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = BFE16BFD2156FD290014EB07 /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
    5453                BFE1CBAD2151908F0014EB07 /* CoreFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BFE1CBAC2151908F0014EB07 /* CoreFoundation.framework */; };
    5554/* End PBXBuildFile section */
    56 
    57 /* Begin PBXCopyFilesBuildPhase section */
    58                 BFE16BFF2156FD890014EB07 /* CopyFiles */ = {
    59                         isa = PBXCopyFilesBuildPhase;
    60                         buildActionMask = 2147483647;
    61                         dstPath = "";
    62                         dstSubfolderSpec = 10;
    63                         files = (
    64                                 BFE16C002156FD9E0014EB07 /* Sparkle.framework in CopyFiles */,
    65                         );
    66                         runOnlyForDeploymentPostprocessing = 0;
    67                 };
    68 /* End PBXCopyFilesBuildPhase section */
    6955
    7056/* Begin PBXFileReference section */
     
    8975                BF3143FD2160C1BD0014EB07 /* DownloadJavaViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DownloadJavaViewController.swift; sourceTree = "<group>"; };
    9076                BF3143FF2160CA350014EB07 /* logger_c.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = logger_c.h; sourceTree = "<group>"; };
    91                 BF4AA39E215AA58B0014EB07 /* NetworkExtension.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NetworkExtension.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/NetworkExtension.framework; sourceTree = DEVELOPER_DIR; };
    9277                BF5061682113C48E0014EB07 /* I2PLauncher.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = I2PLauncher.app; sourceTree = BUILT_PRODUCTS_DIR; };
    9378                BF50616F2113C48E0014EB07 /* I2PLauncher.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = I2PLauncher.xcdatamodel; sourceTree = "<group>"; };
     
    9883                BF5061952113C84E0014EB07 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
    9984                BF5315062150C55B0014EB07 /* RouterRunner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterRunner.swift; sourceTree = "<group>"; };
    100                 BF53150A2150C6E80014EB07 /* I2PSubprocess.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = I2PSubprocess.swift; sourceTree = "<group>"; };
    10185                BF53150C2150CE310014EB07 /* DateTimeUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateTimeUtils.swift; sourceTree = "<group>"; };
    10286                BF5315122150EB510014EB07 /* RouterProcessStatus+ObjectiveC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "RouterProcessStatus+ObjectiveC.swift"; sourceTree = "<group>"; };
    10387                BF531514215105B40014EB07 /* LogViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LogViewController.swift; sourceTree = "<group>"; };
    10488                BF650CA52152AC7D0014EB07 /* bumpInfoPlist.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = bumpInfoPlist.sh; sourceTree = SOURCE_ROOT; };
    105                 BF650CA72152AC7D0014EB07 /* Deployer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Deployer.m; sourceTree = SOURCE_ROOT; };
     89                BF650CA72152AC7D0014EB07 /* Deployer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Deployer.mm; sourceTree = SOURCE_ROOT; };
    10690                BF650CA82152AC7D0014EB07 /* Deployer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Deployer.h; sourceTree = SOURCE_ROOT; };
    10791                BF7506CA21509CFD0014EB07 /* RouterProcessStatus.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterProcessStatus.swift; sourceTree = "<group>"; };
     
    122106                BFBDCB01215060190014EB07 /* DetectJava.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DetectJava.swift; sourceTree = "<group>"; };
    123107                BFBDCB03215060970014EB07 /* StatusBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
     108                BFD899422169EE9F0014EB07 /* LaunchAgent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchAgent.swift; sourceTree = "<group>"; };
     109                BFD899442169EFE90014EB07 /* LaunchAgent+Status.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LaunchAgent+Status.swift"; sourceTree = "<group>"; };
     110                BFD899462169F01B0014EB07 /* LaunchAgentManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LaunchAgentManager.swift; sourceTree = "<group>"; };
    124111                BFDD81D92156B3E30014EB07 /* RouterManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterManager.swift; sourceTree = "<group>"; };
    125112                BFE16BF72156C61E0014EB07 /* RouterStatusView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouterStatusView.swift; sourceTree = "<group>"; };
     
    136123                        files = (
    137124                                BFE1CBAD2151908F0014EB07 /* CoreFoundation.framework in Frameworks */,
    138                                 BF4AA39F215AA58B0014EB07 /* NetworkExtension.framework in Frameworks */,
    139125                                BF865417215182820014EB07 /* Foundation.framework in Frameworks */,
    140                                 BFE16BFE2156FD2A0014EB07 /* Sparkle.framework in Frameworks */,
    141126                                BFBDCB0021505BEE0014EB07 /* AppKit.framework in Frameworks */,
    142127                                BF5061962113C84E0014EB07 /* Cocoa.framework in Frameworks */,
     
    203188                                BF650CA52152AC7D0014EB07 /* bumpInfoPlist.sh */,
    204189                                BF650CA82152AC7D0014EB07 /* Deployer.h */,
    205                                 BF650CA72152AC7D0014EB07 /* Deployer.m */,
     190                                BF650CA72152AC7D0014EB07 /* Deployer.mm */,
    206191                                BF1EFA42215141220014EB07 /* include */,
    207192                                BF1EFA3F215141110014EB07 /* AppDelegate.h */,
     
    231216                        isa = PBXGroup;
    232217                        children = (
    233                                 BF4AA39E215AA58B0014EB07 /* NetworkExtension.framework */,
    234218                                BFE16BFD2156FD290014EB07 /* Sparkle.framework */,
    235219                                BFE1CBAC2151908F0014EB07 /* CoreFoundation.framework */,
     
    249233                                BF5315122150EB510014EB07 /* RouterProcessStatus+ObjectiveC.swift */,
    250234                                BF5315062150C55B0014EB07 /* RouterRunner.swift */,
    251                                 BF53150A2150C6E80014EB07 /* I2PSubprocess.swift */,
    252235                                BFDD81D92156B3E30014EB07 /* RouterManager.swift */,
    253236                        );
     
    264247                                BFE16BF92156DAED0014EB07 /* EventManager.swift */,
    265248                                BF14B711215D9E040014EB07 /* FolderContentMonitor.swift */,
     249                                BFD899422169EE9F0014EB07 /* LaunchAgent.swift */,
     250                                BFD899442169EFE90014EB07 /* LaunchAgent+Status.swift */,
     251                                BFD899462169F01B0014EB07 /* LaunchAgentManager.swift */,
    266252                        );
    267253                        path = Utils;
     
    280266                                BF1EFA4B215142030014EB07 /* ShellScript */,
    281267                                BF5061662113C48E0014EB07 /* Resources */,
    282                                 BFE16BFF2156FD890014EB07 /* CopyFiles */,
    283268                        );
    284269                        buildRules = (
     
    304289                                                DevelopmentTeam = W3C42P2LA8;
    305290                                                LastSwiftMigration = 0940;
    306                                                 ProvisioningStyle = Automatic;
     291                                                ProvisioningStyle = Manual;
    307292                                                SystemCapabilities = {
    308293                                                        com.apple.ApplicationGroups.Mac = {
     
    313298                                                        };
    314299                                                        com.apple.NetworkExtensions = {
    315                                                                 enabled = 1;
     300                                                                enabled = 0;
    316301                                                        };
    317302                                                        com.apple.Sandbox = {
     
    386371                        runOnlyForDeploymentPostprocessing = 0;
    387372                        shellPath = /bin/sh;
    388                         shellScript = "# Run from launchers/macosx\nset -x\n\n# Warning to keep clean files\nfind \"${SRCROOT}\" \\( -name \"*.h\" -or -name \"*.m\" \\) -print0 | xargs -0 wc -l | awk '$1 > 200 && $2 != \"total\" { print $2 \":1: warning: file more than 200 lines\" }'\n\nexport BUILDDIR=$(pwd)\nexport MACOSX_SOURCE_DIR=$SRCROOT\nexport I2P_SOURCE_DIR=$(realpath $SRCROOT/../..)\ncd $MACOSX_SOURCE_DIR/..\n# TODO: Find out why sbt hangs when executed in cli\n#./sbt \";macosx:assembly\"\ncd ..\ncd $I2P_SOURCE_DIR\nant preppkg-osx\ncd pkg-temp\nrm -f $BUILDDIR/base.zip\nzip -r -v -9 $BUILDDIR/base.zip *\ncd $MACOSX_SOURCE_DIR\ncp $MACOSX_SOURCE_DIR/target/scala-2.11/routerLauncher-assembly-0.1.0-SNAPSHOT.jar $BUILDDIR/launcher.jar\n\n\n";
     373                        shellScript = "# Run from launchers/macosx\nset -x\n\n# Warning to keep clean files\nfind \"${SRCROOT}\" \\( -name \"*.h\" -or -name \"*.m\" \\) -print0 | xargs -0 wc -l | awk '$1 > 200 && $2 != \"total\" { print $2 \":1: warning: file more than 200 lines\" }'\n\nif [ ! -z \"${REPACK_I2P}\" ]; then\n    export BUILDDIR=$(pwd)\n    export MACOSX_SOURCE_DIR=$SRCROOT\n    export I2P_SOURCE_DIR=$(realpath $SRCROOT/../..)\n    cd $MACOSX_SOURCE_DIR/..\n    # TODO: Find out why sbt hangs when executed in cli\n    #./sbt \";macosx:assembly\"\n    cd ..\n    cd $I2P_SOURCE_DIR\n    ant preppkg-osx jbigi-osx-only\n    cp build/jbigi.jar pkg-temp/lib/jbigi.jar\n    cd pkg-temp\n    rm -f $BUILDDIR/base.zip\n    zip -r -v -9 $BUILDDIR/base.zip *\n    cd $MACOSX_SOURCE_DIR\n    cp $MACOSX_SOURCE_DIR/target/scala-2.11/routerLauncher-assembly-0.1.0-SNAPSHOT.jar $BUILDDIR/launcher.jar\nfi\n\n";
    389374                };
    390375/* End PBXShellScriptBuildPhase section */
     
    409394                                BFBDCB02215060190014EB07 /* DetectJava.swift in Sources */,
    410395                                BF07789E21506D2B0014EB07 /* PopoverViewController.swift in Sources */,
    411                                 BF650CAB2152AC7D0014EB07 /* Deployer.m in Sources */,
     396                                BFD899472169F01B0014EB07 /* LaunchAgentManager.swift in Sources */,
     397                                BF650CAB2152AC7D0014EB07 /* Deployer.mm in Sources */,
    412398                                BF1EFA40215141110014EB07 /* main.mm in Sources */,
    413399                                BFBDCAF4215042670014EB07 /* AppleStuffExceptionHandler.m in Sources */,
     
    415401                                BF531515215105B40014EB07 /* LogViewController.swift in Sources */,
    416402                                BF5315132150EB510014EB07 /* RouterProcessStatus+ObjectiveC.swift in Sources */,
     403                                BFD899452169EFE90014EB07 /* LaunchAgent+Status.swift in Sources */,
    417404                                BF14B712215D9E040014EB07 /* FolderContentMonitor.swift in Sources */,
    418405                                BFBDCAFE2150567D0014EB07 /* SwiftMainDelegate.swift in Sources */,
     406                                BFD899432169EE9F0014EB07 /* LaunchAgent.swift in Sources */,
    419407                                BFDD81DA2156B3E30014EB07 /* RouterManager.swift in Sources */,
    420                                 BF53150B2150C6E80014EB07 /* I2PSubprocess.swift in Sources */,
    421408                                BF1EFA3A215140E60014EB07 /* SBridge.mm in Sources */,
    422409                                BF14B70F215C98DC0014EB07 /* LoggerWorker.cpp in Sources */,
     
    558545                                ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
    559546                                CODE_SIGN_ENTITLEMENTS = I2PLauncher/I2PLauncher.entitlements;
    560                                 CODE_SIGN_IDENTITY = "Mac Developer";
    561                                 CODE_SIGN_STYLE = Automatic;
     547                                CODE_SIGN_IDENTITY = "Developer ID Application";
     548                                CODE_SIGN_STYLE = Manual;
    562549                                COMBINE_HIDPI_IMAGES = YES;
     550                                COMPRESS_PNG_FILES = YES;
    563551                                COPY_PHASE_STRIP = YES;
    564552                                DEAD_CODE_STRIPPING = YES;
     
    571559                                        "$(PROJECT_DIR)",
    572560                                );
    573                                 HEADER_SEARCH_PATHS = "$(SRCROOT)/include";
     561                                HEADER_SEARCH_PATHS = (
     562                                        "$(SRCROOT)/include",
     563                                        "$(SRCROOT)/../../../Sparkle/Sparkle",
     564                                );
    574565                                INCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = include;
    575566                                INFOPLIST_FILE = I2PLauncher/Info.plist;
     
    577568                                LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/Frameworks @loader_path/../Frameworks";
    578569                                MACOSX_DEPLOYMENT_TARGET = 10.11;
    579                                 PRODUCT_BUNDLE_IDENTIFIER = net.i2p.bootstrap.macosx.I2PLauncher;
     570                                PRODUCT_BUNDLE_IDENTIFIER = "net.i2p.bootstrap-macosx.I2PLauncher";
    580571                                PRODUCT_NAME = "$(TARGET_NAME)";
    581                                 PROVISIONING_PROFILE = "";
    582572                                PROVISIONING_PROFILE_SPECIFIER = "";
    583573                                SDKROOT = macosx;
     
    594584                                ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
    595585                                CODE_SIGN_ENTITLEMENTS = I2PLauncher/I2PLauncher.entitlements;
    596                                 CODE_SIGN_IDENTITY = "Mac Developer";
    597                                 CODE_SIGN_STYLE = Automatic;
     586                                CODE_SIGN_IDENTITY = "Developer ID Application";
     587                                CODE_SIGN_STYLE = Manual;
    598588                                COMBINE_HIDPI_IMAGES = YES;
     589                                COMPRESS_PNG_FILES = YES;
    599590                                COPY_PHASE_STRIP = YES;
    600591                                DEAD_CODE_STRIPPING = YES;
     
    607598                                        "$(PROJECT_DIR)",
    608599                                );
    609                                 HEADER_SEARCH_PATHS = "$(SRCROOT)/include";
     600                                HEADER_SEARCH_PATHS = (
     601                                        "$(SRCROOT)/include",
     602                                        "$(SRCROOT)/../../../Sparkle/Sparkle",
     603                                );
    610604                                INCLUDED_RECURSIVE_SEARCH_PATH_SUBDIRECTORIES = include;
    611605                                INFOPLIST_FILE = I2PLauncher/Info.plist;
     
    613607                                LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @executable_path/Frameworks @loader_path/../Frameworks";
    614608                                MACOSX_DEPLOYMENT_TARGET = 10.11;
    615                                 PRODUCT_BUNDLE_IDENTIFIER = net.i2p.bootstrap.macosx.I2PLauncher;
     609                                PRODUCT_BUNDLE_IDENTIFIER = "net.i2p.bootstrap-macosx.I2PLauncher";
    616610                                PRODUCT_NAME = "$(TARGET_NAME)";
    617611                                PROVISIONING_PROFILE_SPECIFIER = "";
  • launchers/macosx/I2PLauncher/userinterface/PopoverViewController.swift

    r96d31995 re3ab9f8e  
    1010
    1111class PopoverViewController: NSViewController {
     12 
     13  @IBOutlet var routerStatusViewOutlet: RouterStatusView?
     14 
     15  func getRouterStatusView() -> RouterStatusView? {
     16    return self.routerStatusViewOutlet
     17  }
    1218 
    1319  required init?(coder: NSCoder) {
  • launchers/macosx/I2PLauncher/userinterface/RouterStatusView.swift

    r96d31995 re3ab9f8e  
    2323  @IBOutlet var routerStartedByLabel: NSTextField?
    2424  @IBOutlet var routerUptimeLabel: NSTextField?
     25  @IBOutlet var routerPIDLabel: NSTextField?
    2526 
    2627  @IBOutlet var quickControlView: NSView?
    2728  @IBOutlet var routerStartStopButton: NSButton?
     29  @IBOutlet var openConsoleButton: NSButton?
    2830 
    2931  @objc func actionBtnStartRouter(_ sender: Any?) {
    3032    NSLog("START ROUTER")
    31     if (RouterManager.shared().getRouterTask() == nil) {
    32       SBridge.sharedInstance().startupI2PRouter(RouterProcessStatus.i2pDirectoryPath, javaBinPath: RouterProcessStatus.knownJavaBinPath!)
     33    /*if (RouterManager.shared().getRouterTask() == nil) {
     34      SBridge.sharedInstance().startupI2PRouter(RouterProcessStatus.i2pDirectoryPath)
     35    }*/
     36    (sender as! NSButton).isTransparent = true
     37    let routerStatus = RouterRunner.launchAgent?.status()
     38    switch routerStatus {
     39    case .loaded?:
     40      RouterManager.shared().routerRunner.StartAgent(information: RouterRunner.launchAgent)
     41    case .unloaded?:
     42      do {
     43        try LaunchAgentManager.shared.load(RouterRunner.launchAgent!)
     44        RouterManager.shared().routerRunner.StartAgent(information: RouterRunner.launchAgent)
     45      } catch {
     46        RouterManager.shared().eventManager.trigger(eventName: "router_exception", information: error)
     47      }
     48      break
     49    default:
     50      break
    3351    }
    34     RouterManager.shared().updateState()
     52    self.reEnableButton()
    3553  }
    3654 
    3755  @objc func actionBtnStopRouter(_ sender: Any?) {
    3856    NSLog("STOP ROUTER")
    39     if (RouterManager.shared().getRouterTask() != nil) {
     57    let routerStatus = RouterRunner.launchAgent?.status()
     58    switch routerStatus {
     59    case .running?:
    4060      NSLog("Found running router")
    41       RouterManager.shared().getRouterTask()?.requestShutdown()
    42       RouterManager.shared().updateState()
     61      RouterManager.shared().routerRunner.StopAgent()
     62      break
     63    default:
     64      break
    4365    }
     66    self.reEnableButton()
    4467  }
    4568 
    4669  @objc func actionBtnRestartRouter(sender: Any?) {
    4770    if (RouterManager.shared().getRouterTask() != nil) {
    48       RouterManager.shared().getRouterTask()?.requestRestart()
     71      //RouterManager.shared().getRouterTask()?.requestRestart()
    4972    } else {
    5073      NSLog("Can't restart a non running router, start it however...")
    51       SBridge.sharedInstance().startupI2PRouter(RouterProcessStatus.i2pDirectoryPath, javaBinPath: RouterProcessStatus.knownJavaBinPath!)
     74      //SBridge.sharedInstance().startupI2PRouter(RouterProcessStatus.i2pDirectoryPath)
    5275    }
    53     RouterManager.shared().updateState()
    5476  }
    5577 
     78  func handlerRouterStart(information:Any?) {
     79    print("Triggered handlerRouterStart")
     80    NSLog("PID2! %@", information as! String)
     81    routerPIDLabel?.cell?.stringValue = "Router PID: "+(information as! String)
     82    routerPIDLabel?.needsDisplay = true
     83    routerStatusLabel?.cell?.stringValue = "Router status: Running"
     84    self.toggleSetButtonStop()
     85    self.reEnableButton()
     86  }
    5687 
     88  func reEnableButton() {
     89    let currentStatus : AgentStatus = RouterRunner.launchAgent?.status() ?? AgentStatus.unloaded
     90    if currentStatus != AgentStatus.loaded && currentStatus != AgentStatus.unloaded  {
     91      self.toggleSetButtonStop()
     92    } else {
     93      self.toggleSetButtonStart()
     94    }
     95    routerStartStopButton?.isTransparent = false
     96    routerStartStopButton?.needsDisplay = true
     97    self.setRouterStatusLabelText()
     98  }
     99 
     100  func setupObservers() {
     101    RouterManager.shared().eventManager.listenTo(eventName: "router_start", action: handlerRouterStart)
     102    RouterManager.shared().eventManager.listenTo(eventName: "router_stop", action: handleRouterStop)
     103    RouterManager.shared().eventManager.listenTo(eventName: "router_pid", action: handlerRouterStart)
     104    RouterManager.shared().eventManager.listenTo(eventName: "launch_agent_running", action: reEnableButton)
     105    RouterManager.shared().eventManager.listenTo(eventName: "launch_agent_unloaded", action: reEnableButton)
     106    RouterManager.shared().eventManager.listenTo(eventName: "launch_agent_loaded", action: reEnableButton)
     107  }
    57108 
    58109  override func viewWillDraw() {
     
    61112      RouterStatusView.instance = self
    62113    }
    63     self.setRouterStatusLabelText()
     114    self.reEnableButton()
     115  }
     116 
     117  func handleRouterStop() {
     118    routerPIDLabel?.cell?.stringValue = "Router PID: Not running"
     119    self.toggleSetButtonStart()
     120    reEnableButton()
     121  }
     122 
     123  private func toggleSetButtonStart() {
     124    routerStatusLabel?.cell?.stringValue = "Router status: Not running"
     125    routerStartStopButton?.title = "Start Router"
     126    routerStartStopButton?.action = #selector(self.actionBtnStartRouter(_:))
     127  }
     128 
     129  private func toggleSetButtonStop() {
     130    routerStatusLabel?.cell?.stringValue = "Router status: Running"
     131    routerStartStopButton?.title = "Stop Router"
     132    routerStartStopButton?.action = #selector(self.actionBtnStopRouter(_:))
    64133  }
    65134 
    66135  func setRouterStatusLabelText() {
    67     if (RouterProcessStatus.isRouterRunning) {
    68       routerStatusLabel?.cell?.stringValue = "Router status: Running"
    69       routerStartStopButton?.title = "Stop Router"
    70       routerStartStopButton?.action = #selector(self.actionBtnStopRouter(_:))
    71     } else {
    72       routerStatusLabel?.cell?.stringValue = "Router status: Not running"
    73       routerStartStopButton?.title = "Start Router"
    74       routerStartStopButton?.action = #selector(self.actionBtnStartRouter(_:))
    75     }
    76136    routerStartStopButton?.needsDisplay = true
    77137    routerStartStopButton?.target = self
    78138    quickControlView?.needsDisplay = true
     139   
     140    do {
     141      let currentStatus : AgentStatus = RouterRunner.launchAgent!.status()
     142      if currentStatus == AgentStatus.loaded || currentStatus == AgentStatus.unloaded  {
     143        routerStatusLabel?.cell?.stringValue = "Router status: Not running"
     144      } else {
     145        routerStatusLabel?.cell?.stringValue = "Router status: Running"
     146      }
     147    } catch {
     148      // Ensure it's set even AgentStatus is nil (uninitialized yet..)
     149      routerStatusLabel?.cell?.stringValue = "Router status: Not running"
     150    }
    79151   
    80152    let staticStartedByLabelText = "Router started by launcher?"
     
    103175    let c = NSCoder()
    104176    super.init(coder: c)!
    105     self.setRouterStatusLabelText()
     177    self.setupObservers()
     178    self.toggleSetButtonStart()
     179    self.reEnableButton()
    106180  }
    107181 
    108182  required init?(coder decoder: NSCoder) {
    109183    super.init(coder: decoder)
    110     self.setRouterStatusLabelText()
     184    self.setupObservers()
     185    self.toggleSetButtonStart()
     186    self.reEnableButton()
    111187  }
    112188 
  • launchers/macosx/I2PLauncher/userinterface/StatusBarController.swift

    r96d31995 re3ab9f8e  
    1616  let storyboard = NSStoryboard(name: "Storyboard", bundle: Bundle.main)
    1717 
    18   var updateObjectRef : SUUpdater?
     18  var ctrl : PopoverViewController?
     19
     20  @IBOutlet var routerStatusTabView: RouterStatusView?
     21 
     22  //var updateObjectRef : SUUpdater?
    1923 
    2024  @objc func handleOpenConsole(_ sender: Any?) {
     
    2529    let menu = NSMenu()
    2630   
    27     let updateMenuItem = NSMenuItem(title: "Check for updates", action: #selector(self.updateObjectRef?.checkForUpdates(_:)), keyEquivalent: "U")
     31    /*let updateMenuItem = NSMenuItem(title: "Check for updates", action: #selector(self.updateObjectRef?.checkForUpdates(_:)), keyEquivalent: "U")
    2832    updateMenuItem.isEnabled = true
    29    
     33    */
    3034    menu.addItem(NSMenuItem(title: "Open I2P Console", action: #selector(self.handleOpenConsole(_:)), keyEquivalent: "O"))
    3135    menu.addItem(NSMenuItem.separator())
    32     menu.addItem(updateMenuItem)
     36    //menu.addItem(updateMenuItem)
    3337    menu.addItem(NSMenuItem.separator())
    3438    menu.addItem(NSMenuItem(title: "Quit I2P Launcher", action: #selector(SwiftMainDelegate.terminate(_:)), keyEquivalent: "q"))
     
    3640    return menu
    3741  }
     42 
     43  func pidReaction(information:Any?){
     44    let pidStr = information as! String
     45    NSLog("PID! %@", pidStr)
     46    showPopover(sender: nil)
     47    //self.ctrl?.getRouterStatusView()?.handlerRouterStart(information: pidStr)
     48    self.ctrl?.getRouterStatusView()?.needsDisplay = true
     49  }
    3850
    3951 
    4052  override init() {
    4153    super.init()
    42     popover.contentViewController = PopoverViewController.freshController()
    43     updateObjectRef = SUUpdater.shared()
    44     updateObjectRef?.checkForUpdatesInBackground()
     54    self.ctrl = PopoverViewController.freshController()
     55    popover.contentViewController = self.ctrl
     56    //updateObjectRef = SUUpdater.shared()
     57    //updateObjectRef?.checkForUpdatesInBackground()
     58   RouterManager.shared().eventManager.listenTo(eventName: "router_pid", action: pidReaction)
    4559   
    4660   
     
    101115      closePopover(sender: sender)
    102116    } else {
    103       RouterManager.shared().updateState()
    104117      showPopover(sender: sender)
    105118    }
Note: See TracChangeset for help on using the changeset viewer.