aboutsummaryrefslogtreecommitdiff
path: root/src/include/gnunet_social_service.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/include/gnunet_social_service.h')
-rw-r--r--src/include/gnunet_social_service.h156
1 files changed, 96 insertions, 60 deletions
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h
index 4864543fd..24aa871ed 100644
--- a/src/include/gnunet_social_service.h
+++ b/src/include/gnunet_social_service.h
@@ -105,7 +105,7 @@ typedef void
105 105
106 106
107/** 107/**
108 * Function called upon receiving a data fragment of a message. 108 * Function called upon receiving a modifier of a message.
109 * 109 *
110 * @param cls 110 * @param cls
111 * Closure. 111 * Closure.
@@ -115,8 +115,10 @@ typedef void
115 * Message part, as it arrived from the network. 115 * Message part, as it arrived from the network.
116 * @param oper 116 * @param oper
117 * Operation to perform. 117 * Operation to perform.
118 * 0 in case of a modifier continuation.
118 * @param name 119 * @param name
119 * Name of the modifier. 120 * Name of the modifier.
121 * NULL in case of a modifier continuation.
120 * @param value 122 * @param value
121 * Value of the modifier. 123 * Value of the modifier.
122 * @param value_size 124 * @param value_size
@@ -124,12 +126,13 @@ typedef void
124 */ 126 */
125typedef void 127typedef void
126(*GNUNET_SOCIAL_ModifierCallback) (void *cls, 128(*GNUNET_SOCIAL_ModifierCallback) (void *cls,
127 const struct GNUNET_PSYC_MessageModifier *msg, 129 const struct GNUNET_MessageHeader *msg,
128 uint64_t message_id, 130 uint64_t message_id,
129 enum GNUNET_ENV_Operator oper, 131 enum GNUNET_ENV_Operator oper,
130 const char *name, 132 const char *name,
131 const void *value, 133 const void *value,
132 uint16_t value_size); 134 uint16_t value_size,
135 uint16_t full_value_size);
133 136
134 137
135/** 138/**
@@ -185,6 +188,9 @@ typedef void
185/** 188/**
186 * Create a try-and-slice instance. 189 * Create a try-and-slice instance.
187 * 190 *
191 * A slicer processes incoming messages and notifies callbacks about matching
192 * methods or modifiers encountered.
193 *
188 * @return A new try-and-slice construct. 194 * @return A new try-and-slice construct.
189 */ 195 */
190struct GNUNET_SOCIAL_Slicer * 196struct GNUNET_SOCIAL_Slicer *
@@ -194,45 +200,107 @@ GNUNET_SOCIAL_slicer_create (void);
194/** 200/**
195 * Add a method to the try-and-slice instance. 201 * Add a method to the try-and-slice instance.
196 * 202 *
197 * A slicer processes messages and calls methods that match a message. A match 203 * The callbacks are called for messages with a matching @a method_name prefix.
198 * happens whenever the method name of a message starts with the method_name
199 * parameter given here.
200 * 204 *
201 * @param slicer The try-and-slice instance to extend. 205 * @param slicer
202 * @param method_name Name of the given method, use empty string for default. 206 * The try-and-slice instance to extend.
203 * @param method Method to invoke. 207 * @param method_name
204 * @param method_cls Closure for method. 208 * Name of the given method, use empty string to match all.
209 * @param method_cb
210 * Method handler invoked upon a matching message.
211 * @param modifier_cb
212 * Modifier handler, invoked after @a method_cb
213 * for each modifier in the message.
214 * @param data_cb
215 * Data handler, invoked after @a modifier_cb for each data fragment.
216 * @param eom_cb
217 * Invoked upon reaching the end of a matching message.
218 * @param cls
219 * Closure for the callbacks.
205 */ 220 */
206void 221void
207GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer, 222GNUNET_SOCIAL_slicer_method_add (struct GNUNET_SOCIAL_Slicer *slicer,
208 const char *method_name, 223 const char *method_name,
209 GNUNET_SOCIAL_MethodCallback method_cb, 224 GNUNET_SOCIAL_MethodCallback method_cb,
210 GNUNET_SOCIAL_ModifierCallback modifier_cb, 225 GNUNET_SOCIAL_ModifierCallback modifier_cb,
211 GNUNET_SOCIAL_DataCallback data_cb, 226 GNUNET_SOCIAL_DataCallback data_cb,
212 GNUNET_SOCIAL_EndOfMessageCallback eom_cb, 227 GNUNET_SOCIAL_EndOfMessageCallback eom_cb,
213 void *cls); 228 void *cls);
229
230/**
231 * Remove a registered method from the try-and-slice instance.
232 *
233 * Removes one matching handler registered with the given
234 * @a method_name and callbacks.
235 *
236 * @param slicer
237 * The try-and-slice instance.
238 * @param method_name
239 * Name of the method to remove.
240 * @param method_cb
241 * Method handler.
242 * @param modifier_cb
243 * Modifier handler.
244 * @param data_cb
245 * Data handler.
246 * @param eom_cb
247 * End of message handler.
248 *
249 * @return #GNUNET_OK if a method handler was removed,
250 * #GNUNET_NO if no handler matched the given method name and callbacks.
251 */
252int
253GNUNET_SOCIAL_slicer_method_remove (struct GNUNET_SOCIAL_Slicer *slicer,
254 const char *method_name,
255 GNUNET_SOCIAL_MethodCallback method_cb,
256 GNUNET_SOCIAL_ModifierCallback modifier_cb,
257 GNUNET_SOCIAL_DataCallback data_cb,
258 GNUNET_SOCIAL_EndOfMessageCallback eom_cb);
259
260
261/**
262 * Watch a place for changed objects.
263 *
264 * @param slicer
265 * The try-and-slice instance.
266 * @param object_filter
267 * Object prefix to match.
268 * @param modifier_cb
269 * Function to call when encountering a state modifier.
270 * @param cls
271 * Closure for callback.
272 */
273void
274GNUNET_SOCIAL_slicer_modifier_add (struct GNUNET_SOCIAL_Slicer *slicer,
275 const char *object_filter,
276 GNUNET_SOCIAL_ModifierCallback modifier_cb,
277 void *cls);
214 278
215 279
216/** 280/**
217 * Remove a registered method handler from the try-and-slice instance. 281 * Remove a registered modifier from the try-and-slice instance.
282 *
283 * Removes one matching handler registered with the given
284 * @a object_filter and callback.
218 * 285 *
219 * @param slicer The try-and-slice instance. 286 * @param slicer
220 * @param method_name Name of the method to remove. 287 * The try-and-slice instance.
221 * @param method Method handler. 288 * @param object_filter
289 * Object prefix to match.
290 * @param modifier_cb
291 * Function to call when encountering a state modifier changes.
222 */ 292 */
223int 293int
224GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer, 294GNUNET_SOCIAL_slicer_modifier_remove (struct GNUNET_SOCIAL_Slicer *slicer,
225 const char *method_name, 295 const char *object_filter,
226 GNUNET_SOCIAL_MethodCallback method_cb, 296 GNUNET_SOCIAL_ModifierCallback modifier_cb);
227 GNUNET_SOCIAL_ModifierCallback modifier_cb,
228 GNUNET_SOCIAL_DataCallback data_cb,
229 GNUNET_SOCIAL_EndOfMessageCallback eom_cb);
230 297
231 298
232/** 299/**
233 * Destroy a given try-and-slice instance. 300 * Destroy a given try-and-slice instance.
234 * 301 *
235 * @param slicer slicer to destroy 302 * @param slicer
303 * Slicer to destroy
236 */ 304 */
237void 305void
238GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer); 306GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer);
@@ -826,38 +894,6 @@ void
826GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist); 894GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist);
827 895
828 896
829struct GNUNET_SOCIAL_WatchHandle;
830
831/**
832 * Watch a place for changed objects.
833 *
834 * @param place
835 * Place to watch.
836 * @param object_filter
837 * Object prefix to match.
838 * @param var_cb
839 * Function to call when an object/state var changes.
840 * @param cls
841 * Closure for callback.
842 *
843 * @return Handle that can be used to cancel watching.
844 */
845struct GNUNET_SOCIAL_WatchHandle *
846GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place,
847 const char *object_filter,
848 GNUNET_PSYC_StateVarCallback var_cb,
849 void *cls);
850
851
852/**
853 * Cancel watching a place for changed objects.
854 *
855 * @param wh Watch handle to cancel.
856 */
857void
858GNUNET_SOCIAL_place_watch_cancel (struct GNUNET_SOCIAL_WatchHandle *wh);
859
860
861struct GNUNET_SOCIAL_LookHandle; 897struct GNUNET_SOCIAL_LookHandle;
862 898
863 899