NCNetworkingSync.m 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. //
  2. // NCNetworkingSync.m
  3. // Nextcloud
  4. //
  5. // Created by Marino Faggiana on 29/10/17.
  6. // Copyright © 2017 TWS. All rights reserved.
  7. //
  8. #import "NCNetworkingSync.h"
  9. #import "CCUtility.h"
  10. #import "CCCertificate.h"
  11. #import "NCBridgeSwift.h"
  12. @implementation NCNetworkingSync
  13. + (NCNetworkingSync *)sharedManager {
  14. static NCNetworkingSync *sharedManager;
  15. @synchronized(self)
  16. {
  17. if (!sharedManager) {
  18. sharedManager = [NCNetworkingSync new];
  19. }
  20. return sharedManager;
  21. }
  22. }
  23. #pragma --------------------------------------------------------------------------------------------
  24. #pragma mark ============================
  25. #pragma --------------------------------------------------------------------------------------------
  26. - (NSError *)uploadFile:(NSString *)localFilePathName remoteFilePathName:(NSString *)remoteFilePathName user:(NSString *)user userID:(NSString *)userID password:(NSString *)password
  27. {
  28. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  29. __block NSError *returnError = nil;
  30. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  31. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  32. [communication setUserAgent:[CCUtility getUserAgent]];
  33. [communication uploadFileSession:localFilePathName toDestiny:remoteFilePathName onCommunication:communication progress:^(NSProgress *progress) {
  34. // Progress
  35. } successRequest:^(NSURLResponse *response, NSString *redirectedServer) {
  36. dispatch_semaphore_signal(semaphore);
  37. } failureRequest:^(NSURLResponse *response, NSString *redirectedServer, NSError *error) {
  38. NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
  39. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:httpResponse.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Upload file error" forKey:NSLocalizedDescriptionKey]];
  40. dispatch_semaphore_signal(semaphore);
  41. } failureBeforeRequest:^(NSError *error) {
  42. returnError = error;
  43. dispatch_semaphore_signal(semaphore);
  44. }];
  45. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  46. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  47. return returnError;
  48. }
  49. - (NSError *)checkServer:(NSString *)serverUrl user:(NSString *)user userID:(NSString *)userID password:(NSString *)password
  50. {
  51. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  52. __block NSError *returnError = nil;
  53. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  54. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  55. [communication setUserAgent:[CCUtility getUserAgent]];
  56. [communication checkServer:serverUrl onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  57. dispatch_semaphore_signal(semaphore);
  58. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  59. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Check server error" forKey:NSLocalizedDescriptionKey]];
  60. dispatch_semaphore_signal(semaphore);
  61. }];
  62. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  63. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  64. return returnError;
  65. }
  66. - (NSError *)readFile:(NSString *)filePathName user:(NSString *)user userID:(NSString *)userID password:(NSString *)password
  67. {
  68. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  69. __block NSError *returnError = nil;
  70. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  71. [communication setCredentialsWithUser: user andUserID: userID andPassword: password];
  72. [communication setUserAgent:[CCUtility getUserAgent]];
  73. [communication readFile:filePathName onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer) {
  74. dispatch_semaphore_signal(semaphore);
  75. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  76. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Read file error" forKey:NSLocalizedDescriptionKey]];
  77. dispatch_semaphore_signal(semaphore);
  78. }];
  79. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  80. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  81. return returnError;
  82. }
  83. #pragma --------------------------------------------------------------------------------------------
  84. #pragma mark ===== End-to-End Encryption =====
  85. #pragma --------------------------------------------------------------------------------------------
  86. - (NSError *)markEndToEndFolderEncrypted:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID token:(NSString **)token
  87. {
  88. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  89. __block NSError *returnError = nil;
  90. __block NSString *returnToken = nil;
  91. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  92. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  93. [communication setUserAgent:[CCUtility getUserAgent]];
  94. // LOCK
  95. [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:*token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
  96. returnToken = token;
  97. // REMOVE METADATA
  98. [communication deleteEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  99. NSLog(@"Delete metadata");
  100. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  101. NSLog(@"Metadata not present");
  102. }];
  103. // MARK
  104. [communication markEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  105. // UNLOCK
  106. [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:returnToken onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  107. returnToken = nil;
  108. dispatch_semaphore_signal(semaphore);
  109. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  110. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Unlock folder error" forKey:NSLocalizedDescriptionKey]];
  111. dispatch_semaphore_signal(semaphore);
  112. }];
  113. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  114. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Mark folder as encrypted error" forKey:NSLocalizedDescriptionKey]];
  115. dispatch_semaphore_signal(semaphore);
  116. }];
  117. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  118. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Lock folder error" forKey:NSLocalizedDescriptionKey]];
  119. dispatch_semaphore_signal(semaphore);
  120. }];
  121. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  122. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  123. *token = returnToken;
  124. return returnError;
  125. }
  126. - (NSError *)deletemarkEndToEndFolderEncrypted:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID token:(NSString **)token
  127. {
  128. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  129. __block NSError *returnError = nil;
  130. __block NSString *returnToken = nil;
  131. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  132. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  133. [communication setUserAgent:[CCUtility getUserAgent]];
  134. // LOCK
  135. [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:*token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
  136. returnToken = token;
  137. // REMOVE METADATA
  138. [communication deleteEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  139. NSLog(@"Delete metadata");
  140. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  141. NSLog(@"Metadata not present");
  142. }];
  143. // DELETE MARK
  144. [communication deletemarkEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  145. // UNLOCK
  146. [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:returnToken onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  147. returnToken = nil;
  148. dispatch_semaphore_signal(semaphore);
  149. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  150. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Unlock folder error" forKey:NSLocalizedDescriptionKey]];
  151. dispatch_semaphore_signal(semaphore);
  152. }];
  153. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  154. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Mark folder as encrypted error" forKey:NSLocalizedDescriptionKey]];
  155. dispatch_semaphore_signal(semaphore);
  156. }];
  157. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  158. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Lock folder error" forKey:NSLocalizedDescriptionKey]];
  159. dispatch_semaphore_signal(semaphore);
  160. }];
  161. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  162. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  163. *token = returnToken;
  164. return returnError;
  165. }
  166. - (NSError *)getEndToEndMetadata:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID metadata:(NSString **)metadata
  167. {
  168. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  169. __block NSError *returnError = nil;
  170. __block NSString *returnMetadata = nil;
  171. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  172. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  173. [communication setUserAgent:[CCUtility getUserAgent]];
  174. [communication getEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer) {
  175. returnMetadata = encryptedMetadata;
  176. dispatch_semaphore_signal(semaphore);
  177. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  178. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Unlock folder error" forKey:NSLocalizedDescriptionKey]];
  179. dispatch_semaphore_signal(semaphore);
  180. }];
  181. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  182. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  183. *metadata = returnMetadata;
  184. return returnError;
  185. }
  186. - (NSError *)storeEndToEndMetadata:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID metadata:(NSString *)metadata token:(NSString **)token
  187. {
  188. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  189. __block NSError *returnError = nil;
  190. __block NSString *returnToken = nil;
  191. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  192. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  193. [communication setUserAgent:[CCUtility getUserAgent]];
  194. // LOCK
  195. [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:*token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
  196. returnToken = token;
  197. // STORE METADATA
  198. [communication storeEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID encryptedMetadata:metadata onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer) {
  199. // UNLOCK
  200. [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:returnToken onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  201. returnToken = nil;
  202. dispatch_semaphore_signal(semaphore);
  203. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  204. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Unlock folder error" forKey:NSLocalizedDescriptionKey]];
  205. dispatch_semaphore_signal(semaphore);
  206. }];
  207. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  208. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Mark folder as encrypted error" forKey:NSLocalizedDescriptionKey]];
  209. dispatch_semaphore_signal(semaphore);
  210. }];
  211. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  212. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Lock folder error" forKey:NSLocalizedDescriptionKey]];
  213. dispatch_semaphore_signal(semaphore);
  214. }];
  215. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  216. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  217. *token = returnToken;
  218. return returnError;
  219. }
  220. - (NSError *)updateEndToEndMetadata:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID metadata:(NSString *)metadata token:(NSString **)token
  221. {
  222. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  223. __block NSError *returnError = nil;
  224. __block NSString *returnToken = nil;
  225. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  226. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  227. [communication setUserAgent:[CCUtility getUserAgent]];
  228. // LOCK
  229. [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:*token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
  230. returnToken = token;
  231. // UPDATA METADATA
  232. [communication updateEndToEndMetadata:[url stringByAppendingString:@"/"] fileID:fileID encryptedMetadata:metadata token:returnToken onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *encryptedMetadata, NSString *redirectedServer) {
  233. // UNLOCK
  234. [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:returnToken onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  235. returnToken = nil;
  236. dispatch_semaphore_signal(semaphore);
  237. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  238. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Unlock folder error" forKey:NSLocalizedDescriptionKey]];
  239. dispatch_semaphore_signal(semaphore);
  240. }];
  241. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  242. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Mark folder as encrypted error" forKey:NSLocalizedDescriptionKey]];
  243. dispatch_semaphore_signal(semaphore);
  244. }];
  245. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  246. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Lock folder error" forKey:NSLocalizedDescriptionKey]];
  247. dispatch_semaphore_signal(semaphore);
  248. }];
  249. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  250. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  251. *token = returnToken;
  252. return returnError;
  253. }
  254. - (NSError *)lockEndToEndFolderEncrypted:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID token:(NSString **)token
  255. {
  256. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  257. __block NSError *returnError = nil;
  258. __block NSString *returnToken = nil;
  259. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  260. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  261. [communication setUserAgent:[CCUtility getUserAgent]];
  262. [communication lockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:*token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *token, NSString *redirectedServer) {
  263. returnToken = token;
  264. dispatch_semaphore_signal(semaphore);
  265. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  266. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Lock folder error" forKey:NSLocalizedDescriptionKey]];
  267. dispatch_semaphore_signal(semaphore);
  268. }];
  269. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  270. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  271. *token = returnToken;
  272. return returnError;
  273. }
  274. - (NSError *)unlockEndToEndFolderEncrypted:(NSString *)user userID:(NSString *)userID password:(NSString *)password url:(NSString *)url fileID:(NSString *)fileID token:(NSString *)token
  275. {
  276. OCCommunication *communication = [CCNetworking sharedNetworking].sharedOCCommunication;
  277. __block NSError *returnError= nil;
  278. dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
  279. [communication setCredentialsWithUser:user andUserID:userID andPassword:password];
  280. [communication setUserAgent:[CCUtility getUserAgent]];
  281. [communication unlockEndToEndFolderEncrypted:[url stringByAppendingString:@"/"] fileID:fileID token:token onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
  282. dispatch_semaphore_signal(semaphore);
  283. } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
  284. returnError = [NSError errorWithDomain:@"com.nextcloud.nextcloud" code:response.statusCode userInfo:[NSDictionary dictionaryWithObject:@"Unlock folder error" forKey:NSLocalizedDescriptionKey]];
  285. dispatch_semaphore_signal(semaphore);
  286. }];
  287. while (dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER))
  288. [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:k_timeout_webdav]];
  289. return returnError;
  290. }
  291. @end