Skip to content

Commit

Permalink
remove old code (cleaning)
Browse files Browse the repository at this point in the history
Signed-off-by: Marino Faggiana <[email protected]>
  • Loading branch information
marinofaggiana committed Jun 6, 2024
1 parent b325796 commit 2b2cc81
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 146 deletions.
1 change: 0 additions & 1 deletion iOSClient/Utility/CCUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
@interface CCUtility : NSObject

+ (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fileType:(PHAssetMediaType)fileType keyFileName:(NSString *)keyFileName keyFileNameType:(NSString *)keyFileNameType keyFileNameOriginal:(NSString *)keyFileNameOriginal forcedNewFileName:(BOOL)forcedNewFileName;
+ (NSString *)getMimeType:(NSString *)fileNameView;

@end
24 changes: 0 additions & 24 deletions iOSClient/Utility/CCUtility.m
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,4 @@ + (NSString *)createFileName:(NSString *)fileName fileDate:(NSDate *)fileDate fi
return fileName;
}

+ (NSString *)getMimeType:(NSString *)fileNameView
{
CFStringRef fileUTI = nil;
NSString *returnFileUTI = nil;

if ([fileNameView isEqualToString:@"."]) {

return returnFileUTI;

} else {
CFStringRef fileExtension = (__bridge CFStringRef)[fileNameView pathExtension];
NSString *ext = (__bridge NSString *)fileExtension;
ext = ext.uppercaseString;
fileUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);

if (fileUTI != nil) {
returnFileUTI = (__bridge NSString *)fileUTI;
CFRelease(fileUTI);
}
}

return returnFileUTI;
}

@end
41 changes: 11 additions & 30 deletions iOSClient/Utility/NCUtility.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ import Photos
import Alamofire

class NCUtility: NSObject {

let utilityFileSystem = NCUtilityFileSystem()

@objc func isSimulatorOrTestFlight() -> Bool {
func isSimulatorOrTestFlight() -> Bool {
guard let path = Bundle.main.appStoreReceiptURL?.path else {
return false
}
Expand All @@ -48,44 +47,36 @@ class NCUtility: NSObject {
}

func isRichDocument(_ metadata: tableMetadata) -> Bool {
guard let mimeType = CCUtility.getMimeType(metadata.fileNameView) else {
return true
}

// contentype
guard metadata.fileNameView != "." else { return false }
let fileExtension = (metadata.fileNameView as NSString).pathExtension
guard !fileExtension.isEmpty else { return false }
guard let mimeType = UTType(tag: fileExtension.uppercased(), tagClass: .filenameExtension, conformingTo: nil)?.identifier else { return false }
/// contentype
if !NCGlobal.shared.capabilityRichDocumentsMimetypes.filter({ $0.contains(metadata.contentType) || $0.contains("text/plain") }).isEmpty {
return true
}

// mimetype
/// mimetype
if !NCGlobal.shared.capabilityRichDocumentsMimetypes.isEmpty && mimeType.components(separatedBy: ".").count > 2 {
let mimeTypeArray = mimeType.components(separatedBy: ".")
let mimeType = mimeTypeArray[mimeTypeArray.count - 2] + "." + mimeTypeArray[mimeTypeArray.count - 1]
if !NCGlobal.shared.capabilityRichDocumentsMimetypes.filter({ $0.contains(mimeType) }).isEmpty {
return true
}
}

return false
}

func isDirectEditing(account: String, contentType: String) -> [String] {

var editor: [String] = []

guard let results = NCManageDatabase.shared.getDirectEditingEditors(account: account) else {
return editor
}
guard let results = NCManageDatabase.shared.getDirectEditingEditors(account: account) else { return editor }

for result: tableDirectEditingEditors in results {
for mimetype in result.mimetypes {
if mimetype == contentType {
editor.append(result.editor)
}

// HARDCODE
// https://github.com/nextcloud/text/issues/913

if mimetype == "text/markdown" && contentType == "text/x-markdown" {
editor.append(result.editor)
}
Expand All @@ -99,12 +90,10 @@ class NCUtility: NSObject {
}
}
}

return Array(Set(editor))
}

func permissionsContainsString(_ metadataPermissions: String, permissions: String) -> Bool {

for char in permissions {
if metadataPermissions.contains(char) == false {
return false
Expand All @@ -126,7 +115,6 @@ class NCUtility: NSObject {
}

func getCustomUserAgentOnlyOffice() -> String {

let appVersion = Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString")!
if UIDevice.current.userInterfaceIdiom == .pad {
return "Mozilla/5.0 (iPad) Nextcloud-iOS/\(appVersion)"
Expand All @@ -135,22 +123,20 @@ class NCUtility: NSObject {
}
}

@objc func isQuickLookDisplayable(metadata: tableMetadata) -> Bool {
func isQuickLookDisplayable(metadata: tableMetadata) -> Bool {
return true
}

@objc func ocIdToFileId(ocId: String?) -> String? {

func ocIdToFileId(ocId: String?) -> String? {
guard let ocId = ocId else { return nil }

let items = ocId.components(separatedBy: "oc")

if items.count < 2 { return nil }
guard let intFileId = Int(items[0]) else { return nil }
return String(intFileId)
}

func getUserStatus(userIcon: String?, userStatus: String?, userMessage: String?) -> (onlineStatus: UIImage?, statusMessage: String, descriptionMessage: String) {

var onlineStatus: UIImage?
var statusMessage: String = ""
var descriptionMessage: String = ""
Expand Down Expand Up @@ -207,7 +193,6 @@ class NCUtility: NSObject {
*/

func compare(tolerance: Float, expected: Data, observed: Data) throws -> Bool {

enum customError: Error {
case unableToGetUIImageFromData
case unableToGetCGImageFromData
Expand Down Expand Up @@ -311,12 +296,9 @@ class NCUtility: NSObject {
// https://stackoverflow.com/questions/27556807/swift-pointer-problems-with-mach-task-basic-info/27559770#27559770

func getMemoryUsedAndDeviceTotalInMegabytes() -> (Float, Float) {

var usedmegabytes: Float = 0

let totalbytes = Float(ProcessInfo.processInfo.physicalMemory)
let totalmegabytes = totalbytes / 1024.0 / 1024.0

var info = mach_task_basic_info()
var count = mach_msg_type_number_t(MemoryLayout<mach_task_basic_info>.size) / 4

Expand All @@ -340,7 +322,6 @@ class NCUtility: NSObject {
}

func removeForbiddenCharacters(_ fileName: String) -> String {

var fileName = fileName
for character in NCGlobal.shared.forbiddenCharacters {
fileName = fileName.replacingOccurrences(of: character, with: "")
Expand Down
Loading

0 comments on commit 2b2cc81

Please sign in to comment.