marinofaggiana 4 tahun lalu
induk
melakukan
39789ed205

+ 1 - 1
Cartfile.resolved

@@ -19,7 +19,7 @@ github "marinofaggiana/AFNetworking" "2967678c3e0e98c9b8d7e06222ad12d1f49c26f2"
 github "marinofaggiana/KTVHTTPCache" "2.0.2"
 github "marinofaggiana/TOPasscodeViewController" "0.0.6"
 github "marinofaggiana/XLForm" "eb9381ad8129f60402bf412250fb31b95a628a08"
-github "nextcloud/ios-communication-library" "8b85c8a924a86d92bb43412248b025f2e2de18b2"
+github "nextcloud/ios-communication-library" "b85e32823013e4b2048b5df6cc368986a7d75323"
 github "realm/realm-cocoa" "v4.4.1"
 github "rechsteiner/Parchment" "v1.7.0"
 github "scenee/FloatingPanel" "v1.7.4"

+ 8 - 8
Nextcloud.xcodeproj/project.pbxproj

@@ -144,6 +144,8 @@
 		F7381EE5218218C9000B1560 /* NCOffline.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7381EDE218218C9000B1560 /* NCOffline.storyboard */; };
 		F738E8421F90FFD100F95C8E /* NCManageEndToEndEncryption.m in Sources */ = {isa = PBXBuildFile; fileRef = F738E8411F90FFD100F95C8E /* NCManageEndToEndEncryption.m */; };
 		F739513A221B127F00D986C8 /* NCSectionMediaHeader.xib in Resources */ = {isa = PBXBuildFile; fileRef = F7395139221B127F00D986C8 /* NCSectionMediaHeader.xib */; };
+		F73B422B2476764F00A30FD3 /* NCNotification.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F73B42292476764F00A30FD3 /* NCNotification.storyboard */; };
+		F73B422C2476764F00A30FD3 /* NCNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73B422A2476764F00A30FD3 /* NCNotification.swift */; };
 		F73CB3B222E072A000AD728E /* NCShareHeaderView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F73CB3B122E072A000AD728E /* NCShareHeaderView.xib */; };
 		F73D5E47246DE09200DF6467 /* NCElementsJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73D5E46246DE09200DF6467 /* NCElementsJSON.swift */; };
 		F73D5E48246DE09200DF6467 /* NCElementsJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = F73D5E46246DE09200DF6467 /* NCElementsJSON.swift */; };
@@ -313,8 +315,6 @@
 		F7C40BF32199978B0004137E /* MBProgressHUD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7C40BF22199978B0004137E /* MBProgressHUD.framework */; };
 		F7C40C102199BA5D0004137E /* Realm.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7C40C0F2199BA5D0004137E /* Realm.framework */; };
 		F7C40C122199BA620004137E /* RealmSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F7C40C112199BA620004137E /* RealmSwift.framework */; };
-		F7C525A01E3B48B700FFE02C /* CCNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C5259F1E3B48B700FFE02C /* CCNotification.swift */; };
-		F7C525A21E3B6DA800FFE02C /* CCNotification.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7C525A11E3B6DA800FFE02C /* CCNotification.storyboard */; };
 		F7C7B489245EBA4100D93E60 /* NCViewerQuickLook.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C7B488245EBA4100D93E60 /* NCViewerQuickLook.swift */; };
 		F7C9555321F0C4CA0024296E /* NCActivity.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F7C9555221F0C4CA0024296E /* NCActivity.storyboard */; };
 		F7C9555521F0C5470024296E /* NCActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7C9555421F0C5470024296E /* NCActivity.swift */; };
@@ -554,6 +554,8 @@
 		F738E8401F90FFD100F95C8E /* NCManageEndToEndEncryption.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NCManageEndToEndEncryption.h; sourceTree = "<group>"; };
 		F738E8411F90FFD100F95C8E /* NCManageEndToEndEncryption.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NCManageEndToEndEncryption.m; sourceTree = "<group>"; };
 		F7395139221B127F00D986C8 /* NCSectionMediaHeader.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = NCSectionMediaHeader.xib; sourceTree = "<group>"; };
+		F73B42292476764F00A30FD3 /* NCNotification.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = NCNotification.storyboard; path = Notification/NCNotification.storyboard; sourceTree = "<group>"; };
+		F73B422A2476764F00A30FD3 /* NCNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = NCNotification.swift; path = Notification/NCNotification.swift; sourceTree = "<group>"; };
 		F73CB3B122E072A000AD728E /* NCShareHeaderView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = NCShareHeaderView.xib; sourceTree = "<group>"; };
 		F73CB5771ED46807005F2A5A /* NCBridgeSwift.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NCBridgeSwift.h; sourceTree = "<group>"; };
 		F73D5E46246DE09200DF6467 /* NCElementsJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NCElementsJSON.swift; sourceTree = "<group>"; };
@@ -764,8 +766,6 @@
 		F7C40BF22199978B0004137E /* MBProgressHUD.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MBProgressHUD.framework; path = Carthage/Build/iOS/MBProgressHUD.framework; sourceTree = "<group>"; };
 		F7C40C0F2199BA5D0004137E /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = Carthage/Build/iOS/Realm.framework; sourceTree = "<group>"; };
 		F7C40C112199BA620004137E /* RealmSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RealmSwift.framework; path = Carthage/Build/iOS/RealmSwift.framework; sourceTree = "<group>"; };
-		F7C5259F1E3B48B700FFE02C /* CCNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CCNotification.swift; path = Notification/CCNotification.swift; sourceTree = "<group>"; };
-		F7C525A11E3B6DA800FFE02C /* CCNotification.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = CCNotification.storyboard; path = Notification/CCNotification.storyboard; sourceTree = "<group>"; };
 		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>"; };
@@ -1509,8 +1509,8 @@
 		F7C5259A1E3B441D00FFE02C /* Notification */ = {
 			isa = PBXGroup;
 			children = (
-				F7C5259F1E3B48B700FFE02C /* CCNotification.swift */,
-				F7C525A11E3B6DA800FFE02C /* CCNotification.storyboard */,
+				F73B42292476764F00A30FD3 /* NCNotification.storyboard */,
+				F73B422A2476764F00A30FD3 /* NCNotification.swift */,
 			);
 			name = Notification;
 			sourceTree = "<group>";
@@ -2040,10 +2040,10 @@
 				F78ACD54219047D40088454D /* NCSectionFooter.xib in Resources */,
 				F704B5E32430AA6F00632F5F /* NCCreateFormUploadConflict.storyboard in Resources */,
 				F77B0F611D118A16002130FE /* Acknowledgements.rtf in Resources */,
+				F73B422B2476764F00A30FD3 /* NCNotification.storyboard in Resources */,
 				F7D1612023CF19E30039EBBF /* NCViewerRichWorkspace.storyboard in Resources */,
 				F77B0F631D118A16002130FE /* Localizable.strings in Resources */,
 				F7632FC1218353AA00721B71 /* NCTrashSectionFooter.xib in Resources */,
-				F7C525A21E3B6DA800FFE02C /* CCNotification.storyboard in Resources */,
 				F774264A22EB4D0000B23912 /* NCShareUserDropDownCell.xib in Resources */,
 				F722814323C8C34500C41898 /* NCRichWorkspace.xib in Resources */,
 				F77B0F7D1D118A16002130FE /* Images.xcassets in Resources */,
@@ -2230,7 +2230,6 @@
 				F7E9C41B20F4CA870040CF18 /* CCTransfers.m in Sources */,
 				37C83A0F24532BA600618A3B /* CCMain+Swift.swift in Sources */,
 				F77B0DF51D118A16002130FE /* CCUtility.m in Sources */,
-				F7C525A01E3B48B700FFE02C /* CCNotification.swift in Sources */,
 				F711CCBA246AC99E0009B204 /* OCShareUser.m in Sources */,
 				F7B0C0CD1EE7E7750033AC24 /* CCSynchronize.m in Sources */,
 				F711CCE2246AC99E0009B204 /* OCNotifications.m in Sources */,
@@ -2252,6 +2251,7 @@
 				F711CCD6246AC99E0009B204 /* NSDate+ISO8601.m in Sources */,
 				F78E7065219F096B006F23E4 /* NCAvatar.swift in Sources */,
 				F7DFB7F0219C5B8000680748 /* NCCreateFormUploadAssets.swift in Sources */,
+				F73B422C2476764F00A30FD3 /* NCNotification.swift in Sources */,
 				371B5A2E23D0B04500FAFAE9 /* NCMainMenuTableViewController.swift in Sources */,
 				F77444F8222816D5000D5EB0 /* NCPhotosPickerViewController.swift in Sources */,
 				F711CCDE246AC99E0009B204 /* NCComments.m in Sources */,

+ 2 - 2
iOSClient/Main/Main.storyboard

@@ -366,10 +366,10 @@
             </objects>
             <point key="canvasLocation" x="10878" y="425"/>
         </scene>
-        <!--CCNotification.storyboard-->
+        <!--NCNotification.storyboard-->
         <scene sceneID="1sy-aN-34T">
             <objects>
-                <viewControllerPlaceholder storyboardName="CCNotification" referencedIdentifier="CCNotification.storyboard" id="yit-8P-Oea" sceneMemberID="viewController">
+                <viewControllerPlaceholder storyboardName="NCNotification" referencedIdentifier="NCNotification.storyboard" id="yit-8P-Oea" sceneMemberID="viewController">
                     <navigationItem key="navigationItem" id="avL-mw-LlT"/>
                 </viewControllerPlaceholder>
                 <placeholder placeholderIdentifier="IBFirstResponder" id="EoH-78-6Yh" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>

+ 0 - 5
iOSClient/Networking/OCNetworking.h

@@ -45,11 +45,6 @@
 - (void)unshareAccount:(NSString *)account shareID:(NSInteger)shareID completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
 - (void)getUserGroupWithAccount:(NSString *)account searchString:(NSString *)searchString completion:(void (^)(NSString *account, NSArray *item, NSString *message, NSInteger errorCode))completion;
 
-#pragma mark ===== API =====
-
-- (void)getNotificationWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSArray *listOfNotifications, NSString *message, NSInteger errorCode))completion;
-- (void)setNotificationWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl type:(NSString *)type completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion;
-
 #pragma mark ===== Push Notification =====
 
 - (void)subscribingPushNotificationWithAccount:(NSString *)account url:(NSString *)url pushToken:(NSString *)pushToken Hash:(NSString *)pushTokenHash devicePublicKey:(NSString *)devicePublicKey completion:(void(^)(NSString *account, NSString *deviceIdentifier, NSString *deviceIdentifierSignature, NSString *publicKey, NSString *message, NSInteger errorCode))completion;

+ 0 - 98
iOSClient/Networking/OCNetworking.m

@@ -380,104 +380,6 @@
     }];
 }
 
-#pragma --------------------------------------------------------------------------------------------
-#pragma mark ===== VAR =====
-#pragma --------------------------------------------------------------------------------------------
-
-- (void)getNotificationWithAccount:(NSString *)account completion:(void (^)(NSString *account, NSArray *listOfNotifications, NSString *message, NSInteger errorCode))completion
-{
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
-    if (tableAccount == nil) {
-        completion(account, nil, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
-    } else if ([CCUtility getPassword:account].length == 0) {
-        completion(account, nil, NSLocalizedString(@"_bad_username_password_", nil), kOCErrorServerUnauthorized);
-    } else if ([CCUtility getCertificateError:account]) {
-        completion(account, nil, NSLocalizedString(@"_ssl_certificate_untrusted_", nil), NSURLErrorServerCertificateUntrusted);
-    }
-    
-    OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
-
-    [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
-    [communication setUserAgent:[CCUtility getUserAgent]];
-    [communication getNotificationServer:[tableAccount.url stringByAppendingString:@"/"] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *listOfNotifications, NSString *redirectedServer) {
-        
-        completion(account, listOfNotifications, nil, 0);
-        
-    } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
-        
-        NSString *message;
-        NSInteger errorCode = response.statusCode;
-        
-        if (errorCode == 0 || (errorCode >= 200 && errorCode < 300))
-            errorCode = error.code;
-        
-        // Server Unauthorized
-        if (errorCode == kOCErrorServerUnauthorized || errorCode == kOCErrorServerForbidden) {
-#ifndef EXTENSION
-            [[NCNetworkingCheckRemoteUser shared] checkRemoteUserWithAccount:account];
-#endif
-        } else if (errorCode == NSURLErrorServerCertificateUntrusted) {
-            [CCUtility setCertificateError:account error:YES];
-        }
-        
-        // Error
-        if (errorCode == 503) {
-            message = NSLocalizedString(@"_server_error_retry_", nil);
-        } else {
-            message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
-        }
-        
-        completion(account, nil, message, errorCode);
-    }];
-}
-
-- (void)setNotificationWithAccount:(NSString *)account serverUrl:(NSString *)serverUrl type:(NSString *)type completion:(void (^)(NSString *account, NSString *message, NSInteger errorCode))completion
-{
-    tableAccount *tableAccount = [[NCManageDatabase sharedInstance] getAccountWithPredicate:[NSPredicate predicateWithFormat:@"account == %@", account]];
-    if (tableAccount == nil) {
-        completion(account, NSLocalizedString(@"_error_user_not_available_", nil), k_CCErrorUserNotAvailble);
-    } else if ([CCUtility getPassword:account].length == 0) {
-        completion(account, NSLocalizedString(@"_bad_username_password_", nil), kOCErrorServerUnauthorized);
-    } else if ([CCUtility getCertificateError:account]) {
-        completion(account, NSLocalizedString(@"_ssl_certificate_untrusted_", nil), NSURLErrorServerCertificateUntrusted);
-    }
-    
-    OCCommunication *communication = [OCNetworking sharedManager].sharedOCCommunication;
-
-    [communication setCredentialsWithUser:tableAccount.user andUserID:tableAccount.userID andPassword:[CCUtility getPassword:account]];
-    [communication setUserAgent:[CCUtility getUserAgent]];
-    [communication setNotificationServer:serverUrl type:type onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
-        
-        completion(account, nil, 0);
-        
-    } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
-        
-        NSString *message;
-        NSInteger errorCode = response.statusCode;
-        
-        if (errorCode == 0 || (errorCode >= 200 && errorCode < 300))
-            errorCode = error.code;
-        
-        // Server Unauthorized
-        if (errorCode == kOCErrorServerUnauthorized || errorCode == kOCErrorServerForbidden) {
-#ifndef EXTENSION
-            [[NCNetworkingCheckRemoteUser shared] checkRemoteUserWithAccount:account];
-#endif
-        } else if (errorCode == NSURLErrorServerCertificateUntrusted) {
-            [CCUtility setCertificateError:account error:YES];
-        }
-        
-        // Error
-        if (errorCode == 503) {
-            message = NSLocalizedString(@"_server_error_retry_", nil);
-        } else {
-            message = [error.userInfo valueForKey:@"NSLocalizedDescription"];
-        }
-        
-        completion(account, message, errorCode);
-    }];
-}
-
 #pragma --------------------------------------------------------------------------------------------
 #pragma mark ===== Push Notification =====
 #pragma --------------------------------------------------------------------------------------------

+ 2 - 2
iOSClient/Notification/CCNotification.storyboard → iOSClient/Notification/NCNotification.storyboard

@@ -10,13 +10,13 @@
         <!--Notification-->
         <scene sceneID="dZP-R1-zZF">
             <objects>
-                <tableViewController storyboardIdentifier="CCNotification.storyboard" id="c26-Us-IIn" customClass="CCNotification" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
+                <tableViewController storyboardIdentifier="NCNotification.storyboard" id="c26-Us-IIn" customClass="NCNotification" customModule="Nextcloud" customModuleProvider="target" sceneMemberID="viewController">
                     <tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="187" sectionHeaderHeight="28" sectionFooterHeight="28" id="vzh-aE-2MF">
                         <rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
                         <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
                         <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
                         <prototypes>
-                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="187" id="R1c-h5-BOp" customClass="CCNotificationCell" customModule="Nextcloud" customModuleProvider="target">
+                            <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" rowHeight="187" id="R1c-h5-BOp" customClass="NCNotificationCell" customModule="Nextcloud" customModuleProvider="target">
                                 <rect key="frame" x="0.0" y="28" width="375" height="187"/>
                                 <autoresizingMask key="autoresizingMask"/>
                                 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="R1c-h5-BOp" id="9Bv-1W-yVV">

+ 100 - 109
iOSClient/Notification/CCNotification.swift → iOSClient/Notification/NCNotification.swift

@@ -1,5 +1,5 @@
 //
-//  CCNotification.swift
+//  NCNotification.swift
 //  Nextcloud
 //
 //  Created by Marino Faggiana on 27/01/17.
@@ -25,11 +25,10 @@ import UIKit
 import NCCommunication
 import SwiftyJSON
 
-class CCNotification: UITableViewController, CCNotificationCelllDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
-    
+class NCNotification: UITableViewController, NCNotificationCellDelegate, DZNEmptyDataSetSource, DZNEmptyDataSetDelegate {
+  
     let appDelegate = UIApplication.shared.delegate as! AppDelegate
-    static var notifications = [OCNotifications]()
-    static var notificationsAccount = ""
+    var notifications = [NCCommunicationNotifications]()
     
     override func viewDidLoad() {
         super.viewDidLoad()
@@ -94,15 +93,15 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate, DZNEmp
     }
     
     override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-        return CCNotification.notifications.count
+        return notifications.count
     }
     
     override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
     
-        let cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! CCNotificationCell
+        let cell = self.tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! NCNotificationCell
         cell.delegate = self
         
-        let notification = CCNotification.notifications[indexPath.row]
+        let notification = notifications[indexPath.row]
         let urlIcon = URL(string: notification.icon)
         var image : UIImage?
         
@@ -121,6 +120,12 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate, DZNEmp
         cell.avatar.isHidden = true
         cell.avatarLeadingMargin.constant = 10
 
+        if let subjectRichParameters = notification.subjectRichParameters {
+            if let jsonParameter = JSON(subjectRichParameters).dictionary {
+                print("")
+            }
+        }
+        /*
         if let parameter = notification.subjectRichParameters as?  Dictionary<String, Any> {
             if let user = parameter["user"] as? Dictionary<String, Any> {
                 if let name = user["id"] as? String {
@@ -147,12 +152,13 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate, DZNEmp
                 }
             }
         }
+        */
         
         //
         //cell.date.text = DateFormatter.localizedString(from: notification.date, dateStyle: .medium, timeStyle: .medium)
         //
         cell.notification = notification
-        cell.date.text = CCUtility.dateDiff(notification.date)
+        cell.date.text = CCUtility.dateDiff(notification.date as Date)
         cell.date.textColor = .gray
         cell.subject.text = notification.subject
         cell.subject.textColor = NCBrandColor.sharedInstance.textView
@@ -182,49 +188,49 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate, DZNEmp
         cell.messageBottomMargin.constant = 10
         
         // Action
-        if notification.actions.count > 0  {
-            
-            if notification.actions.count == 1 {
-                
-                let action = notification.actions[0] as! OCNotificationsAction
-
-                cell.primary.isEnabled = true
-                cell.primary.isHidden = false
-                cell.primary.setTitle(action.label, for: .normal)
-                
-            } else if notification.actions.count == 2 {
-            
-                cell.primary.isEnabled = true
-                cell.primary.isHidden = false
-                
-                cell.secondary.isEnabled = true
-                cell.secondary.isHidden = false
-            
-                for action in notification.actions {
+        if let actions = notification.actions {
+            if let jsonActions = JSON(actions).array {
+                if jsonActions.count == 1 {
+                    let action = jsonActions[0]
                     
-                    let label = (action as! OCNotificationsAction).label
-                    let primary = (action as! OCNotificationsAction).primary
+                    cell.primary.isEnabled = true
+                    cell.primary.isHidden = false
+                    cell.primary.setTitle(action["label"].stringValue, for: .normal)
                     
-                    if primary {
-                        cell.primary.setTitle(label, for: .normal)
-                    } else {
-                        cell.secondary.setTitle(label, for: .normal)
+                } else if jsonActions.count == 2 {
+                    
+                    cell.primary.isEnabled = true
+                    cell.primary.isHidden = false
+                        
+                    cell.secondary.isEnabled = true
+                    cell.secondary.isHidden = false
+                    
+                    for action in jsonActions {
+                            
+                        let label =  action["label"].stringValue
+                        let primary = action["primary"].boolValue
+                            
+                        if primary {
+                            cell.primary.setTitle(label, for: .normal)
+                        } else {
+                            cell.secondary.setTitle(label, for: .normal)
+                        }
                     }
                 }
+                
+                let widthPrimary = cell.primary.intrinsicContentSize.width + 30;
+                let widthSecondary = cell.secondary.intrinsicContentSize.width + 30;
+                
+                if widthPrimary > widthSecondary {
+                    cell.primaryWidth.constant = widthPrimary
+                    cell.secondaryWidth.constant = widthPrimary
+                } else {
+                    cell.primaryWidth.constant = widthSecondary
+                    cell.secondaryWidth.constant = widthSecondary
+                }
+                
+                cell.messageBottomMargin.constant = 40
             }
-            
-            let widthPrimary = cell.primary.intrinsicContentSize.width + 30;
-            let widthSecondary = cell.secondary.intrinsicContentSize.width + 30;
-            
-            if widthPrimary > widthSecondary {
-                cell.primaryWidth.constant = widthPrimary
-                cell.secondaryWidth.constant = widthPrimary
-            } else {
-                cell.primaryWidth.constant = widthSecondary
-                cell.secondaryWidth.constant = widthSecondary
-            }
-            
-            cell.messageBottomMargin.constant = 40
         }
         
         return cell
@@ -232,52 +238,52 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate, DZNEmp
     
     // MARK: - tap Action
     
-    func tapRemove(with notification: OCNotifications?) {
-        
-        let serverUrl = self.appDelegate.activeUrl + "/" + k_url_acces_remote_notification_api + "/" + String(notification!.idNotification)
-        
-        OCNetworking.sharedManager().setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: serverUrl, type: "DELETE", completion: { (account, message, errorCode) in
-            
+    func tapRemove(with notification: NCCommunicationNotifications?) {
+           
+        NCCommunication.shared.setNotification(serverUrl:nil, idNotification: notification!.idNotification , method: "DELETE", customUserAgent: nil, addCustomHeaders: nil, account: appDelegate.activeAccount) { (account, errorCode, errorDescription) in
             if errorCode == 0 && account == self.appDelegate.activeAccount {
-                
-                //let listOfNotifications = self.appDelegate.listOfNotifications as NSArray as! [OCNotifications]
-                
-                if let index = CCNotification.self.notifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
-                    CCNotification.self.notifications.remove(at: index)
+                                
+                if let index = self.notifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
+                    self.notifications.remove(at: index)
                 }
                 
                 self.reloadDatasource()
                 
             } else if errorCode != 0 {
-                NCContentPresenter.shared.messageNotification("_error_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
             } else {
                 print("[LOG] It has been changed user during networking process, error.")
             }
-        })
+        }
     }
 
-    func tapAction(with notification: OCNotifications?, label: String) {
+    func tapAction(with notification: NCCommunicationNotifications?, label: String) {
         
-        for action in notification!.actions {
-            
-            if (action as! OCNotificationsAction).label == label {
-                
-                OCNetworking.sharedManager().setNotificationWithAccount(self.appDelegate.activeAccount, serverUrl: (action as! OCNotificationsAction).link, type: (action as! OCNotificationsAction).type, completion: { (account, message, errorCode) in
-                    
-                    if errorCode == 0 && account == self.appDelegate.activeAccount {
-                                                
-                        if let index = CCNotification.self.notifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
-                            CCNotification.self.notifications.remove(at: index)
+        if let actions = notification!.actions {
+            if let jsonActions = JSON(actions).array {
+                for action in jsonActions {
+                    if action["label"].string == label {
+                        let serverUrl = action["link"].stringValue
+                        let method = action["type"].stringValue
+                            
+                        NCCommunication.shared.setNotification(serverUrl: serverUrl, idNotification: 0, method: method, customUserAgent: nil, addCustomHeaders: nil, account: appDelegate.activeAccount) { (account, errorCode, errorDescription) in
+                            
+                            if errorCode == 0 && account == self.appDelegate.activeAccount {
+                                                        
+                                if let index = self.notifications.firstIndex(where: {$0.idNotification == notification!.idNotification})  {
+                                    self.notifications.remove(at: index)
+                                }
+                                
+                                self.reloadDatasource()
+                                
+                            } else if errorCode != 0 {
+                                NCContentPresenter.shared.messageNotification("_error_", description: errorDescription, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
+                            } else {
+                                print("[LOG] It has been changed user during networking process, error.")
+                            }
                         }
-                        
-                        self.reloadDatasource()
-                        
-                    } else if errorCode != 0 {
-                        NCContentPresenter.shared.messageNotification("_error_", description: message, delay: TimeInterval(k_dismissAfterSecond), type: NCContentPresenter.messageType.error, errorCode: errorCode)
-                    } else {
-                        print("[LOG] It has been changed user during networking process, error.")
                     }
-                })
+                }
             }
         }
     }
@@ -288,49 +294,34 @@ class CCNotification: UITableViewController, CCNotificationCelllDelegate, DZNEmp
     
         NCUtility.sharedInstance.startActivityIndicator(view: self.navigationController?.view, bottom: 0)
 
-        // Verify User
-        if appDelegate.activeAccount != CCNotification.notificationsAccount {
-            CCNotification.notifications.removeAll()
-            reloadDatasource()
-            CCNotification.notificationsAccount = appDelegate.activeAccount
-        }
+        NCCommunication.shared.getNotifications(customUserAgent: nil, addCustomHeaders: nil, account: appDelegate.activeAccount) { (account, notifications, errorCode, errorDescription) in
          
-        /*
-        NCCommunication.shared.getNotifications(customUserAgent: nil, addCustomHeaders: nil, account: CCNotification.notificationsAccount) { (account, notifications, errorCode, errorDescription) in
-            
-        }
-        */
-        
-        OCNetworking.sharedManager().getNotificationWithAccount(CCNotification.notificationsAccount, completion: { (account, listOfNotifications, message, errorCode) in
-            
-            if errorCode == 0 && account == CCNotification.self.notificationsAccount {
+            if errorCode == 0 && account == self.appDelegate.activeAccount {
                     
-                CCNotification.self.notifications.removeAll()
-                let sortedListOfNotifications = (listOfNotifications! as NSArray).sortedArray(using: [NSSortDescriptor(key: "date", ascending: false)])
+                self.notifications.removeAll()
+                let sortedListOfNotifications = (notifications! as NSArray).sortedArray(using: [NSSortDescriptor(key: "date", ascending: false)])
                     
                 for notification in sortedListOfNotifications {
-                    // download icon
-                    if let icon = (notification as! OCNotifications).icon {
+                    if let icon = (notification as! NCCommunicationNotifications).icon {
                         NCUtility.sharedInstance.convertSVGtoPNGWriteToUserData(svgUrlString: icon, fileName: nil, width: 25, rewrite: false, account: self.appDelegate.activeAccount, closure: { (imageNamePath) in })
-                    }
-                    
-                    CCNotification.self.notifications.append(notification as! OCNotifications)
+                    }                    
+                    self.notifications.append(notification as! NCCommunicationNotifications)
                 }
                 
                 self.reloadDatasource()
             }
             
             NCUtility.sharedInstance.stopActivityIndicator()
-        })
+        }
     }
 }
 
-// MARK: - Class UITableViewCell
+// MARK: -
 
-class CCNotificationCell: UITableViewCell {
+class NCNotificationCell: UITableViewCell {
     
-    var delegate: CCNotificationCelllDelegate?
-    var notification: OCNotifications?
+    var delegate: NCNotificationCellDelegate?
+    var notification: NCCommunicationNotifications?
 
     @IBOutlet weak var icon : UIImageView!
     @IBOutlet weak var avatar : UIImageView!
@@ -365,7 +356,7 @@ class CCNotificationCell: UITableViewCell {
     }
 }
 
-protocol CCNotificationCelllDelegate {
-    func tapRemove(with notification: OCNotifications?)
-    func tapAction(with notification: OCNotifications?, label: String)
+protocol NCNotificationCellDelegate {
+    func tapRemove(with notification: NCCommunicationNotifications?)
+    func tapAction(with notification: NCCommunicationNotifications?, label: String)
 }

+ 1 - 1
iOSClient/Utility/NCContentPresenter.swift

@@ -75,7 +75,7 @@ class NCContentPresenter: NSObject {
                 var description = description
                 if description == nil { description = "" }
                 if type == messageType.error {
-                    description = NSLocalizedString("_error_", comment: "") + ": \(errorCode), " + NSLocalizedString(description!, comment: "")
+                    description = NSLocalizedString("_error_", comment: "") + " " + NSLocalizedString(description!, comment: "")
                 } else {
                     description = NSLocalizedString(description!, comment: "")
                 }