OCWebDAVClient.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. //
  2. // OCWebDAVClient.h
  3. // OCWebDAVClient
  4. //
  5. // This class is based in https://github.com/zwaldowski/DZWebDAVClient. Copyright (c) 2012 Zachary Waldowski, Troy Brant, Marcus Rohrmoser, and Sam Soffes.
  6. //
  7. // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ )
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining a copy
  10. // of this software and associated documentation files (the "Software"), to deal
  11. // in the Software without restriction, including without limitation the rights
  12. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. // copies of the Software, and to permit persons to whom the Software is
  14. // furnished to do so, subject to the following conditions:
  15. // The above copyright notice and this permission notice shall be included in
  16. // all copies or substantial portions of the Software.
  17. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  20. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  23. // THE SOFTWARE.
  24. //
  25. #import "AFHTTPSessionManager.h"
  26. #import "OCHTTPRequestOperation.h"
  27. @class OCCommunication;
  28. @class OCChunkDto;
  29. /** The key for a uniform (MIME) type identifier returned from the property request methods. */
  30. extern NSString * _Nullable OCWebDAVContentTypeKey;
  31. /** The key for a unique entity identifier returned from the property request methods. */
  32. extern NSString * _Nullable OCWebDAVETagKey;
  33. /** The key for a content identifier tag returned from the property request methods. This is only supported on some servers, and usually defines whether the contents of a collection (folder) have changed. */
  34. extern NSString * _Nullable OCWebDAVCTagKey;
  35. /** The key for the creation date of an entity. */
  36. extern NSString * _Nullable OCWebDAVCreationDateKey;
  37. /** The key for last modification date of an entity. */
  38. extern NSString * _Nullable OCWebDAVModificationDateKey;
  39. @interface OCWebDAVClient : NSObject
  40. @property (readwrite, nonatomic, strong) NSMutableDictionary * _Nullable defaultHeaders;
  41. //On redirections AFNetworking lose the request method on iOS6 and set a GET, we use this as workarround
  42. @property (nonatomic, strong) NSString * _Nullable requestMethod;
  43. //We use this variable to return the url of a redirected server to detect if we receive any sesion expired on SSO server
  44. @property (nonatomic, strong) NSString * _Nullable redirectedServer;
  45. //We use this variable to get the Cookies from the storage provider
  46. @property (nonatomic, strong) NSString * _Nullable originalUrlServer;
  47. @property (nonatomic, strong) NSString * _Nullable postStringForShare;
  48. /**
  49. Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
  50. @param username The HTTP basic auth username
  51. @param password The HTTP basic auth password
  52. */
  53. - (void)setAuthorizationHeaderWithUsername:(NSString * _Nonnull)username
  54. password:(NSString * _Nonnull)password;
  55. /**
  56. Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
  57. @param cookieString The HTTP token to login on SSO Servers
  58. */
  59. - (void)setAuthorizationHeaderWithCookie:(NSString * _Nonnull) cookieString;
  60. /**
  61. Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
  62. @param token The authentication token
  63. */
  64. - (void)setAuthorizationHeaderWithToken:(NSString * _Nonnull)token;
  65. /**
  66. Sets the "User-Agent" HTTP header
  67. @param userAgent -> String that indentifies the client app. Ex: "iOS-ownCloud"
  68. */
  69. - (void)setUserAgent:(NSString * _Nonnull)userAgent;
  70. /**
  71. Enqueues an operation to move the object at a path to another path using a `MOVE` request.
  72. @param source The path to move.
  73. @param destination The path to move the item to.
  74. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  75. @param success A block callback, to be fired upon successful completion, with no arguments.
  76. @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and the network error that occurred.
  77. */
  78. - (void)movePath:(NSString * _Nonnull)source toPath:(NSString * _Nonnull)destination
  79. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  80. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  81. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  82. /**
  83. Enqueues an operation to delete the object at a path using a `DELETE` request.
  84. @param path The path for which to create a directory.
  85. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  86. @param success A block callback, to be fired upon successful completion, with no arguments.
  87. @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and the network error that occurred.
  88. */
  89. - (void)deletePath:(NSString * _Nonnull)path
  90. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  91. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  92. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  93. /**
  94. Enqueues a request to list the properties of a single entity using a `PROPFIND` request for the specified path.
  95. @param path The path for which to list the properties.
  96. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  97. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the entity.
  98. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  99. @see listPath:success:failure:
  100. @see recursiveListPath:success:failure:
  101. */
  102. - (void)propertiesOfPath:(NSString * _Nonnull)path
  103. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  104. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  105. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  106. /**
  107. Enqueues a request to list the contents of a single collection and
  108. the properties of each object, including the properties of the
  109. collection itself, using a `PROPFIND` request.
  110. @param path The directory for which to list the contents.
  111. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  112. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the directory and its contents.
  113. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  114. @see propertiesOfPath:success:failure:
  115. @see recursiveListPath:success:failure:
  116. */
  117. - (void)listPath:(NSString * _Nonnull)path
  118. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  119. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject))success
  120. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  121. /**
  122. Enqueues a request to list the contents of a single collection and
  123. the properties of each object, including the properties of the
  124. collection itself, using a `PROPFIND` request.
  125. @param path The directory for which to list the contents.
  126. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  127. @param token User Session token
  128. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the directory and its contents.
  129. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  130. @see propertiesOfPath:success:failure:
  131. @see recursiveListPath:success:failure:
  132. */
  133. - (void)listPath:(NSString * _Nonnull)path
  134. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token
  135. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success
  136. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  137. /**
  138. Creates an `NSURLSessionDownloadTask` with the specified request for a local file.
  139. @param remoteSource is a string with the path of the file in the server
  140. @param localDestination is a string with the local device path for store the file
  141. @param defaultPriority is a bool with a flag to indicate if the download must be download inmediately of not.
  142. @param progress A progress object monitoring the current upload progress.
  143. @param success A block callback, to be fired upon successful completion, with NSURLResponse and string of URL of the filePath
  144. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  145. *
  146. @warning NSURLSession and NSRULSessionUploadTask only can be supported in iOS 7.
  147. */
  148. - (NSURLSessionDownloadTask * _Nonnull)downloadWithSessionPath:(NSString * _Nonnull)remoteSource toPath:(NSString * _Nonnull)localDestination defaultPriority:(BOOL)defaultPriority onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication progress:(void(^ _Nonnull)(NSProgress * _Nonnull progress))downloadProgress success:(void(^ _Nonnull)(NSURLResponse * _Nonnull response, NSURL * _Nonnull filePath))success failure:(void(^ _Nonnull)(NSURLResponse * _Nonnull response, NSError * _Nonnull error))failure;
  149. /**
  150. Enqueues a request to check the server to know the kind of authentication needed.
  151. @param path The path of the server.
  152. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  153. @param success A block callback, to be fired upon successful completion, with no arguments.
  154. @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and the network error that occurred.
  155. */
  156. - (void)checkServer:(NSString * _Nonnull)path onCommunication:
  157. (OCCommunication * _Nonnull)sharedOCCommunication
  158. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  159. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  160. /**
  161. Enqueues a request to creates a directory using a `MKCOL` request for the specified path.
  162. @param path The path for which to create a directory.
  163. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  164. @param success A block callback, to be fired upon successful completion, with no arguments.
  165. @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and the network error that occurred.
  166. */
  167. - (void)makeCollection:(NSString * _Nonnull)path
  168. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  169. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  170. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  171. /**
  172. Creates an `NSURLSessionUploadTask` with the specified request for a local file.
  173. @param localSource is a string with the path of the file to upload
  174. @param remoteDestination A remote path, relative to the HTTP client's base URL, to write the data to.
  175. @param progress A progress object monitoring the current upload progress.
  176. @param success A block callback, to be fired upon successful completion, with NSURLResponse and string of redirected server.
  177. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  178. *
  179. @warning NSURLSession and NSRULSessionUploadTask only can be supported in iOS 7.
  180. */
  181. - (NSURLSessionUploadTask * _Nonnull)putWithSessionLocalPath:(NSString * _Nonnull)localSource atRemotePath:(NSString * _Nonnull)remoteDestination onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication progress:(void(^ _Nonnull)(NSProgress * _Nonnull progress))uploadProgress success:(void(^ _Nonnull)(NSURLResponse * _Nonnull, NSString * _Nonnull))success failure:(void(^ _Nonnull)(NSURLResponse * _Nonnull, id _Nonnull, NSError * _Nonnull))failure failureBeforeRequest:(void(^ _Nonnull)(NSError * _Nonnull)) failureBeforeRequest;
  182. ///-----------------------------------
  183. /// @name requestForUserNameByCookie
  184. ///-----------------------------------
  185. /**
  186. * Method to obtain the User name by the cookie of the session
  187. *
  188. * @param NSString the cookie of the session
  189. *
  190. */
  191. - (void) requestUserNameOfServer:(NSString * _Nonnull) path byCookie:(NSString * _Nonnull) cookieString onCommunication:
  192. (OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  193. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  194. ///-----------------------------------
  195. /// @name Get status of the server
  196. ///-----------------------------------
  197. /**
  198. * Method to get the json of the status.php common in the ownCloud servers
  199. *
  200. * @param serverPath -> url of the server
  201. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  202. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  203. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  204. *
  205. */
  206. - (void) getStatusOfTheServer:(NSString * _Nonnull)serverPath onCommunication:
  207. (OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull responseObject))success
  208. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  209. ///-----------------------------------
  210. /// @name Get All the shared files and folders of a server
  211. ///-----------------------------------
  212. /**
  213. Method to get all the shared files fo an account by the server path and api
  214. @param serverPath -> The url of the server including the path of the Share API.
  215. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  216. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the directory and its contents.
  217. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  218. */
  219. - (void)listSharedByServer:(NSString * _Nonnull)serverPath
  220. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  221. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull responseObject))success
  222. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  223. ///-----------------------------------
  224. /// @name Get All the shared files and folders of concrete folder
  225. ///-----------------------------------
  226. /**
  227. Method to get all the shared files fo an account by the server path and api
  228. @param serverPath -> The url of the server including the path of the Share API.
  229. @param path -> The path of the folder that we want to know the shared
  230. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  231. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the directory and its contents.
  232. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  233. */
  234. - (void)listSharedByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) path
  235. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  236. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  237. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  238. ///-----------------------------------
  239. /// @name shareFileOrFolderByServer
  240. ///-----------------------------------
  241. /**
  242. * Method to share a file or folder with password
  243. *
  244. * @param serverPath -> NSString: Server path where we want to share a file or folder. Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares
  245. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  246. * @param password -> NSString: Password
  247. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  248. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  249. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  250. *
  251. */
  252. - (void)shareByLinkFileOrFolderByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) filePath andPassword:(NSString * _Nonnull)password
  253. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  254. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  255. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  256. ///-----------------------------------
  257. /// @name shareFileOrFolderByServer
  258. ///-----------------------------------
  259. /**
  260. * Method to share a file or folder
  261. *
  262. * @param serverPath -> NSString: Server path where we want to share a file or folder. Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares
  263. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  264. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  265. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  266. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  267. *
  268. */
  269. - (void)shareByLinkFileOrFolderByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) filePath
  270. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  271. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  272. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  273. ///-----------------------------------
  274. /// @name shareWith
  275. ///-----------------------------------
  276. /**
  277. * Method to share a file or folder with user and group
  278. *
  279. * @param userOrGroup -> NSString: user or group (You can get the shares id in the calls searchUsersAndGroupsWith....)
  280. * @param shareeType -> NSInteger: to set the type of sharee (user/group/federated)
  281. * @param serverPath -> NSString: Server path where we want to share a file or folder. Ex: http://10.40.40.20/owncloud/ocs/v2.php/apps/files_sharing/api/v1/sharees?format=json
  282. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  283. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  284. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  285. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  286. *
  287. */
  288. - (void)shareWith:(NSString * _Nonnull)userOrGroup shareeType:(NSInteger)shareeType inServer:(NSString * _Nonnull) serverPath andPath:(NSString * _Nonnull) filePath andPermissions:(NSInteger) permissions onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  289. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  290. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  291. ///-----------------------------------
  292. /// @name unShareFileOrFolderByServer
  293. ///-----------------------------------
  294. /**
  295. * Method to unshare a file or folder
  296. *
  297. * @param serverPath -> NSString: Server path with the id of the file or folder that we want to unshare Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares/44
  298. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  299. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  300. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  301. */
  302. - (void)unShareFileOrFolderByServer:(NSString * _Nonnull)serverPath
  303. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  304. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  305. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  306. ///-----------------------------------
  307. /// @name isShareFileOrFolderByServer
  308. ///-----------------------------------
  309. /**
  310. * Method to know if a share item still shared
  311. *
  312. * @param serverPath -> NSString: Server path with the id of the file or folder that we want know if is shared Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares/44
  313. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  314. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  315. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  316. */
  317. - (void)isShareFileOrFolderByServer:(NSString * _Nonnull)serverPath
  318. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  319. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  320. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  321. ///-----------------------------------
  322. /// @name updateShareItem
  323. ///-----------------------------------
  324. /**
  325. * Method to update a share link
  326. *
  327. * @param shareId -> NSInterger: Share id (You can get the shares id in the calls listSharedByServer....)
  328. * @param serverPath -> NSString: Server path with the id of the file or folder that we want know if is shared Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares/44
  329. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  330. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  331. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  332. */
  333. - (void) updateShareItem:(NSInteger)shareId ofServerPath:(NSString * _Nonnull)serverPath withPasswordProtect:(NSString * _Nonnull)password andExpirationTime:(NSString * _Nonnull)expirationTime andPermissions:(NSInteger)permissions
  334. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  335. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  336. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  337. ///-----------------------------------
  338. /// @name searchUsersAndGroupsWith
  339. ///-----------------------------------
  340. /**
  341. * Method to search users or groups
  342. *
  343. * @param searchString -> NSString: Search string
  344. * @param serverPath -> NSString: Server path with the id of the file or folder that we want know if is shared Ex: http://10.40.40.20/owncloud/ocs/v2.php/apps/files_sharing/api/v1/sharees?format=json
  345. * @param page -> NSInteger: Number of page of the results (pagination support)
  346. * @param resultsPerPage -> NSInteger: Number of results per page (pagination support)
  347. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  348. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  349. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  350. */
  351. - (void) searchUsersAndGroupsWith:(NSString * _Nonnull)searchString forPage:(NSInteger)page with:(NSInteger)resultsPerPage ofServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication
  352. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  353. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  354. ///-----------------------------------
  355. /// @name Get the server capabilities
  356. ///-----------------------------------
  357. /**
  358. * Method read the capabilities of the server
  359. *
  360. * @param serverPath -> NSString server
  361. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  362. *
  363. * @return capabilities -> OCCapabilities
  364. *
  365. */
  366. - (void) getCapabilitiesOfServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  367. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  368. #pragma mark - Remote thumbnails
  369. ///-----------------------------------
  370. /// @name Get the thumbnail for a file
  371. ///-----------------------------------
  372. /**
  373. * Method to get the remote thumbnail for a file
  374. *
  375. * @param serverPath -> NSString server
  376. * @param filePath -> NSString file path
  377. * @param fileWidth -> NSInteger with the width size
  378. * @param fileHeight -> NSInteger with the height size
  379. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  380. *
  381. * @return nsData -> thumbnail of the file with the size requested
  382. *
  383. */
  384. - (OCHTTPRequestOperation * _Nonnull) getRemoteThumbnailByServer:(NSString * _Nonnull)serverPath ofFilePath:(NSString * _Nonnull)filePath withWidth:(NSInteger)fileWidth andHeight:(NSInteger)fileHeight onCommunication:(OCCommunication * _Nonnull)sharedOCComunication
  385. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  386. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  387. #pragma mark - Get Notification
  388. ///-----------------------------------
  389. /// @name Get the server notification
  390. ///-----------------------------------
  391. - (void) getNotificationsOfServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  392. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  393. @end