gnunet_social_service.h 45 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528
  1. /*
  2. This file is part of GNUnet.
  3. Copyright (C) 2013 Christian Grothoff (and other contributing authors)
  4. GNUnet is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published
  6. by the Free Software Foundation; either version 3, or (at your
  7. option) any later version.
  8. GNUnet is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNUnet; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  15. Boston, MA 02110-1301, USA.
  16. */
  17. /**
  18. * @author Gabor X Toth
  19. * @author Christian Grothoff
  20. *
  21. * @file
  22. * Social service; implements social interactions through the PSYC service.
  23. */
  24. /** @defgroup social Social service
  25. Social interactions through the PSYC service.
  26. # Overview
  27. The social service provides an API for social interactions based on a one-to-many messaging model.
  28. It manages subscriptions of applications to places, provides messaging functionality in places,
  29. allows access to the local message history and manages the GNS zone of _egos_ (user identities).
  30. The service stores private and public keys of subscribed places, as well as files received in subscribed places.
  31. # Concepts and terminology
  32. ## Ego, Nym
  33. An _ego_ is an identity of a user, a private-public key pair.
  34. A _nym_ is an identity of another user in the network, identified by its public key.
  35. Each user can have multiple identities.
  36. struct GNUNET_SOCIAL_Ego and struct GNUNET_SOCIAL_Nym represents one of these identities.
  37. ## Place, Host, Guest
  38. A _place_ is where social interactions happen. It is owned and created by an _ego_.
  39. Creating a new place happens by an _ego_ entering a new place as a _host_,
  40. where _guests_ can enter later to receive messages sent to the place.
  41. A place is identified by its public key.
  42. - struct GNUNET_SOCIAL_Host represents a place entered as host,
  43. - struct GNUNET_SOCIAL_Guest is used for a place entered as guest.
  44. - A struct GNUNET_SOCIAL_Place can be obtained for both a host and guest place
  45. using GNUNET_SOCIAL_host_get_place() and GNUNET_SOCIAL_guest_get_place()
  46. and can be used with API functions common to hosts and guests.
  47. ## History
  48. Messages sent to places are stored locally by the PSYCstore service, and can be queried any time.
  49. GNUNET_SOCIAL_history_replay_latest() retrieves the latest N messages sent to the place,
  50. while GNUNET_SOCIAL_history_replay() is used to query a given message ID range.
  51. ## GNU Name System
  52. The GNU Name System is used for assigning human-readable names to nyms and places.
  53. There's a _GNS zone_ corresponding to each _nym_.
  54. An _ego_ can publish PKEY and PLACE records in its own zone, pointing to nyms and places, respectively.
  55. ## Announcement, talk request
  56. The host can _announce_ messages to the place, using GNUNET_SOCIAL_host_announce().
  57. Guests can send _talk_ requests to the host, using GNUNET_SOCIAL_guest_talk().
  58. The host receives talk requests of guests and can _relay_ them to the place,
  59. or process it using a message handler function.
  60. # Using the API
  61. ## Connecting to the service
  62. A client first establishes an _application connection_ to the service using
  63. GNUNET_SOCIAL_app_connect() providing its _application ID_, then receives the
  64. public keys of subscribed places and available egos and in response.
  65. ## Reconnecting to places
  66. Then the application can reconnect to its subscribed places by establishing
  67. _place connections_ with GNUNET_SOCIAL_host_enter_reconnect() and
  68. GNUNET_SOCIAL_guest_enter_reconnect().
  69. ## Subscribing to a place
  70. Entering and subscribing a new host or guest place is done using
  71. GNUNET_SOCIAL_host_enter() and GNUNET_SOCIAL_guest_enter().
  72. ## Disconnecting from a place
  73. An application can disconnect from a place while the social service keeps its
  74. network connection active, using GNUNET_SOCIAL_host_disconnect() and
  75. GNUNET_SOCIAL_guest_disconnect().
  76. ## Leaving a place
  77. To permanently leave a place, see GNUNET_SOCIAL_host_leave() and GNUNET_SOCIAL_guest_leave().
  78. When leaving a place its network connections are closed and all applications are unsubscribed from the place.
  79. # Methods
  80. ## _message
  81. A message sent to the place.
  82. ### Environment
  83. #### _id_reply_to
  84. message ID this message is in reply to.
  85. #### _id_thread
  86. thread ID, the first message ID in the thread.
  87. #### _nym_author__
  88. nym of the author.
  89. #### _sig_author
  90. signature of the message body and its variables by the author.
  91. ## Data
  92. Message body.
  93. ## _notice_place
  94. Notification about a place.
  95. TODO: Applications can decide to auto-subscribe to certain places,
  96. e.g. files under a given size.
  97. ### Environment
  98. #### Using GNS
  99. ##### _gns_place
  100. GNS name of the place in a globally unique .zkey zone
  101. #### Without GNS
  102. ##### _key_pub_place
  103. public key of place
  104. ##### _peer_origin
  105. peer ID of origin
  106. ##### _list_peer_relays
  107. list of peer IDs of relays
  108. ## _notice_place_file
  109. Notification about a place hosting a file.
  110. ### Environment
  111. The environment of _notice_place above, plus the following:
  112. #### _size_file
  113. size of file
  114. #### _mime_file
  115. MIME type of file
  116. #### _name_file
  117. name of file
  118. #### _description_file
  119. description of file
  120. ## _file
  121. Messages with a _file method contain a file,
  122. which is saved to disk upon receipt at the following location:
  123. $GNUNET_DATA_HOME/social/files/<H(place_pub)>/<message_id>
  124. ### Environment
  125. #### _size_file
  126. size of file
  127. #### _mime_file
  128. MIME type of file
  129. #### _name_file
  130. name of file
  131. #### _description_file
  132. description
  133. @{
  134. */
  135. #ifndef GNUNET_SOCIAL_SERVICE_H
  136. #define GNUNET_SOCIAL_SERVICE_H
  137. #ifdef __cplusplus
  138. extern "C"
  139. {
  140. #if 0 /* keep Emacsens' auto-indent happy */
  141. }
  142. #endif
  143. #endif
  144. #include <stdint.h>
  145. #include "gnunet_util_lib.h"
  146. #include "gnunet_env_lib.h"
  147. #include "gnunet_identity_service.h"
  148. #include "gnunet_namestore_service.h"
  149. #include "gnunet_psyc_service.h"
  150. /**
  151. * Version number of GNUnet Social API.
  152. */
  153. #define GNUNET_SOCIAL_VERSION 0x00000000
  154. /**
  155. * Maximum size of client ID including '\0' terminator.
  156. */
  157. #define GNUNET_SOCIAL_APP_MAX_ID_SIZE 256
  158. /**
  159. * Handle for an application.
  160. */
  161. struct GNUNET_SOCIAL_App;
  162. /**
  163. * Handle for an ego (own identity)
  164. */
  165. struct GNUNET_SOCIAL_Ego;
  166. /**
  167. * Handle for a pseudonym of another user in the network.
  168. */
  169. struct GNUNET_SOCIAL_Nym;
  170. /**
  171. * Handle for a place where social interactions happen.
  172. */
  173. struct GNUNET_SOCIAL_Place;
  174. /**
  175. * Host handle for a place that we entered.
  176. */
  177. struct GNUNET_SOCIAL_Host;
  178. /**
  179. * Guest handle for place that we entered.
  180. */
  181. struct GNUNET_SOCIAL_Guest;
  182. /**
  183. * Handle to an implementation of try-and-slice.
  184. */
  185. struct GNUNET_SOCIAL_Slicer;
  186. /**
  187. * Handle that can be used to reconnect to a place as host.
  188. */
  189. struct GNUNET_SOCIAL_HostConnection;
  190. /**
  191. * Handle that can be used to reconnect to a place as guest.
  192. */
  193. struct GNUNET_SOCIAL_GuestConnection;
  194. /**
  195. * Notification about an available identity.
  196. *
  197. * @param cls
  198. * Closure.
  199. * @param pub_key
  200. * Public key of ego.
  201. * @param name
  202. * Name of ego.
  203. */
  204. typedef void
  205. (*GNUNET_SOCIAL_AppEgoCallback) (void *cls,
  206. struct GNUNET_SOCIAL_Ego *ego,
  207. const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
  208. const char *name);
  209. /**
  210. * Entry status of a place.
  211. */
  212. enum GNUNET_SOCIAL_PlaceState
  213. {
  214. /**
  215. * Place was once entered but left since.
  216. */
  217. GNUNET_SOCIAL_PLACE_STATE_ARCHIVED = 0,
  218. /**
  219. * Place is entered but not subscribed.
  220. */
  221. GNUNET_SOCIAL_PLACE_STATE_ENTERED = 1,
  222. /**
  223. * Place is entered and subscribed.
  224. */
  225. GNUNET_SOCIAL_PLACE_STATE_SUBSCRIBED = 2,
  226. };
  227. /**
  228. * Notification about a home.
  229. *
  230. * @param cls
  231. * Closure.
  232. * @param hconn
  233. * Host connection, to be used with GNUNET_SOCIAL_host_enter_reconnect()
  234. * @param ego
  235. * Ego used to enter the place.
  236. * @param place_pub_key
  237. * Public key of the place.
  238. * @param place_state
  239. * @see enum GNUNET_SOCIAL_PlaceState
  240. */
  241. typedef void
  242. (*GNUNET_SOCIAL_AppHostPlaceCallback) (void *cls,
  243. struct GNUNET_SOCIAL_HostConnection *hconn,
  244. struct GNUNET_SOCIAL_Ego *ego,
  245. const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
  246. enum GNUNET_SOCIAL_PlaceState place_state);
  247. /**
  248. * Notification about a place.
  249. *
  250. * @param cls
  251. * Closure.
  252. * @param gconn
  253. * Guest connection, to be used with GNUNET_SOCIAL_guest_enter_reconnect()
  254. * @param ego
  255. * Ego used to enter the place.
  256. * @param place_pub_key
  257. * Public key of the place.
  258. * @param place_state
  259. * @see enum GNUNET_SOCIAL_PlaceState
  260. */
  261. typedef void
  262. (*GNUNET_SOCIAL_AppGuestPlaceCallback) (void *cls,
  263. struct GNUNET_SOCIAL_GuestConnection *gconn,
  264. struct GNUNET_SOCIAL_Ego *ego,
  265. const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
  266. enum GNUNET_SOCIAL_PlaceState place_state);
  267. /**
  268. * Establish application connection to the social service.
  269. *
  270. * The @host_place_cb and @guest_place_cb functions are
  271. * initially called for each entered places,
  272. * then later each time a new place is entered with the current app ID.
  273. *
  274. * @param cfg
  275. * Configuration.
  276. * @param ego_cb
  277. * Function to notify about an available ego.
  278. * @param host_cb
  279. * Function to notify about a place entered as host.
  280. * @param guest_cb
  281. * Function to notify about a place entered as guest.
  282. * @param cls
  283. * Closure for the callbacks.
  284. *
  285. * @return Handle that can be used to stop listening.
  286. */
  287. struct GNUNET_SOCIAL_App *
  288. GNUNET_SOCIAL_app_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
  289. const char *id,
  290. GNUNET_SOCIAL_AppEgoCallback ego_cb,
  291. GNUNET_SOCIAL_AppHostPlaceCallback host_cb,
  292. GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb,
  293. void *cls);
  294. /**
  295. * Disconnect app.
  296. *
  297. * @param c
  298. * App handle.
  299. */
  300. void
  301. GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app);
  302. /**
  303. * Get the public key of @a ego.
  304. *
  305. * @param ego
  306. * Ego.
  307. *
  308. * @return Public key of ego.
  309. */
  310. const struct GNUNET_CRYPTO_EcdsaPublicKey *
  311. GNUNET_SOCIAL_ego_get_pub_key (const struct GNUNET_SOCIAL_Ego *ego);
  312. /**
  313. * Get the name of @a ego.
  314. *
  315. * @param ego
  316. * Ego.
  317. *
  318. * @return Public key of @a ego.
  319. */
  320. const char *
  321. GNUNET_SOCIAL_ego_get_name (const struct GNUNET_SOCIAL_Ego *ego);
  322. /**
  323. * Get the public key of a @a nym.
  324. *
  325. * Suitable, for example, to be used with GNUNET_SOCIAL_zone_add_nym().
  326. *
  327. * @param nym
  328. * Pseudonym to map to a cryptographic identifier.
  329. *
  330. * @return Public key of nym.
  331. */
  332. const struct GNUNET_CRYPTO_EcdsaPublicKey *
  333. GNUNET_SOCIAL_nym_get_pub_key (const struct GNUNET_SOCIAL_Nym *nym);
  334. /**
  335. * Get the hash of the public key of a @a nym.
  336. *
  337. * @param nym
  338. * Pseudonym to map to a cryptographic identifier.
  339. *
  340. * @return Hash of the public key of nym.
  341. */
  342. const struct GNUNET_HashCode *
  343. GNUNET_SOCIAL_nym_get_pub_key_hash (const struct GNUNET_SOCIAL_Nym *nym);
  344. /**
  345. * Function called upon receiving a message indicating a call to a @e method.
  346. *
  347. * This function is called one or more times for each message until all data
  348. * fragments arrive from the network.
  349. *
  350. * @param cls
  351. * Closure.
  352. * @param msg
  353. * Message part, as it arrived from the network.
  354. * @param message_id
  355. * Message counter, monotonically increasing from 1.
  356. * @param nym
  357. * The sender of the message.
  358. * Can be NULL if the message is not connected to a pseudonym.
  359. * @param flags
  360. * OR'ed GNUNET_PSYC_MessageFlags
  361. * @param method_name
  362. * Original method name from PSYC.
  363. * May be more specific than the registered method name due to
  364. * try-and-slice matching.
  365. */
  366. typedef void
  367. (*GNUNET_SOCIAL_MethodCallback) (void *cls,
  368. const struct GNUNET_PSYC_MessageMethod *msg,
  369. uint64_t message_id,
  370. uint32_t flags,
  371. const struct GNUNET_SOCIAL_Nym *nym,
  372. const char *method_name);
  373. /**
  374. * Function called upon receiving a modifier of a message.
  375. *
  376. * @param cls
  377. * Closure.
  378. * @param message_id
  379. * Message ID this data fragment belongs to.
  380. * @param msg
  381. * Message part, as it arrived from the network.
  382. * @param oper
  383. * Operation to perform.
  384. * 0 in case of a modifier continuation.
  385. * @param name
  386. * Name of the modifier.
  387. * NULL in case of a modifier continuation.
  388. * @param value
  389. * Value of the modifier.
  390. * @param value_size
  391. * Size of @value.
  392. */
  393. typedef void
  394. (*GNUNET_SOCIAL_ModifierCallback) (void *cls,
  395. const struct GNUNET_MessageHeader *msg,
  396. uint64_t message_id,
  397. enum GNUNET_ENV_Operator oper,
  398. const char *name,
  399. const void *value,
  400. uint16_t value_size,
  401. uint16_t full_value_size);
  402. /**
  403. * Function called upon receiving a data fragment of a message.
  404. *
  405. * @param cls
  406. * Closure.
  407. * @param message_id
  408. * Message ID this data fragment belongs to.
  409. * @param msg
  410. * Message part, as it arrived from the network.
  411. * @param data_offset
  412. * Byte offset of @a data in the overall data of the method.
  413. * @param data_size
  414. * Number of bytes in @a data.
  415. * @param data
  416. * Data stream given to the method.
  417. * @param end
  418. * End of message?
  419. * #GNUNET_NO if there are further fragments,
  420. * #GNUNET_YES if this is the last fragment,
  421. * #GNUNET_SYSERR indicates the message was cancelled by the sender.
  422. */
  423. typedef void
  424. (*GNUNET_SOCIAL_DataCallback) (void *cls,
  425. const struct GNUNET_MessageHeader *msg,
  426. uint64_t message_id,
  427. uint64_t data_offset,
  428. const void *data,
  429. uint16_t data_size);
  430. /**
  431. * End of message.
  432. *
  433. * @param cls
  434. * Closure.
  435. * @param msg
  436. * Message part, as it arrived from the network.
  437. * @param message_id
  438. * Message ID this data fragment belongs to.
  439. * @param cancelled
  440. * #GNUNET_YES if the message was cancelled,
  441. * #GNUNET_NO if the message is complete.
  442. */
  443. typedef void
  444. (*GNUNET_SOCIAL_EndOfMessageCallback) (void *cls,
  445. const struct GNUNET_MessageHeader *msg,
  446. uint64_t message_id,
  447. uint8_t cancelled);
  448. /**
  449. * Create a try-and-slice instance.
  450. *
  451. * A slicer processes incoming messages and notifies callbacks about matching
  452. * methods or modifiers encountered.
  453. *
  454. * @return A new try-and-slice construct.
  455. */
  456. struct GNUNET_SOCIAL_Slicer *
  457. GNUNET_SOCIAL_slicer_create (void);
  458. /**
  459. * Add a method to the try-and-slice instance.
  460. *
  461. * The callbacks are called for messages with a matching @a method_name prefix.
  462. *
  463. * @param slicer
  464. * The try-and-slice instance to extend.
  465. * @param method_name
  466. * Name of the given method, use empty string to match all.
  467. * @param method_cb
  468. * Method handler invoked upon a matching message.
  469. * @param modifier_cb
  470. * Modifier handler, invoked after @a method_cb
  471. * for each modifier in the message.
  472. * @param data_cb
  473. * Data handler, invoked after @a modifier_cb for each data fragment.
  474. * @param eom_cb
  475. * Invoked upon reaching the end of a matching message.
  476. * @param cls
  477. * Closure for the callbacks.
  478. */
  479. void
  480. GNUNET_SOCIAL_slicer_method_add (struct GNUNET_SOCIAL_Slicer *slicer,
  481. const char *method_name,
  482. GNUNET_SOCIAL_MethodCallback method_cb,
  483. GNUNET_SOCIAL_ModifierCallback modifier_cb,
  484. GNUNET_SOCIAL_DataCallback data_cb,
  485. GNUNET_SOCIAL_EndOfMessageCallback eom_cb,
  486. void *cls);
  487. /**
  488. * Remove a registered method from the try-and-slice instance.
  489. *
  490. * Removes one matching handler registered with the given
  491. * @a method_name and callbacks.
  492. *
  493. * @param slicer
  494. * The try-and-slice instance.
  495. * @param method_name
  496. * Name of the method to remove.
  497. * @param method_cb
  498. * Method handler.
  499. * @param modifier_cb
  500. * Modifier handler.
  501. * @param data_cb
  502. * Data handler.
  503. * @param eom_cb
  504. * End of message handler.
  505. *
  506. * @return #GNUNET_OK if a method handler was removed,
  507. * #GNUNET_NO if no handler matched the given method name and callbacks.
  508. */
  509. int
  510. GNUNET_SOCIAL_slicer_method_remove (struct GNUNET_SOCIAL_Slicer *slicer,
  511. const char *method_name,
  512. GNUNET_SOCIAL_MethodCallback method_cb,
  513. GNUNET_SOCIAL_ModifierCallback modifier_cb,
  514. GNUNET_SOCIAL_DataCallback data_cb,
  515. GNUNET_SOCIAL_EndOfMessageCallback eom_cb);
  516. /**
  517. * Watch a place for changed objects.
  518. *
  519. * @param slicer
  520. * The try-and-slice instance.
  521. * @param object_filter
  522. * Object prefix to match.
  523. * @param modifier_cb
  524. * Function to call when encountering a state modifier.
  525. * @param cls
  526. * Closure for callback.
  527. */
  528. void
  529. GNUNET_SOCIAL_slicer_modifier_add (struct GNUNET_SOCIAL_Slicer *slicer,
  530. const char *object_filter,
  531. GNUNET_SOCIAL_ModifierCallback modifier_cb,
  532. void *cls);
  533. /**
  534. * Remove a registered modifier from the try-and-slice instance.
  535. *
  536. * Removes one matching handler registered with the given
  537. * @a object_filter and callback.
  538. *
  539. * @param slicer
  540. * The try-and-slice instance.
  541. * @param object_filter
  542. * Object prefix to match.
  543. * @param modifier_cb
  544. * Function to call when encountering a state modifier changes.
  545. */
  546. int
  547. GNUNET_SOCIAL_slicer_modifier_remove (struct GNUNET_SOCIAL_Slicer *slicer,
  548. const char *object_filter,
  549. GNUNET_SOCIAL_ModifierCallback modifier_cb);
  550. /**
  551. * Destroy a given try-and-slice instance.
  552. *
  553. * @param slicer
  554. * Slicer to destroy
  555. */
  556. void
  557. GNUNET_SOCIAL_slicer_destroy (struct GNUNET_SOCIAL_Slicer *slicer);
  558. /**
  559. * Function called asking for nym to be admitted to the place.
  560. *
  561. * Should call either GNUNET_SOCIAL_host_admit() or
  562. * GNUNET_SOCIAL_host_reject_entry() (possibly asynchronously). If this host
  563. * cannot decide, it is fine to call neither function, in which case hopefully
  564. * some other host of the place exists that will make the decision. The @a nym
  565. * reference remains valid until the #GNUNET_SOCIAL_FarewellCallback is invoked
  566. * for it.
  567. *
  568. * @param cls Closure.
  569. * @param nym Handle for the user who wants to enter.
  570. * @param method_name Method name in the entry request.
  571. * @param variable_count Number of elements in the @a variables array.
  572. * @param variables Variables present in the message.
  573. * @param data_size Number of bytes in @a data.
  574. * @param data Payload given on enter (e.g. a password).
  575. */
  576. typedef void
  577. (*GNUNET_SOCIAL_AnswerDoorCallback) (void *cls,
  578. struct GNUNET_SOCIAL_Nym *nym,
  579. const char *method_name,
  580. struct GNUNET_ENV_Environment *env,
  581. size_t data_size,
  582. const void *data);
  583. /**
  584. * Function called when a @a nym leaves the place.
  585. *
  586. * This is also called if the @a nym was never given permission to enter
  587. * (i.e. the @a nym stopped asking to get in).
  588. *
  589. * @param cls
  590. * Closure.
  591. * @param nym
  592. * Handle for the user who left.
  593. */
  594. typedef void
  595. (*GNUNET_SOCIAL_FarewellCallback) (void *cls,
  596. const struct GNUNET_SOCIAL_Nym *nym,
  597. struct GNUNET_ENV_Environment *env);
  598. /**
  599. * Function called after the host entered a home.
  600. *
  601. * @param cls
  602. * Closure.
  603. * @param result
  604. * #GNUNET_OK on success, or
  605. * #GNUNET_SYSERR on error.
  606. * @param place_pub_key
  607. * Public key of home.
  608. * @param max_message_id
  609. * Last message ID sent to the channel.
  610. * Or 0 if no messages have been sent to the place yet.
  611. */
  612. typedef void
  613. (*GNUNET_SOCIAL_HostEnterCallback) (void *cls, int result,
  614. const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
  615. uint64_t max_message_id);
  616. /**
  617. * Enter a place as host.
  618. *
  619. * A place is created upon first entering, and it is active until permanently
  620. * left using GNUNET_SOCIAL_host_leave().
  621. *
  622. * @param cfg
  623. * Configuration to contact the social service.
  624. * @param ego
  625. * Identity of the host.
  626. * @param place_key
  627. * Private-public key pair of the place.
  628. * NULL for ephemeral places.
  629. * @param policy
  630. * Policy specifying entry and history restrictions for the place.
  631. * @param slicer
  632. * Slicer to handle incoming messages.
  633. * @param enter_cb
  634. * Function called when the place is entered and ready to use.
  635. * @param answer_door_cb
  636. * Function to handle new nyms that want to enter.
  637. * @param farewell_cb
  638. * Function to handle departing nyms.
  639. * @param cls
  640. * Closure for the callbacks.
  641. *
  642. * @return Handle for the host.
  643. */
  644. struct GNUNET_SOCIAL_Host *
  645. GNUNET_SOCIAL_host_enter (const struct GNUNET_SOCIAL_App *app,
  646. const struct GNUNET_SOCIAL_Ego *ego,
  647. enum GNUNET_PSYC_Policy policy,
  648. struct GNUNET_SOCIAL_Slicer *slicer,
  649. GNUNET_SOCIAL_HostEnterCallback enter_cb,
  650. GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
  651. GNUNET_SOCIAL_FarewellCallback farewell_cb,
  652. void *cls);
  653. /**
  654. * Reconnect to an already entered place as host.
  655. *
  656. * @param hconn
  657. * Host connection handle.
  658. * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppHostPlaceCallback()
  659. * @param slicer
  660. * Slicer to handle incoming messages.
  661. * @param enter_cb
  662. * Function called when the place is entered and ready to use.
  663. * @param answer_door_cb
  664. * Function to handle new nyms that want to enter.
  665. * @param farewell_cb
  666. * Function to handle departing nyms.
  667. * @param cls
  668. * Closure for the callbacks.
  669. *
  670. * @return Handle for the host.
  671. */
  672. struct GNUNET_SOCIAL_Host *
  673. GNUNET_SOCIAL_host_enter_reconnect (struct GNUNET_SOCIAL_HostConnection *hconn,
  674. struct GNUNET_SOCIAL_Slicer *slicer,
  675. GNUNET_SOCIAL_HostEnterCallback enter_cb,
  676. GNUNET_SOCIAL_AnswerDoorCallback answer_door_cb,
  677. GNUNET_SOCIAL_FarewellCallback farewell_cb,
  678. void *cls);
  679. /**
  680. * Decision whether to admit @a nym into the place or refuse entry.
  681. *
  682. * @param hst
  683. * Host of the place.
  684. * @param nym
  685. * Handle for the entity that wanted to enter.
  686. * @param is_admitted
  687. * #GNUNET_YES if @a nym is admitted,
  688. * #GNUNET_NO if @a nym is refused entry,
  689. * #GNUNET_SYSERR if we cannot answer the request.
  690. * @param method_name
  691. * Method name for the rejection message.
  692. * @param env
  693. * Environment containing variables for the message, or NULL.
  694. * @param data
  695. * Data for the rejection message to send back.
  696. * @param data_size
  697. * Number of bytes in @a data for method.
  698. * @return #GNUNET_OK on success,
  699. * #GNUNET_SYSERR if the message is too large.
  700. */
  701. int
  702. GNUNET_SOCIAL_host_entry_decision (struct GNUNET_SOCIAL_Host *hst,
  703. struct GNUNET_SOCIAL_Nym *nym,
  704. int is_admitted,
  705. const struct GNUNET_PSYC_Message *entry_resp);
  706. /**
  707. * Throw @a nym out of the place.
  708. *
  709. * Sends a _notice_place_leave announcement to the home.
  710. *
  711. * The @a nym reference will remain valid until the
  712. * #GNUNET_SOCIAL_FarewellCallback is invoked,
  713. * which should be very soon after this call.
  714. *
  715. * @param host
  716. * Host of the place.
  717. * @param nym
  718. * Handle for the entity to be ejected.
  719. * @param env
  720. * Environment for the message or NULL.
  721. * _nym is set to @e nym regardless whether an @e env is provided.
  722. */
  723. void
  724. GNUNET_SOCIAL_host_eject (struct GNUNET_SOCIAL_Host *host,
  725. const struct GNUNET_SOCIAL_Nym *nym,
  726. struct GNUNET_ENV_Environment *env);
  727. /**
  728. * Flags for announcements by a host.
  729. */
  730. enum GNUNET_SOCIAL_AnnounceFlags
  731. {
  732. GNUNET_SOCIAL_ANNOUNCE_NONE = 0,
  733. /**
  734. * Whether this announcement removes all objects from the place.
  735. *
  736. * New objects can be still added to the now empty place using the @e env
  737. * parameter of the same announcement.
  738. */
  739. GNUNET_SOCIAL_ANNOUNCE_CLEAR_OBJECTS = 1 << 0
  740. };
  741. /**
  742. * Handle for an announcement request.
  743. */
  744. struct GNUNET_SOCIAL_Announcement;
  745. /**
  746. * Send a message to all nyms that are present in the place.
  747. *
  748. * This function is restricted to the host. Nyms can only send requests
  749. * to the host who can decide to relay it to everyone in the place.
  750. *
  751. * @param host
  752. * Host of the place.
  753. * @param method_name
  754. * Method to use for the announcement.
  755. * @param env
  756. * Environment containing variables for the message and operations
  757. * on objects of the place.
  758. * Has to remain available until the first call to @a notify_data.
  759. * Can be NULL.
  760. * @param notify_data
  761. * Function to call to get the payload of the announcement.
  762. * @param notify_data_cls
  763. * Closure for @a notify.
  764. * @param flags
  765. * Flags for this announcement.
  766. *
  767. * @return NULL on error (another announcement already in progress?).
  768. */
  769. struct GNUNET_SOCIAL_Announcement *
  770. GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *host,
  771. const char *method_name,
  772. const struct GNUNET_ENV_Environment *env,
  773. GNUNET_PSYC_TransmitNotifyData notify_data,
  774. void *notify_data_cls,
  775. enum GNUNET_SOCIAL_AnnounceFlags flags);
  776. /**
  777. * Resume transmitting announcement.
  778. *
  779. * @param a
  780. * The announcement to resume.
  781. */
  782. void
  783. GNUNET_SOCIAL_host_announce_resume (struct GNUNET_SOCIAL_Announcement *a);
  784. /**
  785. * Cancel announcement.
  786. *
  787. * @param a
  788. * The announcement to cancel.
  789. */
  790. void
  791. GNUNET_SOCIAL_host_announce_cancel (struct GNUNET_SOCIAL_Announcement *a);
  792. /**
  793. * Allow relaying messages from guests matching a given @a method_prefix.
  794. *
  795. * @param host
  796. * The host.
  797. * @param method_prefix
  798. * Method prefix to allow.
  799. */
  800. void
  801. GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host,
  802. const char *method_prefix);
  803. /**
  804. * Allow relaying changes to objects of the place.
  805. *
  806. * Only applies to messages with an allowed method name.
  807. * @see GNUNET_SCOIAL_host_relay_allow_method()
  808. *
  809. * @param host
  810. * The host.
  811. * @param object_prefix
  812. * Object prefix to allow modifying.
  813. */
  814. void
  815. GNUNET_SOCIAL_host_relay_allow_method (struct GNUNET_SOCIAL_Host *host,
  816. const char *object_prefix);
  817. /**
  818. * Stop relaying messages from guests.
  819. *
  820. * Remove all allowed relay rules.
  821. *
  822. *
  823. *
  824. */
  825. void
  826. GNUNET_SOCIAL_host_relay_stop (struct GNUNET_SOCIAL_Host *host);
  827. /**
  828. * Obtain handle for a hosted place.
  829. *
  830. * The returned handle can be used to access the place API.
  831. *
  832. * @param host
  833. * Handle for the host.
  834. *
  835. * @return Handle for the hosted place, valid as long as @a host is valid.
  836. */
  837. struct GNUNET_SOCIAL_Place *
  838. GNUNET_SOCIAL_host_get_place (struct GNUNET_SOCIAL_Host *host);
  839. /**
  840. * Disconnect from a home.
  841. *
  842. * Invalidates host handle.
  843. *
  844. * @param hst
  845. * The host to disconnect.
  846. * @param disconnect_cb
  847. * Function called after disconnected from the service.
  848. * @param cls
  849. * Closure for @a disconnect_cb.
  850. */
  851. void
  852. GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
  853. GNUNET_ContinuationCallback disconnect_cb,
  854. void *cls);
  855. /**
  856. * Stop hosting a home.
  857. *
  858. * Sends a _notice_place_closed announcement to the home.
  859. * Invalidates host handle.
  860. *
  861. * @param hst
  862. * Host leaving.
  863. * @param env
  864. * Environment for the message or NULL.
  865. * @param disconnect_cb
  866. * Function called after the host left the place
  867. * and disconnected from the service.
  868. * @param cls
  869. * Closure for @a disconnect_cb.
  870. */
  871. void
  872. GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
  873. const struct GNUNET_ENV_Environment *env,
  874. GNUNET_ContinuationCallback disconnect_cb,
  875. void *cls);
  876. /**
  877. * Function called after the guest entered the local copy of the place.
  878. *
  879. * History and object query functions can be used after this call,
  880. * but new messages can't be sent or received.
  881. *
  882. * @param cls
  883. * Closure.
  884. * @param result
  885. * #GNUNET_OK on success, or
  886. * #GNUNET_SYSERR on error, e.g. could not connect to the service, or
  887. * could not resolve GNS name.
  888. * @param max_message_id
  889. * Last message ID sent to the place.
  890. * Or 0 if no messages have been sent to the place yet.
  891. */
  892. typedef void
  893. (*GNUNET_SOCIAL_GuestEnterCallback) (void *cls, int result,
  894. uint64_t max_message_id);
  895. /**
  896. * Function called upon a guest receives a decision about entry to the place.
  897. *
  898. * @param is_admitted
  899. * Is the guest admitted to the place?
  900. * #GNUNET_YES if admitted,
  901. * #GNUNET_NO if refused entry
  902. * #GNUNET_SYSERR if the request could not be answered.
  903. * @param method_name
  904. * Method for the message sent along with the decision.
  905. * NULL if no message was sent.
  906. * @param env
  907. * Environment with variables for the message.
  908. * NULL if there are no variables.
  909. * It has to be freed using GNUNET_ENV_environment_destroy()
  910. * when it is not needed anymore.
  911. * @param data_size
  912. * Size of @data.
  913. * @param data
  914. * Payload of the message.
  915. */
  916. typedef void
  917. (*GNUNET_SOCIAL_EntryDecisionCallback) (void *cls,
  918. int is_admitted,
  919. const struct GNUNET_PSYC_Message *entry_resp);
  920. /**
  921. * Request entry to a place as a guest.
  922. *
  923. * @param app
  924. * Application handle.
  925. * @param ego
  926. * Identity of the guest.
  927. * @param place_pub_key
  928. * Public key of the place to enter.
  929. * @param flags
  930. * Flags for the entry.
  931. * @param origin
  932. * Peer identity of the origin of the underlying multicast group.
  933. * @param relay_count
  934. * Number of elements in the @a relays array.
  935. * @param relays
  936. * Relays for the underlying multicast group.
  937. * @param method_name
  938. * Method name for the message.
  939. * @param env
  940. * Environment containing variables for the message, or NULL.
  941. * @param data
  942. * Payload for the message to give to the enter callback.
  943. * @param data_size
  944. * Number of bytes in @a data.
  945. * @param slicer
  946. * Slicer to use for processing incoming requests from guests.
  947. *
  948. * @return NULL on errors, otherwise handle for the guest.
  949. */
  950. struct GNUNET_SOCIAL_Guest *
  951. GNUNET_SOCIAL_guest_enter (const struct GNUNET_SOCIAL_App *app,
  952. const struct GNUNET_SOCIAL_Ego *ego,
  953. const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
  954. enum GNUNET_PSYC_SlaveJoinFlags flags,
  955. const struct GNUNET_PeerIdentity *origin,
  956. uint32_t relay_count,
  957. const struct GNUNET_PeerIdentity *relays,
  958. const struct GNUNET_PSYC_Message *entry_msg,
  959. struct GNUNET_SOCIAL_Slicer *slicer,
  960. GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
  961. GNUNET_SOCIAL_EntryDecisionCallback entry_dcsn_cb,
  962. void *cls);
  963. /**
  964. * Request entry to a place by name as a guest.
  965. *
  966. * @param app
  967. * Application handle.
  968. * @param ego
  969. * Identity of the guest.
  970. * @param gns_name
  971. * GNS name of the place to enter. Either in the form of
  972. * 'room.friend.gnu', or 'NYMPUBKEY.zkey'. This latter case refers to
  973. * the 'PLACE' record of the empty label ("+") in the GNS zone with the
  974. * nym's public key 'NYMPUBKEY', and can be used to request entry to a
  975. * pseudonym's place directly.
  976. * @param password
  977. * Password to decrypt the record, or NULL for cleartext records.
  978. * @param join_msg
  979. * Entry request message.
  980. * @param slicer
  981. * Slicer to use for processing incoming requests from guests.
  982. * @param local_enter_cb
  983. * Called upon connection established to the social service.
  984. * @param entry_decision_cb
  985. * Called upon receiving entry decision.
  986. *
  987. * @return NULL on errors, otherwise handle for the guest.
  988. */
  989. struct GNUNET_SOCIAL_Guest *
  990. GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app,
  991. const struct GNUNET_SOCIAL_Ego *ego,
  992. const char *gns_name,
  993. const char *password,
  994. const struct GNUNET_PSYC_Message *join_msg,
  995. struct GNUNET_SOCIAL_Slicer *slicer,
  996. GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
  997. GNUNET_SOCIAL_EntryDecisionCallback entry_decision_cb,
  998. void *cls);
  999. /**
  1000. * Reconnect to an already entered place as guest.
  1001. *
  1002. * @param gconn
  1003. * Guest connection handle.
  1004. * @see GNUNET_SOCIAL_app_connect() & GNUNET_SOCIAL_AppGuestPlaceCallback()
  1005. * @param flags
  1006. * Flags for the entry.
  1007. * @param slicer
  1008. * Slicer to use for processing incoming requests from guests.
  1009. * @param local_enter_cb
  1010. * Called upon connection established to the social service.
  1011. * @param entry_decision_cb
  1012. * Called upon receiving entry decision.
  1013. *
  1014. * @return NULL on errors, otherwise handle for the guest.
  1015. */
  1016. struct GNUNET_SOCIAL_Guest *
  1017. GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn,
  1018. enum GNUNET_PSYC_SlaveJoinFlags flags,
  1019. struct GNUNET_SOCIAL_Slicer *slicer,
  1020. GNUNET_SOCIAL_GuestEnterCallback local_enter_cb,
  1021. void *cls);
  1022. /**
  1023. * Flags for talking to the host of a place.
  1024. */
  1025. enum GNUNET_SOCIAL_TalkFlags
  1026. {
  1027. GNUNET_SOCIAL_TALK_NONE = 0
  1028. };
  1029. /**
  1030. * A talk request.
  1031. */
  1032. struct GNUNET_SOCIAL_TalkRequest;
  1033. /**
  1034. * Talk to the host of the place.
  1035. *
  1036. * @param place
  1037. * Place where we want to talk to the host.
  1038. * @param method_name
  1039. * Method to invoke on the host.
  1040. * @param env
  1041. * Environment containing variables for the message, or NULL.
  1042. * @param notify_data
  1043. * Function to use to get the payload for the method.
  1044. * @param notify_data_cls
  1045. * Closure for @a notify_data.
  1046. * @param flags
  1047. * Flags for the message being sent.
  1048. *
  1049. * @return NULL if we are already trying to talk to the host,
  1050. * otherwise handle to cancel the request.
  1051. */
  1052. struct GNUNET_SOCIAL_TalkRequest *
  1053. GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *guest,
  1054. const char *method_name,
  1055. const struct GNUNET_ENV_Environment *env,
  1056. GNUNET_PSYC_TransmitNotifyData notify_data,
  1057. void *notify_data_cls,
  1058. enum GNUNET_SOCIAL_TalkFlags flags);
  1059. /**
  1060. * Resume talking to the host of the place.
  1061. *
  1062. * @param tr
  1063. * Talk request to resume.
  1064. */
  1065. void
  1066. GNUNET_SOCIAL_guest_talk_resume (struct GNUNET_SOCIAL_TalkRequest *tr);
  1067. /**
  1068. * Cancel talking to the host of the place.
  1069. *
  1070. * @param tr
  1071. * Talk request to cancel.
  1072. */
  1073. void
  1074. GNUNET_SOCIAL_guest_talk_cancel (struct GNUNET_SOCIAL_TalkRequest *tr);
  1075. /**
  1076. * Disconnect from a place.
  1077. *
  1078. * Invalidates guest handle.
  1079. *
  1080. * @param gst
  1081. * The guest to disconnect.
  1082. * @param disconnect_cb
  1083. * Function called after disconnected from the service.
  1084. * @param cls
  1085. * Closure for @a disconnect_cb.
  1086. */
  1087. void
  1088. GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
  1089. GNUNET_ContinuationCallback disconnect_cb,
  1090. void *cls);
  1091. /**
  1092. * Leave a place temporarily or permanently.
  1093. *
  1094. * Notifies the owner of the place about leaving, and destroys the place handle.
  1095. *
  1096. * @param place
  1097. * Place to leave.
  1098. * @param env
  1099. * Optional environment for the leave message if @a keep_active
  1100. * is #GNUNET_NO. NULL if not needed.
  1101. * @param disconnect_cb
  1102. * Called upon disconnecting from the social service.
  1103. */
  1104. void
  1105. GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
  1106. struct GNUNET_ENV_Environment *env,
  1107. GNUNET_ContinuationCallback disconnect_cb,
  1108. void *leave_cls);
  1109. /**
  1110. * Obtain handle for a place entered as guest.
  1111. *
  1112. * The returned handle can be used to access the place API.
  1113. *
  1114. * @param guest Handle for the guest.
  1115. *
  1116. * @return Handle for the place, valid as long as @a guest is valid.
  1117. */
  1118. struct GNUNET_SOCIAL_Place *
  1119. GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest);
  1120. /**
  1121. * A history request.
  1122. */
  1123. struct GNUNET_SOCIAL_HistoryRequest;
  1124. /**
  1125. * Learn about the history of a place.
  1126. *
  1127. * Messages are returned through the @a slicer function
  1128. * and have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
  1129. *
  1130. * @param place
  1131. * Place we want to learn more about.
  1132. * @param start_message_id
  1133. * First historic message we are interested in.
  1134. * @param end_message_id
  1135. * Last historic message we are interested in (inclusive).
  1136. * @param method_prefix
  1137. * Only retrieve messages with this method prefix.
  1138. * @param flags
  1139. * OR'ed GNUNET_PSYC_HistoryReplayFlags
  1140. * @param slicer
  1141. * Slicer to use for retrieved messages.
  1142. * Can be the same as the slicer of the place.
  1143. * @param result_cb
  1144. * Function called after all messages retrieved.
  1145. * NULL if not needed.
  1146. * @param cls Closure for @a result_cb.
  1147. */
  1148. struct GNUNET_SOCIAL_HistoryRequest *
  1149. GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc,
  1150. uint64_t start_message_id,
  1151. uint64_t end_message_id,
  1152. const char *method_prefix,
  1153. uint32_t flags,
  1154. struct GNUNET_SOCIAL_Slicer *slicer,
  1155. GNUNET_ResultCallback result_cb,
  1156. void *cls);
  1157. /**
  1158. * Learn about the history of a place.
  1159. *
  1160. * Sends messages through the slicer function of the place where
  1161. * start_message_id <= message_id <= end_message_id.
  1162. * The messages will have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set.
  1163. *
  1164. * To get the latest message, use 0 for both the start and end message ID.
  1165. *
  1166. * @param place
  1167. * Place we want to learn more about.
  1168. * @param message_limit
  1169. * Maximum number of historic messages we are interested in.
  1170. * @param result_cb
  1171. * Function called after all messages retrieved.
  1172. * NULL if not needed.
  1173. * @param cls Closure for @a result_cb.
  1174. */
  1175. struct GNUNET_SOCIAL_HistoryRequest *
  1176. GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc,
  1177. uint64_t message_limit,
  1178. const char *method_prefix,
  1179. uint32_t flags,
  1180. struct GNUNET_SOCIAL_Slicer *slicer,
  1181. GNUNET_ResultCallback result_cb,
  1182. void *cls);
  1183. /**
  1184. * Cancel learning about the history of a place.
  1185. *
  1186. * @param hist
  1187. * History lesson to cancel.
  1188. */
  1189. void
  1190. GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist);
  1191. struct GNUNET_SOCIAL_LookHandle;
  1192. /**
  1193. * Look at a particular object in the place.
  1194. *
  1195. * The best matching object is returned (its name might be less specific than
  1196. * what was requested).
  1197. *
  1198. * @param place
  1199. * The place to look the object at.
  1200. * @param full_name
  1201. * Full name of the object.
  1202. * @param value_size
  1203. * Set to the size of the returned value.
  1204. *
  1205. * @return NULL if there is no such object at this place.
  1206. */
  1207. struct GNUNET_SOCIAL_LookHandle *
  1208. GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *plc,
  1209. const char *full_name,
  1210. GNUNET_PSYC_StateVarCallback var_cb,
  1211. GNUNET_ResultCallback result_cb,
  1212. void *cls);
  1213. /**
  1214. * Look for objects in the place with a matching name prefix.
  1215. *
  1216. * @param place
  1217. * The place to look its objects at.
  1218. * @param name_prefix
  1219. * Look at objects with names beginning with this value.
  1220. * @param var_cb
  1221. * Function to call for each object found.
  1222. * @param cls
  1223. * Closure for callback function.
  1224. *
  1225. * @return Handle that can be used to stop looking at objects.
  1226. */
  1227. struct GNUNET_SOCIAL_LookHandle *
  1228. GNUNET_SOCIAL_place_look_for (struct GNUNET_SOCIAL_Place *plc,
  1229. const char *name_prefix,
  1230. GNUNET_PSYC_StateVarCallback var_cb,
  1231. GNUNET_ResultCallback result_cb,
  1232. void *cls);
  1233. /**
  1234. * Stop looking at objects.
  1235. *
  1236. * @param lh Look handle to stop.
  1237. */
  1238. void
  1239. GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh);
  1240. /**
  1241. * Advertise a @e place in the GNS zone of @a ego.
  1242. *
  1243. * @param app
  1244. * Application handle.
  1245. * @param ego
  1246. * Ego.
  1247. * @param place_pub_key
  1248. * Public key of place to add.
  1249. * @param name
  1250. * The name for the PLACE record to put in the zone.
  1251. * @param password
  1252. * Password used to encrypt the record or NULL to keep it cleartext.
  1253. * @param relay_count
  1254. * Number of elements in the @a relays array.
  1255. * @param relays
  1256. * List of relays to put in the PLACE record to advertise
  1257. * as entry points to the place in addition to the origin.
  1258. * @param expiration_time
  1259. * Expiration time of the record, use 0 to remove the record.
  1260. * @param result_cb
  1261. * Function called with the result of the operation.
  1262. * @param result_cls
  1263. * Closure for @a result_cb
  1264. *
  1265. * @return #GNUNET_OK if the request was sent,
  1266. * #GNUNET_SYSERR on error, e.g. the name/password is too long.
  1267. */
  1268. int
  1269. GNUNET_SOCIAL_zone_add_place (const struct GNUNET_SOCIAL_App *app,
  1270. const struct GNUNET_SOCIAL_Ego *ego,
  1271. const char *name,
  1272. const char *password,
  1273. const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key,
  1274. const struct GNUNET_PeerIdentity *origin,
  1275. uint32_t relay_count,
  1276. const struct GNUNET_PeerIdentity *relays,
  1277. struct GNUNET_TIME_Absolute expiration_time,
  1278. GNUNET_ResultCallback result_cb,
  1279. void *result_cls);
  1280. /**
  1281. * Add public key to the GNS zone of the @e ego.
  1282. *
  1283. * @param cfg
  1284. * Configuration.
  1285. * @param ego
  1286. * Ego.
  1287. * @param name
  1288. * The name for the PKEY record to put in the zone.
  1289. * @param nym_pub_key
  1290. * Public key of nym to add.
  1291. * @param expiration_time
  1292. * Expiration time of the record, use 0 to remove the record.
  1293. * @param result_cb
  1294. * Function called with the result of the operation.
  1295. * @param result_cls
  1296. * Closure for @a result_cb
  1297. *
  1298. * @return #GNUNET_OK if the request was sent,
  1299. * #GNUNET_SYSERR on error, e.g. the name is too long.
  1300. */
  1301. int
  1302. GNUNET_SOCIAL_zone_add_nym (const struct GNUNET_SOCIAL_App *app,
  1303. const struct GNUNET_SOCIAL_Ego *ego,
  1304. const char *name,
  1305. const struct GNUNET_CRYPTO_EcdsaPublicKey *nym_pub_key,
  1306. struct GNUNET_TIME_Absolute expiration_time,
  1307. GNUNET_ResultCallback result_cb,
  1308. void *result_cls);
  1309. #if 0 /* keep Emacsens' auto-indent happy */
  1310. {
  1311. #endif
  1312. #ifdef __cplusplus
  1313. }
  1314. #endif
  1315. /* ifndef GNUNET_SOCIAL_SERVICE_H */
  1316. #endif
  1317. /** @} */ /* end of group social */