This commit is contained in:
marinofaggiana 2020-12-12 10:36:57 +01:00
Родитель f13dcc0238
Коммит f2dbb8fd9b
16 изменённых файлов: 62 добавлений и 94 удалений

Просмотреть файл

@ -21,5 +21,4 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import "CCGlobal.h"
#import "CCUtility.h"

Просмотреть файл

@ -671,7 +671,6 @@
F7C742C01E7BD01F00D9C973 /* iOSClient.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = iOSClient.entitlements; sourceTree = "<group>"; };
F7C742D01E7BD35B00D9C973 /* Share.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Share.entitlements; sourceTree = "<group>"; };
F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCViewerQuickLook.swift; sourceTree = "<group>"; };
F7C8C1901B482CEA0048180E /* CCGlobal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCGlobal.h; sourceTree = "<group>"; };
F7C9555221F0C4CA0024296E /* NCActivity.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCActivity.storyboard; sourceTree = "<group>"; };
F7C9555421F0C5470024296E /* NCActivity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCActivity.swift; sourceTree = "<group>"; };
F7CB68992541676B0050EC94 /* NCMore.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = NCMore.storyboard; sourceTree = "<group>"; };
@ -1468,7 +1467,6 @@
F70211F31BAC56E9003FC03E /* Main */,
F7A582D71A24DAB500E903D7 /* AppDelegate.h */,
F7B174C722FAC0A8000B7579 /* AppDelegate.m */,
F7C8C1901B482CEA0048180E /* CCGlobal.h */,
F7F67BB81A24D27800EE80DA /* Images.xcassets */,
F7A321621E9E37960069AD1B /* Activity */,
F7E0E1DA22327885006B0911 /* AudioRecorder */,

Просмотреть файл

@ -23,7 +23,6 @@
#import <MBProgressHUD/MBProgressHUD.h>
#import "CCGlobal.h"
#import "CCGraphics.h"
#import "CCCellShareExt.h"
#import "NCSelectDestination.h"

Просмотреть файл

@ -318,6 +318,32 @@ class NCBrandColor: NSObject {
@objc let ErrorCharactersForbidden: Int = -99993
@objc let ErrorCreationFile: Int = -99992
// Constants to identify the different permissions of a file
@objc let permissionShared = "S"
@objc let permissionCanShare = "R"
@objc let permissionMounted = "M"
@objc let permissionFileCanWrite = "W"
@objc let permissionCanCreateFile = "C"
@objc let permissionCanCreateFolder = "K"
@objc let permissionCanDelete = "D"
@objc let permissionCanRename = "N"
@objc let permissionCanMove = "V"
//Share permission
//permissions - (int) 1 = read; 2 = update; 4 = create; 8 = delete; 16 = share; 31 = all (default: 31, for public shares: 1)
@objc let permissionReadShare: Int = 1
@objc let permissionUpdateShare: Int = 2
@objc let permissionCreateShare: Int = 4
@objc let permissionDeleteShare: Int = 8
@objc let permissionShareShare: Int = 16
@objc let permissionMinFileShare: Int = 1
@objc let permissionMaxFileShare: Int = 19
@objc let permissionMinFolderShare: Int = 1
@objc let permissionMaxFolderShare: Int = 31
@objc let permissionDefaultFileRemoteShareNoSupportShareOption: Int = 3
@objc let permissionDefaultFolderRemoteShareNoSupportShareOption: Int = 15
// Metadata : FileType
@objc let metadataTypeFileAudio = "audio"
@objc let metadataTypeFileCompress = "compress"
@ -420,3 +446,11 @@ class NCBrandColor: NSObject {
//#if targetEnvironment(simulator)
//#endif
//dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//dispatch_async(dispatch_get_main_queue(), ^{
//dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
//#if TARGET_OS_SIMULATOR
//#endif

Просмотреть файл

@ -1,57 +0,0 @@
//
// CCGlobal.h
// Nextcloud
//
// Created by Marino Faggiana on 13/10/14.
// Copyright (c) 2014 Marino Faggiana. All rights reserved.
//
// Author Marino Faggiana <marino.faggiana@nextcloud.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#import <UIKit/UIKit.h>
//dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
//dispatch_async(dispatch_get_main_queue(), ^{
//dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 0.3 * NSEC_PER_SEC), dispatch_get_main_queue(), ^(void) {
//#if TARGET_OS_SIMULATOR
//#endif
// Constants to identify the different permissions of a file
#define k_permission_shared @"S"
#define k_permission_can_share @"R"
#define k_permission_mounted @"M"
#define k_permission_file_can_write @"W"
#define k_permission_can_create_file @"C"
#define k_permission_can_create_folder @"K"
#define k_permission_can_delete @"D"
#define k_permission_can_rename @"N"
#define k_permission_can_move @"V"
//Share permission
//permissions - (int) 1 = read; 2 = update; 4 = create; 8 = delete; 16 = share; 31 = all (default: 31, for public shares: 1)
#define k_read_share_permission 1
#define k_update_share_permission 2
#define k_create_share_permission 4
#define k_delete_share_permission 8
#define k_share_share_permission 16
#define k_min_file_share_permission 1
#define k_max_file_share_permission 19
#define k_min_folder_share_permission 1
#define k_max_folder_share_permission 31
#define k_default_file_remote_share_permission_no_support_share_option 3
#define k_default_folder_remote_share_permission_no_support_share_option 15

Просмотреть файл

@ -34,7 +34,6 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import "CCGlobal.h"
#import "NSNotificationCenter+MainThread.h"
#endif

Просмотреть файл

@ -2351,13 +2351,13 @@ class NCManageDatabase: NSObject {
if metadataFolder != nil {
isShare = metadata.permissions.contains(k_permission_shared) && !metadataFolder!.permissions.contains(k_permission_shared)
isMounted = metadata.permissions.contains(k_permission_mounted) && !metadataFolder!.permissions.contains(k_permission_mounted)
isShare = metadata.permissions.contains(NCBrandGlobal.shared.permissionShared) && !metadataFolder!.permissions.contains(NCBrandGlobal.shared.permissionShared)
isMounted = metadata.permissions.contains(NCBrandGlobal.shared.permissionMounted) && !metadataFolder!.permissions.contains(NCBrandGlobal.shared.permissionMounted)
} else if let directory = NCManageDatabase.shared.getTableDirectory(predicate: NSPredicate(format: "account == %@ AND serverUrl == %@", metadata.account, metadata.serverUrl)) {
isShare = metadata.permissions.contains(k_permission_shared) && !directory.permissions.contains(k_permission_shared)
isMounted = metadata.permissions.contains(k_permission_mounted) && !directory.permissions.contains(k_permission_mounted)
isShare = metadata.permissions.contains(NCBrandGlobal.shared.permissionShared) && !directory.permissions.contains(NCBrandGlobal.shared.permissionShared)
isMounted = metadata.permissions.contains(NCBrandGlobal.shared.permissionMounted) && !directory.permissions.contains(NCBrandGlobal.shared.permissionMounted)
}
if isShare || isMounted {

Просмотреть файл

@ -1325,8 +1325,8 @@ extension NCCollectionViewCommon: UICollectionViewDataSource {
var isMounted = false
if metadataFolder != nil {
isShare = metadata.permissions.contains(k_permission_shared) && !metadataFolder!.permissions.contains(k_permission_shared)
isMounted = metadata.permissions.contains(k_permission_mounted) && !metadataFolder!.permissions.contains(k_permission_mounted)
isShare = metadata.permissions.contains(NCBrandGlobal.shared.permissionShared) && !metadataFolder!.permissions.contains(NCBrandGlobal.shared.permissionShared)
isMounted = metadata.permissions.contains(NCBrandGlobal.shared.permissionMounted) && !metadataFolder!.permissions.contains(NCBrandGlobal.shared.permissionMounted)
}
if dataSource.metadataShare[metadata.ocId] != nil {

Просмотреть файл

@ -64,8 +64,8 @@ extension NCCollectionViewCommon {
}
if let metadataFolder = metadataFolder {
let isShare = metadata.permissions.contains(k_permission_shared) && !metadataFolder.permissions.contains(k_permission_shared)
let isMounted = metadata.permissions.contains(k_permission_mounted) && !metadataFolder.permissions.contains(k_permission_mounted)
let isShare = metadata.permissions.contains(NCBrandGlobal.shared.permissionShared) && !metadataFolder.permissions.contains(NCBrandGlobal.shared.permissionShared)
let isMounted = metadata.permissions.contains(NCBrandGlobal.shared.permissionMounted) && !metadataFolder.permissions.contains(NCBrandGlobal.shared.permissionMounted)
if isShare || isMounted {
titleDelete = NSLocalizedString("_leave_share_", comment: "")
}

Просмотреть файл

@ -959,7 +959,7 @@ import Queuer
func deleteMetadataPlain(_ metadata: tableMetadata, addCustomHeaders: [String: String]?, completion: @escaping (_ errorCode: Int, _ errorDescription: String)->()) {
// verify permission
let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: k_permission_can_delete)
let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCBrandGlobal.shared.permissionCanDelete)
if metadata.permissions != "" && permission == false {
completion(NCBrandGlobal.shared.ErrorInternalError, "_no_permission_delete_file_")
@ -1100,7 +1100,7 @@ import Queuer
private func renameMetadataPlain(_ metadata: tableMetadata, fileNameNew: String, completion: @escaping (_ errorCode: Int, _ errorDescription: String?)->()) {
let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: k_permission_can_rename)
let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCBrandGlobal.shared.permissionCanRename)
if !(metadata.permissions == "") && !permission {
completion(NCBrandGlobal.shared.ErrorInternalError, "_no_permission_modify_file_")
return
@ -1172,7 +1172,7 @@ import Queuer
private func moveMetadataPlain(_ metadata: tableMetadata, serverUrlTo: String, overwrite: Bool, completion: @escaping (_ errorCode: Int, _ errorDescription: String?)->()) {
let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: k_permission_can_rename)
let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCBrandGlobal.shared.permissionCanRename)
if !(metadata.permissions == "") && !permission {
completion(NCBrandGlobal.shared.ErrorInternalError, "_no_permission_modify_file_")
return
@ -1218,7 +1218,7 @@ import Queuer
private func copyMetadataPlain(_ metadata: tableMetadata, serverUrlTo: String, overwrite: Bool, completion: @escaping (_ errorCode: Int, _ errorDescription: String?)->()) {
let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: k_permission_can_rename)
let permission = NCUtility.shared.permissionsContainsString(metadata.permissions, permissions: NCBrandGlobal.shared.permissionCanRename)
if !(metadata.permissions == "") && !permission {
completion(NCBrandGlobal.shared.ErrorInternalError, "_no_permission_modify_file_")
return

Просмотреть файл

@ -464,8 +464,8 @@ extension NCSelect: UICollectionViewDataSource {
// Download preview
NCOperationQueue.shared.downloadThumbnail(metadata: metadata, urlBase: appDelegate.urlBase, view: collectionView, indexPath: indexPath)
isShare = metadata.permissions.contains(k_permission_shared) && !metadataFolder.permissions.contains(k_permission_shared)
isMounted = metadata.permissions.contains(k_permission_mounted) && !metadataFolder.permissions.contains(k_permission_mounted)
isShare = metadata.permissions.contains(NCBrandGlobal.shared.permissionShared) && !metadataFolder.permissions.contains(NCBrandGlobal.shared.permissionShared)
isMounted = metadata.permissions.contains(NCBrandGlobal.shared.permissionMounted) && !metadataFolder.permissions.contains(NCBrandGlobal.shared.permissionMounted)
if dataSource.metadataShare[metadata.ocId] != nil {
tableShare = dataSource.metadataShare[metadata.ocId]

Просмотреть файл

@ -155,7 +155,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
if metadata.directory {
// File Drop
if tableShare.permissions == k_create_share_permission {
if tableShare.permissions == NCBrandGlobal.shared.permissionCreateShare {
switchReadOnly.setOn(false, animated: false)
switchAllowUploadAndEditing.setOn(false, animated: false)
switchFileDrop.setOn(true, animated: false)
@ -286,7 +286,7 @@ class NCShareLinkMenuView: UIView, UIGestureRecognizerDelegate, NCShareNetworkin
@IBAction func switchFileDrop(sender: UISwitch) {
guard let tableShare = self.tableShare else { return }
let permission = Int(k_create_share_permission)
let permission = NCBrandGlobal.shared.permissionCreateShare
if sender.isOn && permission != tableShare.permissions {
switchReadOnly.setOn(false, animated: false)

Просмотреть файл

@ -75,7 +75,7 @@ class NCShareNetworking: NSObject {
NCUtility.shared.startActivityIndicator(view: view)
let filenamePath = CCUtility.returnFileNamePath(fromFileName: metadata.fileName, serverUrl: metadata.serverUrl, urlBase: urlBase, account: metadata.account)!
var permission: Int = 1
if metadata.directory { permission = Int(k_max_folder_share_permission) } else { permission = Int(k_max_file_share_permission) }
if metadata.directory { permission = NCBrandGlobal.shared.permissionMaxFolderShare } else { permission = NCBrandGlobal.shared.permissionMaxFileShare }
NCCommunication.shared.createShare(path: filenamePath, shareType: shareType, shareWith: shareWith, permissions: permission) { (account, share, errorCode, errorDescription) in
NCUtility.shared.stopActivityIndicator()
if errorCode == 0 && share != nil {

Просмотреть файл

@ -26,8 +26,6 @@
#import <AssetsLibrary/AssetsLibrary.h>
#import <AVFoundation/AVFoundation.h>
#import "CCGlobal.h"
@interface CCGraphics : NSObject
+ (UIImage *)thumbnailImageForVideo:(NSURL *)videoURL atTime:(NSTimeInterval)time;

Просмотреть файл

@ -29,8 +29,6 @@
#import <MessageUI/MessageUI.h>
#import <UICKeyChainStore/UICKeyChainStore.h>
#import <Photos/Photos.h>
#import "CCGlobal.h"
#import "CCGraphics.h"
@class tableMetadata;

Просмотреть файл

@ -1589,44 +1589,44 @@
+ (NSInteger) getPermissionsValueByCanEdit:(BOOL)canEdit andCanCreate:(BOOL)canCreate andCanChange:(BOOL)canChange andCanDelete:(BOOL)canDelete andCanShare:(BOOL)canShare andIsFolder:(BOOL) isFolder
{
NSInteger permissionsValue = k_read_share_permission;
NSInteger permissionsValue = NCBrandGlobal.shared.permissionReadShare;
if (canEdit && !isFolder) {
permissionsValue = permissionsValue + k_update_share_permission;
permissionsValue = permissionsValue + NCBrandGlobal.shared.permissionUpdateShare;
}
if (canCreate & isFolder) {
permissionsValue = permissionsValue + k_create_share_permission;
permissionsValue = permissionsValue + NCBrandGlobal.shared.permissionCreateShare;
}
if (canChange && isFolder) {
permissionsValue = permissionsValue + k_update_share_permission;
permissionsValue = permissionsValue + NCBrandGlobal.shared.permissionUpdateShare;
}
if (canDelete & isFolder) {
permissionsValue = permissionsValue + k_delete_share_permission;
permissionsValue = permissionsValue + NCBrandGlobal.shared.permissionDeleteShare;
}
if (canShare) {
permissionsValue = permissionsValue + k_share_share_permission;
permissionsValue = permissionsValue + NCBrandGlobal.shared.permissionShareShare;
}
return permissionsValue;
}
+ (BOOL) isPermissionToCanCreate:(NSInteger) permissionValue {
BOOL canCreate = ((permissionValue & k_create_share_permission) > 0);
BOOL canCreate = ((permissionValue & NCBrandGlobal.shared.permissionCreateShare) > 0);
return canCreate;
}
+ (BOOL) isPermissionToCanChange:(NSInteger) permissionValue {
BOOL canChange = ((permissionValue & k_update_share_permission) > 0);
BOOL canChange = ((permissionValue & NCBrandGlobal.shared.permissionUpdateShare) > 0);
return canChange;
}
+ (BOOL) isPermissionToCanDelete:(NSInteger) permissionValue {
BOOL canDelete = ((permissionValue & k_delete_share_permission) > 0);
BOOL canDelete = ((permissionValue & NCBrandGlobal.shared.permissionDeleteShare) > 0);
return canDelete;
}
+ (BOOL) isPermissionToCanShare:(NSInteger) permissionValue {
BOOL canShare = ((permissionValue & k_share_share_permission) > 0);
BOOL canShare = ((permissionValue & NCBrandGlobal.shared.permissionShareShare) > 0);
return canShare;
}
@ -1644,7 +1644,7 @@
}
+ (BOOL) isPermissionToRead:(NSInteger) permissionValue {
BOOL canRead = ((permissionValue & k_read_share_permission) > 0);
BOOL canRead = ((permissionValue & NCBrandGlobal.shared.permissionReadShare) > 0);
return canRead;
}