diff options
Diffstat (limited to 'src/conversation/test_conversation_api.c')
-rw-r--r-- | src/conversation/test_conversation_api.c | 526 |
1 files changed, 266 insertions, 260 deletions
diff --git a/src/conversation/test_conversation_api.c b/src/conversation/test_conversation_api.c index a7b394dc3..e58f89e7a 100644 --- a/src/conversation/test_conversation_api.c +++ b/src/conversation/test_conversation_api.c | |||
@@ -16,7 +16,7 @@ | |||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file conversation/test_conversation_api.c | 21 | * @file conversation/test_conversation_api.c |
22 | * @brief testcase for conversation_api.c | 22 | * @brief testcase for conversation_api.c |
@@ -33,9 +33,9 @@ | |||
33 | #include "gnunet_identity_service.h" | 33 | #include "gnunet_identity_service.h" |
34 | #include "gnunet_namestore_service.h" | 34 | #include "gnunet_namestore_service.h" |
35 | 35 | ||
36 | #define FREQ GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 250) | 36 | #define FREQ GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 250) |
37 | 37 | ||
38 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 25) | 38 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 25) |
39 | 39 | ||
40 | static int ok = 1; | 40 | static int ok = 1; |
41 | 41 | ||
@@ -73,174 +73,174 @@ static struct GNUNET_SCHEDULER_Task *call_task; | |||
73 | 73 | ||
74 | 74 | ||
75 | static void | 75 | static void |
76 | phone_send (void *cls) | 76 | phone_send(void *cls) |
77 | { | 77 | { |
78 | static unsigned int i; | 78 | static unsigned int i; |
79 | char buf[32]; | 79 | char buf[32]; |
80 | 80 | ||
81 | (void) cls; | 81 | (void)cls; |
82 | GNUNET_assert (NULL != phone_rdc); | 82 | GNUNET_assert(NULL != phone_rdc); |
83 | GNUNET_snprintf (buf, sizeof (buf), "phone-%u", i++); | 83 | GNUNET_snprintf(buf, sizeof(buf), "phone-%u", i++); |
84 | phone_rdc (phone_rdc_cls, strlen (buf) + 1, buf); | 84 | phone_rdc(phone_rdc_cls, strlen(buf) + 1, buf); |
85 | phone_task = GNUNET_SCHEDULER_add_delayed (FREQ, &phone_send, NULL); | 85 | phone_task = GNUNET_SCHEDULER_add_delayed(FREQ, &phone_send, NULL); |
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
89 | static void | 89 | static void |
90 | call_send (void *cls) | 90 | call_send(void *cls) |
91 | { | 91 | { |
92 | static unsigned int i; | 92 | static unsigned int i; |
93 | char buf[32]; | 93 | char buf[32]; |
94 | 94 | ||
95 | (void) cls; | 95 | (void)cls; |
96 | GNUNET_assert (NULL != call_rdc); | 96 | GNUNET_assert(NULL != call_rdc); |
97 | GNUNET_snprintf (buf, sizeof (buf), "call-%u", i++); | 97 | GNUNET_snprintf(buf, sizeof(buf), "call-%u", i++); |
98 | call_rdc (call_rdc_cls, strlen (buf) + 1, buf); | 98 | call_rdc(call_rdc_cls, strlen(buf) + 1, buf); |
99 | call_task = GNUNET_SCHEDULER_add_delayed (FREQ, &call_send, NULL); | 99 | call_task = GNUNET_SCHEDULER_add_delayed(FREQ, &call_send, NULL); |
100 | } | 100 | } |
101 | 101 | ||
102 | 102 | ||
103 | static int | 103 | static int |
104 | enable_speaker (void *cls) | 104 | enable_speaker(void *cls) |
105 | { | 105 | { |
106 | const char *origin = cls; | 106 | const char *origin = cls; |
107 | 107 | ||
108 | fprintf (stderr, "Speaker %s enabled\n", origin); | 108 | fprintf(stderr, "Speaker %s enabled\n", origin); |
109 | return GNUNET_OK; | 109 | return GNUNET_OK; |
110 | } | 110 | } |
111 | 111 | ||
112 | 112 | ||
113 | static void | 113 | static void |
114 | disable_speaker (void *cls) | 114 | disable_speaker(void *cls) |
115 | { | 115 | { |
116 | const char *origin = cls; | 116 | const char *origin = cls; |
117 | 117 | ||
118 | fprintf (stderr, "Speaker %s disabled\n", origin); | 118 | fprintf(stderr, "Speaker %s disabled\n", origin); |
119 | } | 119 | } |
120 | 120 | ||
121 | 121 | ||
122 | static void | 122 | static void |
123 | play (void *cls, size_t data_size, const void *data) | 123 | play(void *cls, size_t data_size, const void *data) |
124 | { | 124 | { |
125 | const char *origin = cls; | 125 | const char *origin = cls; |
126 | static unsigned int phone_i = 1; | 126 | static unsigned int phone_i = 1; |
127 | static unsigned int call_i; | 127 | static unsigned int call_i; |
128 | char buf[32]; | 128 | char buf[32]; |
129 | 129 | ||
130 | if (0 == strcmp (origin, "phone")) | 130 | if (0 == strcmp(origin, "phone")) |
131 | GNUNET_snprintf (buf, sizeof (buf), "call-%u", call_i++); | 131 | GNUNET_snprintf(buf, sizeof(buf), "call-%u", call_i++); |
132 | else | 132 | else |
133 | GNUNET_snprintf (buf, sizeof (buf), "phone-%u", phone_i++); | 133 | GNUNET_snprintf(buf, sizeof(buf), "phone-%u", phone_i++); |
134 | if ((data_size != strlen (buf) + 1) || (0 != strncmp (buf, data, data_size))) | 134 | if ((data_size != strlen(buf) + 1) || (0 != strncmp(buf, data, data_size))) |
135 | { | 135 | { |
136 | fprintf (stderr, | 136 | fprintf(stderr, |
137 | "Expected %s, received %.*s\n", | 137 | "Expected %s, received %.*s\n", |
138 | buf, | 138 | buf, |
139 | (int) data_size, | 139 | (int)data_size, |
140 | (const char *) data); | 140 | (const char *)data); |
141 | } | 141 | } |
142 | else | 142 | else |
143 | { | 143 | { |
144 | fprintf (stderr, "."); | 144 | fprintf(stderr, "."); |
145 | } | 145 | } |
146 | if ((20 < call_i) && (20 < phone_i) && (NULL != call)) | 146 | if ((20 < call_i) && (20 < phone_i) && (NULL != call)) |
147 | { | 147 | { |
148 | /* time to hang up ... */ | 148 | /* time to hang up ... */ |
149 | GNUNET_CONVERSATION_call_stop (call); | 149 | GNUNET_CONVERSATION_call_stop(call); |
150 | call = NULL; | 150 | call = NULL; |
151 | } | 151 | } |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | static void | 155 | static void |
156 | destroy_speaker (void *cls) | 156 | destroy_speaker(void *cls) |
157 | { | 157 | { |
158 | const char *origin = cls; | 158 | const char *origin = cls; |
159 | 159 | ||
160 | fprintf (stderr, "Speaker %s destroyed\n", origin); | 160 | fprintf(stderr, "Speaker %s destroyed\n", origin); |
161 | } | 161 | } |
162 | 162 | ||
163 | 163 | ||
164 | static struct GNUNET_SPEAKER_Handle call_speaker = {&enable_speaker, | 164 | static struct GNUNET_SPEAKER_Handle call_speaker = { &enable_speaker, |
165 | &play, | ||
166 | &disable_speaker, | ||
167 | &destroy_speaker, | ||
168 | "caller"}; | ||
169 | |||
170 | |||
171 | static struct GNUNET_SPEAKER_Handle phone_speaker = {&enable_speaker, | ||
172 | &play, | 165 | &play, |
173 | &disable_speaker, | 166 | &disable_speaker, |
174 | &destroy_speaker, | 167 | &destroy_speaker, |
175 | "phone"}; | 168 | "caller" }; |
169 | |||
170 | |||
171 | static struct GNUNET_SPEAKER_Handle phone_speaker = { &enable_speaker, | ||
172 | &play, | ||
173 | &disable_speaker, | ||
174 | &destroy_speaker, | ||
175 | "phone" }; | ||
176 | 176 | ||
177 | 177 | ||
178 | static int | 178 | static int |
179 | enable_mic (void *cls, | 179 | enable_mic(void *cls, |
180 | GNUNET_MICROPHONE_RecordedDataCallback rdc, | 180 | GNUNET_MICROPHONE_RecordedDataCallback rdc, |
181 | void *rdc_cls) | 181 | void *rdc_cls) |
182 | { | 182 | { |
183 | const char *origin = cls; | 183 | const char *origin = cls; |
184 | 184 | ||
185 | fprintf (stderr, "Mic %s enabled\n", origin); | 185 | fprintf(stderr, "Mic %s enabled\n", origin); |
186 | if (0 == strcmp (origin, "phone")) | 186 | if (0 == strcmp(origin, "phone")) |
187 | { | 187 | { |
188 | phone_rdc = rdc; | 188 | phone_rdc = rdc; |
189 | phone_rdc_cls = rdc_cls; | 189 | phone_rdc_cls = rdc_cls; |
190 | phone_task = GNUNET_SCHEDULER_add_now (&phone_send, NULL); | 190 | phone_task = GNUNET_SCHEDULER_add_now(&phone_send, NULL); |
191 | } | 191 | } |
192 | else | 192 | else |
193 | { | 193 | { |
194 | call_rdc = rdc; | 194 | call_rdc = rdc; |
195 | call_rdc_cls = rdc_cls; | 195 | call_rdc_cls = rdc_cls; |
196 | call_task = GNUNET_SCHEDULER_add_now (&call_send, NULL); | 196 | call_task = GNUNET_SCHEDULER_add_now(&call_send, NULL); |
197 | } | 197 | } |
198 | return GNUNET_OK; | 198 | return GNUNET_OK; |
199 | } | 199 | } |
200 | 200 | ||
201 | 201 | ||
202 | static void | 202 | static void |
203 | disable_mic (void *cls) | 203 | disable_mic(void *cls) |
204 | { | 204 | { |
205 | const char *origin = cls; | 205 | const char *origin = cls; |
206 | 206 | ||
207 | fprintf (stderr, "Mic %s disabled\n", origin); | 207 | fprintf(stderr, "Mic %s disabled\n", origin); |
208 | if (0 == strcmp (origin, "phone")) | 208 | if (0 == strcmp(origin, "phone")) |
209 | { | 209 | { |
210 | phone_rdc = NULL; | 210 | phone_rdc = NULL; |
211 | phone_rdc_cls = NULL; | 211 | phone_rdc_cls = NULL; |
212 | GNUNET_SCHEDULER_cancel (phone_task); | 212 | GNUNET_SCHEDULER_cancel(phone_task); |
213 | phone_task = NULL; | 213 | phone_task = NULL; |
214 | } | 214 | } |
215 | else | 215 | else |
216 | { | 216 | { |
217 | call_rdc = NULL; | 217 | call_rdc = NULL; |
218 | call_rdc_cls = NULL; | 218 | call_rdc_cls = NULL; |
219 | GNUNET_SCHEDULER_cancel (call_task); | 219 | GNUNET_SCHEDULER_cancel(call_task); |
220 | call_task = NULL; | 220 | call_task = NULL; |
221 | } | 221 | } |
222 | } | 222 | } |
223 | 223 | ||
224 | 224 | ||
225 | static void | 225 | static void |
226 | destroy_mic (void *cls) | 226 | destroy_mic(void *cls) |
227 | { | 227 | { |
228 | const char *origin = cls; | 228 | const char *origin = cls; |
229 | 229 | ||
230 | fprintf (stderr, "Mic %s destroyed\n", origin); | 230 | fprintf(stderr, "Mic %s destroyed\n", origin); |
231 | } | 231 | } |
232 | 232 | ||
233 | 233 | ||
234 | static struct GNUNET_MICROPHONE_Handle call_mic = {&enable_mic, | 234 | static struct GNUNET_MICROPHONE_Handle call_mic = { &enable_mic, |
235 | &disable_mic, | ||
236 | &destroy_mic, | ||
237 | "caller"}; | ||
238 | |||
239 | |||
240 | static struct GNUNET_MICROPHONE_Handle phone_mic = {&enable_mic, | ||
241 | &disable_mic, | 235 | &disable_mic, |
242 | &destroy_mic, | 236 | &destroy_mic, |
243 | "phone"}; | 237 | "caller" }; |
238 | |||
239 | |||
240 | static struct GNUNET_MICROPHONE_Handle phone_mic = { &enable_mic, | ||
241 | &disable_mic, | ||
242 | &destroy_mic, | ||
243 | "phone" }; | ||
244 | 244 | ||
245 | 245 | ||
246 | /** | 246 | /** |
@@ -249,248 +249,254 @@ static struct GNUNET_MICROPHONE_Handle phone_mic = {&enable_mic, | |||
249 | * @param cls closure | 249 | * @param cls closure |
250 | */ | 250 | */ |
251 | static void | 251 | static void |
252 | end_test (void *cls) | 252 | end_test(void *cls) |
253 | { | 253 | { |
254 | (void) cls; | 254 | (void)cls; |
255 | GNUNET_SCHEDULER_shutdown (); | 255 | GNUNET_SCHEDULER_shutdown(); |
256 | if (NULL != op) | 256 | if (NULL != op) |
257 | { | 257 | { |
258 | GNUNET_IDENTITY_cancel (op); | 258 | GNUNET_IDENTITY_cancel(op); |
259 | op = NULL; | 259 | op = NULL; |
260 | } | 260 | } |
261 | if (NULL != call) | 261 | if (NULL != call) |
262 | { | 262 | { |
263 | GNUNET_CONVERSATION_call_stop (call); | 263 | GNUNET_CONVERSATION_call_stop(call); |
264 | call = NULL; | 264 | call = NULL; |
265 | } | 265 | } |
266 | if (NULL != phone) | 266 | if (NULL != phone) |
267 | { | 267 | { |
268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from PHONE service.\n"); | 268 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from PHONE service.\n"); |
269 | GNUNET_CONVERSATION_phone_destroy (phone); | 269 | GNUNET_CONVERSATION_phone_destroy(phone); |
270 | phone = NULL; | 270 | phone = NULL; |
271 | } | 271 | } |
272 | if (NULL != id) | 272 | if (NULL != id) |
273 | { | 273 | { |
274 | GNUNET_IDENTITY_disconnect (id); | 274 | GNUNET_IDENTITY_disconnect(id); |
275 | id = NULL; | 275 | id = NULL; |
276 | } | 276 | } |
277 | if (NULL != qe) | 277 | if (NULL != qe) |
278 | { | 278 | { |
279 | GNUNET_NAMESTORE_cancel (qe); | 279 | GNUNET_NAMESTORE_cancel(qe); |
280 | qe = NULL; | 280 | qe = NULL; |
281 | } | 281 | } |
282 | if (NULL != ns) | 282 | if (NULL != ns) |
283 | { | 283 | { |
284 | GNUNET_NAMESTORE_disconnect (ns); | 284 | GNUNET_NAMESTORE_disconnect(ns); |
285 | ns = NULL; | 285 | ns = NULL; |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | static void | 290 | static void |
291 | caller_event_handler (void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) | 291 | caller_event_handler(void *cls, enum GNUNET_CONVERSATION_CallerEventCode code) |
292 | { | 292 | { |
293 | (void) cls; | 293 | (void)cls; |
294 | switch (code) | 294 | switch (code) |
295 | { | 295 | { |
296 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: | 296 | case GNUNET_CONVERSATION_EC_CALLER_SUSPEND: |
297 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: | 297 | case GNUNET_CONVERSATION_EC_CALLER_RESUME: |
298 | fprintf (stderr, "Unexpected caller code: %d\n", code); | 298 | fprintf(stderr, "Unexpected caller code: %d\n", code); |
299 | break; | 299 | break; |
300 | } | 300 | } |
301 | } | 301 | } |
302 | 302 | ||
303 | 303 | ||
304 | static void | 304 | static void |
305 | phone_event_handler (void *cls, | 305 | phone_event_handler(void *cls, |
306 | enum GNUNET_CONVERSATION_PhoneEventCode code, | 306 | enum GNUNET_CONVERSATION_PhoneEventCode code, |
307 | struct GNUNET_CONVERSATION_Caller *caller, | 307 | struct GNUNET_CONVERSATION_Caller *caller, |
308 | const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) | 308 | const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) |
309 | { | 309 | { |
310 | static enum GNUNET_CONVERSATION_PhoneEventCode expect = | 310 | static enum GNUNET_CONVERSATION_PhoneEventCode expect = |
311 | GNUNET_CONVERSATION_EC_PHONE_RING; | 311 | GNUNET_CONVERSATION_EC_PHONE_RING; |
312 | 312 | ||
313 | (void) cls; | 313 | (void)cls; |
314 | (void) caller_id; | 314 | (void)caller_id; |
315 | GNUNET_break (code == expect); | 315 | GNUNET_break(code == expect); |
316 | switch (code) | 316 | switch (code) |
317 | { | 317 | { |
318 | case GNUNET_CONVERSATION_EC_PHONE_RING: | 318 | case GNUNET_CONVERSATION_EC_PHONE_RING: |
319 | active_caller = caller; | 319 | active_caller = caller; |
320 | GNUNET_CONVERSATION_caller_pick_up (caller, | 320 | GNUNET_CONVERSATION_caller_pick_up(caller, |
321 | &caller_event_handler, | 321 | &caller_event_handler, |
322 | NULL, | 322 | NULL, |
323 | &phone_speaker, | 323 | &phone_speaker, |
324 | &phone_mic); | 324 | &phone_mic); |
325 | expect = GNUNET_CONVERSATION_EC_PHONE_HUNG_UP; | 325 | expect = GNUNET_CONVERSATION_EC_PHONE_HUNG_UP; |
326 | break; | 326 | break; |
327 | case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: | 327 | |
328 | GNUNET_break (caller == active_caller); | 328 | case GNUNET_CONVERSATION_EC_PHONE_HUNG_UP: |
329 | active_caller = NULL; | 329 | GNUNET_break(caller == active_caller); |
330 | if (1 == ok) | 330 | active_caller = NULL; |
331 | ok = 0; | 331 | if (1 == ok) |
332 | GNUNET_SCHEDULER_shutdown (); | 332 | ok = 0; |
333 | break; | 333 | GNUNET_SCHEDULER_shutdown(); |
334 | default: | 334 | break; |
335 | fprintf (stderr, "Unexpected phone code: %d\n", code); | 335 | |
336 | break; | 336 | default: |
337 | } | 337 | fprintf(stderr, "Unexpected phone code: %d\n", code); |
338 | break; | ||
339 | } | ||
338 | } | 340 | } |
339 | 341 | ||
340 | 342 | ||
341 | static void | 343 | static void |
342 | call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code) | 344 | call_event_handler(void *cls, enum GNUNET_CONVERSATION_CallEventCode code) |
343 | { | 345 | { |
344 | static enum GNUNET_CONVERSATION_CallEventCode expect = | 346 | static enum GNUNET_CONVERSATION_CallEventCode expect = |
345 | GNUNET_CONVERSATION_EC_CALL_RINGING; | 347 | GNUNET_CONVERSATION_EC_CALL_RINGING; |
346 | 348 | ||
347 | (void) cls; | 349 | (void)cls; |
348 | GNUNET_break (code == expect); | 350 | GNUNET_break(code == expect); |
349 | switch (code) | 351 | switch (code) |
350 | { | 352 | { |
351 | case GNUNET_CONVERSATION_EC_CALL_RINGING: | 353 | case GNUNET_CONVERSATION_EC_CALL_RINGING: |
352 | expect = GNUNET_CONVERSATION_EC_CALL_PICKED_UP; | 354 | expect = GNUNET_CONVERSATION_EC_CALL_PICKED_UP; |
353 | break; | 355 | break; |
354 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: | 356 | |
355 | expect = -1; | 357 | case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: |
356 | break; | 358 | expect = -1; |
357 | case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: | 359 | break; |
358 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: | 360 | |
359 | call = NULL; | 361 | case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: |
360 | ok = 2; | 362 | case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: |
361 | GNUNET_break (0); | 363 | call = NULL; |
362 | fprintf (stderr, "Unexpected call code: %d\n", code); | 364 | ok = 2; |
363 | break; | 365 | GNUNET_break(0); |
364 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: | 366 | fprintf(stderr, "Unexpected call code: %d\n", code); |
365 | case GNUNET_CONVERSATION_EC_CALL_RESUMED: | 367 | break; |
366 | GNUNET_break (0); | 368 | |
367 | fprintf (stderr, "Unexpected call code: %d\n", code); | 369 | case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: |
368 | ok = 2; | 370 | case GNUNET_CONVERSATION_EC_CALL_RESUMED: |
369 | break; | 371 | GNUNET_break(0); |
370 | case GNUNET_CONVERSATION_EC_CALL_ERROR: | 372 | fprintf(stderr, "Unexpected call code: %d\n", code); |
371 | GNUNET_break (0); | 373 | ok = 2; |
372 | fprintf (stderr, "Unexpected call code: %d\n", code); | 374 | break; |
373 | call = NULL; | 375 | |
374 | ok = 2; | 376 | case GNUNET_CONVERSATION_EC_CALL_ERROR: |
375 | break; | 377 | GNUNET_break(0); |
376 | } | 378 | fprintf(stderr, "Unexpected call code: %d\n", code); |
379 | call = NULL; | ||
380 | ok = 2; | ||
381 | break; | ||
382 | } | ||
377 | } | 383 | } |
378 | 384 | ||
379 | 385 | ||
380 | static void | 386 | static void |
381 | caller_ego_create_cont (void *cls, | 387 | caller_ego_create_cont(void *cls, |
382 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, | 388 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, |
383 | const char *emsg) | 389 | const char *emsg) |
384 | { | 390 | { |
385 | (void) cls; | 391 | (void)cls; |
386 | op = NULL; | 392 | op = NULL; |
387 | GNUNET_assert (NULL == emsg); | 393 | GNUNET_assert(NULL == emsg); |
388 | } | 394 | } |
389 | 395 | ||
390 | 396 | ||
391 | static void | 397 | static void |
392 | namestore_put_cont (void *cls, int32_t success, const char *emsg) | 398 | namestore_put_cont(void *cls, int32_t success, const char *emsg) |
393 | { | 399 | { |
394 | (void) cls; | 400 | (void)cls; |
395 | qe = NULL; | 401 | qe = NULL; |
396 | GNUNET_assert (GNUNET_YES == success); | 402 | GNUNET_assert(GNUNET_YES == success); |
397 | GNUNET_assert (NULL == emsg); | 403 | GNUNET_assert(NULL == emsg); |
398 | GNUNET_assert (NULL == op); | 404 | GNUNET_assert(NULL == op); |
399 | op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL); | 405 | op = GNUNET_IDENTITY_create(id, "caller-ego", &caller_ego_create_cont, NULL); |
400 | } | 406 | } |
401 | 407 | ||
402 | 408 | ||
403 | static void | 409 | static void |
404 | identity_cb (void *cls, | 410 | identity_cb(void *cls, |
405 | struct GNUNET_IDENTITY_Ego *ego, | 411 | struct GNUNET_IDENTITY_Ego *ego, |
406 | void **ctx, | 412 | void **ctx, |
407 | const char *name) | 413 | const char *name) |
408 | { | 414 | { |
409 | struct GNUNET_GNSRECORD_Data rd; | 415 | struct GNUNET_GNSRECORD_Data rd; |
410 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; | 416 | struct GNUNET_CRYPTO_EcdsaPublicKey pub; |
411 | 417 | ||
412 | (void) cls; | 418 | (void)cls; |
413 | (void) ctx; | 419 | (void)ctx; |
414 | if (NULL == name) | 420 | if (NULL == name) |
415 | return; | 421 | return; |
416 | if (NULL == ego) | 422 | if (NULL == ego) |
417 | return; | 423 | return; |
418 | if (0 == strcmp (name, "phone-ego")) | 424 | if (0 == strcmp(name, "phone-ego")) |
419 | { | 425 | { |
420 | GNUNET_IDENTITY_ego_get_public_key (ego, &pub); | 426 | GNUNET_IDENTITY_ego_get_public_key(ego, &pub); |
421 | GNUNET_asprintf (&gns_name, | 427 | GNUNET_asprintf(&gns_name, |
422 | "phone.%s", | 428 | "phone.%s", |
423 | GNUNET_GNSRECORD_pkey_to_zkey (&pub)); | 429 | GNUNET_GNSRECORD_pkey_to_zkey(&pub)); |
424 | phone = | 430 | phone = |
425 | GNUNET_CONVERSATION_phone_create (cfg, ego, &phone_event_handler, NULL); | 431 | GNUNET_CONVERSATION_phone_create(cfg, ego, &phone_event_handler, NULL); |
426 | GNUNET_assert (NULL != phone); | 432 | GNUNET_assert(NULL != phone); |
427 | memset (&rd, 0, sizeof (rd)); | 433 | memset(&rd, 0, sizeof(rd)); |
428 | GNUNET_CONVERSATION_phone_get_record (phone, &rd); | 434 | GNUNET_CONVERSATION_phone_get_record(phone, &rd); |
429 | GNUNET_assert (rd.record_type == GNUNET_GNSRECORD_TYPE_PHONE); | 435 | GNUNET_assert(rd.record_type == GNUNET_GNSRECORD_TYPE_PHONE); |
430 | rd.expiration_time = UINT64_MAX; | 436 | rd.expiration_time = UINT64_MAX; |
431 | qe = | 437 | qe = |
432 | GNUNET_NAMESTORE_records_store (ns, | 438 | GNUNET_NAMESTORE_records_store(ns, |
433 | GNUNET_IDENTITY_ego_get_private_key (ego), | 439 | GNUNET_IDENTITY_ego_get_private_key(ego), |
434 | "phone" /* GNS label */, | 440 | "phone" /* GNS label */, |
435 | 1, | 441 | 1, |
436 | &rd, | 442 | &rd, |
437 | &namestore_put_cont, | 443 | &namestore_put_cont, |
438 | NULL); | 444 | NULL); |
439 | return; | 445 | return; |
440 | } | 446 | } |
441 | if (0 == strcmp (name, "caller-ego")) | 447 | if (0 == strcmp(name, "caller-ego")) |
442 | { | 448 | { |
443 | GNUNET_IDENTITY_ego_get_public_key (ego, &pub); | 449 | GNUNET_IDENTITY_ego_get_public_key(ego, &pub); |
444 | GNUNET_asprintf (&gns_caller_id, | 450 | GNUNET_asprintf(&gns_caller_id, |
445 | "%s", | 451 | "%s", |
446 | GNUNET_GNSRECORD_pkey_to_zkey (&pub)); | 452 | GNUNET_GNSRECORD_pkey_to_zkey(&pub)); |
447 | call = GNUNET_CONVERSATION_call_start (cfg, | 453 | call = GNUNET_CONVERSATION_call_start(cfg, |
448 | ego, | 454 | ego, |
449 | gns_name, | 455 | gns_name, |
450 | &call_speaker, | 456 | &call_speaker, |
451 | &call_mic, | 457 | &call_mic, |
452 | &call_event_handler, | 458 | &call_event_handler, |
453 | NULL); | 459 | NULL); |
454 | return; | 460 | return; |
455 | } | 461 | } |
456 | } | 462 | } |
457 | 463 | ||
458 | 464 | ||
459 | static void | 465 | static void |
460 | phone_ego_create_cont (void *cls, | 466 | phone_ego_create_cont(void *cls, |
461 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, | 467 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, |
462 | const char *emsg) | 468 | const char *emsg) |
463 | { | 469 | { |
464 | (void) cls; | 470 | (void)cls; |
465 | op = NULL; | 471 | op = NULL; |
466 | GNUNET_assert (NULL == emsg); | 472 | GNUNET_assert(NULL == emsg); |
467 | } | 473 | } |
468 | 474 | ||
469 | 475 | ||
470 | static void | 476 | static void |
471 | run (void *cls, | 477 | run(void *cls, |
472 | const struct GNUNET_CONFIGURATION_Handle *c, | 478 | const struct GNUNET_CONFIGURATION_Handle *c, |
473 | struct GNUNET_TESTING_Peer *peer) | 479 | struct GNUNET_TESTING_Peer *peer) |
474 | { | 480 | { |
475 | (void) cls; | 481 | (void)cls; |
476 | (void) peer; | 482 | (void)peer; |
477 | cfg = c; | 483 | cfg = c; |
478 | GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); | 484 | GNUNET_SCHEDULER_add_delayed(TIMEOUT, &end_test, NULL); |
479 | id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); | 485 | id = GNUNET_IDENTITY_connect(cfg, &identity_cb, NULL); |
480 | op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL); | 486 | op = GNUNET_IDENTITY_create(id, "phone-ego", &phone_ego_create_cont, NULL); |
481 | ns = GNUNET_NAMESTORE_connect (cfg); | 487 | ns = GNUNET_NAMESTORE_connect(cfg); |
482 | } | 488 | } |
483 | 489 | ||
484 | 490 | ||
485 | int | 491 | int |
486 | main (int argc, char *argv[]) | 492 | main(int argc, char *argv[]) |
487 | { | 493 | { |
488 | (void) argc; | 494 | (void)argc; |
489 | (void) argv; | 495 | (void)argv; |
490 | if (0 != GNUNET_TESTING_peer_run ("test_conversation_api", | 496 | if (0 != GNUNET_TESTING_peer_run("test_conversation_api", |
491 | "test_conversation.conf", | 497 | "test_conversation.conf", |
492 | &run, | 498 | &run, |
493 | NULL)) | 499 | NULL)) |
494 | return 1; | 500 | return 1; |
495 | return ok; | 501 | return ok; |
496 | } | 502 | } |