diff options
author | Gabor X Toth <*@tg-x.net> | 2015-05-07 12:15:58 +0000 |
---|---|---|
committer | Gabor X Toth <*@tg-x.net> | 2015-05-07 12:15:58 +0000 |
commit | 4725d59b468f1f30ba2910992333ca157682ce29 (patch) | |
tree | 23715ee20879c94a3363e28ea184370a4a71e44d /src/include | |
parent | a5edf8ac9f03a368c87ea6163994d4ac3d62af06 (diff) | |
download | gnunet-4725d59b468f1f30ba2910992333ca157682ce29.tar.gz gnunet-4725d59b468f1f30ba2910992333ca157682ce29.zip |
psyc/social: request history & state from psycstore; more documentation, tests, cleanup
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/gnunet_protocols.h | 2 | ||||
-rw-r--r-- | src/include/gnunet_psyc_service.h | 247 | ||||
-rw-r--r-- | src/include/gnunet_psyc_util_lib.h | 28 | ||||
-rw-r--r-- | src/include/gnunet_psycstore_service.h | 35 | ||||
-rw-r--r-- | src/include/gnunet_social_service.h | 141 |
5 files changed, 325 insertions, 128 deletions
diff --git a/src/include/gnunet_protocols.h b/src/include/gnunet_protocols.h index cdbc46f7f..2c73eadd6 100644 --- a/src/include/gnunet_protocols.h +++ b/src/include/gnunet_protocols.h | |||
@@ -2222,7 +2222,7 @@ extern "C" | |||
2222 | 2222 | ||
2223 | /* 700 */ | 2223 | /* 700 */ |
2224 | 2224 | ||
2225 | /** C->S: client requests channel history from PSYCstore. */ | 2225 | /** C->S: request channel history replay from PSYCstore. */ |
2226 | #define GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY 701 | 2226 | #define GNUNET_MESSAGE_TYPE_PSYC_HISTORY_REPLAY 701 |
2227 | 2227 | ||
2228 | /** S->C: result for a channel history request */ | 2228 | /** S->C: result for a channel history request */ |
diff --git a/src/include/gnunet_psyc_service.h b/src/include/gnunet_psyc_service.h index 5239acb16..c7692f074 100644 --- a/src/include/gnunet_psyc_service.h +++ b/src/include/gnunet_psyc_service.h | |||
@@ -376,6 +376,106 @@ struct GNUNET_PSYC_JoinDecisionMessage | |||
376 | /* Followed by struct GNUNET_MessageHeader join_response */ | 376 | /* Followed by struct GNUNET_MessageHeader join_response */ |
377 | }; | 377 | }; |
378 | 378 | ||
379 | |||
380 | enum GNUNET_PSYC_HistoryReplayFlags | ||
381 | { | ||
382 | /** | ||
383 | * Replay locally available messages. | ||
384 | */ | ||
385 | GNUNET_PSYC_HISTORY_REPLAY_LOCAL = 0, | ||
386 | |||
387 | /** | ||
388 | * Replay messages from remote peers if not found locally. | ||
389 | */ | ||
390 | GNUNET_PSYC_HISTORY_REPLAY_REMOTE = 1, | ||
391 | }; | ||
392 | |||
393 | |||
394 | struct GNUNET_PSYC_HistoryRequestMessage | ||
395 | { | ||
396 | /** | ||
397 | * Type: GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_HISTORY_REPLAY | ||
398 | */ | ||
399 | struct GNUNET_MessageHeader header; | ||
400 | |||
401 | /** | ||
402 | * @see enum GNUNET_PSYC_HistoryReplayFlags | ||
403 | */ | ||
404 | uint32_t flags GNUNET_PACKED; | ||
405 | |||
406 | /** | ||
407 | * ID for this operation. | ||
408 | */ | ||
409 | uint64_t op_id GNUNET_PACKED; | ||
410 | |||
411 | uint64_t start_message_id GNUNET_PACKED; | ||
412 | |||
413 | uint64_t end_message_id GNUNET_PACKED; | ||
414 | |||
415 | uint64_t message_limit GNUNET_PACKED; | ||
416 | |||
417 | /* Followed by NUL-terminated method name prefix. */ | ||
418 | }; | ||
419 | |||
420 | |||
421 | struct GNUNET_PSYC_StateRequestMessage | ||
422 | { | ||
423 | /** | ||
424 | * Types: | ||
425 | * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_GET | ||
426 | * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_GET_PREFIX | ||
427 | */ | ||
428 | struct GNUNET_MessageHeader header; | ||
429 | |||
430 | uint32_t reserved GNUNET_PACKED; | ||
431 | |||
432 | /** | ||
433 | * ID for this operation. | ||
434 | */ | ||
435 | uint64_t op_id GNUNET_PACKED; | ||
436 | |||
437 | /* Followed by NUL-terminated name. */ | ||
438 | }; | ||
439 | |||
440 | |||
441 | /**** service -> library ****/ | ||
442 | |||
443 | |||
444 | /** | ||
445 | * Answer from service to client about last operation. | ||
446 | */ | ||
447 | struct GNUNET_PSYC_OperationResultMessage | ||
448 | { | ||
449 | /** | ||
450 | * Types: | ||
451 | * - GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE | ||
452 | * - GNUNET_MESSAGE_TYPE_PSYC_CHANNEL_STATE_RESULT | ||
453 | */ | ||
454 | struct GNUNET_MessageHeader header; | ||
455 | |||
456 | uint32_t reserved GNUNET_PACKED; | ||
457 | |||
458 | /** | ||
459 | * Operation ID. | ||
460 | */ | ||
461 | uint64_t op_id GNUNET_PACKED; | ||
462 | |||
463 | /** | ||
464 | * Status code for the operation. | ||
465 | */ | ||
466 | uint64_t result_code GNUNET_PACKED; | ||
467 | |||
468 | /* Followed by: | ||
469 | * - on error: NUL-terminated error message | ||
470 | * - on success: one of the following message types | ||
471 | * | ||
472 | * For a STATE_RESULT, one of: | ||
473 | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER | ||
474 | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT | ||
475 | * - GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_END | ||
476 | */ | ||
477 | }; | ||
478 | |||
379 | GNUNET_NETWORK_STRUCT_END | 479 | GNUNET_NETWORK_STRUCT_END |
380 | 480 | ||
381 | 481 | ||
@@ -907,23 +1007,6 @@ struct GNUNET_PSYC_Channel; | |||
907 | 1007 | ||
908 | 1008 | ||
909 | /** | 1009 | /** |
910 | * Function called with the result of an asynchronous operation. | ||
911 | * | ||
912 | * @param cls | ||
913 | * Closure. | ||
914 | * @param result | ||
915 | * Result of the operation. | ||
916 | * Usually one of #GNUNET_OK, #GNUNET_YES, #GNUNET_NO, or #GNUNET_SYSERR. | ||
917 | * @param err_msg | ||
918 | * Error message. | ||
919 | */ | ||
920 | typedef void | ||
921 | (*GNUNET_PSYC_ResultCallback) (void *cls, | ||
922 | int64_t result, | ||
923 | const char *err_msg); | ||
924 | |||
925 | |||
926 | /** | ||
927 | * Convert a channel @a master to a @e channel handle to access the @e channel | 1010 | * Convert a channel @a master to a @e channel handle to access the @e channel |
928 | * APIs. | 1011 | * APIs. |
929 | * | 1012 | * |
@@ -960,17 +1043,28 @@ GNUNET_PSYC_slave_get_channel (struct GNUNET_PSYC_Slave *slave); | |||
960 | * correctly; not doing so correctly will result in either denying other slaves | 1043 | * correctly; not doing so correctly will result in either denying other slaves |
961 | * access or offering access to channel data to non-members. | 1044 | * access or offering access to channel data to non-members. |
962 | * | 1045 | * |
963 | * @param channel Channel handle. | 1046 | * @param channel |
964 | * @param slave_key Identity of channel slave to add. | 1047 | * Channel handle. |
965 | * @param announced_at ID of the message that announced the membership change. | 1048 | * @param slave_key |
966 | * @param effective_since Addition of slave is in effect since this message ID. | 1049 | * Identity of channel slave to add. |
1050 | * @param announced_at | ||
1051 | * ID of the message that announced the membership change. | ||
1052 | * @param effective_since | ||
1053 | * Addition of slave is in effect since this message ID. | ||
1054 | * @param result_cb | ||
1055 | * Function to call with the result of the operation. | ||
1056 | * The @e result_code argument is #GNUNET_OK on success, or | ||
1057 | * #GNUNET_SYSERR on error. In case of an error, the @e data argument | ||
1058 | * can contain an optional error message. | ||
1059 | * @param cls | ||
1060 | * Closure for @a result_cb. | ||
967 | */ | 1061 | */ |
968 | void | 1062 | void |
969 | GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel, | 1063 | GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel, |
970 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | 1064 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
971 | uint64_t announced_at, | 1065 | uint64_t announced_at, |
972 | uint64_t effective_since, | 1066 | uint64_t effective_since, |
973 | GNUNET_PSYC_ResultCallback result_cb, | 1067 | GNUNET_ResultCallback result_cb, |
974 | void *cls); | 1068 | void *cls); |
975 | 1069 | ||
976 | 1070 | ||
@@ -991,33 +1085,33 @@ GNUNET_PSYC_channel_slave_add (struct GNUNET_PSYC_Channel *channel, | |||
991 | * denying members access or offering access to channel data to | 1085 | * denying members access or offering access to channel data to |
992 | * non-members. | 1086 | * non-members. |
993 | * | 1087 | * |
994 | * @param channel Channel handle. | 1088 | * @param channel |
995 | * @param slave_key Identity of channel slave to remove. | 1089 | * Channel handle. |
996 | * @param announced_at ID of the message that announced the membership change. | 1090 | * @param slave_key |
1091 | * Identity of channel slave to remove. | ||
1092 | * @param announced_at | ||
1093 | * ID of the message that announced the membership change. | ||
1094 | * @param result_cb | ||
1095 | * Function to call with the result of the operation. | ||
1096 | * The @e result_code argument is #GNUNET_OK on success, or | ||
1097 | * #GNUNET_SYSERR on error. In case of an error, the @e data argument | ||
1098 | * can contain an optional error message. | ||
1099 | * @param cls | ||
1100 | * Closure for @a result_cb. | ||
997 | */ | 1101 | */ |
998 | void | 1102 | void |
999 | GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel, | 1103 | GNUNET_PSYC_channel_slave_remove (struct GNUNET_PSYC_Channel *channel, |
1000 | const struct GNUNET_CRYPTO_EcdsaPublicKey | 1104 | const struct GNUNET_CRYPTO_EcdsaPublicKey |
1001 | *slave_key, | 1105 | *slave_key, |
1002 | uint64_t announced_at, | 1106 | uint64_t announced_at, |
1003 | GNUNET_PSYC_ResultCallback result_cb, | 1107 | GNUNET_ResultCallback result_cb, |
1004 | void *cls); | 1108 | void *cls); |
1005 | 1109 | ||
1006 | 1110 | ||
1007 | /** | 1111 | /** |
1008 | * Function called to inform a member about stored state values for a channel. | 1112 | * History request handle. |
1009 | * | ||
1010 | * @param cls Closure. | ||
1011 | * @param name Name of the state variable. A NULL value indicates that there | ||
1012 | * are no more state variables to be returned. | ||
1013 | * @param value Value of the state variable. | ||
1014 | * @param value_size Number of bytes in @a value. | ||
1015 | */ | 1113 | */ |
1016 | typedef void | 1114 | struct GNUNET_PSYC_HistoryRequest; |
1017 | (*GNUNET_PSYC_StateVarCallback) (void *cls, | ||
1018 | const char *name, | ||
1019 | const void *value, | ||
1020 | size_t value_size); | ||
1021 | 1115 | ||
1022 | 1116 | ||
1023 | /** | 1117 | /** |
@@ -1032,22 +1126,28 @@ typedef void | |||
1032 | * Earliest interesting point in history. | 1126 | * Earliest interesting point in history. |
1033 | * @param end_message_id | 1127 | * @param end_message_id |
1034 | * Last (inclusive) interesting point in history. | 1128 | * Last (inclusive) interesting point in history. |
1035 | * @param finish_cb | 1129 | * @param method_prefix |
1036 | * Function to call when the requested history has been fully replayed | 1130 | * Retrieve only messages with a matching method prefix. |
1037 | * (counting message IDs might not suffice, as some messages might be | 1131 | * @param flags |
1038 | * secret and thus the listener would not know the story is finished | 1132 | * OR'ed enum GNUNET_PSYC_HistoryReplayFlags |
1039 | * without being told explicitly)o once this function has been called, the | 1133 | * @param result_cb |
1040 | * client must not call GNUNET_PSYC_channel_history_replay_cancel() anymore. | 1134 | * Function to call when the requested history has been fully replayed. |
1135 | * Once this function has been called, the client must not call | ||
1136 | * GNUNET_PSYC_channel_history_replay_cancel() anymore. | ||
1041 | * @param cls | 1137 | * @param cls |
1042 | * Closure for the callbacks. | 1138 | * Closure for the callbacks. |
1043 | * | 1139 | * |
1044 | * @return Handle to cancel history replay operation. | 1140 | * @return Handle to cancel history replay operation. |
1045 | */ | 1141 | */ |
1046 | void | 1142 | struct GNUNET_PSYC_HistoryRequest * |
1047 | GNUNET_PSYC_channel_history_replay (struct GNUNET_PSYC_Channel *channel, | 1143 | GNUNET_PSYC_channel_history_replay (struct GNUNET_PSYC_Channel *channel, |
1048 | uint64_t start_message_id, | 1144 | uint64_t start_message_id, |
1049 | uint64_t end_message_id, | 1145 | uint64_t end_message_id, |
1050 | GNUNET_PSYC_ResultCallback finish_cb, | 1146 | const char *method_prefix, |
1147 | uint32_t flags, | ||
1148 | GNUNET_PSYC_MessageCallback message_cb, | ||
1149 | GNUNET_PSYC_MessagePartCallback message_part_cb, | ||
1150 | GNUNET_ResultCallback result_cb, | ||
1051 | void *cls); | 1151 | void *cls); |
1052 | 1152 | ||
1053 | 1153 | ||
@@ -1061,6 +1161,8 @@ GNUNET_PSYC_channel_history_replay (struct GNUNET_PSYC_Channel *channel, | |||
1061 | * Which channel should be replayed? | 1161 | * Which channel should be replayed? |
1062 | * @param message_limit | 1162 | * @param message_limit |
1063 | * Maximum number of messages to replay. | 1163 | * Maximum number of messages to replay. |
1164 | * @param flags | ||
1165 | * OR'ed enum GNUNET_PSYC_HistoryReplayFlags | ||
1064 | * @param finish_cb | 1166 | * @param finish_cb |
1065 | * Function to call when the requested history has been fully replayed | 1167 | * Function to call when the requested history has been fully replayed |
1066 | * (counting message IDs might not suffice, as some messages might be | 1168 | * (counting message IDs might not suffice, as some messages might be |
@@ -1072,13 +1174,44 @@ GNUNET_PSYC_channel_history_replay (struct GNUNET_PSYC_Channel *channel, | |||
1072 | * | 1174 | * |
1073 | * @return Handle to cancel history replay operation. | 1175 | * @return Handle to cancel history replay operation. |
1074 | */ | 1176 | */ |
1075 | void | 1177 | struct GNUNET_PSYC_HistoryRequest * |
1076 | GNUNET_PSYC_channel_history_replay_latest (struct GNUNET_PSYC_Channel *channel, | 1178 | GNUNET_PSYC_channel_history_replay_latest (struct GNUNET_PSYC_Channel *channel, |
1077 | uint64_t message_limit, | 1179 | uint64_t message_limit, |
1078 | GNUNET_PSYC_ResultCallback finish_cb, | 1180 | const char *method_prefix, |
1181 | uint32_t flags, | ||
1182 | GNUNET_PSYC_MessageCallback message_cb, | ||
1183 | GNUNET_PSYC_MessagePartCallback message_part_cb, | ||
1184 | GNUNET_ResultCallback result_cb, | ||
1079 | void *cls); | 1185 | void *cls); |
1080 | 1186 | ||
1081 | 1187 | ||
1188 | void | ||
1189 | GNUNET_PSYC_channel_history_replay_cancel (struct GNUNET_PSYC_Channel *channel, | ||
1190 | struct GNUNET_PSYC_HistoryRequest *hr); | ||
1191 | |||
1192 | |||
1193 | /** | ||
1194 | * Function called to inform a member about stored state values for a channel. | ||
1195 | * | ||
1196 | * @param cls Closure. | ||
1197 | * @param name Name of the state variable. A NULL value indicates that there | ||
1198 | * are no more state variables to be returned. | ||
1199 | * @param value Value of the state variable. | ||
1200 | * @param value_size Number of bytes in @a value. | ||
1201 | */ | ||
1202 | typedef void | ||
1203 | (*GNUNET_PSYC_StateVarCallback) (void *cls, | ||
1204 | const char *name, | ||
1205 | const void *value, | ||
1206 | size_t value_size); | ||
1207 | |||
1208 | |||
1209 | /** | ||
1210 | * State request handle. | ||
1211 | */ | ||
1212 | struct GNUNET_PSYC_StateRequest; | ||
1213 | |||
1214 | |||
1082 | /** | 1215 | /** |
1083 | * Retrieve the best matching channel state variable. | 1216 | * Retrieve the best matching channel state variable. |
1084 | * | 1217 | * |
@@ -1100,11 +1233,11 @@ GNUNET_PSYC_channel_history_replay_latest (struct GNUNET_PSYC_Channel *channel, | |||
1100 | * @param cls | 1233 | * @param cls |
1101 | * Closure for the callbacks. | 1234 | * Closure for the callbacks. |
1102 | */ | 1235 | */ |
1103 | void | 1236 | struct GNUNET_PSYC_StateRequest * |
1104 | GNUNET_PSYC_channel_state_get (struct GNUNET_PSYC_Channel *channel, | 1237 | GNUNET_PSYC_channel_state_get (struct GNUNET_PSYC_Channel *channel, |
1105 | const char *full_name, | 1238 | const char *full_name, |
1106 | GNUNET_PSYC_StateVarCallback var_cb, | 1239 | GNUNET_PSYC_StateVarCallback var_cb, |
1107 | GNUNET_PSYC_ResultCallback result_cb, | 1240 | GNUNET_ResultCallback result_cb, |
1108 | void *cls); | 1241 | void *cls); |
1109 | 1242 | ||
1110 | 1243 | ||
@@ -1131,13 +1264,23 @@ GNUNET_PSYC_channel_state_get (struct GNUNET_PSYC_Channel *channel, | |||
1131 | * @param cls | 1264 | * @param cls |
1132 | * Closure for the callbacks. | 1265 | * Closure for the callbacks. |
1133 | */ | 1266 | */ |
1134 | void | 1267 | struct GNUNET_PSYC_StateRequest * |
1135 | GNUNET_PSYC_channel_state_get_prefix (struct GNUNET_PSYC_Channel *channel, | 1268 | GNUNET_PSYC_channel_state_get_prefix (struct GNUNET_PSYC_Channel *channel, |
1136 | const char *name_prefix, | 1269 | const char *name_prefix, |
1137 | GNUNET_PSYC_StateVarCallback var_cb, | 1270 | GNUNET_PSYC_StateVarCallback var_cb, |
1138 | GNUNET_PSYC_ResultCallback result_cb, | 1271 | GNUNET_ResultCallback result_cb, |
1139 | void *cls); | 1272 | void *cls); |
1140 | 1273 | ||
1274 | /** | ||
1275 | * Cancel a state request operation. | ||
1276 | * | ||
1277 | * @param sr | ||
1278 | * Handle for the operation to cancel. | ||
1279 | */ | ||
1280 | void | ||
1281 | GNUNET_PSYC_channel_state_get_cancel (struct GNUNET_PSYC_StateRequest *sr); | ||
1282 | |||
1283 | |||
1141 | 1284 | ||
1142 | #if 0 /* keep Emacsens' auto-indent happy */ | 1285 | #if 0 /* keep Emacsens' auto-indent happy */ |
1143 | { | 1286 | { |
diff --git a/src/include/gnunet_psyc_util_lib.h b/src/include/gnunet_psyc_util_lib.h index 488edc03b..3ec9fe1bf 100644 --- a/src/include/gnunet_psyc_util_lib.h +++ b/src/include/gnunet_psyc_util_lib.h | |||
@@ -115,16 +115,24 @@ GNUNET_PSYC_transmit_destroy (struct GNUNET_PSYC_TransmitHandle *tmit); | |||
115 | /** | 115 | /** |
116 | * Transmit a message. | 116 | * Transmit a message. |
117 | * | 117 | * |
118 | * @param tmit Transmission handle. | 118 | * @param tmit |
119 | * @param method_name Which method should be invoked. | 119 | * Transmission handle. |
120 | * @param env Environment for the message. | 120 | * @param method_name |
121 | * Should stay available until the first call to notify_data. | 121 | * Which method should be invoked. |
122 | * Can be NULL if there are no modifiers or @a notify_mod is provided instead. | 122 | * @param env |
123 | * @param notify_mod Function to call to obtain modifiers. | 123 | * Environment for the message. |
124 | * Can be NULL if there are no modifiers or @a env is provided instead. | 124 | * Should stay available until the first call to notify_data. |
125 | * @param notify_data Function to call to obtain fragments of the data. | 125 | * Can be NULL if there are no modifiers or @a notify_mod is |
126 | * @param notify_cls Closure for @a notify_mod and @a notify_data. | 126 | * provided instead. |
127 | * @param flags Flags for the message being transmitted. | 127 | * @param notify_mod |
128 | * Function to call to obtain modifiers. | ||
129 | * Can be NULL if there are no modifiers or @a env is provided instead. | ||
130 | * @param notify_data | ||
131 | * Function to call to obtain fragments of the data. | ||
132 | * @param notify_cls | ||
133 | * Closure for @a notify_mod and @a notify_data. | ||
134 | * @param flags | ||
135 | * Flags for the message being transmitted. | ||
128 | * | 136 | * |
129 | * @return #GNUNET_OK if the transmission was started. | 137 | * @return #GNUNET_OK if the transmission was started. |
130 | * #GNUNET_SYSERR if another transmission is already going on. | 138 | * #GNUNET_SYSERR if another transmission is already going on. |
diff --git a/src/include/gnunet_psycstore_service.h b/src/include/gnunet_psycstore_service.h index 2cb155f69..40acdae61 100644 --- a/src/include/gnunet_psycstore_service.h +++ b/src/include/gnunet_psycstore_service.h | |||
@@ -107,15 +107,20 @@ struct GNUNET_PSYCSTORE_OperationHandle; | |||
107 | /** | 107 | /** |
108 | * Function called with the result of an asynchronous operation. | 108 | * Function called with the result of an asynchronous operation. |
109 | * | 109 | * |
110 | * @param cls | ||
111 | * Closure. | ||
110 | * @param result | 112 | * @param result |
111 | * #GNUNET_YES on success or if the peer was a member, | 113 | * Result of the operation. |
112 | * #GNUNET_NO if the peer was not a member, | 114 | * @param err_msg |
113 | * #GNUNET_SYSERR on error, | 115 | * Error message, or NULL if there's no error. |
116 | * @param err_msg_size | ||
117 | * Size of @a err_msg | ||
114 | */ | 118 | */ |
115 | typedef void | 119 | typedef void |
116 | (*GNUNET_PSYCSTORE_ResultCallback) (void *cls, | 120 | (*GNUNET_PSYCSTORE_ResultCallback) (void *cls, |
117 | int64_t result, | 121 | int64_t result, |
118 | const char *err_msg); | 122 | const char *err_msg, |
123 | uint16_t err_msg_size); | ||
119 | 124 | ||
120 | 125 | ||
121 | /** | 126 | /** |
@@ -318,15 +323,15 @@ GNUNET_PSYCSTORE_fragment_get_latest (struct GNUNET_PSYCSTORE_Handle *h, | |||
318 | * @param channel_key | 323 | * @param channel_key |
319 | * The channel we are interested in. | 324 | * The channel we are interested in. |
320 | * @param slave_key | 325 | * @param slave_key |
321 | * The slave requesting the message. If not NULL, a membership test is | 326 | * The slave requesting the message. |
322 | * performed first and the message is only returned if the slave has | 327 | * If not NULL, a membership test is performed first |
323 | * access to it. | 328 | * and the message is only returned if the slave has access to it. |
324 | * @param first_message_id | 329 | * @param first_message_id |
325 | * First message ID to retrieve. | 330 | * First message ID to retrieve. |
326 | * Use 0 to get the latest message. | ||
327 | * @param last_message_id | 331 | * @param last_message_id |
328 | * Last consecutive message ID to retrieve. | 332 | * Last consecutive message ID to retrieve. |
329 | * Use 0 to get the latest message. | 333 | * @param method_prefix |
334 | * Retrieve only messages with a matching method prefix. | ||
330 | * @param fragment_cb | 335 | * @param fragment_cb |
331 | * Callback to call with the retrieved fragments. | 336 | * Callback to call with the retrieved fragments. |
332 | * @param result_cb | 337 | * @param result_cb |
@@ -342,6 +347,7 @@ GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h, | |||
342 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | 347 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
343 | uint64_t first_message_id, | 348 | uint64_t first_message_id, |
344 | uint64_t last_message_id, | 349 | uint64_t last_message_id, |
350 | const char *method_prefix, | ||
345 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, | 351 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, |
346 | GNUNET_PSYCSTORE_ResultCallback result_cb, | 352 | GNUNET_PSYCSTORE_ResultCallback result_cb, |
347 | void *cls); | 353 | void *cls); |
@@ -355,14 +361,16 @@ GNUNET_PSYCSTORE_message_get (struct GNUNET_PSYCSTORE_Handle *h, | |||
355 | * @param channel_key | 361 | * @param channel_key |
356 | * The channel we are interested in. | 362 | * The channel we are interested in. |
357 | * @param slave_key | 363 | * @param slave_key |
358 | * The slave requesting the message. If not NULL, a membership test is | 364 | * The slave requesting the message. |
359 | * performed first and the message is only returned if the slave has | 365 | * If not NULL, a membership test is performed first |
360 | * access to it. | 366 | * and the message is only returned if the slave has access to it. |
361 | * @param message_limit | 367 | * @param message_limit |
362 | * Maximum number of messages to retrieve. | 368 | * Maximum number of messages to retrieve. |
369 | * @param method_prefix | ||
370 | * Retrieve only messages with a matching method prefix. | ||
363 | * @param fragment_cb | 371 | * @param fragment_cb |
364 | * Callback to call with the retrieved fragments. | 372 | * Callback to call with the retrieved fragments. |
365 | * @param rcb | 373 | * @param result_cb |
366 | * Callback to call with the result of the operation. | 374 | * Callback to call with the result of the operation. |
367 | * @param cls | 375 | * @param cls |
368 | * Closure for the callbacks. | 376 | * Closure for the callbacks. |
@@ -374,6 +382,7 @@ GNUNET_PSYCSTORE_message_get_latest (struct GNUNET_PSYCSTORE_Handle *h, | |||
374 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, | 382 | const struct GNUNET_CRYPTO_EddsaPublicKey *channel_key, |
375 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, | 383 | const struct GNUNET_CRYPTO_EcdsaPublicKey *slave_key, |
376 | uint64_t message_limit, | 384 | uint64_t message_limit, |
385 | const char *method_prefix, | ||
377 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, | 386 | GNUNET_PSYCSTORE_FragmentCallback fragment_cb, |
378 | GNUNET_PSYCSTORE_ResultCallback rcb, | 387 | GNUNET_PSYCSTORE_ResultCallback rcb, |
379 | void *cls); | 388 | void *cls); |
diff --git a/src/include/gnunet_social_service.h b/src/include/gnunet_social_service.h index fcfc8a359..a17446cf5 100644 --- a/src/include/gnunet_social_service.h +++ b/src/include/gnunet_social_service.h | |||
@@ -749,9 +749,45 @@ GNUNET_SOCIAL_guest_get_place (struct GNUNET_SOCIAL_Guest *guest); | |||
749 | 749 | ||
750 | 750 | ||
751 | /** | 751 | /** |
752 | * A history lesson. | 752 | * A history request. |
753 | */ | 753 | */ |
754 | struct GNUNET_SOCIAL_HistoryLesson; | 754 | struct GNUNET_SOCIAL_HistoryRequest; |
755 | |||
756 | |||
757 | /** | ||
758 | * Learn about the history of a place. | ||
759 | * | ||
760 | * Messages are returned through the @a slicer function | ||
761 | * and have the #GNUNET_PSYC_MESSAGE_HISTORIC flag set. | ||
762 | * | ||
763 | * @param place | ||
764 | * Place we want to learn more about. | ||
765 | * @param start_message_id | ||
766 | * First historic message we are interested in. | ||
767 | * @param end_message_id | ||
768 | * Last historic message we are interested in (inclusive). | ||
769 | * @param method_prefix | ||
770 | * Only retrieve messages with this method prefix. | ||
771 | * @param flags | ||
772 | * OR'ed GNUNET_PSYC_HistoryReplayFlags | ||
773 | * @param slicer | ||
774 | * Slicer to use for retrieved messages. | ||
775 | * Can be the same as the slicer of the place. | ||
776 | * @param result_cb | ||
777 | * Function called after all messages retrieved. | ||
778 | * NULL if not needed. | ||
779 | * @param cls Closure for @a result_cb. | ||
780 | */ | ||
781 | struct GNUNET_SOCIAL_HistoryRequest * | ||
782 | GNUNET_SOCIAL_place_history_replay (struct GNUNET_SOCIAL_Place *plc, | ||
783 | uint64_t start_message_id, | ||
784 | uint64_t end_message_id, | ||
785 | const char *method_prefix, | ||
786 | uint32_t flags, | ||
787 | struct GNUNET_SOCIAL_Slicer *slicer, | ||
788 | GNUNET_ResultCallback result_cb, | ||
789 | void *cls); | ||
790 | |||
755 | 791 | ||
756 | /** | 792 | /** |
757 | * Learn about the history of a place. | 793 | * Learn about the history of a place. |
@@ -762,36 +798,32 @@ struct GNUNET_SOCIAL_HistoryLesson; | |||
762 | * | 798 | * |
763 | * To get the latest message, use 0 for both the start and end message ID. | 799 | * To get the latest message, use 0 for both the start and end message ID. |
764 | * | 800 | * |
765 | * @param place Place we want to learn more about. | 801 | * @param place |
766 | * @param start_message_id First historic message we are interested in. | 802 | * Place we want to learn more about. |
767 | * @param end_message_id Last historic message we are interested in (inclusive). | 803 | * @param message_limit |
768 | * @param slicer Slicer to use to process history. Can be the same as the | 804 | * Maximum number of historic messages we are interested in. |
769 | * slicer of the place, as the HISTORIC flag allows distinguishing | 805 | * @param result_cb |
770 | * old messages from fresh ones. | 806 | * Function called after all messages retrieved. |
771 | * @param finish_cb Function called after the last message in the history lesson | 807 | * NULL if not needed. |
772 | * is passed through the @a slicer. NULL if not needed. | 808 | * @param cls Closure for @a result_cb. |
773 | * @param finish_cb_cls Closure for @a finish_cb. | ||
774 | * @return Handle to abort history lesson, never NULL (multiple lessons | ||
775 | * at the same time are allowed). | ||
776 | */ | 809 | */ |
777 | struct GNUNET_SOCIAL_HistoryLesson * | 810 | struct GNUNET_SOCIAL_HistoryRequest * |
778 | GNUNET_SOCIAL_place_get_history (struct GNUNET_SOCIAL_Place *place, | 811 | GNUNET_SOCIAL_place_history_replay_latest (struct GNUNET_SOCIAL_Place *plc, |
779 | uint64_t start_message_id, | 812 | uint64_t message_limit, |
780 | uint64_t end_message_id, | 813 | const char *method_prefix, |
781 | const struct GNUNET_SOCIAL_Slicer *slicer, | 814 | uint32_t flags, |
782 | void (*finish_cb)(void *), | 815 | struct GNUNET_SOCIAL_Slicer *slicer, |
783 | void *finish_cb_cls); | 816 | GNUNET_ResultCallback result_cb, |
784 | 817 | void *cls); | |
785 | 818 | ||
786 | /** | 819 | /** |
787 | * Stop processing messages from the history lesson. | 820 | * Cancel learning about the history of a place. |
788 | * | ||
789 | * Must not be called after the finish callback of the history lesson is called. | ||
790 | * | 821 | * |
791 | * @param hist History lesson to cancel. | 822 | * @param hist |
823 | * History lesson to cancel. | ||
792 | */ | 824 | */ |
793 | void | 825 | void |
794 | GNUNET_SOCIAL_place_get_history_cancel (struct GNUNET_SOCIAL_HistoryLesson *hist); | 826 | GNUNET_SOCIAL_place_history_replay_cancel (struct GNUNET_SOCIAL_HistoryRequest *hist); |
795 | 827 | ||
796 | 828 | ||
797 | struct GNUNET_SOCIAL_WatchHandle; | 829 | struct GNUNET_SOCIAL_WatchHandle; |
@@ -803,7 +835,7 @@ struct GNUNET_SOCIAL_WatchHandle; | |||
803 | * Place to watch. | 835 | * Place to watch. |
804 | * @param object_filter | 836 | * @param object_filter |
805 | * Object prefix to match. | 837 | * Object prefix to match. |
806 | * @param state_var_cb | 838 | * @param var_cb |
807 | * Function to call when an object/state var changes. | 839 | * Function to call when an object/state var changes. |
808 | * @param cls | 840 | * @param cls |
809 | * Closure for callback. | 841 | * Closure for callback. |
@@ -813,7 +845,7 @@ struct GNUNET_SOCIAL_WatchHandle; | |||
813 | struct GNUNET_SOCIAL_WatchHandle * | 845 | struct GNUNET_SOCIAL_WatchHandle * |
814 | GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place, | 846 | GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place, |
815 | const char *object_filter, | 847 | const char *object_filter, |
816 | GNUNET_PSYC_StateVarCallback state_var_cb, | 848 | GNUNET_PSYC_StateVarCallback var_cb, |
817 | void *cls); | 849 | void *cls); |
818 | 850 | ||
819 | 851 | ||
@@ -830,13 +862,35 @@ struct GNUNET_SOCIAL_LookHandle; | |||
830 | 862 | ||
831 | 863 | ||
832 | /** | 864 | /** |
833 | * Look at objects in the place with a matching name prefix. | 865 | * Look at a particular object in the place. |
866 | * | ||
867 | * The best matching object is returned (its name might be less specific than | ||
868 | * what was requested). | ||
869 | * | ||
870 | * @param place | ||
871 | * The place to look the object at. | ||
872 | * @param full_name | ||
873 | * Full name of the object. | ||
874 | * @param value_size | ||
875 | * Set to the size of the returned value. | ||
876 | * | ||
877 | * @return NULL if there is no such object at this place. | ||
878 | */ | ||
879 | struct GNUNET_SOCIAL_LookHandle * | ||
880 | GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *plc, | ||
881 | const char *full_name, | ||
882 | GNUNET_PSYC_StateVarCallback var_cb, | ||
883 | GNUNET_ResultCallback result_cb, | ||
884 | void *cls); | ||
885 | |||
886 | /** | ||
887 | * Look for objects in the place with a matching name prefix. | ||
834 | * | 888 | * |
835 | * @param place | 889 | * @param place |
836 | * The place to look its objects at. | 890 | * The place to look its objects at. |
837 | * @param name_prefix | 891 | * @param name_prefix |
838 | * Look at objects with names beginning with this value. | 892 | * Look at objects with names beginning with this value. |
839 | * @param state_var_cb | 893 | * @param var_cb |
840 | * Function to call for each object found. | 894 | * Function to call for each object found. |
841 | * @param cls | 895 | * @param cls |
842 | * Closure for callback function. | 896 | * Closure for callback function. |
@@ -844,10 +898,11 @@ struct GNUNET_SOCIAL_LookHandle; | |||
844 | * @return Handle that can be used to stop looking at objects. | 898 | * @return Handle that can be used to stop looking at objects. |
845 | */ | 899 | */ |
846 | struct GNUNET_SOCIAL_LookHandle * | 900 | struct GNUNET_SOCIAL_LookHandle * |
847 | GNUNET_SOCIAL_place_look (struct GNUNET_SOCIAL_Place *place, | 901 | GNUNET_SOCIAL_place_look_for (struct GNUNET_SOCIAL_Place *plc, |
848 | const char *name_prefix, | 902 | const char *name_prefix, |
849 | GNUNET_PSYC_StateVarCallback state_var_cb, | 903 | GNUNET_PSYC_StateVarCallback var_cb, |
850 | void *cls); | 904 | GNUNET_ResultCallback result_cb, |
905 | void *cls); | ||
851 | 906 | ||
852 | 907 | ||
853 | /** | 908 | /** |
@@ -859,24 +914,6 @@ void | |||
859 | GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh); | 914 | GNUNET_SOCIAL_place_look_cancel (struct GNUNET_SOCIAL_LookHandle *lh); |
860 | 915 | ||
861 | 916 | ||
862 | |||
863 | /** | ||
864 | * Look at a particular object in the place. | ||
865 | * | ||
866 | * The best matching object is returned (its name might be less specific than | ||
867 | * what was requested). | ||
868 | * | ||
869 | * @param place The place to look the object at. | ||
870 | * @param full_name Full name of the object. | ||
871 | * @param value_size Set to the size of the returned value. | ||
872 | * @return NULL if there is no such object at this place. | ||
873 | */ | ||
874 | const void * | ||
875 | GNUNET_SOCIAL_place_look_at (struct GNUNET_SOCIAL_Place *place, | ||
876 | const char *full_name, | ||
877 | size_t *value_size); | ||
878 | |||
879 | |||
880 | #if 0 /* keep Emacsens' auto-indent happy */ | 917 | #if 0 /* keep Emacsens' auto-indent happy */ |
881 | { | 918 | { |
882 | #endif | 919 | #endif |