aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/test_conversation_api_reject.c
diff options
context:
space:
mode:
authorng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
committerng0 <ng0@n0.is>2019-09-08 12:33:09 +0000
commitd41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb (patch)
tree9efd18ea7d425652085ed0bd5e8e45604bc5f6b9 /src/conversation/test_conversation_api_reject.c
parenta0fce305c565c0937d917a92712f15e9c5736260 (diff)
downloadgnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.tar.gz
gnunet-d41ed82a4ea0cc8e1674b6d5d2c49fd6462610bb.zip
uncrustify as demanded.
Diffstat (limited to 'src/conversation/test_conversation_api_reject.c')
-rw-r--r--src/conversation/test_conversation_api_reject.c362
1 files changed, 183 insertions, 179 deletions
diff --git a/src/conversation/test_conversation_api_reject.c b/src/conversation/test_conversation_api_reject.c
index b0a479dc2..2d7a56e3d 100644
--- a/src/conversation/test_conversation_api_reject.c
+++ b/src/conversation/test_conversation_api_reject.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_reject.c 21 * @file conversation/test_conversation_api_reject.c
22 * @brief testcase for conversation_api.c 22 * @brief testcase for conversation_api.c
@@ -33,7 +33,7 @@
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 TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 25) 36#define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 25)
37 37
38static int ok = 1; 38static int ok = 1;
39 39
@@ -57,78 +57,78 @@ static char *gns_caller_id;
57 57
58 58
59static int 59static int
60enable_speaker (void *cls) 60enable_speaker(void *cls)
61{ 61{
62 (void) cls; 62 (void)cls;
63 GNUNET_break (0); 63 GNUNET_break(0);
64 return GNUNET_SYSERR; 64 return GNUNET_SYSERR;
65} 65}
66 66
67 67
68static void 68static void
69disable_speaker (void *cls) 69disable_speaker(void *cls)
70{ 70{
71 (void) cls; 71 (void)cls;
72 GNUNET_break (0); 72 GNUNET_break(0);
73} 73}
74 74
75 75
76static void 76static void
77play (void *cls, size_t data_size, const void *data) 77play(void *cls, size_t data_size, const void *data)
78{ 78{
79 (void) cls; 79 (void)cls;
80 (void) data_size; 80 (void)data_size;
81 (void) data; 81 (void)data;
82 GNUNET_break (0); 82 GNUNET_break(0);
83} 83}
84 84
85 85
86static void 86static void
87destroy_speaker (void *cls) 87destroy_speaker(void *cls)
88{ 88{
89 (void) cls; 89 (void)cls;
90} 90}
91 91
92 92
93static struct GNUNET_SPEAKER_Handle call_speaker = {&enable_speaker, 93static struct GNUNET_SPEAKER_Handle call_speaker = { &enable_speaker,
94 &play, 94 &play,
95 &disable_speaker, 95 &disable_speaker,
96 &destroy_speaker, 96 &destroy_speaker,
97 "caller"}; 97 "caller" };
98 98
99 99
100static int 100static int
101enable_mic (void *cls, 101enable_mic(void *cls,
102 GNUNET_MICROPHONE_RecordedDataCallback rdc, 102 GNUNET_MICROPHONE_RecordedDataCallback rdc,
103 void *rdc_cls) 103 void *rdc_cls)
104{ 104{
105 (void) cls; 105 (void)cls;
106 (void) rdc; 106 (void)rdc;
107 (void) rdc_cls; 107 (void)rdc_cls;
108 GNUNET_break (0); 108 GNUNET_break(0);
109 return GNUNET_SYSERR; 109 return GNUNET_SYSERR;
110} 110}
111 111
112 112
113static void 113static void
114disable_mic (void *cls) 114disable_mic(void *cls)
115{ 115{
116 (void) cls; 116 (void)cls;
117 GNUNET_break (0); 117 GNUNET_break(0);
118} 118}
119 119
120 120
121static void 121static void
122destroy_mic (void *cls) 122destroy_mic(void *cls)
123{ 123{
124 (void) cls; 124 (void)cls;
125} 125}
126 126
127 127
128static struct GNUNET_MICROPHONE_Handle call_mic = {&enable_mic, 128static struct GNUNET_MICROPHONE_Handle call_mic = { &enable_mic,
129 &disable_mic, 129 &disable_mic,
130 &destroy_mic, 130 &destroy_mic,
131 "caller"}; 131 "caller" };
132 132
133 133
134/** 134/**
@@ -137,215 +137,219 @@ static struct GNUNET_MICROPHONE_Handle call_mic = {&enable_mic,
137 * @param cls closure 137 * @param cls closure
138 */ 138 */
139static void 139static void
140end_test (void *cls) 140end_test(void *cls)
141{ 141{
142 (void) cls; 142 (void)cls;
143 GNUNET_SCHEDULER_shutdown (); 143 GNUNET_SCHEDULER_shutdown();
144 if (NULL != op) 144 if (NULL != op)
145 { 145 {
146 GNUNET_IDENTITY_cancel (op); 146 GNUNET_IDENTITY_cancel(op);
147 op = NULL; 147 op = NULL;
148 } 148 }
149 if (NULL != call) 149 if (NULL != call)
150 { 150 {
151 GNUNET_CONVERSATION_call_stop (call); 151 GNUNET_CONVERSATION_call_stop(call);
152 call = NULL; 152 call = NULL;
153 } 153 }
154 if (NULL != phone) 154 if (NULL != phone)
155 { 155 {
156 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from PHONE service.\n"); 156 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Disconnecting from PHONE service.\n");
157 GNUNET_CONVERSATION_phone_destroy (phone); 157 GNUNET_CONVERSATION_phone_destroy(phone);
158 phone = NULL; 158 phone = NULL;
159 } 159 }
160 if (NULL != id) 160 if (NULL != id)
161 { 161 {
162 GNUNET_IDENTITY_disconnect (id); 162 GNUNET_IDENTITY_disconnect(id);
163 id = NULL; 163 id = NULL;
164 } 164 }
165 if (NULL != qe) 165 if (NULL != qe)
166 { 166 {
167 GNUNET_NAMESTORE_cancel (qe); 167 GNUNET_NAMESTORE_cancel(qe);
168 qe = NULL; 168 qe = NULL;
169 } 169 }
170 if (NULL != ns) 170 if (NULL != ns)
171 { 171 {
172 GNUNET_NAMESTORE_disconnect (ns); 172 GNUNET_NAMESTORE_disconnect(ns);
173 ns = NULL; 173 ns = NULL;
174 } 174 }
175} 175}
176 176
177 177
178static void 178static void
179phone_event_handler (void *cls, 179phone_event_handler(void *cls,
180 enum GNUNET_CONVERSATION_PhoneEventCode code, 180 enum GNUNET_CONVERSATION_PhoneEventCode code,
181 struct GNUNET_CONVERSATION_Caller *caller, 181 struct GNUNET_CONVERSATION_Caller *caller,
182 const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id) 182 const struct GNUNET_CRYPTO_EcdsaPublicKey *caller_id)
183{ 183{
184 static enum GNUNET_CONVERSATION_PhoneEventCode expect = 184 static enum GNUNET_CONVERSATION_PhoneEventCode expect =
185 GNUNET_CONVERSATION_EC_PHONE_RING; 185 GNUNET_CONVERSATION_EC_PHONE_RING;
186 186
187 (void) cls; 187 (void)cls;
188 (void) caller_id; 188 (void)caller_id;
189 GNUNET_break (code == expect); 189 GNUNET_break(code == expect);
190 switch (code) 190 switch (code)
191 { 191 {
192 case GNUNET_CONVERSATION_EC_PHONE_RING: 192 case GNUNET_CONVERSATION_EC_PHONE_RING:
193 GNUNET_CONVERSATION_caller_hang_up (caller); 193 GNUNET_CONVERSATION_caller_hang_up(caller);
194 break; 194 break;
195 default: 195
196 fprintf (stderr, "Unexpected phone code: %d\n", code); 196 default:
197 break; 197 fprintf(stderr, "Unexpected phone code: %d\n", code);
198 } 198 break;
199 }
199} 200}
200 201
201 202
202static void 203static void
203call_event_handler (void *cls, enum GNUNET_CONVERSATION_CallEventCode code) 204call_event_handler(void *cls, enum GNUNET_CONVERSATION_CallEventCode code)
204{ 205{
205 static enum GNUNET_CONVERSATION_CallEventCode expect = 206 static enum GNUNET_CONVERSATION_CallEventCode expect =
206 GNUNET_CONVERSATION_EC_CALL_RINGING; 207 GNUNET_CONVERSATION_EC_CALL_RINGING;
207 208
208 (void) cls; 209 (void)cls;
209 GNUNET_break (code == expect); 210 GNUNET_break(code == expect);
210 switch (code) 211 switch (code)
211 { 212 {
212 case GNUNET_CONVERSATION_EC_CALL_RINGING: 213 case GNUNET_CONVERSATION_EC_CALL_RINGING:
213 expect = GNUNET_CONVERSATION_EC_CALL_HUNG_UP; 214 expect = GNUNET_CONVERSATION_EC_CALL_HUNG_UP;
214 break; 215 break;
215 case GNUNET_CONVERSATION_EC_CALL_HUNG_UP: 216
216 call = NULL; 217 case GNUNET_CONVERSATION_EC_CALL_HUNG_UP:
217 ok = 0; 218 call = NULL;
218 GNUNET_SCHEDULER_shutdown (); 219 ok = 0;
219 expect = -1; 220 GNUNET_SCHEDULER_shutdown();
220 break; 221 expect = -1;
221 case GNUNET_CONVERSATION_EC_CALL_PICKED_UP: 222 break;
222 case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL: 223
223 case GNUNET_CONVERSATION_EC_CALL_SUSPENDED: 224 case GNUNET_CONVERSATION_EC_CALL_PICKED_UP:
224 case GNUNET_CONVERSATION_EC_CALL_RESUMED: 225 case GNUNET_CONVERSATION_EC_CALL_GNS_FAIL:
225 fprintf (stderr, "Unexpected call code: %d\n", code); 226 case GNUNET_CONVERSATION_EC_CALL_SUSPENDED:
226 break; 227 case GNUNET_CONVERSATION_EC_CALL_RESUMED:
227 case GNUNET_CONVERSATION_EC_CALL_ERROR: 228 fprintf(stderr, "Unexpected call code: %d\n", code);
228 fprintf (stderr, "Unexpected call code: %d\n", code); 229 break;
229 call = NULL; 230
230 break; 231 case GNUNET_CONVERSATION_EC_CALL_ERROR:
231 } 232 fprintf(stderr, "Unexpected call code: %d\n", code);
233 call = NULL;
234 break;
235 }
232} 236}
233 237
234 238
235static void 239static void
236caller_ego_create_cont (void *cls, 240caller_ego_create_cont(void *cls,
237 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 241 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
238 const char *emsg) 242 const char *emsg)
239{ 243{
240 (void) cls; 244 (void)cls;
241 op = NULL; 245 op = NULL;
242 GNUNET_assert (NULL == emsg); 246 GNUNET_assert(NULL == emsg);
243} 247}
244 248
245 249
246static void 250static void
247namestore_put_cont (void *cls, int32_t success, const char *emsg) 251namestore_put_cont(void *cls, int32_t success, const char *emsg)
248{ 252{
249 (void) cls; 253 (void)cls;
250 qe = NULL; 254 qe = NULL;
251 GNUNET_assert (GNUNET_YES == success); 255 GNUNET_assert(GNUNET_YES == success);
252 GNUNET_assert (NULL == emsg); 256 GNUNET_assert(NULL == emsg);
253 GNUNET_assert (NULL == op); 257 GNUNET_assert(NULL == op);
254 op = GNUNET_IDENTITY_create (id, "caller-ego", &caller_ego_create_cont, NULL); 258 op = GNUNET_IDENTITY_create(id, "caller-ego", &caller_ego_create_cont, NULL);
255} 259}
256 260
257 261
258static void 262static void
259identity_cb (void *cls, 263identity_cb(void *cls,
260 struct GNUNET_IDENTITY_Ego *ego, 264 struct GNUNET_IDENTITY_Ego *ego,
261 void **ctx, 265 void **ctx,
262 const char *name) 266 const char *name)
263{ 267{
264 struct GNUNET_GNSRECORD_Data rd; 268 struct GNUNET_GNSRECORD_Data rd;
265 struct GNUNET_CRYPTO_EcdsaPublicKey pub; 269 struct GNUNET_CRYPTO_EcdsaPublicKey pub;
266 270
267 (void) cls; 271 (void)cls;
268 (void) ctx; 272 (void)ctx;
269 if (NULL == name) 273 if (NULL == name)
270 return; 274 return;
271 if (NULL == ego) 275 if (NULL == ego)
272 return; 276 return;
273 if (0 == strcmp (name, "phone-ego")) 277 if (0 == strcmp(name, "phone-ego"))
274 { 278 {
275 GNUNET_IDENTITY_ego_get_public_key (ego, &pub); 279 GNUNET_IDENTITY_ego_get_public_key(ego, &pub);
276 GNUNET_asprintf (&gns_name, 280 GNUNET_asprintf(&gns_name,
277 "phone.%s", 281 "phone.%s",
278 GNUNET_GNSRECORD_pkey_to_zkey (&pub)); 282 GNUNET_GNSRECORD_pkey_to_zkey(&pub));
279 phone = 283 phone =
280 GNUNET_CONVERSATION_phone_create (cfg, ego, &phone_event_handler, NULL); 284 GNUNET_CONVERSATION_phone_create(cfg, ego, &phone_event_handler, NULL);
281 GNUNET_assert (NULL != phone); 285 GNUNET_assert(NULL != phone);
282 memset (&rd, 0, sizeof (rd)); 286 memset(&rd, 0, sizeof(rd));
283 GNUNET_CONVERSATION_phone_get_record (phone, &rd); 287 GNUNET_CONVERSATION_phone_get_record(phone, &rd);
284 GNUNET_assert (rd.record_type == GNUNET_GNSRECORD_TYPE_PHONE); 288 GNUNET_assert(rd.record_type == GNUNET_GNSRECORD_TYPE_PHONE);
285 rd.expiration_time = UINT64_MAX; 289 rd.expiration_time = UINT64_MAX;
286 qe = 290 qe =
287 GNUNET_NAMESTORE_records_store (ns, 291 GNUNET_NAMESTORE_records_store(ns,
288 GNUNET_IDENTITY_ego_get_private_key (ego), 292 GNUNET_IDENTITY_ego_get_private_key(ego),
289 "phone" /* GNS label */, 293 "phone" /* GNS label */,
290 1, 294 1,
291 &rd, 295 &rd,
292 &namestore_put_cont, 296 &namestore_put_cont,
293 NULL); 297 NULL);
294 return; 298 return;
295 } 299 }
296 if (0 == strcmp (name, "caller-ego")) 300 if (0 == strcmp(name, "caller-ego"))
297 { 301 {
298 GNUNET_IDENTITY_ego_get_public_key (ego, &pub); 302 GNUNET_IDENTITY_ego_get_public_key(ego, &pub);
299 GNUNET_asprintf (&gns_caller_id, 303 GNUNET_asprintf(&gns_caller_id,
300 "%s", 304 "%s",
301 GNUNET_GNSRECORD_pkey_to_zkey (&pub)); 305 GNUNET_GNSRECORD_pkey_to_zkey(&pub));
302 call = GNUNET_CONVERSATION_call_start (cfg, 306 call = GNUNET_CONVERSATION_call_start(cfg,
303 ego, 307 ego,
304 gns_name, 308 gns_name,
305 &call_speaker, 309 &call_speaker,
306 &call_mic, 310 &call_mic,
307 &call_event_handler, 311 &call_event_handler,
308 NULL); 312 NULL);
309 return; 313 return;
310 } 314 }
311} 315}
312 316
313 317
314static void 318static void
315phone_ego_create_cont (void *cls, 319phone_ego_create_cont(void *cls,
316 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk, 320 const struct GNUNET_CRYPTO_EcdsaPrivateKey *pk,
317 const char *emsg) 321 const char *emsg)
318{ 322{
319 (void) cls; 323 (void)cls;
320 op = NULL; 324 op = NULL;
321 GNUNET_assert (NULL == emsg); 325 GNUNET_assert(NULL == emsg);
322} 326}
323 327
324 328
325static void 329static void
326run (void *cls, 330run(void *cls,
327 const struct GNUNET_CONFIGURATION_Handle *c, 331 const struct GNUNET_CONFIGURATION_Handle *c,
328 struct GNUNET_TESTING_Peer *peer) 332 struct GNUNET_TESTING_Peer *peer)
329{ 333{
330 (void) cls; 334 (void)cls;
331 (void) peer; 335 (void)peer;
332 cfg = c; 336 cfg = c;
333 GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_test, NULL); 337 GNUNET_SCHEDULER_add_delayed(TIMEOUT, &end_test, NULL);
334 id = GNUNET_IDENTITY_connect (cfg, &identity_cb, NULL); 338 id = GNUNET_IDENTITY_connect(cfg, &identity_cb, NULL);
335 op = GNUNET_IDENTITY_create (id, "phone-ego", &phone_ego_create_cont, NULL); 339 op = GNUNET_IDENTITY_create(id, "phone-ego", &phone_ego_create_cont, NULL);
336 ns = GNUNET_NAMESTORE_connect (cfg); 340 ns = GNUNET_NAMESTORE_connect(cfg);
337} 341}
338 342
339 343
340int 344int
341main (int argc, char *argv[]) 345main(int argc, char *argv[])
342{ 346{
343 (void) argc; 347 (void)argc;
344 (void) argv; 348 (void)argv;
345 if (0 != GNUNET_TESTING_peer_run ("test_conversation_api", 349 if (0 != GNUNET_TESTING_peer_run("test_conversation_api",
346 "test_conversation.conf", 350 "test_conversation.conf",
347 &run, 351 &run,
348 NULL)) 352 NULL))
349 return 1; 353 return 1;
350 return ok; 354 return ok;
351} 355}