Browse Source

Add getNotificationsOfServerFailure

Marino Faggiana 8 years ago
parent
commit
c3f3c67518

+ 8 - 2
Libraries external/OCCommunicationLib/ownCloud iOS library.xcodeproj/project.pbxproj

@@ -584,7 +584,10 @@
 				GCC_PREFIX_HEADER = "OCCommunicationLib/ownCloud iOS library-Prefix.pch";
 				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 				ONLY_ACTIVE_ARCH = NO;
-				OTHER_LDFLAGS = "-ObjC";
+				OTHER_LDFLAGS = (
+					"-ObjC",
+					"-all_load",
+				);
 				PRODUCT_NAME = ownCloudiOS;
 				SKIP_INSTALL = YES;
 				VALID_ARCHS = "armv7 armv7s arm64";
@@ -600,7 +603,10 @@
 				GCC_PREFIX_HEADER = "OCCommunicationLib/ownCloud iOS library-Prefix.pch";
 				IPHONEOS_DEPLOYMENT_TARGET = 8.0;
 				ONLY_ACTIVE_ARCH = NO;
-				OTHER_LDFLAGS = "-ObjC";
+				OTHER_LDFLAGS = (
+					"-ObjC",
+					"-all_load",
+				);
 				PRODUCT_NAME = ownCloudiOS;
 				SKIP_INSTALL = YES;
 				VALID_ARCHS = "armv7 armv7s arm64";

+ 1 - 1
iOSClient/AppDelegate.m

@@ -136,7 +136,7 @@
     
     // Add notification change session
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(sessionChanged:) name:networkingSessionNotification object:nil];
-    
+        
     // Inizializzazioni Share
     self.sharesID = [[NSMutableDictionary alloc] init];
     self.sharesLink = [[NSMutableDictionary alloc] init];

+ 15 - 0
iOSClient/Main/CCMain.m

@@ -1010,6 +1010,21 @@
 #pragma mark ==== Request Server  ====
 #pragma --------------------------------------------------------------------------------------------
 
+- (void)getNotificationsOfServerSuccess:(NSArray *)listOfNotifications
+{
+    app.listOfNotifications = [[NSArray alloc] initWithArray:listOfNotifications];
+    
+    for (OCNotifications *notification in listOfNotifications) {
+                
+        //[app messageNotification:@"Notication" description:notification.subject visible:YES delay:dismissAfterSecond type:TWMessageBarMessageTypeError];
+    }
+}
+
+- (void)getNotificationsOfServerFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode
+{
+    NSLog(@"Error Notification");
+}
+
 - (void)getCapabilitiesOfServerSuccess:(OCCapabilities *)capabilities
 {
     app.capabilities = capabilities;

+ 1 - 0
iOSClient/Networking/OCNetworking.h

@@ -97,6 +97,7 @@
 
 // Notification
 - (void)getNotificationsOfServerSuccess:(NSArray *)listOfNotifications;
+- (void)getNotificationsOfServerFailure:(CCMetadataNet *)metadataNet message:(NSString *)message errorCode:(NSInteger)errorCode;
 
 // HUD
 - (void)progressTask:(NSString *)fileID serverUrl:(NSString *)serverUrl cryptated:(BOOL)cryptated progress:(float)progress;

+ 15 - 0
iOSClient/Networking/OCNetworking.m

@@ -944,11 +944,26 @@
     
     [communication getNotificationsOfServer:[_activeUrl stringByAppendingString:@"/"] onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *listOfNotifications, NSString *redirectedServer) {
         
+        if ([self.delegate respondsToSelector:@selector(getNotificationsOfServerSuccess:)])
+            [self.delegate getNotificationsOfServerSuccess:listOfNotifications];
+        
         [self complete];
         
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
         
+        NSInteger errorCode = response.statusCode;
+        if (errorCode == 0)
+            errorCode = error.code;
+        
+        if([self.delegate respondsToSelector:@selector(getNotificationsOfServerFailure:message:errorCode:)])
+            [self.delegate getNotificationsOfServerFailure:_metadataNet message:[error.userInfo valueForKey:@"NSLocalizedDescription"] errorCode:errorCode];
+        
+        // Request trusted certificated
+        if ([error code] == NSURLErrorServerCertificateUntrusted)
+            [[CCCertificate sharedManager] presentViewControllerCertificateWithTitle:[error localizedDescription] viewController:(UIViewController *)self.delegate delegate:self];
+        
         [self complete];
+
     }];
 }