mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-21 05:46:03 +00:00
Strings
This commit is contained in:
1 parent
0614ab56cd
commit
fd524adca1
4 files changed
+48
-1
No files matched your search
@@ -399,5 +399,9 @@ public class NearbyConnectionManager : NSObject, NetServiceDelegate, InboundNear
|
||||
}
|
||||
outgoingTransfers.removeValue(forKey: connection.id)
|
||||
}
|
||||
|
||||
public func getActiveConnectionsCount() -> Int {
|
||||
return activeConnections.count
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// SleepManager.swift
|
||||
// QuickDrop
|
||||
//
|
||||
// Created by Leon Böttger on 03.05.25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import IOKit
|
||||
import IOKit.pwr_mgt
|
||||
|
||||
class SleepManager{
|
||||
public static let shared = SleepManager()
|
||||
private var assertionID: IOPMAssertionID = 0
|
||||
|
||||
public func disableSleep() {
|
||||
if(assertionID != 0) {
|
||||
return
|
||||
}
|
||||
|
||||
IOPMAssertionCreateWithName(
|
||||
kIOPMAssertionTypePreventUserIdleSystemSleep as CFString,
|
||||
IOPMAssertionLevel(kIOPMAssertionLevelOn),
|
||||
"QuickDrop Data Transfer" as CFString,
|
||||
&assertionID
|
||||
)
|
||||
}
|
||||
|
||||
public func enableSleep() {
|
||||
if(assertionID == 0 || NearbyConnectionManager.shared.getActiveConnectionsCount() != 0){
|
||||
return
|
||||
}
|
||||
|
||||
IOPMAssertionRelease(assertionID)
|
||||
assertionID = 0
|
||||
}
|
||||
|
||||
private init() {}
|
||||
}
|
||||
Reference in new issue
Block a user