Skip to content

Commit

Permalink
Version 6.1.7 (#3221)
Browse files Browse the repository at this point in the history
  • Loading branch information
marinofaggiana authored Dec 4, 2024
1 parent 84f7922 commit 566dad5
Show file tree
Hide file tree
Showing 167 changed files with 689 additions and 558 deletions.
2 changes: 1 addition & 1 deletion Brand/Database.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ import Foundation
// Database Realm
//
let databaseName = "nextcloud.realm"
let databaseSchemaVersion: UInt64 = 366
let databaseSchemaVersion: UInt64 = 367
5 changes: 0 additions & 5 deletions Brand/Intro/NCIntroCollectionViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,4 @@ class NCIntroCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var imageView: UIImageView!

var indexPath = IndexPath()

override func awakeFromNib() {
super.awakeFromNib()
}

}
7 changes: 5 additions & 2 deletions Brand/NCBrand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ let userAgent: String = {
var disable_show_more_nextcloud_apps_in_settings: Bool = false
var doNotAskPasscodeAtStartup: Bool = false
var disable_source_code_in_settings: Bool = false
var enforce_passcode_lock = false

// (name: "Name 1", url: "https://cloud.nextcloud.com"),(name: "Name 2", url: "https://cloud.nextcloud.com")
var enforce_servers: [(name: String, url: String)] = []

// Internal option behaviour
var cleanUpDay: Int = 0 // Set default "Delete, in the cache, all files older than" possible days value are: 0, 1, 7, 30, 90, 180, 365
var cleanUpDay: Int = 0 // Set default "Delete all cached files older than" possible days value are: 0, 1, 7, 30, 90, 180, 365

// Max download/upload concurrent
let maxConcurrentOperationDownload: Int = 5
Expand All @@ -95,7 +96,6 @@ let userAgent: String = {
override init() {
// wrapper AppConfig
if let configurationManaged = UserDefaults.standard.dictionary(forKey: "com.apple.configuration.managed"), use_AppConfig {

if let str = configurationManaged[NCGlobal.shared.configuration_brand] as? String {
brand = str
}
Expand All @@ -117,6 +117,9 @@ let userAgent: String = {
if let str = configurationManaged[NCGlobal.shared.configuration_disable_openin_file] as? String {
disable_openin_file = (str as NSString).boolValue
}
if let str = configurationManaged[NCGlobal.shared.configuration_enforce_passcode_lock] as? String {
enforce_passcode_lock = (str as NSString).boolValue
}
}
}

Expand Down
53 changes: 33 additions & 20 deletions Nextcloud.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

23 changes: 17 additions & 6 deletions Notification Service Extension/NotificationService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ import UIKit
import UserNotifications

class NotificationService: UNNotificationServiceExtension {

var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
var request: UNNotificationRequest?

override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
self.request = request
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)

if let bestAttemptContent = bestAttemptContent {
Expand All @@ -37,11 +38,19 @@ class NotificationService: UNNotificationServiceExtension {
do {
if let message = bestAttemptContent.userInfo["subject"] as? String {
for tableAccount in NCManageDatabase.shared.getAllTableAccount() {
guard let privateKey = NCKeychain().getPushNotificationPrivateKey(account: tableAccount.account),
let decryptedMessage = NCPushNotificationEncryption.shared().decryptPushNotification(message, withDevicePrivateKey: privateKey),
let data = decryptedMessage.data(using: .utf8) else {
guard let privateKey = NCKeychain().getPushNotificationPrivateKey(account: tableAccount.account) else {
bestAttemptContent.body = "Error retrieving private key for \(tableAccount.account)"
continue
}
guard let decryptedMessage = NCPushNotificationEncryption.shared().decryptPushNotification(message, withDevicePrivateKey: privateKey) else {
bestAttemptContent.body = "Error decryption for \(tableAccount.account)"
continue
}
guard let data = decryptedMessage.data(using: .utf8) else {
bestAttemptContent.body = "Error decryption data utf8 for \(tableAccount.account)"
continue
}

if var json = try JSONSerialization.jsonObject(with: data) as? [String: AnyObject],
let subject = json["subject"] as? String {
bestAttemptContent.body = subject
Expand All @@ -50,7 +59,10 @@ class NotificationService: UNNotificationServiceExtension {
pref.set(json, forKey: "NOTIFICATION_DATA")
pref.synchronize()
}
} else {
bestAttemptContent.body = "Error JSON Serialization for \(tableAccount.account)"
}
break
}
}
} catch let error as NSError {
Expand All @@ -66,9 +78,8 @@ class NotificationService: UNNotificationServiceExtension {
// Use this as an opportunity to deliver your "best attempt" at modified content, otherwise the original push payload will be used.
if let contentHandler = contentHandler, let bestAttemptContent = bestAttemptContent {
bestAttemptContent.title = ""
bestAttemptContent.body = "Nextcloud notification"
bestAttemptContent.body = "Nextcloud Notification Time Will Expire"
contentHandler(bestAttemptContent)
}
}

}
1 change: 1 addition & 0 deletions Share/NCShareExtension+NCAccountRequestDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ extension NCShareExtension: NCCreateFormUploadConflictDelegate {
}

self.uploadMetadata.append(contentsOf: metadatas)
uploadStarted = true
self.upload()
}
}
Expand Down
2 changes: 1 addition & 1 deletion Share/NCShareExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ extension NCShareExtension {
metadataForUpload.size = utilityFileSystem.getFileSize(filePath: toPath)
metadataForUpload.status = NCGlobal.shared.metadataStatusWaitUpload
metadataForUpload.sessionDate = Date()
if self.database.getMetadataConflict(account: session.account, serverUrl: serverUrl, fileNameView: fileName) != nil {
if self.database.getMetadataConflict(account: session.account, serverUrl: serverUrl, fileNameView: fileName, nativeFormat: metadataForUpload.nativeFormat) != nil {
conflicts.append(metadataForUpload)
} else {
uploadMetadata.append(metadataForUpload)
Expand Down
2 changes: 1 addition & 1 deletion Widget/Dashboard/DashboardData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func getDashboardDataEntry(configuration: DashboardIntent?, isPreview: Bool, dis
if FileManager().fileExists(atPath: fileNamePath), let image = UIImage(contentsOfFile: fileNamePath) {
icon = image
} else {
let (_, data, error) = await NCNetworking.shared.downloadPreview(url: url, account: activeTableAccount.account)
let (_, _, error) = await NCNetworking.shared.downloadPreview(url: url, account: activeTableAccount.account)
if error == .success,
let data = responseData?.data,
let image = convertDataToImage(data: data, size: NCGlobal.shared.size256, fileNameToWrite: fileName) {
Expand Down
18 changes: 18 additions & 0 deletions Widget/Intent/hr.lproj/Intent.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"13zjVT" = "Account";

"CAIVXf" = "Applications";

"DN8Bxl" = "Account";

"LIw8E9" = "Widget";

"NO1rJU" = "Dashboard";

"V3exc2" = "Account";

"VfbA9C" = "Account";

"ZgvlYN" = "Dashboard Widget";

"tAlZ1R" = "Accounts";

18 changes: 18 additions & 0 deletions Widget/Intent/lo.lproj/Intent.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"13zjVT" = "Account";

"CAIVXf" = "Applications";

"DN8Bxl" = "Account";

"LIw8E9" = "Widget";

"NO1rJU" = "Dashboard";

"V3exc2" = "Account";

"VfbA9C" = "Account";

"ZgvlYN" = "Dashboard Widget";

"tAlZ1R" = "Accounts";

18 changes: 18 additions & 0 deletions Widget/Intent/sl.lproj/Intent.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
"13zjVT" = "Account";

"CAIVXf" = "Applications";

"DN8Bxl" = "Account";

"LIw8E9" = "Widget";

"NO1rJU" = "Dashboard";

"V3exc2" = "Account";

"VfbA9C" = "Account";

"ZgvlYN" = "Dashboard Widget";

"tAlZ1R" = "Accounts";

50 changes: 23 additions & 27 deletions iOSClient/Account Settings/NCAccountSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,31 +47,28 @@ struct NCAccountSettingsView: View {
///
/// User
VStack {
ZStack {
Image(uiImage: avatar)
.resizable()
.scaledToFit()
.frame(width: UIScreen.main.bounds.width, height: 75)
if let statusImage = status.statusImage {
ZStack {
Circle()
.fill(.white)
.frame(width: 30, height: 30)
Image(uiImage: statusImage)
.resizable()
.scaledToFit()
.frame(width: 30, height: 30)
}
.offset(x: 30, y: 30)
Image(uiImage: avatar)
.resizable()
.scaledToFit()
.frame(width: UIScreen.main.bounds.width, height: 75)
if let statusImage = status.statusImage {
ZStack {
Circle()
.fill(.white)
.frame(width: 30, height: 30)
Image(uiImage: statusImage)
.resizable()
.scaledToFit()
.frame(width: 30, height: 30)
}
.offset(x: 30, y: -30)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
Text(model.getUserName())
.font(.system(size: 16))
.font(.subheadline)
Spacer()
.frame(height: 10)
Text(status.statusMessage)
.font(.system(size: 10))
.font(.caption)
Spacer()
.frame(height: 20)
///
Expand Down Expand Up @@ -124,7 +121,7 @@ struct NCAccountSettingsView: View {
}
}
}
.font(.system(size: 14))
.font(.subheadline)
.tabViewStyle(PageTabViewStyle(indexDisplayMode: .never))
.frame(height: model.getTableViewHeight())
.animation(.easeIn(duration: 0.3), value: animation)
Expand All @@ -137,19 +134,18 @@ struct NCAccountSettingsView: View {
VStack {
HStack {
Text(NSLocalizedString("_alias_", comment: "") + ":")
.font(.system(size: 17))
.fontWeight(.medium)
Spacer()
TextField(NSLocalizedString("_alias_placeholder_", comment: ""), text: $model.alias)
.font(.system(size: 16))
.font(.callout)
.multilineTextAlignment(.trailing)
.onChange(of: model.alias) { newValue in
model.setAlias(newValue)
}
}
Text(NSLocalizedString("_alias_footer_", comment: ""))
.frame(maxWidth: .infinity, alignment: .leading)
.font(.system(size: 12))
.font(.caption)
.lineLimit(2)
.foregroundStyle(Color(UIColor.lightGray))
}
Expand All @@ -172,7 +168,7 @@ struct NCAccountSettingsView: View {
.foregroundStyle(Color(NCBrandColor.shared.textColor))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 20))
}
.font(.system(size: 14))
.font(.subheadline)
})
.sheet(isPresented: $showUserStatus) {
if let account = model.tblAccount?.account {
Expand Down Expand Up @@ -200,7 +196,7 @@ struct NCAccountSettingsView: View {
.foregroundStyle(Color(NCBrandColor.shared.textColor))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 20))
}
.font(.system(size: 14))
.font(.subheadline)
})
.sheet(isPresented: $showServerCertificate) {
if let url = URL(string: model.tblAccount?.urlBase), let host = url.host {
Expand All @@ -225,7 +221,7 @@ struct NCAccountSettingsView: View {
.foregroundStyle(Color(NCBrandColor.shared.textColor))
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 20))
}
.font(.system(size: 14))
.font(.subheadline)
})
.sheet(isPresented: $showPushCertificate) {
if let url = URL(string: NCBrandOptions.shared.pushNotificationServerProxy), let host = url.host {
Expand Down Expand Up @@ -253,7 +249,7 @@ struct NCAccountSettingsView: View {
.foregroundStyle(.red)
.padding(EdgeInsets(top: 0, leading: 0, bottom: 0, trailing: 20))
}
.font(.system(size: 14))
.font(.callout)
})
.alert(NSLocalizedString("_want_delete_account_", comment: ""), isPresented: $showDeleteAccountAlert) {
Button(NSLocalizedString("_remove_local_account_", comment: ""), role: .destructive) {
Expand Down
4 changes: 0 additions & 4 deletions iOSClient/Activity/NCActivityTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ class NCActivityCollectionViewCell: UICollectionViewCell {

var fileId = ""
var indexPath = IndexPath()

override func awakeFromNib() {
super.awakeFromNib()
}
}

class NCActivityTableViewCell: UITableViewCell, NCCellProtocol {
Expand Down
49 changes: 27 additions & 22 deletions iOSClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
self.handleProcessingTask(task)
}

if NCBrandOptions.shared.enforce_passcode_lock {
NCKeychain().requestPasscodeAtStart = true
}

/// Activation singleton
_ = NCActionCenter.shared
_ = NCNetworkingProcess.shared
Expand Down Expand Up @@ -275,35 +279,36 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
}

func nextcloudPushNotificationAction(data: [String: AnyObject]) {
guard let data = NCApplicationHandle().nextcloudPushNotificationAction(data: data) else { return }
var findAccount: String?

if let accountPush = data["account"] as? String {
for tableAccount in NCManageDatabase.shared.getAllTableAccount() {
if tableAccount.account == accountPush {
for controller in SceneManager.shared.getControllers() {
if controller.account == accountPush {
NCAccount().changeAccount(tableAccount.account, userProfile: nil, controller: controller) {
findAccount = tableAccount.account
}
}
}
}
}
if let account = findAccount, let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification {
guard let data = NCApplicationHandle().nextcloudPushNotificationAction(data: data),
let account = data["account"] as? String
else {
return
}

func openNotification(controller: NCMainTabBarController) {
if let viewController = UIStoryboard(name: "NCNotification", bundle: nil).instantiateInitialViewController() as? NCNotification {
viewController.session = NCSession.shared.getSession(account: account)
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
let navigationController = UINavigationController(rootViewController: viewController)
navigationController.modalPresentationStyle = .fullScreen
UIApplication.shared.firstWindow?.rootViewController?.present(navigationController, animated: true)
controller.present(navigationController, animated: true)
}
} else {
let message = NSLocalizedString("_the_account_", comment: "") + " " + accountPush + " " + NSLocalizedString("_does_not_exist_", comment: "")
let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
UIApplication.shared.firstWindow?.rootViewController?.present(alertController, animated: true, completion: { })
}
}

if let controller = SceneManager.shared.getControllers().first(where: { $0.account == account }) {
openNotification(controller: controller)
} else if let tableAccount = NCManageDatabase.shared.getAllTableAccount().first(where: { $0.account == account }),
let controller = UIApplication.shared.firstWindow?.rootViewController as? NCMainTabBarController {
NCAccount().changeAccount(tableAccount.account, userProfile: nil, controller: controller) {
openNotification(controller: controller)
}
} else {
let message = NSLocalizedString("_the_account_", comment: "") + " " + account + " " + NSLocalizedString("_does_not_exist_", comment: "")
let alertController = UIAlertController(title: NSLocalizedString("_info_", comment: ""), message: message, preferredStyle: .alert)
alertController.addAction(UIAlertAction(title: NSLocalizedString("_ok_", comment: ""), style: .default, handler: { _ in }))
UIApplication.shared.firstWindow?.rootViewController?.present(alertController, animated: true, completion: { })
}
}

// MARK: - Login
Expand Down
Loading

0 comments on commit 566dad5

Please sign in to comment.