Yini  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
DBRestClient.h
Go to the documentation of this file.
1 //
2 // DBRestClient.h
3 // DropboxSDK
4 //
5 // Created by Brian Smith on 4/9/10.
6 // Copyright 2010 Dropbox, Inc. All rights reserved.
7 //
8 
9 
10 #import "DBSession.h"
11 
12 @protocol DBRestClientDelegate;
13 @class DBAccountInfo;
14 @class DBMetadata;
15 
16 @interface DBRestClient : NSObject {
18  NSString* userId;
19  NSString* root;
20  NSMutableSet* requests;
21  /* Map from path to the load request. Needs to be expanded to a general framework for cancelling
22  requests. */
23  NSMutableDictionary* loadRequests;
24  NSMutableDictionary* imageLoadRequests;
25  NSMutableDictionary* uploadRequests;
26  id<DBRestClientDelegate> delegate;
27 }
28 
29 - (id)initWithSession:(DBSession*)session;
30 - (id)initWithSession:(DBSession *)session userId:(NSString *)userId;
31 
32 /* Cancels all outstanding requests. No callback for those requests will be sent */
33 - (void)cancelAllRequests;
34 
35 
36 /* Loads metadata for the object at the given root/path and returns the result to the delegate as a
37  dictionary */
38 - (void)loadMetadata:(NSString*)path withHash:(NSString*)hash;
39 
40 - (void)loadMetadata:(NSString*)path;
41 
42 /* This will load the metadata of a file at a given rev */
43 - (void)loadMetadata:(NSString *)path atRev:(NSString *)rev;
44 
45 /* Loads a list of files (represented as DBDeltaEntry objects) that have changed since the cursor was generated */
46 - (void)loadDelta:(NSString *)cursor;
47 
48 
49 /* Loads the file contents at the given root/path and stores the result into destinationPath */
50 - (void)loadFile:(NSString *)path intoPath:(NSString *)destinationPath;
51 
52 /* This will load a file as it existed at a given rev */
53 - (void)loadFile:(NSString *)path atRev:(NSString *)rev intoPath:(NSString *)destPath;
54 
55 - (void)cancelFileLoad:(NSString*)path;
56 
57 
58 - (void)loadThumbnail:(NSString *)path ofSize:(NSString *)size intoPath:(NSString *)destinationPath;
59 - (void)cancelThumbnailLoad:(NSString*)path size:(NSString*)size;
60 
61 /* Uploads a file that will be named filename to the given path on the server. sourcePath is the
62  full path of the file you want to upload. If you are modifying a file, parentRev represents the
63  rev of the file before you modified it as returned from the server. If you are uploading a new
64  file set parentRev to nil. */
65 - (void)uploadFile:(NSString *)filename toPath:(NSString *)path withParentRev:(NSString *)parentRev
66  fromPath:(NSString *)sourcePath;
67 
68 - (void)cancelFileUpload:(NSString *)path;
69 
70 /* Avoid using this because it is very easy to overwrite conflicting changes. Provided for backwards
71  compatibility reasons only */
72 - (void)uploadFile:(NSString*)filename toPath:(NSString*)path fromPath:(NSString *)sourcePath __attribute__((deprecated));
73 
74 
75 /* Loads a list of up to 10 DBMetadata objects representing past revisions of the file at path */
76 - (void)loadRevisionsForFile:(NSString *)path;
77 
78 /* Same as above but with a configurable limit to number of DBMetadata objects returned, up to 1000 */
79 - (void)loadRevisionsForFile:(NSString *)path limit:(NSInteger)limit;
80 
81 /* Restores a file at path as it existed at the given rev and returns the metadata of the restored
82  file after restoration */
83 - (void)restoreFile:(NSString *)path toRev:(NSString *)rev;
84 
85 /* Creates a folder at the given root/path */
86 - (void)createFolder:(NSString*)path;
87 
88 - (void)deletePath:(NSString*)path;
89 
90 - (void)copyFrom:(NSString*)fromPath toPath:(NSString *)toPath;
91 
92 - (void)createCopyRef:(NSString *)path; // Used to copy between Dropboxes
93 - (void)copyFromRef:(NSString*)copyRef toPath:(NSString *)toPath; // Takes copy ref created by above call
94 
95 - (void)moveFrom:(NSString*)fromPath toPath:(NSString *)toPath;
96 
97 - (void)loadAccountInfo;
98 
99 - (void)searchPath:(NSString*)path forKeyword:(NSString*)keyword;
100 
101 - (void)loadSharableLinkForFile:(NSString *)path;
102 
103 - (void)loadStreamableURLForFile:(NSString *)path;
104 
105 - (NSUInteger)requestCount;
106 
107 @property (nonatomic, assign) id<DBRestClientDelegate> delegate;
108 
109 @end
110 
111 
112 
113 
114 /* The delegate provides allows the user to get the result of the calls made on the DBRestClient.
115  Right now, the error parameter of failed calls may be nil and [error localizedDescription] does
116  not contain an error message appropriate to show to the user. */
117 @protocol DBRestClientDelegate <NSObject>
118 
119 @optional
120 
121 - (void)restClient:(DBRestClient*)client loadedMetadata:(DBMetadata*)metadata;
122 - (void)restClient:(DBRestClient*)client metadataUnchangedAtPath:(NSString*)path;
123 - (void)restClient:(DBRestClient*)client loadMetadataFailedWithError:(NSError*)error;
124 // [error userInfo] contains the root and path of the call that failed
125 
126 - (void)restClient:(DBRestClient*)client loadedDeltaEntries:(NSArray *)entries reset:(BOOL)shouldReset cursor:(NSString *)cursor hasMore:(BOOL)hasMore;
127 - (void)restClient:(DBRestClient*)client loadDeltaFailedWithError:(NSError *)error;
128 
129 - (void)restClient:(DBRestClient*)client loadedAccountInfo:(DBAccountInfo*)info;
130 - (void)restClient:(DBRestClient*)client loadAccountInfoFailedWithError:(NSError*)error;
131 
132 - (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath;
133 // Implement the following callback instead of the previous if you care about the value of the
134 // Content-Type HTTP header and the file metadata. Only one will be called per successful response.
135 - (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath contentType:(NSString*)contentType metadata:(DBMetadata*)metadata;
136 - (void)restClient:(DBRestClient*)client loadProgress:(CGFloat)progress forFile:(NSString*)destPath;
137 - (void)restClient:(DBRestClient*)client loadFileFailedWithError:(NSError*)error;
138 // [error userInfo] contains the destinationPath
139 
140 
141 - (void)restClient:(DBRestClient*)client loadedThumbnail:(NSString*)destPath metadata:(DBMetadata*)metadata;
142 - (void)restClient:(DBRestClient*)client loadThumbnailFailedWithError:(NSError*)error;
143 
144 - (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath from:(NSString*)srcPath
145  metadata:(DBMetadata*)metadata;
146 - (void)restClient:(DBRestClient*)client uploadProgress:(CGFloat)progress
147  forFile:(NSString*)destPath from:(NSString*)srcPath;
148 - (void)restClient:(DBRestClient*)client uploadFileFailedWithError:(NSError*)error;
149 // [error userInfo] contains the sourcePath
150 
151 // Deprecated upload callback
152 - (void)restClient:(DBRestClient*)client uploadedFile:(NSString*)destPath from:(NSString*)srcPath;
153 
154 // Deprecated download callbacks
155 - (void)restClient:(DBRestClient*)client loadedFile:(NSString*)destPath contentType:(NSString*)contentType;
156 - (void)restClient:(DBRestClient*)client loadedThumbnail:(NSString*)destPath;
157 
158 - (void)restClient:(DBRestClient*)client loadedRevisions:(NSArray *)revisions forFile:(NSString *)path;
159 - (void)restClient:(DBRestClient*)client loadRevisionsFailedWithError:(NSError *)error;
160 
161 - (void)restClient:(DBRestClient*)client restoredFile:(DBMetadata *)fileMetadata;
162 - (void)restClient:(DBRestClient*)client restoreFileFailedWithError:(NSError *)error;
163 
164 - (void)restClient:(DBRestClient*)client createdFolder:(DBMetadata*)folder;
165 // Folder is the metadata for the newly created folder
166 - (void)restClient:(DBRestClient*)client createFolderFailedWithError:(NSError*)error;
167 // [error userInfo] contains the root and path
168 
169 - (void)restClient:(DBRestClient*)client deletedPath:(NSString *)path;
170 - (void)restClient:(DBRestClient*)client deletePathFailedWithError:(NSError*)error;
171 // [error userInfo] contains the root and path
172 
173 - (void)restClient:(DBRestClient*)client copiedPath:(NSString *)fromPath to:(DBMetadata *)to;
174 - (void)restClient:(DBRestClient*)client copyPathFailedWithError:(NSError*)error;
175 // [error userInfo] contains the root and path
176 
177 - (void)restClient:(DBRestClient*)client createdCopyRef:(NSString *)copyRef;
178 - (void)restClient:(DBRestClient*)client createCopyRefFailedWithError:(NSError *)error;
179 
180 - (void)restClient:(DBRestClient*)client copiedRef:(NSString *)copyRef to:(DBMetadata *)to;
181 - (void)restClient:(DBRestClient*)client copyFromRefFailedWithError:(NSError*)error;
182 
183 - (void)restClient:(DBRestClient*)client movedPath:(NSString *)from_path to:(DBMetadata *)result;
184 - (void)restClient:(DBRestClient*)client movePathFailedWithError:(NSError*)error;
185 // [error userInfo] contains the root and path
186 
187 - (void)restClient:(DBRestClient*)restClient loadedSearchResults:(NSArray*)results
188 forPath:(NSString*)path keyword:(NSString*)keyword;
189 // results is a list of DBMetadata * objects
190 - (void)restClient:(DBRestClient*)restClient searchFailedWithError:(NSError*)error;
191 
192 - (void)restClient:(DBRestClient*)restClient loadedSharableLink:(NSString*)link
193 forFile:(NSString*)path;
194 - (void)restClient:(DBRestClient*)restClient loadSharableLinkFailedWithError:(NSError*)error;
195 
196 - (void)restClient:(DBRestClient*)restClient loadedStreamableURL:(NSURL*)url forFile:(NSString*)path;
197 - (void)restClient:(DBRestClient*)restClient loadStreamableURLFailedWithError:(NSError*)error;
198 
199 
200 @end
201 
202