|
@@ -23,6 +23,66 @@
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+#pragma --------------------------------------------------------------------------------------------
|
|
|
+#pragma mark ============================
|
|
|
+#pragma --------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
+- (NSError *)checkServer:(NSString *)serverUrl user:(NSString *)user userID:(NSString *)userID password:(NSString *)password
|
|
|
+{
|
|
|
+ OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
+ __block NSError *returnError = nil;
|
|
|
+
|
|
|
+ dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
|
+
|
|
|
+ [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
|
|
|
+ [communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
+
|
|
|
+ [communication checkServer:serverUrl onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnError = error;
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
+
|
|
|
+ while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW))
|
|
|
+ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
|
|
|
+
|
|
|
+ return returnError;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSError *)readFile:(NSString *)filePathName user:(NSString *)user userID:(NSString *)userID password:(NSString *)password
|
|
|
+{
|
|
|
+ OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|
|
|
+ __block NSError *returnError = nil;
|
|
|
+
|
|
|
+ dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
|
|
|
+
|
|
|
+ [communication setCredentialsWithUser: user andUserID: userID andPassword: password];
|
|
|
+ [communication setUserAgent:[CCUtility getUserAgent]];
|
|
|
+
|
|
|
+ [communication readFile:filePathName onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+
|
|
|
+ } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
|
|
|
+
|
|
|
+ returnError = error;
|
|
|
+ dispatch_semaphore_signal(semaphore);
|
|
|
+ }];
|
|
|
+
|
|
|
+ while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_NOW))
|
|
|
+ [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
|
|
|
+
|
|
|
+ return returnError;
|
|
|
+}
|
|
|
+
|
|
|
+#pragma --------------------------------------------------------------------------------------------
|
|
|
+#pragma mark ===== End-to-End Encryption =====
|
|
|
+#pragma --------------------------------------------------------------------------------------------
|
|
|
+
|
|
|
- (NSError *)lockEndToEndFolderEncrypted:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID token:(NSString **)token
|
|
|
{
|
|
|
OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
|