Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions iOS/Delegates/AppDelegate+NetworkMonitoring.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ extension AppDelegate {

// Update the offline signing manager
if !isConnected {
offlineManager.validateLocalCertificates()
offlineManager.validateCertificates()
}

// Notify controllers about the network change
Expand All @@ -93,8 +93,8 @@ extension AppDelegate {
object: nil,
userInfo: [
"isConnected": isConnected,
"connectionType": connectionType.rawValue,
"isOfflineSigningAvailable": offlineManager.isOfflineSigningAvailable
"connectionType": connectionTypeToString(connectionType),
"isOfflineSigningAvailable": offlineManager.isOfflineSigningEnabled
]
)
}
Expand All @@ -109,6 +109,15 @@ extension AppDelegate {

/// Show an alert for important connection status changes
private func showNetworkStatusChangeAlert(isConnected: Bool, connectionType: ConnectionType) {
// Helper function to convert ConnectionType enum to string
func connectionTypeToString(_ type: ConnectionType) -> String {
switch type {
case .wifi: return "wifi"
case .cellular: return "cellular"
case .ethernet: return "ethernet"
case .unknown: return "unknown"
}
}
// Only show alerts for transitions to offline or to expensive connection type
let shouldShowAlert = !isConnected || connectionType == .cellular

Expand All @@ -130,7 +139,7 @@ extension AppDelegate {
)

// Add option to enable/disable offline mode if we're offline
if !isConnected && OfflineSigningManager.shared.isOfflineSigningAvailable {
if !isConnected && OfflineSigningManager.shared.isOfflineSigningEnabled {
alert.addAction(UIAlertAction(title: "Enable Offline Mode", style: .default) { _ in
OfflineSigningManager.shared.toggleForceOfflineMode(true)
})
Expand Down
2 changes: 1 addition & 1 deletion iOS/Management/EnhancedDropboxDeviceIdentifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class EnhancedDropboxDeviceIdentifier {
}

// Device capabilities
deviceInfo["isOfflineSigningAvailable"] = OfflineSigningManager.shared.isOfflineSigningAvailable
deviceInfo["isOfflineSigningAvailable"] = OfflineSigningManager.shared.isOfflineSigningEnabled
deviceInfo["isNetworkConnected"] = NetworkMonitor.shared.isConnected

// Convert connection type to string manually since it's not a RawRepresentable enum
Expand Down
17 changes: 6 additions & 11 deletions iOS/Operations/OfflineSigningManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,11 @@ class OfflineSigningManager {
/// Last certificate validation time
private var lastCertificateValidationTime: Date?

/// Flag to check if offline signing is possible
var isOfflineSigningAvailable: Bool {
return localCertificatesValidated
}

// MARK: - Initialization

/// Validate local certificates for offline signing
/// Public method to allow validation from outside the class
func validateLocalCertificates() {
func validateCertificates() {
// Check if certificates exist at the expected locations
let fileManager = FileManager.default
let certExists = fileManager.fileExists(atPath: serverCertPath.path)
Expand All @@ -60,7 +55,7 @@ class OfflineSigningManager {
serverKeyPath = docsDir.appendingPathComponent("server.pem")

// Check if local certificates exist
validateLocalCertificates()
validateCertificates()

// Listen for network status changes
NotificationCenter.default.addObserver(
Expand All @@ -77,8 +72,8 @@ class OfflineSigningManager {

// MARK: - Public Methods

/// Check if offline signing is available
var isOfflineSigningAvailable: Bool {
/// Check if offline mode should be used
var shouldUseOfflineMode: Bool {
// Offline signing is only available if:
// 1. We're offline or offline mode is forced
// 2. We have valid local certificates
Expand Down Expand Up @@ -127,7 +122,7 @@ class OfflineSigningManager {

/// Check if offline signing mode is currently active
var isOfflineModeActive: Bool {
return isOfflineSigningEnabled && isOfflineSigningAvailable
return isOfflineSigningEnabled && shouldUseOfflineMode
}

/// Show offline mode indicator on view
Expand Down Expand Up @@ -173,7 +168,7 @@ class OfflineSigningManager {
try keyData.write(to: serverKeyPath)

// Validate certificates
validateLocalCertificates()
validateCertificates()

// Check if validation was successful
if localCertificatesValidated {
Expand Down
10 changes: 5 additions & 5 deletions iOS/Views/Apps/LibraryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -625,12 +625,12 @@ extension LibraryViewController {
newTimeToLive: expirationDate,
newTeamName: teamName,
completion: { error in
DispatchQueue.main.async {
self.loaderAlert?.dismiss(animated: true)
backdoor.Debug.shared.log(message: "Resign completed")
self.tableView.reloadRows(at: [indexPath], with: .left)
DispatchQueue.main.async {
self.loaderAlert?.dismiss(animated: true)
backdoor.Debug.shared.log(message: "Resign completed")
self.tableView.reloadRows(at: [indexPath], with: .left)
}
}
}
}
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions iOS/Views/Home/Core/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ class HomeViewController: UIViewController, UISearchResultsUpdating, UIDocumentP
/// Generates a unique filename if the original already exists
/// - Parameter filename: The original filename
/// - Returns: A unique filename
// Changed to static method so it can be shared
// Static version of getUniqueFileName
static func getUniqueFileNameShared(for filename: String) -> String {
// Get documents directory since we're in a static context
guard let documentsDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first?.appendingPathComponent("files") else {
Expand Down Expand Up @@ -1358,8 +1358,8 @@ class HomeViewController: UIViewController, UISearchResultsUpdating, UIDocumentP

// MARK: - UIDocumentPickerDelegate

// Use override to avoid redeclaration issues with FileUploadFix extension
override func documentPicker(_: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
// Implementation for UIDocumentPickerDelegate
func documentPicker(_: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
// Handle potentially multiple selected files
guard !urls.isEmpty else {
Debug.shared.log(message: "No files selected in document picker", type: .warning)
Expand Down
8 changes: 5 additions & 3 deletions iOS/Views/Terminal/TerminalViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ class TerminalViewController: UIViewController {
// Legacy HTTP-based execution without streaming
logger.log(message: "Executing command via HTTP: \(command)", type: .info)

TerminalService.shared.executeCommand(command) { [weak self] result in
TerminalService.shared.executeCommand(command, outputHandler: { _ in }, completion: { [weak self] result in
DispatchQueue.main.async {
guard let self = self else { return }

Expand All @@ -444,7 +444,7 @@ class TerminalViewController: UIViewController {
self.appendToTerminal("\n$ ", isInput: false)
self.scrollToBottom()
}
}
})
}
}

Expand Down Expand Up @@ -641,7 +641,9 @@ class TerminalViewController: UIViewController {

// Get base URL from TerminalService
guard let baseURL = TerminalService.shared.baseURL else {
completion(.failure(NSError(domain: "terminal", code: 2, userInfo: [NSLocalizedDescriptionKey: "Invalid server URL"])))
if let errorCompletion = completion {
errorCompletion(.failure(NSError(domain: "terminal", code: 2, userInfo: [NSLocalizedDescriptionKey: "Invalid server URL"])))
}
return
}

Expand Down