motion-firebase 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,383 @@
1
+ /*
2
+ * Firebase iOS Client Library
3
+ *
4
+ * Copyright © 2013 Firebase - All Rights Reserved
5
+ * https://www.firebase.com
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice, this
11
+ * list of conditions and the following disclaimer.
12
+ *
13
+ * 2. Redistributions in binaryform must reproduce the above copyright notice,
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR
18
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20
+ * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT,
21
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ */
28
+
29
+ #import <Foundation/Foundation.h>
30
+ #import "FEventType.h"
31
+ #import "FDataSnapshot.h"
32
+
33
+ typedef NSUInteger FirebaseHandle;
34
+
35
+ /**
36
+ * An FQuery instance represents a query over the data at a particular location.
37
+ *
38
+ * You create one by calling one of the query methods (queryStartingAtPriority:, queryEndingAtPriority:, etc.)
39
+ * on a Firebase reference. The query methods can be chained to further specify the data you are interested in
40
+ * observing
41
+ */
42
+ @interface FQuery : NSObject
43
+
44
+
45
+ /** @name Attaching observers to read data */
46
+
47
+
48
+ /**
49
+ * observeEventType:withBlock: is used to listen for data changes at a particular location.
50
+ * This is the primary way to read data from Firebase. Your block will be triggered
51
+ * for the initial data and again whenever the data changes.
52
+ *
53
+ * Use removeObserverWithHandle: to stop receiving updates.
54
+ *
55
+ * @param eventType The type of event to listen for.
56
+ * @param block The block that should be called with initial data and updates.
57
+ * @return A handle used to unregister this block later using removeObserverWithHandle:
58
+ */
59
+ - (FirebaseHandle) observeEventType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block;
60
+
61
+
62
+ /**
63
+ * observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location.
64
+ * This is the primary way to read data from Firebase. Your block will be triggered
65
+ * for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and
66
+ * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.
67
+ *
68
+ * Use removeObserverWithHandle: to stop receiving updates.
69
+ *
70
+ * @param eventType The type of event to listen for.
71
+ * @param block The block that should be called with initial data and updates, as well as the previous child's key.
72
+ * @return A handle used to unregister this block later using removeObserverWithHandle:
73
+ */
74
+ - (FirebaseHandle) observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block;
75
+
76
+
77
+ /**
78
+ * observeEventType:withBlock: is used to listen for data changes at a particular location.
79
+ * This is the primary way to read data from Firebase. Your block will be triggered
80
+ * for the initial data and again whenever the data changes.
81
+ *
82
+ * The cancelBlock will be called if you will no longer receive new events due to no longer having permission.
83
+ *
84
+ * Use removeObserverWithHandle: to stop receiving updates.
85
+ *
86
+ * @param eventType The type of event to listen for.
87
+ * @param block The block that should be called with initial data and updates.
88
+ * @param cancelBlock The block that should be called if this client no longer has permission to receive these events
89
+ * @return A handle used to unregister this block later using removeObserverWithHandle:
90
+ */
91
+ - (FirebaseHandle) observeEventType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block withCancelBlock:(void (^)(NSError* error))cancelBlock;
92
+
93
+
94
+ /**
95
+ * observeEventType:andPreviousSiblingKeyWithBlock: is used to listen for data changes at a particular location.
96
+ * This is the primary way to read data from Firebase. Your block will be triggered
97
+ * for the initial data and again whenever the data changes. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and
98
+ * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.
99
+ *
100
+ * The cancelBlock will be called if you will no longer receive new events due to no longer having permission.
101
+ *
102
+ * Use removeObserverWithHandle: to stop receiving updates.
103
+ *
104
+ * @param eventType The type of event to listen for.
105
+ * @param block The block that should be called with initial data and updates, as well as the previous child's key.
106
+ * @param cancelBlock The block that should be called if this client no longer has permission to receive these events
107
+ * @return A handle used to unregister this block later using removeObserverWithHandle:
108
+ */
109
+ - (FirebaseHandle) observeEventType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block withCancelBlock:(void (^)(NSError* error))cancelBlock;
110
+
111
+
112
+ /**
113
+ * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned.
114
+ *
115
+ * @param eventType The type of event to listen for.
116
+ * @param block The block that should be called with initial data and updates.
117
+ */
118
+ - (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block;
119
+
120
+
121
+ /**
122
+ * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and
123
+ * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.
124
+ *
125
+ * @param eventType The type of event to listen for.
126
+ * @param block The block that should be called with initial data and updates.
127
+ */
128
+ - (void) observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block;
129
+
130
+
131
+ /**
132
+ * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned.
133
+ *
134
+ * The cancelBlock will be called if you do not have permission to read data at this location.
135
+ *
136
+ * @param eventType The type of event to listen for.
137
+ * @param block The block that should be called with initial data and updates.
138
+ * @param cancelBlock The block that will be called if you don't have permission to access this data
139
+ */
140
+ - (void) observeSingleEventOfType:(FEventType)eventType withBlock:(void (^)(FDataSnapshot* snapshot))block withCancelBlock:(void (^)(NSError* error))cancelBlock;
141
+
142
+
143
+ /**
144
+ * This is equivalent to observeEventType:withBlock:, except the block is immediately canceled after the initial data is returned. In addition, for FEventTypeChildAdded, FEventTypeChildMoved, and
145
+ * FEventTypeChildChanged events, your block will be passed the key of the previous node by priority order.
146
+ *
147
+ * The cancelBlock will be called if you do not have permission to read data at this location.
148
+ *
149
+ * @param eventType The type of event to listen for.
150
+ * @param block The block that should be called with initial data and updates.
151
+ * @param cancelBlock The block that will be called if you don't have permission to access this data
152
+ */
153
+ - (void) observeSingleEventOfType:(FEventType)eventType andPreviousSiblingKeyWithBlock:(void (^)(FDataSnapshot* snapshot, NSString* prevKey))block withCancelBlock:(void (^)(NSError* error))cancelBlock;
154
+
155
+ /** @name Detaching observers */
156
+
157
+ /**
158
+ * Detach a block previously attached with observeEventType:withBlock:.
159
+ *
160
+ * @param handle The handle returned by the call to observeEventType:withBlock: which we are trying to remove.
161
+ */
162
+ - (void) removeObserverWithHandle:(FirebaseHandle)handle;
163
+
164
+
165
+ /**
166
+ * Detach all blocks previously attached to this Firebase location with observeEventType:withBlock:
167
+ */
168
+ - (void) removeAllObservers;
169
+
170
+
171
+ /** @name Querying and limiting */
172
+
173
+
174
+ /**
175
+ * This method is deprecated in favor of using queryStartingAtValue:. This can be used with queryOrderedByPriority
176
+ * to query by priority.
177
+ *
178
+ * queryStartingAtPriority: is used to generate a reference to a limited view of the data at this location.
179
+ * The FQuery instance returned by queryStartingAtPriority: will respond to events at nodes with a priority
180
+ * greater than or equal to startPriority
181
+ *
182
+ * @param startPriority The lower bound, inclusive, for the priority of data visible to the returned FQuery
183
+ * @return An FQuery instance, limited to data with priority greater than or equal to startPriority
184
+ */
185
+ - (FQuery *) queryStartingAtPriority:(id)startPriority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryStartingAtValue:] instead")));
186
+
187
+
188
+ /**
189
+ * This method is deprecated in favor of using queryStartingAtValue:childKey:. This can be used with queryOrderedByPriority
190
+ * to query by priority.
191
+ *
192
+ * queryStartingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location.
193
+ * The FQuery instance returned by queryStartingAtPriority:andChildName will respond to events at nodes with a priority
194
+ * greater than startPriority, or equal to startPriority and with a name greater than or equal to childName
195
+ *
196
+ * @param startPriority The lower bound, inclusive, for the priority of data visible to the returned FQuery
197
+ * @param childName The lower bound, inclusive, for the name of nodes with priority equal to startPriority
198
+ * @return An FQuery instance, limited to data with priority greater than or equal to startPriority
199
+ */
200
+ - (FQuery *) queryStartingAtPriority:(id)startPriority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryStartingAtValue:childKey:] instead")));
201
+
202
+ /**
203
+ * This method is deprecated in favor of using queryEndingAtValue:. This can be used with queryOrderedByPriority
204
+ * to query by priority.
205
+ *
206
+ * queryEndingAtPriority: is used to generate a reference to a limited view of the data at this location.
207
+ * The FQuery instance returned by queryEndingAtPriority: will respond to events at nodes with a priority
208
+ * less than or equal to startPriority and with a name greater than or equal to childName
209
+ *
210
+ * @param endPriority The upper bound, inclusive, for the priority of data visible to the returned FQuery
211
+ * @return An FQuery instance, limited to data with priority less than or equal to endPriority
212
+ */
213
+ - (FQuery *) queryEndingAtPriority:(id)endPriority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEndingAtValue:] instead")));
214
+
215
+
216
+ /**
217
+ * This method is deprecated in favor of using queryEndingAtValue:childKey:. This can be used with queryOrderedByPriority
218
+ * to query by priority.
219
+ *
220
+ * queryEndingAtPriority:andChildName: is used to generate a reference to a limited view of the data at this location.
221
+ * The FQuery instance returned by queryEndingAtPriority:andChildName will respond to events at nodes with a priority
222
+ * less than endPriority, or equal to endPriority and with a name less than or equal to childName
223
+ *
224
+ * @param endPriority The upper bound, inclusive, for the priority of data visible to the returned FQuery
225
+ * @param childName The upper bound, inclusive, for the name of nodes with priority equal to endPriority
226
+ * @return An FQuery instance, limited to data with priority less than endPriority or equal to endPriority and with a name less than or equal to childName
227
+ */
228
+ - (FQuery *) queryEndingAtPriority:(id)endPriority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEndingAtValue:childKey:] instead")));
229
+
230
+
231
+ /**
232
+ * This method is deprecated in favor of using queryEqualToValue:. This can be used with queryOrderedByPriority
233
+ * to query by priority.
234
+ *
235
+ * queryEqualToPriority: is used to generate a reference to a limited view of the data at this location.
236
+ * The FQuery instance returned by queryEqualToPriority: will respond to events at nodes with a priority equal to
237
+ * supplied argument.
238
+ *
239
+ * @param priority The priority that the data returned by this FQuery will have
240
+ * @return An Fquery instance, limited to data with the supplied priority.
241
+ */
242
+ - (FQuery *) queryEqualToPriority:(id)priority __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEqualToValue:] instead")));
243
+
244
+
245
+ /**
246
+ * This method is deprecated in favor of using queryEqualAtValue:childKey:. This can be used with queryOrderedByPriority
247
+ * to query by priority.
248
+ *
249
+ * queryEqualToPriority:andChildName: is used to generate a reference to a limited view of the data at this location.
250
+ * The FQuery instance returned by queryEqualToPriority:andChildName will respond to events at nodes with a priority
251
+ * equal to the supplied argument with a name equal to childName. There will be at most one node that matches because
252
+ * child names are unique.
253
+ *
254
+ * @param priority The priority that the data returned by this FQuery will have
255
+ * @param childName The name of nodes with the right priority
256
+ * @return An FQuery instance, limited to data with the supplied priority and the name.
257
+ */
258
+ - (FQuery *) queryEqualToPriority:(id)priority andChildName:(NSString *)childName __attribute__((deprecated("Use [[FQuery queryOrderedByPriority] queryEqualToValue:childKey:] instead")));
259
+
260
+ /**
261
+ * This method is deprecated in favor of using queryLimitedToFirst:limit or queryLimitedToLast:limit instead.
262
+ *
263
+ * queryLimitedToNumberOfChildren: is used to generate a reference to a limited view of the data at this location.
264
+ * The FQuery instance returned by queryLimitedToNumberOfChildren: will respond to events from at most limit child nodes.
265
+ *
266
+ * @param limit The upper bound, inclusive, for the number of child nodes to receive events for
267
+ * @return An FQuery instance, limited to at most limit child nodes.
268
+ */
269
+ - (FQuery *) queryLimitedToNumberOfChildren:(NSUInteger)limit __attribute__((deprecated("Use [FQuery queryLimitedToFirst:limit] or [FQuery queryLimitedToLast:limit] instead")));
270
+
271
+
272
+ /**
273
+ * queryLimitedToFirst: is used to generate a reference to a limited view of the data at this location.
274
+ * The FQuery instance returned by queryLimitedToFirst: will respond to at most the first limit child nodes.
275
+ *
276
+ * @param limit The upper bound, inclusive, for the number of child nodes to receive events for
277
+ * @return An FQuery instance, limited to at most limit child nodes.
278
+ */
279
+ - (FQuery *) queryLimitedToFirst:(NSUInteger)limit;
280
+
281
+
282
+ /**
283
+ * queryLimitedToLast: is used to generate a reference to a limited view of the data at this location.
284
+ * The FQuery instance returned by queryLimitedToLast: will respond to at most the last limit child nodes.
285
+ *
286
+ * @param limit The upper bound, inclusive, for the number of child nodes to receive events for
287
+ * @return An FQuery instance, limited to at most limit child nodes.
288
+ */
289
+ - (FQuery *) queryLimitedToLast:(NSUInteger)limit;
290
+
291
+ /**
292
+ * queryOrderBy: is used to generate a reference to a view of the data that's been sorted by the values of
293
+ * a particular child key. This method is intended to be used in combination with queryStartingAtValue:,
294
+ * queryEndingAtValue:, or queryEqualToValue:.
295
+ *
296
+ * @param key The child key to use in ordering data visible to the returned FQuery
297
+ * @return An FQuery instance, ordered by the values of the specified child key.
298
+ */
299
+ - (FQuery *) queryOrderedByChild:(NSString *)key;
300
+
301
+ /**
302
+ * queryOrderedByKey: is used to generate a reference to a view of the data that's been sorted by child key.
303
+ * This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:,
304
+ * or queryEqualToValue:.
305
+ *
306
+ * @return An FQuery instance, ordered by child keys.
307
+ */
308
+ - (FQuery *) queryOrderedByKey;
309
+
310
+ /**
311
+ * queryOrderedByPriority: is used to generate a reference to a view of the data that's been sorted by child
312
+ * priority. This method is intended to be used in combination with queryStartingAtValue:, queryEndingAtValue:,
313
+ * or queryEqualToValue:.
314
+ *
315
+ * @return An FQuery instance, ordered by child priorities.
316
+ */
317
+ - (FQuery *) queryOrderedByPriority;
318
+
319
+ /**
320
+ * queryStartingAtValue: is used to generate a reference to a limited view of the data at this location.
321
+ * The FQuery instance returned by queryStartingAtValue: will respond to events at nodes with a value
322
+ * greater than or equal to startValue.
323
+ *
324
+ * @param startValue The lower bound, inclusive, for the value of data visible to the returned FQuery
325
+ * @return An FQuery instance, limited to data with value greater than or equal to startValue
326
+ */
327
+ - (FQuery *) queryStartingAtValue:(id)startValue;
328
+
329
+ /**
330
+ * queryStartingAtValue:childKey: is used to generate a reference to a limited view of the data at this location.
331
+ * The FQuery instance returned by queryStartingAtValue:childKey will respond to events at nodes with a value
332
+ * greater than startValue, or equal to startValue and with a key greater than or equal to childKey.
333
+ *
334
+ * @param startValue The lower bound, inclusive, for the value of data visible to the returned FQuery
335
+ * @param childKey The lower bound, inclusive, for the key of nodes with value equal to startValue
336
+ * @return An FQuery instance, limited to data with value greater than or equal to startValue
337
+ */
338
+ - (FQuery *) queryStartingAtValue:(id)startValue childKey:(NSString *)childKey;
339
+
340
+ /**
341
+ * queryEndingAtValue: is used to generate a reference to a limited view of the data at this location.
342
+ * The FQuery instance returned by queryEndingAtValue: will respond to events at nodes with a value
343
+ * less than or equal to endValue.
344
+ *
345
+ * @param endValue The upper bound, inclusive, for the value of data visible to the returned FQuery
346
+ * @return An FQuery instance, limited to data with value less than or equal to endValue
347
+ */
348
+ - (FQuery *) queryEndingAtValue:(id)endValue;
349
+
350
+ /**
351
+ * queryEndingAtValue:childKey: is used to generate a reference to a limited view of the data at this location.
352
+ * The FQuery instance returned by queryEndingAtValue:childKey will respond to events at nodes with a value
353
+ * less than endValue, or equal to endValue and with a key less than or equal to childKey.
354
+ *
355
+ * @param endValue The upper bound, inclusive, for the value of data visible to the returned FQuery
356
+ * @param childKey The upper bound, inclusive, for the key of nodes with value equal to endValue
357
+ * @return An FQuery instance, limited to data with value less than or equal to endValue
358
+ */
359
+ - (FQuery *) queryEndingAtValue:(id)endValue childKey:(NSString *)childKey;
360
+
361
+ /**
362
+ * queryEqualToValue: is used to generate a reference to a limited view of the data at this location.
363
+ * The FQuery instance returned by queryEqualToValue: will respond to events at nodes with a value equal
364
+ * to the supplied argument.
365
+ *
366
+ * @param value The value that the data returned by this FQuery will have
367
+ * @return An Fquery instance, limited to data with the supplied value.
368
+ */
369
+ - (FQuery *) queryEqualToValue:(id)value;
370
+
371
+ /**
372
+ * queryEqualToValue:childKey: is used to generate a reference to a limited view of the data at this location.
373
+ * The FQuery instance returned by queryEqualToValue:childKey will respond to events at nodes with a value
374
+ * equal to the supplied argument with a name equal to childKey. There will be at most one node that matches because
375
+ * child keys are unique.
376
+ *
377
+ * @param value The value that the data returned by this FQuery will have
378
+ * @param childKey The name of nodes with the right value
379
+ * @return An FQuery instance, limited to data with the supplied value and the key.
380
+ */
381
+ - (FQuery *) queryEqualToValue:(id)value childKey:(NSString *)childKey;
382
+
383
+ @end
@@ -0,0 +1,53 @@
1
+ /*
2
+ * Firebase iOS Client Library
3
+ *
4
+ * Copyright © 2013 Firebase - All Rights Reserved
5
+ * https://www.firebase.com
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain the above copyright notice, this
11
+ * list of conditions and the following disclaimer.
12
+ *
13
+ * 2. Redistributions in binaryform must reproduce the above copyright notice,
14
+ * this list of conditions and the following disclaimer in the documentation
15
+ * and/or other materials provided with the distribution.
16
+ *
17
+ * THIS SOFTWARE IS PROVIDED BY FIREBASE AS IS AND ANY EXPRESS OR
18
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
20
+ * EVENT SHALL FIREBASE BE LIABLE FOR ANY DIRECT,
21
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
22
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
24
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
25
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
26
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+ */
28
+
29
+ #import <Foundation/Foundation.h>
30
+ #import "FMutableData.h"
31
+
32
+ /**
33
+ * Used for runTransactionBlock:. An FTransactionResult instance is a container for the results of the transaction.
34
+ */
35
+ @interface FTransactionResult : NSObject
36
+
37
+ /**
38
+ * Used for runTransactionBlock:. Indicates that the new value should be saved at this location
39
+ *
40
+ * @param value An FMutableData instance containing the new value to be set
41
+ * @return An FTransactionResult instance that can be used as a return value from the block given to runTransactionBlock:
42
+ */
43
+ + (FTransactionResult *) successWithValue:(FMutableData *)value;
44
+
45
+
46
+ /**
47
+ * Used for runTransactionBlock:. Indicates that the current transaction should no longer proceed.
48
+ *
49
+ * @return An FTransactionResult instance that can be used as a return value from the block given to runTransactionBlock:
50
+ */
51
+ + (FTransactionResult *) abort;
52
+
53
+ @end