aboutsummaryrefslogtreecommitdiff
path: root/src/social/test_social.c
diff options
context:
space:
mode:
authorGabor X Toth <*@tg-x.net>2015-12-17 14:12:44 +0000
committerGabor X Toth <*@tg-x.net>2015-12-17 14:12:44 +0000
commitc159ab01bd16e9f3ad1776fa6fb26398cb7986d9 (patch)
tree61b0cad0b3e94f7e2dc7a8b48de7dc24784e229d /src/social/test_social.c
parent6cf89fa848bbcb9e1f941bad1ac0c4ec6066fdd7 (diff)
downloadgnunet-c159ab01bd16e9f3ad1776fa6fb26398cb7986d9.tar.gz
gnunet-c159ab01bd16e9f3ad1776fa6fb26398cb7986d9.zip
social: API changes for application connections: store/load app subscriptions to places
Diffstat (limited to 'src/social/test_social.c')
-rw-r--r--src/social/test_social.c356
1 files changed, 267 insertions, 89 deletions
diff --git a/src/social/test_social.c b/src/social/test_social.c
index 158fa469d..38710cd1a 100644
--- a/src/social/test_social.c
+++ b/src/social/test_social.c
@@ -45,6 +45,9 @@
45 */ 45 */
46int res; 46int res;
47 47
48struct GNUNET_SOCIAL_App *app;
49const char *app_id = "test";
50
48/** 51/**
49 * Handle for task for timeout termination. 52 * Handle for task for timeout termination.
50 */ 53 */
@@ -57,8 +60,8 @@ struct GNUNET_PeerIdentity this_peer;
57 60
58struct GNUNET_IDENTITY_Handle *id; 61struct GNUNET_IDENTITY_Handle *id;
59 62
60const struct GNUNET_IDENTITY_Ego *host_ego; 63const struct GNUNET_SOCIAL_Ego *host_ego;
61const struct GNUNET_IDENTITY_Ego *guest_ego; 64const struct GNUNET_SOCIAL_Ego *guest_ego;
62 65
63const char *host_name = "Host One"; 66const char *host_name = "Host One";
64const char *guest_name = "Guest One"; 67const char *guest_name = "Guest One";
@@ -67,6 +70,8 @@ struct GNUNET_CRYPTO_EddsaPrivateKey *place_key;
67struct GNUNET_CRYPTO_EcdsaPrivateKey *guest_key; 70struct GNUNET_CRYPTO_EcdsaPrivateKey *guest_key;
68 71
69struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key; 72struct GNUNET_CRYPTO_EddsaPublicKey place_pub_key;
73struct GNUNET_HashCode place_pub_hash;
74
70struct GNUNET_CRYPTO_EcdsaPublicKey guest_pub_key; 75struct GNUNET_CRYPTO_EcdsaPublicKey guest_pub_key;
71struct GNUNET_CRYPTO_EcdsaPublicKey host_pub_key; 76struct GNUNET_CRYPTO_EcdsaPublicKey host_pub_key;
72 77
@@ -111,32 +116,57 @@ struct GNUNET_PSYC_Message *join_resp;
111 116
112uint32_t counter; 117uint32_t counter;
113 118
114uint8_t guest_pkey_added = GNUNET_NO; 119uint8_t is_guest_nym_added = GNUNET_NO;
120uint8_t is_host_reconnected = GNUNET_NO;
121uint8_t is_guest_reconnected = GNUNET_NO;
115 122
116enum 123enum
117{ 124{
118 TEST_NONE = 0, 125 TEST_NONE = 0,
119 TEST_HOST_ANSWER_DOOR_REFUSE = 1, 126 TEST_HOST_CREATE = 1,
120 TEST_GUEST_RECV_ENTRY_DCSN_REFUSE = 2, 127 TEST_HOST_ENTER = 2,
121 TEST_HOST_ANSWER_DOOR_ADMIT = 3, 128 TEST_GUEST_CREATE = 3,
122 TEST_GUEST_RECV_ENTRY_DCSN_ADMIT = 4, 129 TEST_GUEST_ENTER = 4,
123 TEST_HOST_ANNOUNCE = 5, 130 TEST_HOST_ANSWER_DOOR_REFUSE = 5,
124 TEST_HOST_ANNOUNCE_END = 6, 131 TEST_GUEST_RECV_ENTRY_DCSN_REFUSE = 6,
125 TEST_HOST_ANNOUNCE2 = 7, 132 TEST_HOST_ANSWER_DOOR_ADMIT = 7,
126 TEST_HOST_ANNOUNCE2_END = 8, 133 TEST_GUEST_RECV_ENTRY_DCSN_ADMIT = 8,
127 TEST_GUEST_TALK = 9, 134 TEST_HOST_ANNOUNCE = 9,
128 TEST_GUEST_HISTORY_REPLAY = 10, 135 TEST_HOST_ANNOUNCE_END = 10,
129 TEST_GUEST_HISTORY_REPLAY_LATEST = 11, 136 TEST_HOST_ANNOUNCE2 = 11,
130 TEST_GUEST_LOOK_AT = 12, 137 TEST_HOST_ANNOUNCE2_END = 12,
131 TEST_GUEST_LOOK_FOR = 13, 138 TEST_GUEST_TALK = 13,
132 TEST_GUEST_LEAVE = 14, 139 TEST_GUEST_HISTORY_REPLAY = 14,
133 TEST_HOST_ADVERTISE = 15, 140 TEST_GUEST_HISTORY_REPLAY_LATEST = 15,
134 TEST_GUEST_ENTER_BY_NAME = 16, 141 TEST_GUEST_LOOK_AT = 16,
135 TEST_HOST_LEAVE = 17, 142 TEST_GUEST_LOOK_FOR = 17,
143 TEST_GUEST_LEAVE = 18,
144 TEST_ZONE_ADD_PLACE = 19,
145 TEST_GUEST_ENTER_BY_NAME = 20,
146 TEST_RECONNECT = 21,
147 TEST_GUEST_LEAVE2 = 22,
148 TEST_HOST_LEAVE = 23,
136} test; 149} test;
137 150
138 151
139static void 152static void
153schedule_guest_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
154
155static void
156host_answer_door (void *cls,
157 struct GNUNET_SOCIAL_Nym *nym,
158 const char *method_name,
159 struct GNUNET_ENV_Environment *env,
160 size_t data_size,
161 const void *data);
162
163static void
164host_enter ();
165
166static void
167guest_init ();
168
169static void
140guest_enter (); 170guest_enter ();
141 171
142static void 172static void
@@ -167,18 +197,31 @@ cleanup ()
167 id = NULL; 197 id = NULL;
168 } 198 }
169 199
200 if (NULL != guest_slicer)
201 {
202 GNUNET_SOCIAL_slicer_destroy (guest_slicer);
203 guest_slicer = NULL;
204 }
205
206 if (NULL != host_slicer)
207 {
208 GNUNET_SOCIAL_slicer_destroy (host_slicer);
209 host_slicer = NULL;
210 }
211
170 if (NULL != gst) 212 if (NULL != gst)
171 { 213 {
172 GNUNET_SOCIAL_guest_leave (gst, GNUNET_NO, NULL, NULL, NULL); 214 GNUNET_SOCIAL_guest_leave (gst, NULL, NULL, NULL);
173 gst = NULL; 215 gst = NULL;
174 gst_plc = NULL; 216 gst_plc = NULL;
175 } 217 }
176 if (NULL != hst) 218 if (NULL != hst)
177 { 219 {
178 GNUNET_SOCIAL_host_leave (hst, GNUNET_NO, NULL, NULL); 220 GNUNET_SOCIAL_host_leave (hst, NULL, NULL, NULL);
179 hst = NULL; 221 hst = NULL;
180 hst_plc = NULL; 222 hst_plc = NULL;
181 } 223 }
224 GNUNET_SOCIAL_app_disconnect (app);
182 GNUNET_SCHEDULER_shutdown (); 225 GNUNET_SCHEDULER_shutdown ();
183} 226}
184 227
@@ -295,58 +338,186 @@ host_left ()
295{ 338{
296 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 339 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
297 "The host has left the place.\n"); 340 "The host has left the place.\n");
298 GNUNET_SOCIAL_slicer_destroy (host_slicer); 341 end ();
299 host_slicer = NULL; 342}
343
344
345static void
346schedule_host_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
347{
348 test = TEST_HOST_LEAVE;
349 GNUNET_SOCIAL_host_leave (hst, NULL, &host_left, NULL);
300 hst = NULL; 350 hst = NULL;
301 hst_plc = NULL; 351 hst_plc = NULL;
352}
302 353
303 // TODO: GNUNET_SOCIAL_place_listen_start ()
304 354
305 end (); 355static void
356host_farewell2 (void *cls,
357 const struct GNUNET_SOCIAL_Nym *nym,
358 struct GNUNET_ENV_Environment *env)
359{
360 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
361 "Nym left the place again.\n");
362 GNUNET_SCHEDULER_add_now (schedule_host_leave, NULL);
306} 363}
307 364
308 365
309static void 366static void
310schedule_host_leave (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 367host_reconnected (void *cls, int result,
368 const struct GNUNET_CRYPTO_EddsaPublicKey *home_pub_key,
369 uint64_t max_message_id)
311{ 370{
312 test = TEST_HOST_LEAVE; 371 place_pub_key = *home_pub_key;
313 GNUNET_SOCIAL_host_leave (hst, GNUNET_NO, &host_left, NULL); 372 GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash);
373 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
374 "Test #%u: Host reconnected to place %s\n",
375 test, GNUNET_h2s (&place_pub_hash));
376
377 is_host_reconnected = GNUNET_YES;
378 if (GNUNET_YES == is_guest_reconnected)
379 {
380 GNUNET_SCHEDULER_add_now (schedule_guest_leave, NULL);
381 }
314} 382}
315 383
316 384
317static void 385static void
318id_guest_ego_cb2 (void *cls, const struct GNUNET_IDENTITY_Ego *ego) 386guest_reconnected (void *cls, int result, uint64_t max_message_id)
319{ 387{
320 GNUNET_assert (NULL != ego); 388 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
321 guest_ego = ego; 389 "Test #%u: Guest reconnected to place: %d\n",
390 test, result);
391 GNUNET_assert (0 <= result);
322 392
323 guest_enter_by_name (); 393 is_guest_reconnected = GNUNET_YES;
394 if (GNUNET_YES == is_host_reconnected)
395 {
396 GNUNET_SCHEDULER_add_now (schedule_guest_leave, NULL);
397 }
324} 398}
325 399
326 400
327static void 401static void
328host_recv_advertise_result (void *cls, int32_t success, const char *emsg) 402app_recv_host (void *cls,
403 struct GNUNET_SOCIAL_HostConnection *hconn,
404 struct GNUNET_SOCIAL_Ego *ego,
405 const struct GNUNET_CRYPTO_EddsaPublicKey *host_pub_key)
406{
407 struct GNUNET_HashCode host_pub_hash;
408 GNUNET_CRYPTO_hash (host_pub_key, sizeof (*host_pub_key), &host_pub_hash);
409
410 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
411 "Got app host place notification: %s\n",
412 GNUNET_h2s (&host_pub_hash));
413
414 if (test == TEST_RECONNECT)
415 {
416 if (0 == memcmp (&place_pub_key, host_pub_key, sizeof (*host_pub_key)))
417 {
418 hst = GNUNET_SOCIAL_host_enter_reconnect (hconn, host_slicer, host_reconnected,
419 host_answer_door, host_farewell2, NULL);
420 }
421 }
422}
423
424
425static void
426app_recv_guest (void *cls,
427 struct GNUNET_SOCIAL_GuestConnection *gconn,
428 struct GNUNET_SOCIAL_Ego *ego,
429 const struct GNUNET_CRYPTO_EddsaPublicKey *guest_pub_key)
430{
431 struct GNUNET_HashCode guest_pub_hash;
432 GNUNET_CRYPTO_hash (guest_pub_key, sizeof (*guest_pub_key), &guest_pub_hash);
433
434 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
435 "Got app guest place notification: %s\n",
436 GNUNET_h2s (&guest_pub_hash));
437
438 if (test == TEST_RECONNECT)
439 {
440 if (0 == memcmp (&place_pub_key, guest_pub_key, sizeof (*guest_pub_key)))
441 {
442 gst = GNUNET_SOCIAL_guest_enter_reconnect (gconn, guest_slicer,
443 guest_reconnected, NULL);
444 }
445 }
446}
447
448
449static void
450app_recv_ego (void *cls,
451 struct GNUNET_SOCIAL_Ego *ego,
452 const struct GNUNET_CRYPTO_EcdsaPublicKey *ego_pub_key,
453 const char *name)
329{ 454{
330 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 455 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
331 "Test #%u: Advertise result: %d (%s).\n", 456 "Got app ego notification: %p %s %s\n",
332 test, success, emsg); 457 ego, name,
333 GNUNET_assert (GNUNET_YES == success); 458 GNUNET_CRYPTO_ecdsa_public_key_to_string (ego_pub_key));
459
460 if (NULL != strstr (name, host_name) && TEST_HOST_CREATE == test)
461 {
462 host_ego = ego;
463 host_pub_key = *(GNUNET_SOCIAL_ego_get_pub_key (host_ego));
464 GNUNET_assert (TEST_HOST_CREATE == test);
465 host_enter ();
466 }
467 else if (NULL != strstr (name, guest_name))
468 {
469 guest_ego = ego;
470
471 if (TEST_GUEST_CREATE == test)
472 guest_init ();
473 }
474}
475
476
477static void
478schedule_reconnect (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
479{
480 test = TEST_RECONNECT;
334 481
335 GNUNET_assert (GNUNET_YES == guest_pkey_added); 482 GNUNET_SOCIAL_host_disconnect (hst, NULL, NULL);
336 GNUNET_IDENTITY_ego_lookup (cfg, guest_name, id_guest_ego_cb2, NULL); 483 GNUNET_SOCIAL_guest_disconnect (gst, NULL, NULL);
484 hst = NULL;
485 gst = NULL;
486
487 GNUNET_SOCIAL_app_disconnect (app);
488 app = GNUNET_SOCIAL_app_connect (cfg, app_id,
489 app_recv_ego,
490 app_recv_host,
491 app_recv_guest,
492 NULL);
337} 493}
338 494
339 495
340static void 496static void
341host_advertise () 497host_recv_zone_add_place_result (void *cls, int64_t result,
498 const void *data, uint16_t data_size)
342{ 499{
343 test = TEST_HOST_ADVERTISE;
344 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 500 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
345 "Test #%u: Advertising place.\n", test); 501 "Test #%u: Zone add place result: %d (%.*s).\n",
502 test, result, data_size, data);
503 GNUNET_assert (GNUNET_YES == result);
346 504
347 GNUNET_SOCIAL_host_advertise (hst, "home", 1, &this_peer, 505 GNUNET_assert (GNUNET_YES == is_guest_nym_added);
506 guest_enter_by_name ();
507}
508
509
510static void
511zone_add_place ()
512{
513 test = TEST_ZONE_ADD_PLACE;
514 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
515 "Test #%u: Adding place to zone.\n", test);
516
517 GNUNET_SOCIAL_zone_add_place (app, host_ego, "home", "let.me*in!",
518 &place_pub_key, &this_peer, 1, &this_peer,
348 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES), 519 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES),
349 "let.me*in!", host_recv_advertise_result, hst); 520 host_recv_zone_add_place_result, app);
350} 521}
351 522
352 523
@@ -356,12 +527,12 @@ host_farewell (void *cls,
356 struct GNUNET_ENV_Environment *env) 527 struct GNUNET_ENV_Environment *env)
357{ 528{
358 const struct GNUNET_CRYPTO_EcdsaPublicKey * 529 const struct GNUNET_CRYPTO_EcdsaPublicKey *
359 nym_key = GNUNET_SOCIAL_nym_get_key (nym); 530 nym_key = GNUNET_SOCIAL_nym_get_pub_key (nym);
360 531
361 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key); 532 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (nym_key);
362 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 533 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
363 "Farewell: nym %s (%s) has left the place.\n", 534 "Farewell: nym %s (%s) has left the place.\n",
364 GNUNET_h2s (GNUNET_SOCIAL_nym_get_key_hash (nym)), str); 535 GNUNET_h2s (GNUNET_SOCIAL_nym_get_pub_key_hash (nym)), str);
365 GNUNET_free (str); 536 GNUNET_free (str);
366 GNUNET_assert (1 == GNUNET_ENV_environment_get_count (env)); 537 GNUNET_assert (1 == GNUNET_ENV_environment_get_count (env));
367 if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key))) 538 if (0 != memcmp (&guest_pub_key, nym_key, sizeof (*nym_key)))
@@ -372,7 +543,7 @@ host_farewell (void *cls,
372 GNUNET_free (str); 543 GNUNET_free (str);
373 GNUNET_assert (0); 544 GNUNET_assert (0);
374 } 545 }
375 host_advertise (); 546 zone_add_place ();
376} 547}
377 548
378 549
@@ -381,25 +552,24 @@ guest_left (void *cls)
381{ 552{
382 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 553 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
383 "The guest has left the place.\n"); 554 "The guest has left the place.\n");
384 GNUNET_SOCIAL_slicer_destroy (guest_slicer);
385 guest_slicer = NULL;
386 gst = NULL;
387 gst_plc = NULL;
388} 555}
389 556
390 557
391static void 558static void
392guest_leave() 559guest_leave()
393{ 560{
394 test = TEST_GUEST_LEAVE; 561 if (test < TEST_RECONNECT)
562 test = TEST_GUEST_LEAVE;
563 else
564 test = TEST_GUEST_LEAVE2;
395 565
396 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create (); 566 struct GNUNET_ENV_Environment *env = GNUNET_ENV_environment_create ();
397 GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_SET, 567 GNUNET_ENV_environment_add (env, GNUNET_ENV_OP_SET,
398 "_message", DATA2ARG ("Leaving.")); 568 "_message", DATA2ARG ("Leaving."));
399 GNUNET_SOCIAL_guest_leave (gst, GNUNET_NO, env, &guest_left, NULL); 569 GNUNET_SOCIAL_guest_leave (gst, env, &guest_left, NULL);
400 GNUNET_ENV_environment_destroy (env); 570 GNUNET_ENV_environment_destroy (env);
401 571 gst = NULL;
402 /* @todo test keep_active */ 572 gst_plc = NULL;
403} 573}
404 574
405 575
@@ -871,7 +1041,7 @@ guest_recv_entry_decision (void *cls,
871 break; 1041 break;
872 1042
873 case TEST_GUEST_ENTER_BY_NAME: 1043 case TEST_GUEST_ENTER_BY_NAME:
874 GNUNET_SCHEDULER_add_now (schedule_host_leave, NULL); 1044 GNUNET_SCHEDULER_add_now (schedule_reconnect, NULL);
875 break; 1045 break;
876 1046
877 default: 1047 default:
@@ -951,7 +1121,7 @@ guest_enter ()
951 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env, 1121 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env,
952 emsg->data, emsg->data_size); 1122 emsg->data, emsg->data_size);
953 1123
954 gst = GNUNET_SOCIAL_guest_enter (cfg, guest_ego, &place_pub_key, 1124 gst = GNUNET_SOCIAL_guest_enter (app, guest_ego, &place_pub_key,
955 &this_peer, 0, NULL, emsg->msg, guest_slicer, 1125 &this_peer, 0, NULL, emsg->msg, guest_slicer,
956 guest_recv_local_enter, 1126 guest_recv_local_enter,
957 guest_recv_entry_decision, NULL); 1127 guest_recv_entry_decision, NULL);
@@ -979,7 +1149,7 @@ guest_enter_by_name ()
979 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env, 1149 emsg->msg = GNUNET_PSYC_message_create (emsg->method_name, emsg->env,
980 emsg->data, emsg->data_size); 1150 emsg->data, emsg->data_size);
981 1151
982 gst = GNUNET_SOCIAL_guest_enter_by_name (cfg, guest_ego, 1152 gst = GNUNET_SOCIAL_guest_enter_by_name (app, guest_ego,
983 "home.host.gnu", "let.me*in!", 1153 "home.host.gnu", "let.me*in!",
984 emsg->msg, guest_slicer, 1154 emsg->msg, guest_slicer,
985 guest_recv_local_enter, 1155 guest_recv_local_enter,
@@ -989,19 +1159,18 @@ guest_enter_by_name ()
989 1159
990 1160
991static void 1161static void
992guest_recv_add_pkey_result (void *cls, int32_t success, const char *emsg) 1162app_recv_zone_add_nym_result (void *cls, int64_t result,
1163 const void *data, uint16_t data_size)
993{ 1164{
994 GNUNET_assert (GNUNET_YES == success); 1165 GNUNET_assert (GNUNET_YES == result);
995 guest_pkey_added = GNUNET_YES; 1166 is_guest_nym_added = GNUNET_YES;
996} 1167}
997 1168
998 1169
999static void 1170static void
1000id_guest_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) 1171guest_init ()
1001{ 1172{
1002 GNUNET_assert (NULL != ego); 1173 guest_pub_key = *(GNUNET_SOCIAL_ego_get_pub_key (guest_ego));
1003 guest_ego = ego;
1004 GNUNET_IDENTITY_ego_get_public_key (ego, &guest_pub_key);
1005 1174
1006 guest_slicer = GNUNET_SOCIAL_slicer_create (); 1175 guest_slicer = GNUNET_SOCIAL_slicer_create ();
1007 GNUNET_SOCIAL_slicer_method_add (guest_slicer, "", 1176 GNUNET_SOCIAL_slicer_method_add (guest_slicer, "",
@@ -1011,10 +1180,9 @@ id_guest_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
1011 guest_recv_mod_foo_bar, &mod_foo_bar_rcls); 1180 guest_recv_mod_foo_bar, &mod_foo_bar_rcls);
1012 test = TEST_HOST_ANSWER_DOOR_ADMIT; 1181 test = TEST_HOST_ANSWER_DOOR_ADMIT;
1013 1182
1014 GNUNET_SOCIAL_zone_add_pkey (cfg, guest_ego, "host", &host_pub_key, 1183 GNUNET_SOCIAL_zone_add_nym (app, guest_ego, "host", &host_pub_key,
1015 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES), 1184 GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_MINUTES),
1016 guest_recv_add_pkey_result, NULL); 1185 app_recv_zone_add_nym_result, NULL);
1017
1018 guest_enter (); 1186 guest_enter ();
1019} 1187}
1020 1188
@@ -1030,37 +1198,40 @@ id_guest_created (void *cls, const char *emsg)
1030 GNUNET_assert (0); 1198 GNUNET_assert (0);
1031#endif 1199#endif
1032 } 1200 }
1033 1201 if (NULL != guest_ego)
1034 GNUNET_IDENTITY_ego_lookup (cfg, guest_name, &id_guest_ego_cb, NULL); 1202 guest_init ();
1035} 1203}
1036 1204
1037 1205
1038static void 1206static void
1039host_entered (void *cls, int result, uint64_t max_message_id) 1207host_entered (void *cls, int result,
1208 const struct GNUNET_CRYPTO_EddsaPublicKey *home_pub_key,
1209 uint64_t max_message_id)
1040{ 1210{
1041 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Host entered to place.\n"); 1211 place_pub_key = *home_pub_key;
1212 GNUNET_CRYPTO_hash (&place_pub_key, sizeof (place_pub_key), &place_pub_hash);
1213 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1214 "Host entered to place %s\n", GNUNET_h2s (&place_pub_hash));
1042 1215
1216 test = TEST_GUEST_CREATE;
1043 GNUNET_IDENTITY_create (id, guest_name, &id_guest_created, NULL); 1217 GNUNET_IDENTITY_create (id, guest_name, &id_guest_created, NULL);
1044} 1218}
1045 1219
1046 1220
1047static void 1221static void
1048id_host_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego) 1222host_enter ()
1049{ 1223{
1050 GNUNET_assert (NULL != ego);
1051 host_ego = ego;
1052 GNUNET_IDENTITY_ego_get_public_key (ego, &host_pub_key);
1053
1054 host_slicer = GNUNET_SOCIAL_slicer_create (); 1224 host_slicer = GNUNET_SOCIAL_slicer_create ();
1055 GNUNET_SOCIAL_slicer_method_add (host_slicer, "", 1225 GNUNET_SOCIAL_slicer_method_add (host_slicer, "",
1056 &host_recv_method, &host_recv_modifier, 1226 &host_recv_method, &host_recv_modifier,
1057 &host_recv_data, &host_recv_eom, NULL); 1227 &host_recv_data, &host_recv_eom, NULL);
1058 1228
1059 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n"); 1229 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Entering to place as host.\n");
1060 hst = GNUNET_SOCIAL_host_enter (cfg, host_ego, place_key, 1230 test = TEST_HOST_ENTER;
1061 GNUNET_PSYC_CHANNEL_PRIVATE, host_slicer, 1231 hst = GNUNET_SOCIAL_host_enter (app, host_ego,
1062 host_entered, host_answer_door, 1232 GNUNET_PSYC_CHANNEL_PRIVATE,
1063 host_farewell, NULL); 1233 host_slicer, host_entered,
1234 host_answer_door, host_farewell, NULL);
1064 hst_plc = GNUNET_SOCIAL_host_get_place (hst); 1235 hst_plc = GNUNET_SOCIAL_host_get_place (hst);
1065} 1236}
1066 1237
@@ -1068,6 +1239,12 @@ id_host_ego_cb (void *cls, const struct GNUNET_IDENTITY_Ego *ego)
1068static void 1239static void
1069id_host_created (void *cls, const char *emsg) 1240id_host_created (void *cls, const char *emsg)
1070{ 1241{
1242 if (NULL != core)
1243 {
1244 GNUNET_CORE_disconnect (core);
1245 core = NULL;
1246 }
1247
1071 if (NULL != emsg) 1248 if (NULL != emsg)
1072 { 1249 {
1073 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1250 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -1077,7 +1254,11 @@ id_host_created (void *cls, const char *emsg)
1077#endif 1254#endif
1078 } 1255 }
1079 1256
1080 GNUNET_IDENTITY_ego_lookup (cfg, host_name, &id_host_ego_cb, NULL); 1257 app = GNUNET_SOCIAL_app_connect (cfg, app_id,
1258 app_recv_ego,
1259 app_recv_host,
1260 app_recv_guest,
1261 NULL);
1081} 1262}
1082 1263
1083 1264
@@ -1085,7 +1266,6 @@ static void
1085identity_ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, 1266identity_ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego,
1086 void **ctx, const char *name) 1267 void **ctx, const char *name)
1087{ 1268{
1088
1089} 1269}
1090 1270
1091 1271
@@ -1093,8 +1273,9 @@ static void
1093core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) 1273core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity)
1094{ 1274{
1095 this_peer = *my_identity; 1275 this_peer = *my_identity;
1096
1097 id = GNUNET_IDENTITY_connect (cfg, &identity_ego_cb, NULL); 1276 id = GNUNET_IDENTITY_connect (cfg, &identity_ego_cb, NULL);
1277
1278 test = TEST_HOST_CREATE;
1098 GNUNET_IDENTITY_create (id, host_name, &id_host_created, NULL); 1279 GNUNET_IDENTITY_create (id, host_name, &id_host_created, NULL);
1099} 1280}
1100 1281
@@ -1119,9 +1300,6 @@ run (void *cls,
1119 cfg = c; 1300 cfg = c;
1120 end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); 1301 end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL);
1121 1302
1122 place_key = GNUNET_CRYPTO_eddsa_key_create ();
1123 GNUNET_CRYPTO_eddsa_key_get_public (place_key, &place_pub_key);
1124
1125 core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL, 1303 core = GNUNET_CORE_connect (cfg, NULL, &core_connected, NULL, NULL,
1126 NULL, GNUNET_NO, NULL, GNUNET_NO, NULL); 1304 NULL, GNUNET_NO, NULL, GNUNET_NO, NULL);
1127} 1305}