OCWebDAVClient.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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. //
  26. // Add : getNotificationServer & setNotificationServer
  27. // Add : getUserProfileServer
  28. //
  29. // Author Marino Faggiana <m.faggiana@twsweb.it>
  30. //
  31. #import "AFHTTPSessionManager.h"
  32. #import "OCHTTPRequestOperation.h"
  33. @class OCCommunication;
  34. @class OCChunkDto;
  35. /** The key for a uniform (MIME) type identifier returned from the property request methods. */
  36. extern NSString * _Nullable OCWebDAVContentTypeKey;
  37. /** The key for a unique entity identifier returned from the property request methods. */
  38. extern NSString * _Nullable OCWebDAVETagKey;
  39. /** 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. */
  40. extern NSString * _Nullable OCWebDAVCTagKey;
  41. /** The key for the creation date of an entity. */
  42. extern NSString * _Nullable OCWebDAVCreationDateKey;
  43. /** The key for last modification date of an entity. */
  44. extern NSString * _Nullable OCWebDAVModificationDateKey;
  45. @interface OCWebDAVClient : NSObject
  46. @property (readwrite, nonatomic, strong) NSMutableDictionary * _Nullable defaultHeaders;
  47. //On redirections AFNetworking lose the request method on iOS6 and set a GET, we use this as workarround
  48. @property (nonatomic, strong) NSString * _Nullable requestMethod;
  49. //We use this variable to return the url of a redirected server to detect if we receive any sesion expired on SSO server
  50. @property (nonatomic, strong) NSString * _Nullable redirectedServer;
  51. //We use this variable to get the Cookies from the storage provider
  52. @property (nonatomic, strong) NSString * _Nullable originalUrlServer;
  53. @property (nonatomic, strong) NSString * _Nullable postStringForShare;
  54. /**
  55. 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.
  56. @param username The HTTP basic auth username
  57. @param password The HTTP basic auth password
  58. */
  59. - (void)setAuthorizationHeaderWithUsername:(NSString * _Nonnull)username
  60. password:(NSString * _Nonnull)password;
  61. /**
  62. 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.
  63. @param cookieString The HTTP token to login on SSO Servers
  64. */
  65. - (void)setAuthorizationHeaderWithCookie:(NSString * _Nonnull) cookieString;
  66. /**
  67. 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.
  68. @param token The authentication token
  69. */
  70. - (void)setAuthorizationHeaderWithToken:(NSString * _Nonnull)token;
  71. /**
  72. Sets the "User-Agent" HTTP header
  73. @param userAgent -> String that indentifies the client app. Ex: "iOS-ownCloud"
  74. */
  75. - (void)setUserAgent:(NSString * _Nonnull)userAgent;
  76. /**
  77. Enqueues an operation to move the object at a path to another path using a `MOVE` request.
  78. @param source The path to move.
  79. @param destination The path to move the item to.
  80. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  81. @param success A block callback, to be fired upon successful completion, with no arguments.
  82. @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.
  83. */
  84. - (void)movePath:(NSString * _Nonnull)source toPath:(NSString * _Nonnull)destination
  85. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  86. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  87. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  88. /**
  89. Enqueues an operation to delete the object at a path using a `DELETE` request.
  90. @param path The path for which to create a directory.
  91. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  92. @param success A block callback, to be fired upon successful completion, with no arguments.
  93. @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.
  94. */
  95. - (void)deletePath:(NSString * _Nonnull)path
  96. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  97. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  98. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  99. /**
  100. Enqueues a request to list the properties of a single entity using a `PROPFIND` request for the specified path.
  101. @param path The path for which to list the properties.
  102. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  103. @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.
  104. @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.
  105. @see listPath:success:failure:
  106. @see recursiveListPath:success:failure:
  107. */
  108. - (void)propertiesOfPath:(NSString * _Nonnull)path
  109. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  110. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  111. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  112. /**
  113. Enqueues a request to list the contents of a single collection and
  114. the properties of each object, including the properties of the
  115. collection itself, using a `PROPFIND` request.
  116. @param path The directory for which to list the contents.
  117. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  118. @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.
  119. @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.
  120. @see propertiesOfPath:success:failure:
  121. @see recursiveListPath:success:failure:
  122. */
  123. - (void)listPath:(NSString * _Nonnull)path
  124. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  125. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject))success
  126. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  127. /**
  128. Enqueues a request to list the contents of a single collection and
  129. the properties of each object, including the properties of the
  130. collection itself, using a `PROPFIND` request.
  131. @param path The directory for which to list the contents.
  132. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  133. @param token User Session token
  134. @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.
  135. @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.
  136. @see propertiesOfPath:success:failure:
  137. @see recursiveListPath:success:failure:
  138. */
  139. - (void)listPath:(NSString * _Nonnull)path
  140. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token
  141. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success
  142. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  143. /**
  144. */
  145. - (void)search:(NSString * _Nonnull)path folder:(NSString * _Nonnull)folder fileName:(NSString * _Nonnull)fileName depth:(NSString * _Nonnull)depth user:(NSString * _Nonnull)user onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  146. /**
  147. */
  148. - (void)settingFavorite:(NSString * _Nonnull)path favorite:(BOOL)favorite onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  149. /**
  150. */
  151. - (void)listingFavorites:(NSString * _Nonnull)path folder:(NSString * _Nonnull)folder user:(NSString * _Nonnull)user onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  152. /**
  153. Creates an `NSURLSessionDownloadTask` with the specified request for a local file.
  154. @param remoteSource is a string with the path of the file in the server
  155. @param localDestination is a string with the local device path for store the file
  156. @param defaultPriority is a bool with a flag to indicate if the download must be download inmediately of not.
  157. @param progress A progress object monitoring the current upload progress.
  158. @param success A block callback, to be fired upon successful completion, with NSURLResponse and string of URL of the filePath
  159. @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.
  160. *
  161. @warning NSURLSession and NSRULSessionUploadTask only can be supported in iOS 7.
  162. */
  163. - (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;
  164. /**
  165. Enqueues a request to check the server to know the kind of authentication needed.
  166. @param path The path of the server.
  167. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  168. @param success A block callback, to be fired upon successful completion, with no arguments.
  169. @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.
  170. */
  171. - (void)checkServer:(NSString * _Nonnull)path onCommunication:
  172. (OCCommunication * _Nonnull)sharedOCCommunication
  173. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  174. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  175. /**
  176. Enqueues a request to creates a directory using a `MKCOL` request for the specified path.
  177. @param path The path for which to create a directory.
  178. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  179. @param success A block callback, to be fired upon successful completion, with no arguments.
  180. @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.
  181. */
  182. - (void)makeCollection:(NSString * _Nonnull)path
  183. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  184. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  185. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  186. /**
  187. Creates an `NSURLSessionUploadTask` with the specified request for a local file.
  188. @param localSource is a string with the path of the file to upload
  189. @param remoteDestination A remote path, relative to the HTTP client's base URL, to write the data to.
  190. @param progress A progress object monitoring the current upload progress.
  191. @param success A block callback, to be fired upon successful completion, with NSURLResponse and string of redirected server.
  192. @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.
  193. *
  194. @warning NSURLSession and NSRULSessionUploadTask only can be supported in iOS 7.
  195. */
  196. - (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;
  197. ///-----------------------------------
  198. /// @name requestForUserNameByCookie
  199. ///-----------------------------------
  200. /**
  201. * Method to obtain the User name by the cookie of the session
  202. *
  203. * @param NSString the cookie of the session
  204. *
  205. */
  206. - (void) requestUserNameOfServer:(NSString * _Nonnull) path byCookie:(NSString * _Nonnull) cookieString onCommunication:
  207. (OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  208. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  209. ///-----------------------------------
  210. /// @name Get status of the server
  211. ///-----------------------------------
  212. /**
  213. * Method to get the json of the status.php common in the ownCloud servers
  214. *
  215. * @param serverPath -> url of the server
  216. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  217. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  218. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  219. *
  220. */
  221. - (void) getStatusOfTheServer:(NSString * _Nonnull)serverPath onCommunication:
  222. (OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull responseObject))success
  223. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  224. ///-----------------------------------
  225. /// @name Get All the shared files and folders of a server
  226. ///-----------------------------------
  227. /**
  228. Method to get all the shared files fo an account by the server path and api
  229. @param serverPath -> The url of the server including the path of the Share API.
  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
  235. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  236. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull responseObject))success
  237. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  238. ///-----------------------------------
  239. /// @name Get All the shared files and folders of concrete folder
  240. ///-----------------------------------
  241. /**
  242. Method to get all the shared files fo an account by the server path and api
  243. @param serverPath -> The url of the server including the path of the Share API.
  244. @param path -> The path of the folder that we want to know the shared
  245. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  246. @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.
  247. @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.
  248. */
  249. - (void)listSharedByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) path
  250. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  251. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  252. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  253. ///-----------------------------------
  254. /// @name shareFileOrFolderByServer
  255. ///-----------------------------------
  256. /**
  257. * Method to share a file or folder with password
  258. *
  259. * @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
  260. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  261. * @param password -> NSString: Password
  262. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  263. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  264. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  265. *
  266. */
  267. - (void)shareByLinkFileOrFolderByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) filePath andPassword:(NSString * _Nonnull)password
  268. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  269. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  270. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  271. ///-----------------------------------
  272. /// @name shareFileOrFolderByServer
  273. ///-----------------------------------
  274. /**
  275. * Method to share a file or folder
  276. *
  277. * @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
  278. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  279. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  280. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  281. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  282. *
  283. */
  284. - (void)shareByLinkFileOrFolderByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) filePath
  285. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  286. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  287. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  288. ///-----------------------------------
  289. /// @name shareWith
  290. ///-----------------------------------
  291. /**
  292. * Method to share a file or folder with user and group
  293. *
  294. * @param userOrGroup -> NSString: user or group (You can get the shares id in the calls searchUsersAndGroupsWith....)
  295. * @param shareeType -> NSInteger: to set the type of sharee (user/group/federated)
  296. * @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
  297. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  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. */
  303. - (void)shareWith:(NSString * _Nonnull)userOrGroup shareeType:(NSInteger)shareeType inServer:(NSString * _Nonnull) serverPath andPath:(NSString * _Nonnull) filePath andPermissions:(NSInteger) permissions 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 unShareFileOrFolderByServer
  308. ///-----------------------------------
  309. /**
  310. * Method to unshare a file or folder
  311. *
  312. * @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
  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)unShareFileOrFolderByServer:(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 isShareFileOrFolderByServer
  323. ///-----------------------------------
  324. /**
  325. * Method to know if a share item still shared
  326. *
  327. * @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
  328. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  329. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  330. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  331. */
  332. - (void)isShareFileOrFolderByServer:(NSString * _Nonnull)serverPath
  333. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  334. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  335. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  336. ///-----------------------------------
  337. /// @name updateShareItem
  338. ///-----------------------------------
  339. /**
  340. * Method to update a share link
  341. *
  342. * @param shareId -> NSInterger: Share id (You can get the shares id in the calls listSharedByServer....)
  343. * @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
  344. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  345. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  346. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  347. */
  348. - (void) updateShareItem:(NSInteger)shareId ofServerPath:(NSString * _Nonnull)serverPath withPasswordProtect:(NSString * _Nonnull)password andExpirationTime:(NSString * _Nonnull)expirationTime andPermissions:(NSInteger)permissions
  349. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  350. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  351. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  352. ///-----------------------------------
  353. /// @name searchUsersAndGroupsWith
  354. ///-----------------------------------
  355. /**
  356. * Method to search users or groups
  357. *
  358. * @param searchString -> NSString: Search string
  359. * @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
  360. * @param page -> NSInteger: Number of page of the results (pagination support)
  361. * @param resultsPerPage -> NSInteger: Number of results per page (pagination support)
  362. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  363. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  364. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  365. */
  366. - (void) searchUsersAndGroupsWith:(NSString * _Nonnull)searchString forPage:(NSInteger)page with:(NSInteger)resultsPerPage ofServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication
  367. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  368. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  369. ///-----------------------------------
  370. /// @name Get the server capabilities
  371. ///-----------------------------------
  372. /**
  373. * Method read the capabilities of the server
  374. *
  375. * @param serverPath -> NSString server
  376. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  377. *
  378. * @return capabilities -> OCCapabilities
  379. *
  380. */
  381. - (void) getCapabilitiesOfServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  382. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  383. #pragma mark - Remote thumbnails
  384. ///-----------------------------------
  385. /// @name Get the thumbnail for a file
  386. ///-----------------------------------
  387. /**
  388. * Method to get the remote thumbnail for a file
  389. *
  390. * @param serverPath -> NSString server
  391. * @param filePath -> NSString file path
  392. * @param fileWidth -> NSInteger with the width size
  393. * @param fileHeight -> NSInteger with the height size
  394. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  395. *
  396. * @return nsData -> thumbnail of the file with the size requested
  397. *
  398. */
  399. - (OCHTTPRequestOperation * _Nonnull) getRemoteThumbnailByServer:(NSString * _Nonnull)serverPath ofFilePath:(NSString * _Nonnull)filePath withWidth:(NSInteger)fileWidth andHeight:(NSInteger)fileHeight onCommunication:(OCCommunication * _Nonnull)sharedOCComunication
  400. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  401. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  402. #pragma mark - Notification
  403. ///-----------------------------------
  404. /// @name Get the server Notification
  405. ///-----------------------------------
  406. /**
  407. * Method read the notification of the server
  408. *
  409. * @param serverPath -> NSString server
  410. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  411. *
  412. * @return listOfNotifications -> OCNotification
  413. *
  414. */
  415. - (void) getNotificationServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  416. ///-----------------------------------
  417. /// @name set server Notification
  418. ///-----------------------------------
  419. /**
  420. * Method read the notification of the server
  421. *
  422. * @param serverPath -> NSString server
  423. * @param type -> NSString "POST" "DELETE"
  424. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  425. *
  426. */
  427. - (void)setNotificationServer:(NSString * _Nonnull)serverPath type:(NSString * _Nonnull)type onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  428. ///-----------------------------------
  429. /// @name Get User Profile
  430. ///-----------------------------------
  431. /**
  432. * Method read the notification of the server
  433. *
  434. * @param serverPath -> NSString server
  435. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  436. *
  437. * @return userProfile -> OCUserProfile
  438. *
  439. */
  440. - (void) getUserProfileServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  441. @end