aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/include/gnunet_psyc_service.h6
-rw-r--r--src/include/gnunet_social_service.h422
-rw-r--r--src/multicast/multicast_api.c2
-rw-r--r--src/social/social_api.c377
4 files changed, 447 insertions, 360 deletions
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h
index 4f4c99c1f..e6f2a78c1 100644
--- a/src/include/gnunet_psyc_service.h
+++ b/src/include/gnunet_psyc_service.h
@@ -307,8 +307,10 @@ struct GNUNET_PSYC_JoinHandle;
307/** 307/**
308 * Method called from PSYC upon receiving part of a message. 308 * Method called from PSYC upon receiving part of a message.
309 * 309 *
310 * @param cls Closure. 310 * @param cls Closure.
311 * @param msg Message part, one of the following types: 311 * @param message_id Sequence number of the message.
312 * @param flags OR'ed GNUNET_PSYC_MessageFlags
313 * @param msg Message part, one of the following types:
312 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER 314 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_HEADER
313 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD 315 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_METHOD
314 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER 316 * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h
index ba698aee6..e68d84d2f 100644
--- a/src/include/gnunet_social_service.h
+++ b/src/include/gnunet_social_service.h
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file include/gnunet_social_service.h 22 * @file include/gnunet_social_service.h
23 * @brief Social service; implements social functionality using the PSYC service. 23 * @brief Social service; implements social interactions using the PSYC service.
24 * @author Gabor X Toth 24 * @author Gabor X Toth
25 * @author Christian Grothoff 25 * @author Christian Grothoff
26 */ 26 */
@@ -48,7 +48,7 @@ extern "C"
48 48
49 49
50/** 50/**
51 * Handle for another user (who is likely pseudonymous) in the network. 51 * Handle for a pseudonym of another user in the network.
52 */ 52 */
53struct GNUNET_SOCIAL_Nym; 53struct GNUNET_SOCIAL_Nym;
54 54
@@ -58,9 +58,14 @@ struct GNUNET_SOCIAL_Nym;
58struct GNUNET_SOCIAL_Place; 58struct GNUNET_SOCIAL_Place;
59 59
60/** 60/**
61 * Handle for a place that one of our egos hosts. 61 * Host handle for a place that we entered.
62 */ 62 */
63struct GNUNET_SOCIAL_Home; 63struct GNUNET_SOCIAL_Host;
64
65/**
66 * Guest handle for place that we entered.
67 */
68struct GNUNET_SOCIAL_Guest;
64 69
65/** 70/**
66 * Handle to an implementation of try-and-slice. 71 * Handle to an implementation of try-and-slice.
@@ -69,36 +74,45 @@ struct GNUNET_SOCIAL_Slicer;
69 74
70 75
71/** 76/**
72 * Method called from SOCIAL upon receiving a message indicating a call 77 * Function called upon receiving a message indicating a call to a @e method.
73 * to a @e method.
74 * 78 *
75 * @param cls Closure. 79 * This function is called one or more times for each message until all data
76 * @param nym The sender of the message. NULL for the ego's own messages to the home. 80 * fragments arrive from the network.
77 * @param full_method_name Original method name from PSYC (may be more 81 *
78 * specific than the registered method name due to try-and-slice matching). 82 * @param cls Closure.
79 83 * @param message_id Message counter, monotonically increasing from 1.
80 * @param message_id Unique message counter for this message 84 * @param nym The sender of the message. Can be NULL if the message is not
81 * (unique only in combination with the given sender for 85 * connected to a pseudonym.
82 * this channel). 86 * @param flags OR'ed GNUNET_PSYC_MessageFlags
83 * @param modifier_count Number of elements in the @a modifiers array. 87 * @param method_name Original method name from PSYC (may be more specific
84 * @param modifiers Modifiers present in the message. FIXME: use environment instead? 88 * than the registered method name due to try-and-slice matching).
85 * @param data_offset Byte offset of @a data in the overall data of the method. 89 * @param env Environment containing variables for the message and operations
86 * @param data Data stream given to the method (might not be zero-terminated 90 * on objects of the place, or NULL.
87 * if data is binary). 91 * Only set for the first call of this function for each @a message_id,
88 * @param data_size Number of bytes in @a data. 92 * NULL when notifying about further data fragments.
89 * @param flags Message flags indicating fragmentation status. 93 * @param data_offset Byte offset of @a data in the overall data of the method.
94 * @param data_size Number of bytes in @a data.
95 * @param data Data stream given to the method (might not be zero-terminated
96 * if data is binary).
97 * @param end End of message?
98 * #GNUNET_NO if there are further fragments,
99 * #GNUNET_YES if this is the last fragment,
100 * #GNUNET_SYSERR indicates the message was cancelled by the sender.
101 *
102 * @return #GNUNET_YES the application keeps @a env for further use,
103 * #GNUNET_NO @a env is free()'d after the function returns.
90 */ 104 */
91typedef int 105typedef int
92(*GNUNET_SOCIAL_Method) (void *cls, 106(*GNUNET_SOCIAL_MethodCallback) (void *cls,
93 struct GNUNET_SOCIAL_Nym *nym, 107 uint64_t message_id,
94 const char *full_method_name, 108 uint32_t flags,
95 uint64_t message_id, 109 const struct GNUNET_SOCIAL_Nym *nym,
96 size_t modifier_count, 110 const char *method_name,
97 struct GNUNET_ENV_Modifier *modifiers, 111 struct GNUNET_ENV_Environment *env,
98 uint64_t data_offset, 112 uint64_t data_offset,
99 const void *data, 113 size_t data_size,
100 size_t data_size, 114 const void *data,
101 enum GNUNET_PSYC_MessageFlags flags); 115 int end);
102 116
103 117
104/** 118/**
@@ -125,8 +139,8 @@ GNUNET_SOCIAL_slicer_create (void);
125void 139void
126GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer, 140GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer,
127 const char *method_name, 141 const char *method_name,
128 GNUNET_SOCIAL_Method method, 142 GNUNET_SOCIAL_MethodCallback method_cb,
129 void *method_cls); 143 void *cls);
130 144
131 145
132/** 146/**
@@ -139,7 +153,7 @@ GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer,
139void 153void
140GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer, 154GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer,
141 const char *method_name, 155 const char *method_name,
142 GNUNET_SOCIAL_Method method); 156 GNUNET_SOCIAL_MethodCallback method_cb);
143 157
144/** 158/**
145 * Destroy a given try-and-slice instance. 159 * Destroy a given try-and-slice instance.
@@ -153,10 +167,10 @@ GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer);
153/** 167/**
154 * Function called asking for nym to be admitted to the place. 168 * Function called asking for nym to be admitted to the place.
155 * 169 *
156 * Should call either GNUNET_SOCIAL_home_admit() or 170 * Should call either GNUNET_SOCIAL_host_admit() or
157 * GNUNET_SOCIAL_home_reject_entry() (possibly asynchronously). If this owner 171 * GNUNET_SOCIAL_host_reject_entry() (possibly asynchronously). If this host
158 * cannot decide, it is fine to call neither function, in which case hopefully 172 * cannot decide, it is fine to call neither function, in which case hopefully
159 * some other owner of the home exists that will make the decision. The @a nym 173 * some other host of the place exists that will make the decision. The @a nym
160 * reference remains valid until the #GNUNET_SOCIAL_FarewellCallback is invoked 174 * reference remains valid until the #GNUNET_SOCIAL_FarewellCallback is invoked
161 * for it. 175 * for it.
162 * 176 *
@@ -197,26 +211,26 @@ typedef void
197 211
198 212
199/** 213/**
200 * Enter a home where guests (nyms) can be hosted. 214 * Enter a place as host.
201 * 215 *
202 * A home is created upon first entering, and exists until 216 * A place is created upon first entering, and it is active until permanently
203 * GNUNET_SOCIAL_home_destroy() is called. It can also be left temporarily using 217 * left using GNUNET_SOCIAL_host_leave().
204 * GNUNET_SOCIAL_home_leave().
205 * 218 *
206 * @param cfg Configuration to contact the social service. 219 * @param cfg Configuration to contact the social service.
207 * @param home_keyfile File with the private-public key pair of the home, 220 * @param place_keyfile File with the private-public key pair of the place,
208 * created if the file does not exist; pass NULL for ephemeral homes. 221 * created if the file does not exist; pass NULL for ephemeral places.
209 * @param policy Policy specifying entry and history restrictions of the home. 222 * @param policy Policy specifying entry and history restrictions of the place.
210 * @param ego Owner of the home (host). 223 * @param ego Identity of the host.
211 * @param slicer Slicer to handle guests talking. 224 * @param slicer Slicer to handle incoming messages.
212 * @param listener_cb Function to handle new nyms that want to enter. 225 * @param listener_cb Function to handle new nyms that want to enter.
213 * @param farewell_cb Function to handle departing nyms. 226 * @param farewell_cb Function to handle departing nyms.
214 * @param cls Closure for @a listener_cb and @a farewell_cb. 227 * @param cls Closure for @a listener_cb and @a farewell_cb.
215 * @return Handle for a new home. 228 *
216 */ 229 * @return Handle for the host.
217struct GNUNET_SOCIAL_Home * 230 */
218GNUNET_SOCIAL_home_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, 231struct GNUNET_SOCIAL_Host *
219 const char *home_keyfile, 232GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
233 const char *place_keyfile,
220 enum GNUNET_PSYC_Policy policy, 234 enum GNUNET_PSYC_Policy policy,
221 struct GNUNET_IDENTITY_Ego *ego, 235 struct GNUNET_IDENTITY_Ego *ego,
222 struct GNUNET_SOCIAL_Slicer *slicer, 236 struct GNUNET_SOCIAL_Slicer *slicer,
@@ -226,38 +240,38 @@ GNUNET_SOCIAL_home_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
226 240
227 241
228/** 242/**
229 * Admit @a nym to the @a home. 243 * Admit @a nym to the place.
230 * 244 *
231 * The @a nym reference will remain valid until either the home is destroyed or 245 * The @a nym reference will remain valid until either the @a host or @a nym
232 * @a nym leaves. 246 * leaves the place.
233 * 247 *
234 * @param home Home to allow @a nym to enter. 248 * @param host Host of the place.
235 * @param nym Handle for the entity that wants to enter. 249 * @param nym Handle for the entity that wants to enter.
236 */ 250 */
237void 251void
238GNUNET_SOCIAL_home_admit (struct GNUNET_SOCIAL_Home *home, 252GNUNET_SOCIAL_host_admit (struct GNUNET_SOCIAL_Host *host,
239 struct GNUNET_SOCIAL_Nym *nym); 253 struct GNUNET_SOCIAL_Nym *nym);
240 254
241 255
242/** 256/**
243 * Throw @a nym out of the @a home. 257 * Throw @a nym out of the place.
244 * 258 *
245 * The @a nym reference will remain valid until the 259 * The @a nym reference will remain valid until the
246 * #GNUNET_SOCIAL_FarewellCallback is invoked, 260 * #GNUNET_SOCIAL_FarewellCallback is invoked,
247 * which should be very soon after this call. 261 * which should be very soon after this call.
248 * 262 *
249 * @param home Home to eject @a nym from. 263 * @param host Host of the place.
250 * @param nym Handle for the entity to be ejected. 264 * @param nym Handle for the entity to be ejected.
251 */ 265 */
252void 266void
253GNUNET_SOCIAL_home_eject (struct GNUNET_SOCIAL_Home *home, 267GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
254 struct GNUNET_SOCIAL_Nym *nym); 268 struct GNUNET_SOCIAL_Nym *nym);
255 269
256 270
257/** 271/**
258 * Refuse @a nym entry into the @a home. 272 * Refuse @a nym entry into the place.
259 * 273 *
260 * @param home Home to disallow @a nym to enter. 274 * @param host Host of the place.
261 * @param nym Handle for the entity that wanted to enter. 275 * @param nym Handle for the entity that wanted to enter.
262 * @param method_name Method name for the rejection message. 276 * @param method_name Method name for the rejection message.
263 * @param env Environment containing variables for the message, or NULL. 277 * @param env Environment containing variables for the message, or NULL.
@@ -265,7 +279,7 @@ GNUNET_SOCIAL_home_eject (struct GNUNET_SOCIAL_Home *home,
265 * @param data_size Number of bytes in @a data for method. 279 * @param data_size Number of bytes in @a data for method.
266 */ 280 */
267void 281void
268GNUNET_SOCIAL_home_reject_entry (struct GNUNET_SOCIAL_Home *home, 282GNUNET_SOCIAL_host_refuse_entry (struct GNUNET_SOCIAL_Host *host,
269 struct GNUNET_SOCIAL_Nym *nym, 283 struct GNUNET_SOCIAL_Nym *nym,
270 const char *method_name, 284 const char *method_name,
271 const struct GNUNET_ENV_Environment *env, 285 const struct GNUNET_ENV_Environment *env,
@@ -274,7 +288,7 @@ GNUNET_SOCIAL_home_reject_entry (struct GNUNET_SOCIAL_Home *home,
274 288
275 289
276/** 290/**
277 * Get the public key of a nym. 291 * Get the public key of a @a nym.
278 * 292 *
279 * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). 293 * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name().
280 * 294 *
@@ -287,20 +301,22 @@ GNUNET_SOCIAL_nym_get_key (struct GNUNET_SOCIAL_Nym *nym,
287 301
288 302
289/** 303/**
290 * Obtain the private-public key pair of the home. 304 * Obtain the private-public key pair of the host.
291 * 305 *
292 * @param home Home to get the key of. 306 * @param host Host to get the key of.
293 * @param[out] home_key Set to the private-public key pair of the home. The public part is suitable for storing in GNS within a "PLACE" record, along with peer IDs to join at. 307 * @param[out] host_key Set to the private-public key pair of the host. The
308 * public part is suitable for storing in GNS within a "PLACE"
309 * record, along with peer IDs to join at.
294 */ 310 */
295void 311void
296GNUNET_SOCIAL_home_get_key (struct GNUNET_SOCIAL_Home *home, 312GNUNET_SOCIAL_host_get_key (struct GNUNET_SOCIAL_Host *host,
297 struct GNUNET_CRYPTO_EddsaPrivateKey *home_key); 313 struct GNUNET_CRYPTO_EddsaPrivateKey *host_key);
298 314
299 315
300/** 316/**
301 * Advertise @a home under @a name in the GNS zone of the @e ego. 317 * Advertise the place in the GNS zone of the @e ego of the @a host.
302 * 318 *
303 * @param home The home to advertise. 319 * @param host Host of the place.
304 * @param name The name for the PLACE record to put in the zone. 320 * @param name The name for the PLACE record to put in the zone.
305 * @param peer_count Number of elements in the @a peers array. 321 * @param peer_count Number of elements in the @a peers array.
306 * @param peers List of peers in the PLACE record that can be used to send join 322 * @param peers List of peers in the PLACE record that can be used to send join
@@ -309,7 +325,7 @@ GNUNET_SOCIAL_home_get_key (struct GNUNET_SOCIAL_Home *home,
309 * @param password Password used to encrypt the record. 325 * @param password Password used to encrypt the record.
310 */ 326 */
311void 327void
312GNUNET_SOCIAL_home_advertise (struct GNUNET_SOCIAL_Home *home, 328GNUNET_SOCIAL_host_advertise (struct GNUNET_SOCIAL_Host *host,
313 const char *name, 329 const char *name,
314 size_t peer_count, 330 size_t peer_count,
315 const struct GNUNET_PeerIdentity *peers, 331 const struct GNUNET_PeerIdentity *peers,
@@ -318,16 +334,16 @@ GNUNET_SOCIAL_home_advertise (struct GNUNET_SOCIAL_Home *home,
318 334
319 335
320/** 336/**
321 * Flags for announcements in a home. 337 * Flags for announcements by a host.
322 */ 338 */
323enum GNUNET_SOCIAL_AnnounceFlags 339enum GNUNET_SOCIAL_AnnounceFlags
324{ 340{
325 GNUNET_SOCIAL_ANNOUNCE_NONE = 0, 341 GNUNET_SOCIAL_ANNOUNCE_NONE = 0,
326 342
327 /** 343 /**
328 * Whether this announcement removes all objects from the home. 344 * Whether this announcement removes all objects from the place.
329 * 345 *
330 * New objects can be still added to the now empty home using the @e env 346 * New objects can be still added to the now empty place using the @e env
331 * parameter of the same announcement. 347 * parameter of the same announcement.
332 */ 348 */
333 GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS = 1 << 0 349 GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS = 1 << 0
@@ -341,22 +357,23 @@ struct GNUNET_SOCIAL_Announcement;
341 357
342 358
343/** 359/**
344 * Send a message to all nyms that are present in the home. 360 * Send a message to all nyms that are present in the place.
345 * 361 *
346 * This function is restricted to the home owner. Nyms can only send requests 362 * This function is restricted to the host. Nyms can only send requests
347 * to the home owner who can decide to relay it to other guests. 363 * to the host who can decide to relay it to everyone in the place.
348 * 364 *
349 * @param home Home to address the announcement to. 365 * @param host Host of the place.
350 * @param method_name Method to use for the announcement. 366 * @param method_name Method to use for the announcement.
351 * @param env Environment containing variables for the message and operations on 367 * @param env Environment containing variables for the message and operations
352 * objects of the home, or NULL. 368 * on objects of the place. Can be NULL.
353 * @param notify Function to call to get the payload of the announcement. 369 * @param notify Function to call to get the payload of the announcement.
354 * @param notify_cls Closure for @a notify. 370 * @param notify_cls Closure for @a notify.
355 * @param flags Flags for this announcement. 371 * @param flags Flags for this announcement.
372 *
356 * @return NULL on error (announcement already in progress?). 373 * @return NULL on error (announcement already in progress?).
357 */ 374 */
358struct GNUNET_SOCIAL_Announcement * 375struct GNUNET_SOCIAL_Announcement *
359GNUNET_SOCIAL_home_announce (struct GNUNET_SOCIAL_Home *home, 376GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
360 const char *method_name, 377 const char *method_name,
361 const struct GNUNET_ENV_Environment *env, 378 const struct GNUNET_ENV_Environment *env,
362 GNUNET_CONNECTION_TransmitReadyNotify notify, 379 GNUNET_CONNECTION_TransmitReadyNotify notify,
@@ -370,37 +387,39 @@ GNUNET_SOCIAL_home_announce (struct GNUNET_SOCIAL_Home *home,
370 * @param a The announcement to cancel. 387 * @param a The announcement to cancel.
371 */ 388 */
372void 389void
373GNUNET_SOCIAL_home_announce_cancel (struct GNUNET_SOCIAL_Announcement *a); 390GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
374 391
375 392
376/** 393/**
377 * Convert our home to a place so we can access it via the place API. 394 * Obtain handle for a hosted place.
395 *
396 * The returned handle can be used to access the place API.
378 * 397 *
379 * @param home Handle for the home. 398 * @param host Handle for the host.
380 * @return Place handle for the same home, valid as long as @a home is valid; 399 *
381 * do NOT try to GNUNET_SOCIAL_place_leave() this place, it's your home! 400 * @return Handle for the hosted place, valid as long as @a host is valid.
382 */ 401 */
383struct GNUNET_SOCIAL_Place * 402struct GNUNET_SOCIAL_Place *
384GNUNET_SOCIAL_home_get_place (struct GNUNET_SOCIAL_Home *home); 403GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host);
385 404
386 405
387/** 406/**
388 * Leave a home. 407 * Stop hosting a place.
389 408 *
390 * Invalidates home handle. 409 * Invalidates host handle.
391 * Guests will be disconnected until the home is restarted.
392 * 410 *
393 * @param home Home to leave. 411 * @param host Host leaving the place.
394 * @param keep_active Keep home active after last application disconnected. 412 * @param keep_active Keep the place active after last host disconnected.
395 */ 413 */
396void 414void
397GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home, int keep_active); 415GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *host, int keep_active);
416
398 417
399/** 418/**
400 * Request entry to a place (home hosted by someone else). 419 * Request entry to a place as a guest.
401 * 420 *
402 * @param cfg Configuration to contact the social service. 421 * @param cfg Configuration to contact the social service.
403 * @param ego Owner of the home (host). 422 * @param ego Identity of the guest.
404 * @param address GNS name of the place to enter. Either in the form of 423 * @param address GNS name of the place to enter. Either in the form of
405 * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to 424 * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to
406 * the 'PLACE' record of the empty label ("+") in the GNS zone with the 425 * the 'PLACE' record of the empty label ("+") in the GNS zone with the
@@ -411,10 +430,11 @@ GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home, int keep_active);
411 * @param data Payload for the message to give to the enter callback. 430 * @param data Payload for the message to give to the enter callback.
412 * @param data_size Number of bytes in @a data. 431 * @param data_size Number of bytes in @a data.
413 * @param slicer Slicer to use for processing incoming requests from guests. 432 * @param slicer Slicer to use for processing incoming requests from guests.
414 * @return NULL on errors, otherwise handle to the place. 433 *
434 * @return NULL on errors, otherwise handle for the guest.
415 */ 435 */
416struct GNUNET_SOCIAL_Place * 436struct GNUNET_SOCIAL_Guest *
417GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, 437GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
418 struct GNUNET_IDENTITY_Ego *ego, 438 struct GNUNET_IDENTITY_Ego *ego,
419 char *address, 439 char *address,
420 const char *method_name, 440 const char *method_name,
@@ -424,10 +444,10 @@ GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
424 struct GNUNET_SOCIAL_Slicer *slicer); 444 struct GNUNET_SOCIAL_Slicer *slicer);
425 445
426/** 446/**
427 * Request entry to a place (home hosted by someone else). 447 * Request entry to a place as a guest.
428 * 448 *
429 * @param cfg Configuration to contact the social service. 449 * @param cfg Configuration to contact the social service.
430 * @param ego Owner of the home (host). 450 * @param ego Identity of the guest.
431 * @param crypto_address Public key of the place to enter. 451 * @param crypto_address Public key of the place to enter.
432 * @param origin Peer identity of the origin of the underlying multicast group. 452 * @param origin Peer identity of the origin of the underlying multicast group.
433 * @param relay_count Number of elements in the @a relays array. 453 * @param relay_count Number of elements in the @a relays array.
@@ -437,10 +457,11 @@ GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
437 * @param data Payload for the message to give to the enter callback. 457 * @param data Payload for the message to give to the enter callback.
438 * @param data_size Number of bytes in @a data. 458 * @param data_size Number of bytes in @a data.
439 * @param slicer Slicer to use for processing incoming requests from guests. 459 * @param slicer Slicer to use for processing incoming requests from guests.
440 * @return NULL on errors, otherwise handle to the place. 460 *
461 * @return NULL on errors, otherwise handle for the guest.
441 */ 462 */
442struct GNUNET_SOCIAL_Place * 463struct GNUNET_SOCIAL_Guest *
443GNUNET_SOCIAL_place_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg, 464GNUNET_SOCIAL_guest_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
444 struct GNUNET_IDENTITY_Ego *ego, 465 struct GNUNET_IDENTITY_Ego *ego,
445 struct GNUNET_CRYPTO_EddsaPublicKey *crypto_address, 466 struct GNUNET_CRYPTO_EddsaPublicKey *crypto_address,
446 struct GNUNET_PeerIdentity *origin, 467 struct GNUNET_PeerIdentity *origin,
@@ -453,81 +474,6 @@ GNUNET_SOCIAL_place_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
453 struct GNUNET_SOCIAL_Slicer *slicer); 474 struct GNUNET_SOCIAL_Slicer *slicer);
454 475
455 476
456struct GNUNET_SOCIAL_WatchHandle;
457
458/**
459 * Watch a place for changed objects.
460 *
461 * @param place Place to watch.
462 * @param object_filter Object prefix to match.
463 * @param state_cb Function to call when an object/state changes.
464 * @param state_cb_cls Closure for callback.
465 *
466 * @return Handle that can be used to cancel watching.
467 */
468struct GNUNET_SOCIAL_WatchHandle *
469GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place,
470 const char *object_filter,
471 GNUNET_PSYC_StateCallback state_cb,
472 void *state_cb_cls);
473
474
475/**
476 * Cancel watching a place for changed objects.
477 *
478 * @param wh Watch handle to cancel.
479 */
480void
481GNUNET_SOCIAL_place_watch_cancel (struct GNUNET_SOCIAL_WatchHandle *wh);
482
483
484struct GNUNET_SOCIAL_LookHandle;
485
486
487/**
488 * Look at objects in the place with a matching name prefix.
489 *
490 * @param place The place to look its objects at.
491 * @param name_prefix Look at objects with names beginning with this value.
492 * @param state_cb Function to call for each object found.
493 * @param state_cb_cls Closure for callback function.
494 *
495 * @return Handle that can be used to stop looking at objects.
496 */
497struct GNUNET_SOCIAL_LookHandle *
498GNUNET_SOCIAL_place_look (struct GNUNET_SOCIAL_Place *place,
499 const char *name_prefix,
500 GNUNET_PSYC_StateCallback state_cb,
501 void *state_cb_cls);
502
503
504/**
505 * Stop looking at objects.
506 *
507 * @param lh Look handle to stop.
508 */
509void
510GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh);
511
512
513
514/**
515 * Look at a particular object in the place.
516 *
517 * The best matching object is returned (its name might be less specific than
518 * what was requested).
519 *
520 * @param place The place to look the object at.
521 * @param full_name Full name of the object.
522 * @param value_size Set to the size of the returned value.
523 * @return NULL if there is no such object at this place.
524 */
525const void *
526GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *place,
527 const char *full_name,
528 size_t *value_size);
529
530
531/** 477/**
532 * Flags for talking to the host of a place. 478 * Flags for talking to the host of a place.
533 */ 479 */
@@ -542,6 +488,7 @@ enum GNUNET_SOCIAL_TalkFlags
542 */ 488 */
543struct GNUNET_SOCIAL_TalkRequest; 489struct GNUNET_SOCIAL_TalkRequest;
544 490
491
545/** 492/**
546 * Talk to the host of the place. 493 * Talk to the host of the place.
547 * 494 *
@@ -551,11 +498,12 @@ struct GNUNET_SOCIAL_TalkRequest;
551 * @param notify Function to use to get the payload for the method. 498 * @param notify Function to use to get the payload for the method.
552 * @param notify_cls Closure for @a notify. 499 * @param notify_cls Closure for @a notify.
553 * @param flags Flags for the message being sent. 500 * @param flags Flags for the message being sent.
501 *
554 * @return NULL if we are already trying to talk to the host, 502 * @return NULL if we are already trying to talk to the host,
555 * otherwise handle to cancel the request. 503 * otherwise handle to cancel the request.
556 */ 504 */
557struct GNUNET_SOCIAL_TalkRequest * 505struct GNUNET_SOCIAL_TalkRequest *
558GNUNET_SOCIAL_place_talk (struct GNUNET_SOCIAL_Place *place, 506GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Place *place,
559 const char *method_name, 507 const char *method_name,
560 const struct GNUNET_ENV_Environment *env, 508 const struct GNUNET_ENV_Environment *env,
561 GNUNET_CONNECTION_TransmitReadyNotify notify, 509 GNUNET_CONNECTION_TransmitReadyNotify notify,
@@ -569,7 +517,32 @@ GNUNET_SOCIAL_place_talk (struct GNUNET_SOCIAL_Place *place,
569 * @param tr Talk request to cancel. 517 * @param tr Talk request to cancel.
570 */ 518 */
571void 519void
572GNUNET_SOCIAL_place_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr); 520GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
521
522
523/**
524 * Leave a place permanently.
525 *
526 * Notifies the owner of the place about leaving, and destroys the place handle.
527 *
528 * @param place Place to leave permanently.
529 * @param keep_active Keep place active after last application disconnected.
530 */
531void
532GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Place *place, int keep_active);
533
534
535/**
536 * Obtain handle for a place entered as guest.
537 *
538 * The returned handle can be used to access the place API.
539 *
540 * @param guest Handle for the guest.
541 *
542 * @return Handle for the place, valid as long as @a guest is valid.
543 */
544struct GNUNET_SOCIAL_Place *
545GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Host *guest);
573 546
574 547
575/** 548/**
@@ -618,16 +591,79 @@ void
618GNUNET_SOCIAL_place_get_history_cancel (struct GNUNET_SOCIAL_HistoryLesson *hist); 591GNUNET_SOCIAL_place_get_history_cancel (struct GNUNET_SOCIAL_HistoryLesson *hist);
619 592
620 593
594struct GNUNET_SOCIAL_WatchHandle;
595
621/** 596/**
622 * Leave a place permanently. 597 * Watch a place for changed objects.
623 * 598 *
624 * Notifies the owner of the place about leaving, and destroys the place handle. 599 * @param place Place to watch.
600 * @param object_filter Object prefix to match.
601 * @param state_cb Function to call when an object/state changes.
602 * @param state_cb_cls Closure for callback.
625 * 603 *
626 * @param place Place to leave permanently. 604 * @return Handle that can be used to cancel watching.
627 * @param keep_active Keep place active after last application disconnected. 605 */
606struct GNUNET_SOCIAL_WatchHandle *
607GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place,
608 const char *object_filter,
609 GNUNET_PSYC_StateCallback state_cb,
610 void *state_cb_cls);
611
612
613/**
614 * Cancel watching a place for changed objects.
615 *
616 * @param wh Watch handle to cancel.
628 */ 617 */
629void 618void
630GNUNET_SOCIAL_place_leave (struct GNUNET_SOCIAL_Place *place, int keep_active); 619GNUNET_SOCIAL_place_watch_cancel (struct GNUNET_SOCIAL_WatchHandle *wh);
620
621
622struct GNUNET_SOCIAL_LookHandle;
623
624
625/**
626 * Look at objects in the place with a matching name prefix.
627 *
628 * @param place The place to look its objects at.
629 * @param name_prefix Look at objects with names beginning with this value.
630 * @param state_cb Function to call for each object found.
631 * @param state_cb_cls Closure for callback function.
632 *
633 * @return Handle that can be used to stop looking at objects.
634 */
635struct GNUNET_SOCIAL_LookHandle *
636GNUNET_SOCIAL_place_look (struct GNUNET_SOCIAL_Place *place,
637 const char *name_prefix,
638 GNUNET_PSYC_StateCallback state_cb,
639 void *state_cb_cls);
640
641
642/**
643 * Stop looking at objects.
644 *
645 * @param lh Look handle to stop.
646 */
647void
648GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh);
649
650
651
652/**
653 * Look at a particular object in the place.
654 *
655 * The best matching object is returned (its name might be less specific than
656 * what was requested).
657 *
658 * @param place The place to look the object at.
659 * @param full_name Full name of the object.
660 * @param value_size Set to the size of the returned value.
661 * @return NULL if there is no such object at this place.
662 */
663const void *
664GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *place,
665 const char *full_name,
666 size_t *value_size);
631 667
632 668
633#if 0 /* keep Emacsens' auto-indent happy */ 669#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/multicast/multicast_api.c b/src/multicast/multicast_api.c
index e568e77ee..36d564d52 100644
--- a/src/multicast/multicast_api.c
+++ b/src/multicast/multicast_api.c
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file multicast/multicast_api.c 22 * @file multicast/multicast_api.c
23 * @brief multicast service; establish tunnels to distant peers 23 * @brief Multicast service; implements multicast groups using CADET connections.
24 * @author Christian Grothoff 24 * @author Christian Grothoff
25 * @author Gabor X Toth 25 * @author Gabor X Toth
26 */ 26 */
diff --git a/src/social/social_api.c b/src/social/social_api.c
index fd6e8f04a..ee13c7d61 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -20,7 +20,7 @@
20 20
21/** 21/**
22 * @file social/social_api.c 22 * @file social/social_api.c
23 * @brief Social service; implements social functionality using the PSYC service. 23 * @brief Social service; implements social interactions using the PSYC service.
24 * @author Gabor X Toth 24 * @author Gabor X Toth
25 */ 25 */
26 26
@@ -35,7 +35,7 @@
35 35
36 36
37/** 37/**
38 * Handle for another user (who is likely pseudonymous) in the network. 38 * Handle for a pseudonym of another user in the network.
39 */ 39 */
40struct GNUNET_SOCIAL_Nym 40struct GNUNET_SOCIAL_Nym
41{ 41{
@@ -53,9 +53,18 @@ struct GNUNET_SOCIAL_Place
53 53
54 54
55/** 55/**
56 * Handle for a place that one of our egos hosts. 56 * Host handle for a place that we entered.
57 */ 57 */
58struct GNUNET_SOCIAL_Home 58struct GNUNET_SOCIAL_Host
59{
60
61};
62
63
64/**
65 * Guest handle for place that we entered.
66 */
67struct GNUNET_SOCIAL_Guest
59{ 68{
60 69
61}; 70};
@@ -109,6 +118,8 @@ struct GNUNET_SOCIAL_HistoryLesson
109}; 118};
110 119
111 120
121
122
112/** 123/**
113 * Create a try-and-slice instance. 124 * Create a try-and-slice instance.
114 * 125 *
@@ -136,8 +147,8 @@ GNUNET_SOCIAL_slicer_create (void)
136void 147void
137GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer, 148GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer,
138 const char *method_name, 149 const char *method_name,
139 GNUNET_SOCIAL_Method method, 150 GNUNET_SOCIAL_MethodCallback method_cb,
140 void *method_cls) 151 void *cls)
141{ 152{
142 153
143} 154}
@@ -153,12 +164,11 @@ GNUNET_SOCIAL_slicer_add (struct GNUNET_SOCIAL_Slicer *slicer,
153void 164void
154GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer, 165GNUNET_SOCIAL_slicer_remove (struct GNUNET_SOCIAL_Slicer *slicer,
155 const char *method_name, 166 const char *method_name,
156 GNUNET_SOCIAL_Method method) 167 GNUNET_SOCIAL_MethodCallback method_cb)
157{ 168{
158 169
159} 170}
160 171
161
162/** 172/**
163 * Destroy a given try-and-slice instance. 173 * Destroy a given try-and-slice instance.
164 * 174 *
@@ -172,26 +182,26 @@ GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer)
172 182
173 183
174/** 184/**
175 * Enter a home where guests (nyms) can be hosted. 185 * Enter a place as host.
176 * 186 *
177 * A home is created upon first entering, and exists until 187 * A place is created upon first entering, and it is active until permanently
178 * GNUNET_SOCIAL_home_destroy() is called. It can also be left temporarily using 188 * left using GNUNET_SOCIAL_host_leave().
179 * GNUNET_SOCIAL_home_leave().
180 * 189 *
181 * @param cfg Configuration to contact the social service. 190 * @param cfg Configuration to contact the social service.
182 * @param home_keyfile File with the private-public key pair of the home, 191 * @param place_keyfile File with the private-public key pair of the place,
183 * created if the file does not exist; pass NULL for ephemeral homes. 192 * created if the file does not exist; pass NULL for ephemeral places.
184 * @param policy Policy specifying entry and history restrictions of the home. 193 * @param policy Policy specifying entry and history restrictions of the place.
185 * @param ego Owner of the home (host). 194 * @param ego Identity of the host.
186 * @param slicer Slicer to handle guests talking. 195 * @param slicer Slicer to handle incoming messages.
187 * @param listener_cb Function to handle new nyms that want to enter. 196 * @param listener_cb Function to handle new nyms that want to enter.
188 * @param farewell_cb Function to handle departing nyms. 197 * @param farewell_cb Function to handle departing nyms.
189 * @param cls Closure for @a listener_cb and @a farewell_cb. 198 * @param cls Closure for @a listener_cb and @a farewell_cb.
190 * @return Handle for a new home. 199 *
191 */ 200 * @return Handle for the host.
192struct GNUNET_SOCIAL_Home * 201 */
193GNUNET_SOCIAL_home_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, 202struct GNUNET_SOCIAL_Host *
194 const char *home_keyfile, 203GNUNET_SOCIAL_host_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
204 const char *place_keyfile,
195 enum GNUNET_PSYC_Policy policy, 205 enum GNUNET_PSYC_Policy policy,
196 struct GNUNET_IDENTITY_Ego *ego, 206 struct GNUNET_IDENTITY_Ego *ego,
197 struct GNUNET_SOCIAL_Slicer *slicer, 207 struct GNUNET_SOCIAL_Slicer *slicer,
@@ -204,16 +214,16 @@ GNUNET_SOCIAL_home_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
204 214
205 215
206/** 216/**
207 * Admit @a nym to the @a home. 217 * Admit @a nym to the place.
208 * 218 *
209 * The @a nym reference will remain valid until either the home is destroyed or 219 * The @a nym reference will remain valid until either the @a host or @a nym
210 * @a nym leaves. 220 * leaves the place.
211 * 221 *
212 * @param home Home to allow @a nym to enter. 222 * @param host Host of the place.
213 * @param nym Handle for the entity that wants to enter. 223 * @param nym Handle for the entity that wants to enter.
214 */ 224 */
215void 225void
216GNUNET_SOCIAL_home_admit (struct GNUNET_SOCIAL_Home *home, 226GNUNET_SOCIAL_host_admit (struct GNUNET_SOCIAL_Host *host,
217 struct GNUNET_SOCIAL_Nym *nym) 227 struct GNUNET_SOCIAL_Nym *nym)
218{ 228{
219 229
@@ -221,17 +231,17 @@ GNUNET_SOCIAL_home_admit (struct GNUNET_SOCIAL_Home *home,
221 231
222 232
223/** 233/**
224 * Throw @a nym out of the @a home. 234 * Throw @a nym out of the place.
225 * 235 *
226 * The @a nym reference will remain valid until the 236 * The @a nym reference will remain valid until the
227 * #GNUNET_SOCIAL_FarewellCallback is invoked, 237 * #GNUNET_SOCIAL_FarewellCallback is invoked,
228 * which should be very soon after this call. 238 * which should be very soon after this call.
229 * 239 *
230 * @param home Home to eject @a nym from. 240 * @param host Host of the place.
231 * @param nym Handle for the entity to be ejected. 241 * @param nym Handle for the entity to be ejected.
232 */ 242 */
233void 243void
234GNUNET_SOCIAL_home_eject (struct GNUNET_SOCIAL_Home *home, 244GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
235 struct GNUNET_SOCIAL_Nym *nym) 245 struct GNUNET_SOCIAL_Nym *nym)
236{ 246{
237 247
@@ -239,9 +249,9 @@ GNUNET_SOCIAL_home_eject (struct GNUNET_SOCIAL_Home *home,
239 249
240 250
241/** 251/**
242 * Refuse @a nym entry into the @a home. 252 * Refuse @a nym entry into the place.
243 * 253 *
244 * @param home Home to disallow @a nym to enter. 254 * @param host Host of the place.
245 * @param nym Handle for the entity that wanted to enter. 255 * @param nym Handle for the entity that wanted to enter.
246 * @param method_name Method name for the rejection message. 256 * @param method_name Method name for the rejection message.
247 * @param env Environment containing variables for the message, or NULL. 257 * @param env Environment containing variables for the message, or NULL.
@@ -249,7 +259,7 @@ GNUNET_SOCIAL_home_eject (struct GNUNET_SOCIAL_Home *home,
249 * @param data_size Number of bytes in @a data for method. 259 * @param data_size Number of bytes in @a data for method.
250 */ 260 */
251void 261void
252GNUNET_SOCIAL_home_reject_entry (struct GNUNET_SOCIAL_Home *home, 262GNUNET_SOCIAL_host_refuse_entry (struct GNUNET_SOCIAL_Host *host,
253 struct GNUNET_SOCIAL_Nym *nym, 263 struct GNUNET_SOCIAL_Nym *nym,
254 const char *method_name, 264 const char *method_name,
255 const struct GNUNET_ENV_Environment *env, 265 const struct GNUNET_ENV_Environment *env,
@@ -261,7 +271,7 @@ GNUNET_SOCIAL_home_reject_entry (struct GNUNET_SOCIAL_Home *home,
261 271
262 272
263/** 273/**
264 * Get the public key of a nym. 274 * Get the public key of a @a nym.
265 * 275 *
266 * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name(). 276 * Suitable, for example, to be used with GNUNET_NAMESTORE_zone_to_name().
267 * 277 *
@@ -277,23 +287,25 @@ GNUNET_SOCIAL_nym_get_key (struct GNUNET_SOCIAL_Nym *nym,
277 287
278 288
279/** 289/**
280 * Obtain the private-public key pair of the home. 290 * Obtain the private-public key pair of the host.
281 * 291 *
282 * @param home Home to get the key of. 292 * @param host Host to get the key of.
283 * @param[out] home_key Set to the private-public key pair of the home. The public part is suitable for storing in GNS within a "PLACE" record, along with peer IDs to join at. 293 * @param[out] host_key Set to the private-public key pair of the host. The
294 * public part is suitable for storing in GNS within a "PLACE"
295 * record, along with peer IDs to join at.
284 */ 296 */
285void 297void
286GNUNET_SOCIAL_home_get_key (struct GNUNET_SOCIAL_Home *home, 298GNUNET_SOCIAL_host_get_key (struct GNUNET_SOCIAL_Host *host,
287 struct GNUNET_CRYPTO_EddsaPrivateKey *home_key) 299 struct GNUNET_CRYPTO_EddsaPrivateKey *host_key)
288{ 300{
289 301
290} 302}
291 303
292 304
293/** 305/**
294 * Advertise @a home under @a name in the GNS zone of the @e ego. 306 * Advertise the place in the GNS zone of the @e ego of the @a host.
295 * 307 *
296 * @param home The home to advertise. 308 * @param host Host of the place.
297 * @param name The name for the PLACE record to put in the zone. 309 * @param name The name for the PLACE record to put in the zone.
298 * @param peer_count Number of elements in the @a peers array. 310 * @param peer_count Number of elements in the @a peers array.
299 * @param peers List of peers in the PLACE record that can be used to send join 311 * @param peers List of peers in the PLACE record that can be used to send join
@@ -302,7 +314,7 @@ GNUNET_SOCIAL_home_get_key (struct GNUNET_SOCIAL_Home *home,
302 * @param password Password used to encrypt the record. 314 * @param password Password used to encrypt the record.
303 */ 315 */
304void 316void
305GNUNET_SOCIAL_home_advertise (struct GNUNET_SOCIAL_Home *home, 317GNUNET_SOCIAL_host_advertise (struct GNUNET_SOCIAL_Host *host,
306 const char *name, 318 const char *name,
307 size_t peer_count, 319 size_t peer_count,
308 const struct GNUNET_PeerIdentity *peers, 320 const struct GNUNET_PeerIdentity *peers,
@@ -314,22 +326,23 @@ GNUNET_SOCIAL_home_advertise (struct GNUNET_SOCIAL_Home *home,
314 326
315 327
316/** 328/**
317 * Send a message to all nyms that are present in the home. 329 * Send a message to all nyms that are present in the place.
318 * 330 *
319 * This function is restricted to the home owner. Nyms can only send requests 331 * This function is restricted to the host. Nyms can only send requests
320 * to the home owner who can decide to relay it to other guests. 332 * to the host who can decide to relay it to everyone in the place.
321 * 333 *
322 * @param home Home to address the announcement to. 334 * @param host Host of the place.
323 * @param method_name Method to use for the announcement. 335 * @param method_name Method to use for the announcement.
324 * @param env Environment containing variables for the message and operations on 336 * @param env Environment containing variables for the message and operations
325 * objects of the home, or NULL. 337 * on objects of the place. Can be NULL.
326 * @param notify Function to call to get the payload of the announcement. 338 * @param notify Function to call to get the payload of the announcement.
327 * @param notify_cls Closure for @a notify. 339 * @param notify_cls Closure for @a notify.
328 * @param flags Flags for this announcement. 340 * @param flags Flags for this announcement.
341 *
329 * @return NULL on error (announcement already in progress?). 342 * @return NULL on error (announcement already in progress?).
330 */ 343 */
331struct GNUNET_SOCIAL_Announcement * 344struct GNUNET_SOCIAL_Announcement *
332GNUNET_SOCIAL_home_announce (struct GNUNET_SOCIAL_Home *home, 345GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
333 const char *method_name, 346 const char *method_name,
334 const struct GNUNET_ENV_Environment *env, 347 const struct GNUNET_ENV_Environment *env,
335 GNUNET_CONNECTION_TransmitReadyNotify notify, 348 GNUNET_CONNECTION_TransmitReadyNotify notify,
@@ -346,46 +359,48 @@ GNUNET_SOCIAL_home_announce (struct GNUNET_SOCIAL_Home *home,
346 * @param a The announcement to cancel. 359 * @param a The announcement to cancel.
347 */ 360 */
348void 361void
349GNUNET_SOCIAL_home_announce_cancel (struct GNUNET_SOCIAL_Announcement *a) 362GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a)
350{ 363{
351 364
352} 365}
353 366
354 367
355/** 368/**
356 * Convert our home to a place so we can access it via the place API. 369 * Obtain handle for a hosted place.
370 *
371 * The returned handle can be used to access the place API.
357 * 372 *
358 * @param home Handle for the home. 373 * @param host Handle for the host.
359 * @return Place handle for the same home, valid as long as @a home is valid; 374 *
360 * do NOT try to GNUNET_SOCIAL_place_leave() this place, it's your home! 375 * @return Handle for the hosted place, valid as long as @a host is valid.
361 */ 376 */
362struct GNUNET_SOCIAL_Place * 377struct GNUNET_SOCIAL_Place *
363GNUNET_SOCIAL_home_get_place (struct GNUNET_SOCIAL_Home *home) 378GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host)
364{ 379{
365 return NULL; 380 return NULL;
366} 381}
367 382
368 383
369/** 384/**
370 * Leave a home. 385 * Stop hosting a place.
371
372 * Invalidates home handle.
373 * Guests will be disconnected until the home is restarted.
374 * 386 *
375 * @param home Home to leave. 387 * Invalidates host handle.
376 * @param keep_active Keep home active after last application disconnected. 388 *
389 * @param host Host leaving the place.
390 * @param keep_active Keep the place active after last host disconnected.
377 */ 391 */
378void 392void
379GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home, int keep_active) 393GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *host, int keep_active)
380{ 394{
381 395
382} 396}
383 397
398
384/** 399/**
385 * Request entry to a place (home hosted by someone else). 400 * Request entry to a place as a guest.
386 * 401 *
387 * @param cfg Configuration to contact the social service. 402 * @param cfg Configuration to contact the social service.
388 * @param ego Owner of the home (host). 403 * @param ego Identity of the guest.
389 * @param address GNS name of the place to enter. Either in the form of 404 * @param address GNS name of the place to enter. Either in the form of
390 * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to 405 * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to
391 * the 'PLACE' record of the empty label ("+") in the GNS zone with the 406 * the 'PLACE' record of the empty label ("+") in the GNS zone with the
@@ -396,10 +411,11 @@ GNUNET_SOCIAL_home_leave (struct GNUNET_SOCIAL_Home *home, int keep_active)
396 * @param data Payload for the message to give to the enter callback. 411 * @param data Payload for the message to give to the enter callback.
397 * @param data_size Number of bytes in @a data. 412 * @param data_size Number of bytes in @a data.
398 * @param slicer Slicer to use for processing incoming requests from guests. 413 * @param slicer Slicer to use for processing incoming requests from guests.
399 * @return NULL on errors, otherwise handle to the place. 414 *
415 * @return NULL on errors, otherwise handle for the guest.
400 */ 416 */
401struct GNUNET_SOCIAL_Place * 417struct GNUNET_SOCIAL_Guest *
402GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg, 418GNUNET_SOCIAL_guest_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
403 struct GNUNET_IDENTITY_Ego *ego, 419 struct GNUNET_IDENTITY_Ego *ego,
404 char *address, 420 char *address,
405 const char *method_name, 421 const char *method_name,
@@ -412,10 +428,10 @@ GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
412} 428}
413 429
414/** 430/**
415 * Request entry to a place (home hosted by someone else). 431 * Request entry to a place as a guest.
416 * 432 *
417 * @param cfg Configuration to contact the social service. 433 * @param cfg Configuration to contact the social service.
418 * @param ego Owner of the home (host). 434 * @param ego Identity of the guest.
419 * @param crypto_address Public key of the place to enter. 435 * @param crypto_address Public key of the place to enter.
420 * @param origin Peer identity of the origin of the underlying multicast group. 436 * @param origin Peer identity of the origin of the underlying multicast group.
421 * @param relay_count Number of elements in the @a relays array. 437 * @param relay_count Number of elements in the @a relays array.
@@ -425,10 +441,11 @@ GNUNET_SOCIAL_place_enter (const struct GNUNET_CONFIGURATION_Handle *cfg,
425 * @param data Payload for the message to give to the enter callback. 441 * @param data Payload for the message to give to the enter callback.
426 * @param data_size Number of bytes in @a data. 442 * @param data_size Number of bytes in @a data.
427 * @param slicer Slicer to use for processing incoming requests from guests. 443 * @param slicer Slicer to use for processing incoming requests from guests.
428 * @return NULL on errors, otherwise handle to the place. 444 *
445 * @return NULL on errors, otherwise handle for the guest.
429 */ 446 */
430struct GNUNET_SOCIAL_Place * 447struct GNUNET_SOCIAL_Guest *
431GNUNET_SOCIAL_place_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg, 448GNUNET_SOCIAL_guest_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
432 struct GNUNET_IDENTITY_Ego *ego, 449 struct GNUNET_IDENTITY_Ego *ego,
433 struct GNUNET_CRYPTO_EddsaPublicKey *crypto_address, 450 struct GNUNET_CRYPTO_EddsaPublicKey *crypto_address,
434 struct GNUNET_PeerIdentity *origin, 451 struct GNUNET_PeerIdentity *origin,
@@ -445,125 +462,77 @@ GNUNET_SOCIAL_place_enter2 (const struct GNUNET_CONFIGURATION_Handle *cfg,
445 462
446 463
447/** 464/**
448 * Watch a place for changed objects. 465 * Talk to the host of the place.
449 * 466 *
450 * @param place Place to watch. 467 * @param place Place where we want to talk to the host.
451 * @param object_filter Object prefix to match. 468 * @param method_name Method to invoke on the host.
452 * @param state_cb Function to call when an object/state changes. 469 * @param env Environment containing variables for the message, or NULL.
453 * @param state_cb_cls Closure for callback. 470 * @param notify Function to use to get the payload for the method.
471 * @param notify_cls Closure for @a notify.
472 * @param flags Flags for the message being sent.
454 * 473 *
455 * @return Handle that can be used to cancel watching. 474 * @return NULL if we are already trying to talk to the host,
475 * otherwise handle to cancel the request.
456 */ 476 */
457struct GNUNET_SOCIAL_WatchHandle * 477struct GNUNET_SOCIAL_TalkRequest *
458GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place, 478GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Place *place,
459 const char *object_filter, 479 const char *method_name,
460 GNUNET_PSYC_StateCallback state_cb, 480 const struct GNUNET_ENV_Environment *env,
461 void *state_cb_cls) 481 GNUNET_CONNECTION_TransmitReadyNotify notify,
482 void *notify_cls,
483 enum GNUNET_SOCIAL_TalkFlags flags)
462{ 484{
463 return NULL; 485 return NULL;
464} 486}
465 487
466 488
467/** 489/**
468 * Cancel watching a place for changed objects. 490 * Cancel talking to the host of the place.
469 * 491 *
470 * @param wh Watch handle to cancel. 492 * @param tr Talk request to cancel.
471 */ 493 */
472void 494void
473GNUNET_SOCIAL_place_watch_cancel (struct GNUNET_SOCIAL_WatchHandle *wh) 495GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr)
474{ 496{
475 497
476} 498}
477 499
478 500
479/** 501/**
480 * Look at objects in the place with a matching name prefix. 502 * Leave a place permanently.
481 *
482 * @param place The place to look its objects at.
483 * @param name_prefix Look at objects with names beginning with this value.
484 * @param state_cb Function to call for each object found.
485 * @param state_cb_cls Closure for callback function.
486 * 503 *
487 * @return Handle that can be used to stop looking at objects. 504 * Notifies the owner of the place about leaving, and destroys the place handle.
488 */
489struct GNUNET_SOCIAL_LookHandle *
490GNUNET_SOCIAL_place_look (struct GNUNET_SOCIAL_Place *place,
491 const char *name_prefix,
492 GNUNET_PSYC_StateCallback state_cb,
493 void *state_cb_cls)
494{
495 return NULL;
496}
497
498
499/**
500 * Stop looking at objects.
501 * 505 *
502 * @param lh Look handle to stop. 506 * @param place Place to leave permanently.
507 * @param keep_active Keep place active after last application disconnected.
503 */ 508 */
504void 509void
505GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh) 510GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Place *place, int keep_active)
506{ 511{
507 512
508} 513}
509 514
510 515
511
512/** 516/**
513 * Look at a particular object in the place. 517 * Obtain handle for a place entered as guest.
514 * 518 *
515 * The best matching object is returned (its name might be less specific than 519 * The returned handle can be used to access the place API.
516 * what was requested).
517 * 520 *
518 * @param place The place to look the object at. 521 * @param guest Handle for the guest.
519 * @param full_name Full name of the object.
520 * @param value_size Set to the size of the returned value.
521 * @return NULL if there is no such object at this place.
522 */
523const void *
524GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *place,
525 const char *full_name,
526 size_t *value_size)
527{
528 return NULL;
529}
530
531
532/**
533 * Talk to the host of the place.
534 * 522 *
535 * @param place Place where we want to talk to the host. 523 * @return Handle for the place, valid as long as @a guest is valid.
536 * @param method_name Method to invoke on the host.
537 * @param env Environment containing variables for the message, or NULL.
538 * @param notify Function to use to get the payload for the method.
539 * @param notify_cls Closure for @a notify.
540 * @param flags Flags for the message being sent.
541 * @return NULL if we are already trying to talk to the host,
542 * otherwise handle to cancel the request.
543 */ 524 */
544struct GNUNET_SOCIAL_TalkRequest * 525struct GNUNET_SOCIAL_Place *
545GNUNET_SOCIAL_place_talk (struct GNUNET_SOCIAL_Place *place, 526GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Host *guest)
546 const char *method_name,
547 const struct GNUNET_ENV_Environment *env,
548 GNUNET_CONNECTION_TransmitReadyNotify notify,
549 void *notify_cls,
550 enum GNUNET_SOCIAL_TalkFlags flags)
551{ 527{
552 return NULL; 528 return NULL;
553} 529}
554 530
555 531
556/** 532/**
557 * Cancel talking to the host of the place. 533 * A history lesson.
558 *
559 * @param tr Talk request to cancel.
560 */ 534 */
561void 535struct GNUNET_SOCIAL_HistoryLesson;
562GNUNET_SOCIAL_place_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr)
563{
564
565}
566
567 536
568/** 537/**
569 * Learn about the history of a place. 538 * Learn about the history of a place.
@@ -612,16 +581,96 @@ GNUNET_SOCIAL_place_get_history_cancel (struct GNUNET_SOCIAL_HistoryLesson *hist
612} 581}
613 582
614 583
584struct GNUNET_SOCIAL_WatchHandle;
585
615/** 586/**
616 * Leave a place permanently. 587 * Watch a place for changed objects.
617 * 588 *
618 * Notifies the owner of the place about leaving, and destroys the place handle. 589 * @param place Place to watch.
590 * @param object_filter Object prefix to match.
591 * @param state_cb Function to call when an object/state changes.
592 * @param state_cb_cls Closure for callback.
619 * 593 *
620 * @param place Place to leave permanently. 594 * @return Handle that can be used to cancel watching.
621 * @param keep_active Keep place active after last application disconnected. 595 */
596struct GNUNET_SOCIAL_WatchHandle *
597GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place,
598 const char *object_filter,
599 GNUNET_PSYC_StateCallback state_cb,
600 void *state_cb_cls)
601{
602 return NULL;
603}
604
605
606/**
607 * Cancel watching a place for changed objects.
608 *
609 * @param wh Watch handle to cancel.
610 */
611void
612GNUNET_SOCIAL_place_watch_cancel (struct GNUNET_SOCIAL_WatchHandle *wh)
613{
614
615}
616
617
618struct GNUNET_SOCIAL_LookHandle;
619
620
621/**
622 * Look at objects in the place with a matching name prefix.
623 *
624 * @param place The place to look its objects at.
625 * @param name_prefix Look at objects with names beginning with this value.
626 * @param state_cb Function to call for each object found.
627 * @param state_cb_cls Closure for callback function.
628 *
629 * @return Handle that can be used to stop looking at objects.
630 */
631struct GNUNET_SOCIAL_LookHandle *
632GNUNET_SOCIAL_place_look (struct GNUNET_SOCIAL_Place *place,
633 const char *name_prefix,
634 GNUNET_PSYC_StateCallback state_cb,
635 void *state_cb_cls)
636{
637 return NULL;
638}
639
640
641/**
642 * Stop looking at objects.
643 *
644 * @param lh Look handle to stop.
622 */ 645 */
623void 646void
624GNUNET_SOCIAL_place_leave (struct GNUNET_SOCIAL_Place *place, int keep_active) 647GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh)
625{ 648{
626 649
627} 650}
651
652
653
654/**
655 * Look at a particular object in the place.
656 *
657 * The best matching object is returned (its name might be less specific than
658 * what was requested).
659 *
660 * @param place The place to look the object at.
661 * @param full_name Full name of the object.
662 * @param value_size Set to the size of the returned value.
663 * @return NULL if there is no such object at this place.
664 */
665const void *
666GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *place,
667 const char *full_name,
668 size_t *value_size)
669{
670 return NULL;
671}
672
673
674
675
676/* end of social_api.c */