Skip to content

Commit

Permalink
Migrate to Sparkle 2 (#261)
Browse files Browse the repository at this point in the history
Closes #255
  • Loading branch information
williambj1 authored Jul 31, 2024
1 parent cb25dc7 commit eed0892
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ jobs:
' ]]>'
' </description>'
' <sparkle:minimumSystemVersion>10.12</sparkle:minimumSystemVersion>'
" <enclosure url=\"https://heliport.bat-bat.workers.dev/https://github.com/OpenIntelWireless/HeliPort/releases/latest/download/HeliPort.dmg\" sparkle:version=\"${VER}-stable-${SHORT_SHA}\" sparkle:shortVersionString=\"${VER}\" type=\"application/octet-stream\" $($SPARKLE_BIN/sign_update -s ${SPARKLE_KEY} ./Artifacts/HeliPort.dmg)/>"
" <enclosure url=\"https://github.com/OpenIntelWireless/HeliPort/releases/latest/download/HeliPort.dmg\" sparkle:version=\"${VER}-stable-${SHORT_SHA}\" sparkle:shortVersionString=\"${VER}\" type=\"application/octet-stream\" $($SPARKLE_BIN/sign_update -s ${SPARKLE_KEY} ./Artifacts/HeliPort.dmg)/>"
' </item>'
' </channel>'
'</rss>'
Expand Down
4 changes: 4 additions & 0 deletions HeliPort.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
50B86ABA24B22E9B008E4FE4 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 50B86AB824B22E9B008E4FE4 /* Localizable.strings */; };
50C5F2D027C23074009E3F68 /* KeychainAccess in Frameworks */ = {isa = PBXBuildFile; productRef = 50C5F2CF27C23074009E3F68 /* KeychainAccess */; };
50C5F2D327C230D6009E3F68 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 50C5F2D227C230D6009E3F68 /* Sparkle */; };
50E7700F2C5A7CE100DB1160 /* UpdateManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50E7700E2C5A7CD600DB1160 /* UpdateManager.swift */; };
50F4959824BDD26D00AE4C08 /* LoginItemManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F4959724BDD26D00AE4C08 /* LoginItemManager.swift */; };
50F495A024BDEB6500AE4C08 /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 50F4959F24BDEB6500AE4C08 /* main.swift */; };
50F495AC24BDEBB500AE4C08 /* HeliPort Launcher.app in Embed Launcher */ = {isa = PBXBuildFile; fileRef = 50F4959D24BDEB6500AE4C08 /* HeliPort Launcher.app */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -73,6 +74,7 @@
50B86AB924B22E9B008E4FE4 /* es */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; lineEnding = 0; name = es; path = es.lproj/Localizable.strings; sourceTree = "<group>"; };
50B86ABC24B22F75008E4FE4 /* zh-Hans */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; lineEnding = 0; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
50B86ABD24B22FEE008E4FE4 /* pt-BR */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; lineEnding = 0; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
50E7700E2C5A7CD600DB1160 /* UpdateManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UpdateManager.swift; sourceTree = "<group>"; };
50F4959724BDD26D00AE4C08 /* LoginItemManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoginItemManager.swift; sourceTree = "<group>"; };
50F4959D24BDEB6500AE4C08 /* HeliPort Launcher.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HeliPort Launcher.app"; sourceTree = BUILT_PRODUCTS_DIR; };
50F4959F24BDEB6500AE4C08 /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -197,6 +199,7 @@
F379276E24A0A4A50087FF2B /* CredentialsManager.swift */,
50F4959724BDD26D00AE4C08 /* LoginItemManager.swift */,
75FDF38A2481D22000B2A601 /* NetworkManager.swift */,
50E7700E2C5A7CD600DB1160 /* UpdateManager.swift */,
BCFA32F22424D2BF00E23603 /* HeliPort.entitlements */,
7557CDF324935260000F0F71 /* Credits.rtf */,
F34B2B8B24AA4C08009AB1BB /* Supporting files */,
Expand Down Expand Up @@ -415,6 +418,7 @@
1380C36524D5580200A448CF /* PrefsWindow.swift in Sources */,
50F4959824BDD26D00AE4C08 /* LoginItemManager.swift in Sources */,
F34B2B8D24AA4C1E009AB1BB /* NSMenuItem+Extensions.swift in Sources */,
50E7700F2C5A7CE100DB1160 /* UpdateManager.swift in Sources */,
1317990B256986E5006957D8 /* String+NonNullTerminated.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
19 changes: 4 additions & 15 deletions HeliPort/Appearance/Preferences/PrefsGeneralView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import Sparkle

class PrefsGeneralView: NSView {

let updater = SUUpdater.shared()

let updatesLabel: NSTextField = {
let view = NSTextField(labelWithString: .startup)
view.alignment = .right
Expand Down Expand Up @@ -60,17 +58,8 @@ class PrefsGeneralView: NSView {
gridView.addRow(with: [updatesLabel])
gridView.addColumn(with: [autoUpdateCheckbox, autoDownloadCheckbox])

if let isAutoUpdate = updater?.automaticallyChecksForUpdates {
autoUpdateCheckbox.state = isAutoUpdate ? .on : .off
} else {
Log.debug("Cannot get auto update state")
}

if let isAutoDownload = updater?.automaticallyDownloadsUpdates {
autoDownloadCheckbox.state = isAutoDownload ? .on : .off
} else {
Log.debug("Cannot get auto download state")
}
autoUpdateCheckbox.state = UpdateManager.sharedUpdater.automaticallyChecksForUpdates ? .on : .off
autoDownloadCheckbox.state = UpdateManager.sharedUpdater.automaticallyDownloadsUpdates ? .on : .off

addSubview(gridView)
setupConstraints()
Expand Down Expand Up @@ -98,9 +87,9 @@ extension PrefsGeneralView {

switch identifier {
case .autoUpdateId:
updater?.automaticallyChecksForUpdates = sender.state == .on
UpdateManager.sharedUpdater.automaticallyChecksForUpdates = sender.state == .on
case .autoDownloadId:
updater?.automaticallyDownloadsUpdates = sender.state == .on
UpdateManager.sharedUpdater.automaticallyDownloadsUpdates = sender.state == .on
default:
break
}
Expand Down
13 changes: 7 additions & 6 deletions HeliPort/Appearance/StatusMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ final class StatusMenu: NSMenu, NSMenuDelegate {

// - MARK: Properties

private let heliPortUpdater = SUUpdater()

private let networkListUpdatePeriod: Double = 5
private let statusUpdatePeriod: Double = 2

Expand Down Expand Up @@ -202,7 +200,12 @@ final class StatusMenu: NSMenu, NSMenuDelegate {
private let networkPanelItem = NSMenuItem(title: .openNetworkPrefs)

private let aboutItem = NSMenuItem(title: .aboutHeliport)
private let checkUpdateItem = NSMenuItem(title: .checkUpdates)
private let checkUpdateItem = {
let item = NSMenuItem(title: .checkUpdates)
item.target = UpdateManager.sharedController
item.action = #selector(SPUStandardUpdaterController.checkForUpdates(_:))
return item
}()
private let quitSeparator = NSMenuItem.separator()
private let quitItem = NSMenuItem(title: .quitHeliport,
action: #selector(clickMenuItem(_:)), keyEquivalent: "q")
Expand Down Expand Up @@ -312,7 +315,7 @@ final class StatusMenu: NSMenu, NSMenuDelegate {
addItem(NSMenuItem.separator())

addClickItem(toggleLaunchItem)
addClickItem(checkUpdateItem)
addItem(checkUpdateItem)
addClickItem(aboutItem)

addItem(quitSeparator)
Expand Down Expand Up @@ -446,8 +449,6 @@ final class StatusMenu: NSMenu, NSMenuDelegate {
case .openNetworkPrefs:
preferenceWindow.close()
preferenceWindow.show()
case .checkUpdates:
heliPortUpdater.checkForUpdates(self)
case .launchLogin:
LoginItemManager.setStatus(enabled: LoginItemManager.isEnabled() ? false : true)
isAutoLaunch = LoginItemManager.isEnabled()
Expand Down
2 changes: 1 addition & 1 deletion HeliPort/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<key>NSSupportsSuddenTermination</key>
<false/>
<key>SUFeedURL</key>
<string>https://heliport.bat-bat.workers.dev/https://github.com/zxystd/HeliPort/releases/latest/download/appcast.xml</string>
<string>https://github.com/OpenIntelWireless/HeliPort/releases/latest/download/appcast.xml</string>
<key>SUPublicEDKey</key>
<string>ktrt51VPmrIyECEE/mqZCmOSNFBX6HLCpP+OB1V6G28=</string>
</dict>
Expand Down
20 changes: 20 additions & 0 deletions HeliPort/UpdateManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UpdateManager.swift
// HeliPort
//
// Created by Bat.bat on 1/8/2024.
// Copyright © 2024 OpenIntelWireless. All rights reserved.
//

import Foundation
import Sparkle

final class UpdateManager {
public static let sharedController = SPUStandardUpdaterController(startingUpdater: true,
updaterDelegate: nil,
userDriverDelegate: nil)

public static var sharedUpdater: SPUUpdater { return sharedController.updater }

private init() {}
}

0 comments on commit eed0892

Please sign in to comment.