diff options
author | lurchi <lurchi@strangeplace.net> | 2017-10-13 19:25:45 +0200 |
---|---|---|
committer | lurchi <lurchi@strangeplace.net> | 2017-10-13 19:25:45 +0200 |
commit | 6d067bc953382bc09712810604747b3ea37b97ec (patch) | |
tree | 92ad9ee6e54f2001678d40a4aa3e093030be5677 /src/social/gnunet-service-social.c | |
parent | 56ddece0edfd7d5a6fa01bc1eb2a51dd8c317ee8 (diff) | |
download | gnunet-6d067bc953382bc09712810604747b3ea37b97ec.tar.gz gnunet-6d067bc953382bc09712810604747b3ea37b97ec.zip |
trying to fix test_social and social service with a lot of debug outputs
Diffstat (limited to 'src/social/gnunet-service-social.c')
-rw-r--r-- | src/social/gnunet-service-social.c | 370 |
1 files changed, 214 insertions, 156 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index dee68fdb8..30e113f18 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -96,7 +96,7 @@ static struct GNUNET_CONTAINER_MultiHashMap *apps_places; | |||
96 | * Application subscriptions per place. | 96 | * Application subscriptions per place. |
97 | * H(place_pub_key) -> H(app_id) | 97 | * H(place_pub_key) -> H(app_id) |
98 | */ | 98 | */ |
99 | static struct GNUNET_CONTAINER_MultiHashMap *places_apps; | 99 | //static struct GNUNET_CONTAINER_MultiHashMap *places_apps; |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * Connected applications. | 102 | * Connected applications. |
@@ -501,6 +501,9 @@ cleanup_host (struct Host *hst) | |||
501 | static void | 501 | static void |
502 | cleanup_guest (struct Guest *gst) | 502 | cleanup_guest (struct Guest *gst) |
503 | { | 503 | { |
504 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
505 | "cleanup_guest, gst = %p\n", | ||
506 | gst); | ||
504 | struct Place *plc = &gst->place; | 507 | struct Place *plc = &gst->place; |
505 | struct GNUNET_CONTAINER_MultiHashMap * | 508 | struct GNUNET_CONTAINER_MultiHashMap * |
506 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, | 509 | plc_gst = GNUNET_CONTAINER_multihashmap_get (place_guests, |
@@ -536,7 +539,7 @@ cleanup_place (void *cls) | |||
536 | { | 539 | { |
537 | struct Place *plc = cls; | 540 | struct Place *plc = cls; |
538 | 541 | ||
539 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 542 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
540 | "%p Cleaning up place %s\n", | 543 | "%p Cleaning up place %s\n", |
541 | plc, GNUNET_h2s (&plc->pub_key_hash)); | 544 | plc, GNUNET_h2s (&plc->pub_key_hash)); |
542 | 545 | ||
@@ -1173,7 +1176,11 @@ app_place_add (const char *app_id, | |||
1173 | return GNUNET_NO; | 1176 | return GNUNET_NO; |
1174 | 1177 | ||
1175 | if (GNUNET_SYSERR == place_add (ereq)) | 1178 | if (GNUNET_SYSERR == place_add (ereq)) |
1179 | { | ||
1180 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1181 | "could not add place\n"); | ||
1176 | return GNUNET_SYSERR; | 1182 | return GNUNET_SYSERR; |
1183 | } | ||
1177 | 1184 | ||
1178 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, NULL, | 1185 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (app_places, &ego_place_pub_hash, NULL, |
1179 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | 1186 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) |
@@ -1182,30 +1189,30 @@ app_place_add (const char *app_id, | |||
1182 | return GNUNET_SYSERR; | 1189 | return GNUNET_SYSERR; |
1183 | } | 1190 | } |
1184 | 1191 | ||
1185 | struct GNUNET_HashCode place_pub_hash; | 1192 | //struct GNUNET_HashCode place_pub_hash; |
1186 | GNUNET_CRYPTO_hash (&ereq->place_pub_key, sizeof (ereq->place_pub_key), &place_pub_hash); | 1193 | //GNUNET_CRYPTO_hash (&ereq->place_pub_key, sizeof (ereq->place_pub_key), &place_pub_hash); |
1187 | 1194 | ||
1188 | struct GNUNET_CONTAINER_MultiHashMap * | 1195 | //struct GNUNET_CONTAINER_MultiHashMap * |
1189 | place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); | 1196 | // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); |
1190 | if (NULL == place_apps) | 1197 | //if (NULL == place_apps) |
1191 | { | 1198 | //{ |
1192 | place_apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 1199 | // place_apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
1193 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places_apps, &place_pub_hash, place_apps, | 1200 | // if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (places_apps, &place_pub_hash, place_apps, |
1194 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) | 1201 | // GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST)) |
1195 | { | 1202 | // { |
1196 | GNUNET_break (0); | 1203 | // GNUNET_break (0); |
1197 | } | 1204 | // } |
1198 | } | 1205 | //} |
1199 | 1206 | ||
1200 | size_t app_id_size = strlen (app_id) + 1; | 1207 | //size_t app_id_size = strlen (app_id) + 1; |
1201 | void *app_id_value = GNUNET_malloc (app_id_size); | 1208 | //void *app_id_value = GNUNET_malloc (app_id_size); |
1202 | GNUNET_memcpy (app_id_value, app_id, app_id_size); | 1209 | //GNUNET_memcpy (app_id_value, app_id, app_id_size); |
1203 | 1210 | ||
1204 | if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (place_apps, &app_id_hash, app_id_value, | 1211 | //if (GNUNET_OK != GNUNET_CONTAINER_multihashmap_put (place_apps, &app_id_hash, app_id_value, |
1205 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | 1212 | // GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) |
1206 | { | 1213 | //{ |
1207 | GNUNET_break (0); | 1214 | // GNUNET_break (0); |
1208 | } | 1215 | //} |
1209 | 1216 | ||
1210 | return GNUNET_OK; | 1217 | return GNUNET_OK; |
1211 | } | 1218 | } |
@@ -1223,7 +1230,10 @@ static int | |||
1223 | app_place_save (const char *app_id, | 1230 | app_place_save (const char *app_id, |
1224 | const struct PlaceEnterRequest *ereq) | 1231 | const struct PlaceEnterRequest *ereq) |
1225 | { | 1232 | { |
1226 | app_place_add (app_id, ereq); | 1233 | if (GNUNET_SYSERR == app_place_add (app_id, ereq)) |
1234 | { | ||
1235 | GNUNET_assert (0); | ||
1236 | } | ||
1227 | 1237 | ||
1228 | if (NULL == dir_places) | 1238 | if (NULL == dir_places) |
1229 | return GNUNET_SYSERR; | 1239 | return GNUNET_SYSERR; |
@@ -1304,17 +1314,17 @@ app_place_remove (const char *app_id, | |||
1304 | if (NULL != app_places) | 1314 | if (NULL != app_places) |
1305 | GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL); | 1315 | GNUNET_CONTAINER_multihashmap_remove (app_places, &place_pub_hash, NULL); |
1306 | 1316 | ||
1307 | struct GNUNET_CONTAINER_MultiHashMap * | 1317 | //struct GNUNET_CONTAINER_MultiHashMap * |
1308 | place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); | 1318 | // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &place_pub_hash); |
1309 | if (NULL != place_apps) | 1319 | //if (NULL != place_apps) |
1310 | { | 1320 | //{ |
1311 | void *app_id_value = GNUNET_CONTAINER_multihashmap_get (place_apps, &app_id_hash); | 1321 | // void *app_id_value = GNUNET_CONTAINER_multihashmap_get (place_apps, &app_id_hash); |
1312 | if (NULL != app_id_value) | 1322 | // if (NULL != app_id_value) |
1313 | { | 1323 | // { |
1314 | GNUNET_CONTAINER_multihashmap_remove (place_apps, &app_id_hash, app_id_value); | 1324 | // GNUNET_CONTAINER_multihashmap_remove (place_apps, &app_id_hash, app_id_value); |
1315 | GNUNET_free (app_id_value); | 1325 | // GNUNET_free (app_id_value); |
1316 | } | 1326 | // } |
1317 | } | 1327 | //} |
1318 | 1328 | ||
1319 | int ret = GNUNET_OK; | 1329 | int ret = GNUNET_OK; |
1320 | 1330 | ||
@@ -1407,6 +1417,120 @@ msg_proc_parse (const struct MsgProcRequest *mpreq, | |||
1407 | } | 1417 | } |
1408 | 1418 | ||
1409 | 1419 | ||
1420 | void | ||
1421 | app_notify_place (const struct GNUNET_MessageHeader *msg, | ||
1422 | struct GNUNET_SERVICE_Client *client) | ||
1423 | { | ||
1424 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1425 | "%p Sending place notification of type %u to client.\n", | ||
1426 | client, ntohs (msg->type)); | ||
1427 | |||
1428 | uint16_t msg_size = ntohs (msg->size); | ||
1429 | struct AppPlaceMessage amsg; | ||
1430 | amsg.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); | ||
1431 | amsg.header.size = htons (sizeof (amsg)); | ||
1432 | // FIXME: also notify about not entered places | ||
1433 | amsg.place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; | ||
1434 | |||
1435 | switch (ntohs (msg->type)) | ||
1436 | { | ||
1437 | case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER: | ||
1438 | if (msg_size < sizeof (struct HostEnterRequest)) | ||
1439 | return; | ||
1440 | struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; | ||
1441 | amsg.is_host = GNUNET_YES; | ||
1442 | amsg.ego_pub_key = hreq->ego_pub_key; | ||
1443 | amsg.place_pub_key = hreq->place_pub_key; | ||
1444 | break; | ||
1445 | |||
1446 | case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER: | ||
1447 | if (msg_size < sizeof (struct GuestEnterRequest)) | ||
1448 | return; | ||
1449 | struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; | ||
1450 | amsg.is_host = GNUNET_NO; | ||
1451 | amsg.ego_pub_key = greq->ego_pub_key; | ||
1452 | amsg.place_pub_key = greq->place_pub_key; | ||
1453 | break; | ||
1454 | |||
1455 | default: | ||
1456 | return; | ||
1457 | } | ||
1458 | |||
1459 | client_send_msg (client, &amsg.header); | ||
1460 | } | ||
1461 | |||
1462 | |||
1463 | void | ||
1464 | app_notify_place_end (struct GNUNET_SERVICE_Client *client) | ||
1465 | { | ||
1466 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1467 | "%p Sending end of place list notification to client\n", | ||
1468 | client); | ||
1469 | |||
1470 | struct GNUNET_MessageHeader msg; | ||
1471 | msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END); | ||
1472 | msg.size = htons (sizeof (msg)); | ||
1473 | |||
1474 | client_send_msg (client, &msg); | ||
1475 | } | ||
1476 | |||
1477 | |||
1478 | void | ||
1479 | app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client) | ||
1480 | { | ||
1481 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1482 | "%p Sending ego notification to client: %s\n", | ||
1483 | client, ego->name); | ||
1484 | |||
1485 | size_t name_size = strlen (ego->name) + 1; | ||
1486 | struct AppEgoMessage *emsg = GNUNET_malloc (sizeof (*emsg) + name_size); | ||
1487 | emsg->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO); | ||
1488 | emsg->header.size = htons (sizeof (*emsg) + name_size); | ||
1489 | |||
1490 | GNUNET_CRYPTO_ecdsa_key_get_public (&ego->key, &emsg->ego_pub_key); | ||
1491 | GNUNET_memcpy (&emsg[1], ego->name, name_size); | ||
1492 | |||
1493 | client_send_msg (client, &emsg->header); | ||
1494 | GNUNET_free (emsg); | ||
1495 | } | ||
1496 | |||
1497 | |||
1498 | void | ||
1499 | app_notify_ego_end (struct GNUNET_SERVICE_Client *client) | ||
1500 | { | ||
1501 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1502 | "%p Sending end of ego list notification to client\n", | ||
1503 | client); | ||
1504 | |||
1505 | struct GNUNET_MessageHeader msg; | ||
1506 | msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END); | ||
1507 | msg.size = htons (sizeof (msg)); | ||
1508 | |||
1509 | client_send_msg (client, &msg); | ||
1510 | } | ||
1511 | |||
1512 | |||
1513 | int | ||
1514 | app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
1515 | { | ||
1516 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1517 | "app_place_entry_notify\n"); | ||
1518 | struct GNUNET_MessageHeader * | ||
1519 | msg = GNUNET_CONTAINER_multihashmap_get (places, key); | ||
1520 | if (NULL != msg) | ||
1521 | app_notify_place (msg, cls); | ||
1522 | return GNUNET_YES; | ||
1523 | } | ||
1524 | |||
1525 | |||
1526 | int | ||
1527 | ego_entry (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
1528 | { | ||
1529 | app_notify_ego (value, cls); | ||
1530 | return GNUNET_YES; | ||
1531 | } | ||
1532 | |||
1533 | |||
1410 | static int | 1534 | static int |
1411 | check_client_msg_proc_set (void *cls, | 1535 | check_client_msg_proc_set (void *cls, |
1412 | const struct MsgProcRequest *mpreq) | 1536 | const struct MsgProcRequest *mpreq) |
@@ -1518,12 +1642,15 @@ static void | |||
1518 | handle_client_host_enter (void *cls, | 1642 | handle_client_host_enter (void *cls, |
1519 | const struct HostEnterRequest *hr) | 1643 | const struct HostEnterRequest *hr) |
1520 | { | 1644 | { |
1521 | struct Client *c = cls; | 1645 | struct Client *c = cls; |
1522 | struct GNUNET_SERVICE_Client *client = c->client; | 1646 | struct GNUNET_SERVICE_Client *client = c->client; |
1523 | 1647 | ||
1524 | struct HostEnterRequest * | 1648 | struct HostEnterRequest * |
1525 | hreq = (struct HostEnterRequest *) GNUNET_copy_message (&hr->header); | 1649 | hreq = (struct HostEnterRequest *) GNUNET_copy_message (&hr->header); |
1526 | 1650 | ||
1651 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1652 | "handle_client_host_enter\n"); | ||
1653 | |||
1527 | uint8_t app_id_size = ntohs (hreq->header.size) - sizeof (*hreq); | 1654 | uint8_t app_id_size = ntohs (hreq->header.size) - sizeof (*hreq); |
1528 | const char *app_id = NULL; | 1655 | const char *app_id = NULL; |
1529 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &hreq[1], | 1656 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &hreq[1], |
@@ -1586,6 +1713,7 @@ handle_client_host_enter (void *cls, | |||
1586 | cli->client = client; | 1713 | cli->client = client; |
1587 | GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); | 1714 | GNUNET_CONTAINER_DLL_insert (plc->clients_head, plc->clients_tail, cli); |
1588 | c->place = plc; | 1715 | c->place = plc; |
1716 | app_notify_place (&hreq->header, client); | ||
1589 | } | 1717 | } |
1590 | 1718 | ||
1591 | GNUNET_CRYPTO_eddsa_key_clear (&hreq->place_key); | 1719 | GNUNET_CRYPTO_eddsa_key_clear (&hreq->place_key); |
@@ -1622,7 +1750,11 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1622 | struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); | 1750 | struct Ego *ego = GNUNET_CONTAINER_multihashmap_get (egos, &ego_pub_hash); |
1623 | 1751 | ||
1624 | if (NULL == ego) | 1752 | if (NULL == ego) |
1753 | { | ||
1754 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1755 | "NULL == ego\n"); | ||
1625 | return GNUNET_SYSERR; | 1756 | return GNUNET_SYSERR; |
1757 | } | ||
1626 | 1758 | ||
1627 | struct GNUNET_HashCode place_pub_hash; | 1759 | struct GNUNET_HashCode place_pub_hash; |
1628 | GNUNET_CRYPTO_hash (&greq->place_pub_key, sizeof (greq->place_pub_key), | 1760 | GNUNET_CRYPTO_hash (&greq->place_pub_key, sizeof (greq->place_pub_key), |
@@ -1635,6 +1767,10 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1635 | if (NULL != plc_gst) | 1767 | if (NULL != plc_gst) |
1636 | gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); | 1768 | gst = GNUNET_CONTAINER_multihashmap_get (plc_gst, &ego_pub_hash); |
1637 | 1769 | ||
1770 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1771 | "guest enter, gst = %p\n", | ||
1772 | gst); | ||
1773 | |||
1638 | if (NULL == gst || NULL == gst->slave) | 1774 | if (NULL == gst || NULL == gst->slave) |
1639 | { | 1775 | { |
1640 | gst = GNUNET_new (struct Guest); | 1776 | gst = GNUNET_new (struct Guest); |
@@ -1672,6 +1808,9 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1672 | struct GNUNET_PSYC_Message *join_msg = NULL; | 1808 | struct GNUNET_PSYC_Message *join_msg = NULL; |
1673 | uint16_t join_msg_size = 0; | 1809 | uint16_t join_msg_size = 0; |
1674 | 1810 | ||
1811 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1812 | "guest_enter 2\n"); | ||
1813 | |||
1675 | if (sizeof (struct GNUNET_MessageHeader) <= remaining) | 1814 | if (sizeof (struct GNUNET_MessageHeader) <= remaining) |
1676 | { | 1815 | { |
1677 | join_msg = (struct GNUNET_PSYC_Message *) p; | 1816 | join_msg = (struct GNUNET_PSYC_Message *) p; |
@@ -1711,10 +1850,15 @@ guest_enter (const struct GuestEnterRequest *greq, struct Guest **ret_gst) | |||
1711 | (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, | 1850 | (void) GNUNET_CONTAINER_multihashmap_put (place_guests, &plc->pub_key_hash, plc_gst, |
1712 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1851 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1713 | } | 1852 | } |
1853 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1854 | "Adding guest %p\n", | ||
1855 | gst); | ||
1714 | (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, | 1856 | (void) GNUNET_CONTAINER_multihashmap_put (plc_gst, &plc->ego_pub_hash, gst, |
1715 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | 1857 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); |
1716 | (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, | 1858 | (void) GNUNET_CONTAINER_multihashmap_put (guests, &plc->pub_key_hash, gst, |
1717 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 1859 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
1860 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1861 | "GNUNET_PSYC_slave_join\n"); | ||
1718 | gst->slave | 1862 | gst->slave |
1719 | = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, | 1863 | = GNUNET_PSYC_slave_join (cfg, &plc->pub_key, &plc->ego_key, |
1720 | gst->join_flags, &gst->origin, | 1864 | gst->join_flags, &gst->origin, |
@@ -1748,9 +1892,14 @@ static void | |||
1748 | handle_client_guest_enter (void *cls, | 1892 | handle_client_guest_enter (void *cls, |
1749 | const struct GuestEnterRequest *greq) | 1893 | const struct GuestEnterRequest *greq) |
1750 | { | 1894 | { |
1895 | // FIXME: this must not be called directly by gns_result_guest_enter because then | ||
1896 | // GNUNET_SERVICE_client_continue is called twice | ||
1751 | struct Client *c = cls; | 1897 | struct Client *c = cls; |
1752 | struct GNUNET_SERVICE_Client *client = c->client; | 1898 | struct GNUNET_SERVICE_Client *client = c->client; |
1753 | 1899 | ||
1900 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
1901 | "handle_client_guest_enter\n"); | ||
1902 | |||
1754 | uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq); | 1903 | uint16_t remaining = ntohs (greq->header.size) - sizeof (*greq); |
1755 | const char *app_id = NULL; | 1904 | const char *app_id = NULL; |
1756 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &greq[1], | 1905 | uint16_t offset = GNUNET_STRINGS_buffer_tokenize ((const char *) &greq[1], |
@@ -1771,6 +1920,7 @@ handle_client_guest_enter (void *cls, | |||
1771 | plc = c->place = &gst->place; | 1920 | plc = c->place = &gst->place; |
1772 | plc->guest = gst; | 1921 | plc->guest = gst; |
1773 | app_place_save (app_id, (const struct PlaceEnterRequest *) greq); | 1922 | app_place_save (app_id, (const struct PlaceEnterRequest *) greq); |
1923 | app_notify_place (&greq->header, client); | ||
1774 | break; | 1924 | break; |
1775 | 1925 | ||
1776 | case GNUNET_NO: | 1926 | case GNUNET_NO: |
@@ -1960,118 +2110,7 @@ handle_client_guest_enter_by_name (void *cls, | |||
1960 | GNUNET_GNSRECORD_TYPE_PLACE, | 2110 | GNUNET_GNSRECORD_TYPE_PLACE, |
1961 | GNUNET_GNS_LO_DEFAULT, | 2111 | GNUNET_GNS_LO_DEFAULT, |
1962 | &gns_result_guest_enter, gcls); | 2112 | &gns_result_guest_enter, gcls); |
1963 | } | 2113 | GNUNET_SERVICE_client_continue (client); |
1964 | |||
1965 | |||
1966 | void | ||
1967 | app_notify_place (struct GNUNET_MessageHeader *msg, | ||
1968 | struct GNUNET_SERVICE_Client *client) | ||
1969 | { | ||
1970 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
1971 | "%p Sending place notification of type %u to client.\n", | ||
1972 | client, ntohs (msg->type)); | ||
1973 | |||
1974 | uint16_t msg_size = ntohs (msg->size); | ||
1975 | struct AppPlaceMessage amsg; | ||
1976 | amsg.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE); | ||
1977 | amsg.header.size = htons (sizeof (amsg)); | ||
1978 | // FIXME: also notify about not entered places | ||
1979 | amsg.place_state = GNUNET_SOCIAL_PLACE_STATE_ENTERED; | ||
1980 | |||
1981 | switch (ntohs (msg->type)) | ||
1982 | { | ||
1983 | case GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER: | ||
1984 | if (msg_size < sizeof (struct HostEnterRequest)) | ||
1985 | return; | ||
1986 | struct HostEnterRequest *hreq = (struct HostEnterRequest *) msg; | ||
1987 | amsg.is_host = GNUNET_YES; | ||
1988 | amsg.ego_pub_key = hreq->ego_pub_key; | ||
1989 | amsg.place_pub_key = hreq->place_pub_key; | ||
1990 | break; | ||
1991 | |||
1992 | case GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER: | ||
1993 | if (msg_size < sizeof (struct GuestEnterRequest)) | ||
1994 | return; | ||
1995 | struct GuestEnterRequest *greq = (struct GuestEnterRequest *) msg; | ||
1996 | amsg.is_host = GNUNET_NO; | ||
1997 | amsg.ego_pub_key = greq->ego_pub_key; | ||
1998 | amsg.place_pub_key = greq->place_pub_key; | ||
1999 | break; | ||
2000 | |||
2001 | default: | ||
2002 | return; | ||
2003 | } | ||
2004 | |||
2005 | client_send_msg (client, &amsg.header); | ||
2006 | } | ||
2007 | |||
2008 | |||
2009 | void | ||
2010 | app_notify_place_end (struct GNUNET_SERVICE_Client *client) | ||
2011 | { | ||
2012 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2013 | "%p Sending end of place list notification to client\n", | ||
2014 | client); | ||
2015 | |||
2016 | struct GNUNET_MessageHeader msg; | ||
2017 | msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END); | ||
2018 | msg.size = htons (sizeof (msg)); | ||
2019 | |||
2020 | client_send_msg (client, &msg); | ||
2021 | } | ||
2022 | |||
2023 | |||
2024 | void | ||
2025 | app_notify_ego (struct Ego *ego, struct GNUNET_SERVICE_Client *client) | ||
2026 | { | ||
2027 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2028 | "%p Sending ego notification to client: %s\n", | ||
2029 | client, ego->name); | ||
2030 | |||
2031 | size_t name_size = strlen (ego->name) + 1; | ||
2032 | struct AppEgoMessage *emsg = GNUNET_malloc (sizeof (*emsg) + name_size); | ||
2033 | emsg->header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO); | ||
2034 | emsg->header.size = htons (sizeof (*emsg) + name_size); | ||
2035 | |||
2036 | GNUNET_CRYPTO_ecdsa_key_get_public (&ego->key, &emsg->ego_pub_key); | ||
2037 | GNUNET_memcpy (&emsg[1], ego->name, name_size); | ||
2038 | |||
2039 | client_send_msg (client, &emsg->header); | ||
2040 | GNUNET_free (emsg); | ||
2041 | } | ||
2042 | |||
2043 | |||
2044 | void | ||
2045 | app_notify_ego_end (struct GNUNET_SERVICE_Client *client) | ||
2046 | { | ||
2047 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2048 | "%p Sending end of ego list notification to client\n", | ||
2049 | client); | ||
2050 | |||
2051 | struct GNUNET_MessageHeader msg; | ||
2052 | msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END); | ||
2053 | msg.size = htons (sizeof (msg)); | ||
2054 | |||
2055 | client_send_msg (client, &msg); | ||
2056 | } | ||
2057 | |||
2058 | |||
2059 | int | ||
2060 | app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
2061 | { | ||
2062 | struct GNUNET_MessageHeader * | ||
2063 | msg = GNUNET_CONTAINER_multihashmap_get (places, key); | ||
2064 | if (NULL != msg) | ||
2065 | app_notify_place (msg, cls); | ||
2066 | return GNUNET_YES; | ||
2067 | } | ||
2068 | |||
2069 | |||
2070 | int | ||
2071 | ego_entry (void *cls, const struct GNUNET_HashCode *key, void *value) | ||
2072 | { | ||
2073 | app_notify_ego (value, cls); | ||
2074 | return GNUNET_YES; | ||
2075 | } | 2114 | } |
2076 | 2115 | ||
2077 | 2116 | ||
@@ -2107,6 +2146,8 @@ handle_client_app_connect (void *cls, | |||
2107 | struct GNUNET_HashCode app_id_hash; | 2146 | struct GNUNET_HashCode app_id_hash; |
2108 | GNUNET_CRYPTO_hash (app_id, app_id_size, &app_id_hash); | 2147 | GNUNET_CRYPTO_hash (app_id, app_id_size, &app_id_hash); |
2109 | 2148 | ||
2149 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2150 | "iterating egos\n"); | ||
2110 | GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client); | 2151 | GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client); |
2111 | app_notify_ego_end (client); | 2152 | app_notify_ego_end (client); |
2112 | 2153 | ||
@@ -2174,6 +2215,10 @@ handle_client_place_leave (void *cls, | |||
2174 | struct Client *c = cls; | 2215 | struct Client *c = cls; |
2175 | struct GNUNET_SERVICE_Client *client = c->client; | 2216 | struct GNUNET_SERVICE_Client *client = c->client; |
2176 | struct Place *plc = c->place; | 2217 | struct Place *plc = c->place; |
2218 | |||
2219 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
2220 | "handle_client_place_leave\n"); | ||
2221 | |||
2177 | if (NULL == plc) | 2222 | if (NULL == plc) |
2178 | { | 2223 | { |
2179 | GNUNET_break (0); | 2224 | GNUNET_break (0); |
@@ -2183,12 +2228,12 @@ handle_client_place_leave (void *cls, | |||
2183 | 2228 | ||
2184 | /* FIXME: remove all app subscriptions and leave this place */ | 2229 | /* FIXME: remove all app subscriptions and leave this place */ |
2185 | 2230 | ||
2186 | struct GNUNET_CONTAINER_MultiHashMap * | 2231 | //struct GNUNET_CONTAINER_MultiHashMap * |
2187 | place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &plc->pub_key_hash); | 2232 | // place_apps = GNUNET_CONTAINER_multihashmap_get (places_apps, &plc->pub_key_hash); |
2188 | if (NULL != place_apps) | 2233 | //if (NULL != place_apps) |
2189 | { | 2234 | //{ |
2190 | GNUNET_CONTAINER_multihashmap_iterate (place_apps, app_places_entry_remove, plc); | 2235 | // GNUNET_CONTAINER_multihashmap_iterate (place_apps, app_places_entry_remove, plc); |
2191 | } | 2236 | //} |
2192 | 2237 | ||
2193 | /* FIXME: disconnect from the network, but keep local connection for history access */ | 2238 | /* FIXME: disconnect from the network, but keep local connection for history access */ |
2194 | 2239 | ||
@@ -2215,6 +2260,7 @@ handle_client_place_leave (void *cls, | |||
2215 | cleanup_place (plc); | 2260 | cleanup_place (plc); |
2216 | } | 2261 | } |
2217 | } | 2262 | } |
2263 | //GNUNET_SERVICE_client_continue (client); | ||
2218 | } | 2264 | } |
2219 | 2265 | ||
2220 | 2266 | ||
@@ -3237,6 +3283,8 @@ namestore_recv_records_store_result (void *cls, int32_t result, | |||
3237 | struct OperationClosure *opcls = cls; | 3283 | struct OperationClosure *opcls = cls; |
3238 | struct Client *c = opcls->client; | 3284 | struct Client *c = opcls->client; |
3239 | 3285 | ||
3286 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3287 | "namestore_recv_records_store_result\n"); | ||
3240 | // FIXME: client might have been disconnected | 3288 | // FIXME: client might have been disconnected |
3241 | client_send_result (c->client, opcls->op_id, result, err_msg, | 3289 | client_send_result (c->client, opcls->op_id, result, err_msg, |
3242 | (NULL != err_msg) ? strlen (err_msg) : 0); | 3290 | (NULL != err_msg) ? strlen (err_msg) : 0); |
@@ -3468,7 +3516,10 @@ file_place_load (void *cls, const char *place_filename) | |||
3468 | return GNUNET_OK; | 3516 | return GNUNET_OK; |
3469 | } | 3517 | } |
3470 | 3518 | ||
3471 | app_place_add (plcls->app_id, ereq); | 3519 | if (GNUNET_SYSERR == app_place_add (plcls->app_id, ereq)) |
3520 | { | ||
3521 | GNUNET_assert (0); | ||
3522 | } | ||
3472 | GNUNET_free (ereq); | 3523 | GNUNET_free (ereq); |
3473 | return GNUNET_OK; | 3524 | return GNUNET_OK; |
3474 | } | 3525 | } |
@@ -3523,6 +3574,10 @@ identity_recv_ego (void *cls, struct GNUNET_IDENTITY_Ego *id_ego, | |||
3523 | if (NULL == id_ego) // end of initial list of egos | 3574 | if (NULL == id_ego) // end of initial list of egos |
3524 | return; | 3575 | return; |
3525 | 3576 | ||
3577 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3578 | "social service received ego %s\n", | ||
3579 | name); | ||
3580 | |||
3526 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key; | 3581 | struct GNUNET_CRYPTO_EcdsaPublicKey ego_pub_key; |
3527 | GNUNET_IDENTITY_ego_get_public_key (id_ego, &ego_pub_key); | 3582 | GNUNET_IDENTITY_ego_get_public_key (id_ego, &ego_pub_key); |
3528 | 3583 | ||
@@ -3571,6 +3626,9 @@ run (void *cls, | |||
3571 | const struct GNUNET_CONFIGURATION_Handle *c, | 3626 | const struct GNUNET_CONFIGURATION_Handle *c, |
3572 | struct GNUNET_SERVICE_Handle *svc) | 3627 | struct GNUNET_SERVICE_Handle *svc) |
3573 | { | 3628 | { |
3629 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
3630 | "starting social service\n"); | ||
3631 | |||
3574 | cfg = c; | 3632 | cfg = c; |
3575 | service = svc; | 3633 | service = svc; |
3576 | GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); | 3634 | GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); |
@@ -3583,7 +3641,7 @@ run (void *cls, | |||
3583 | apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); | 3641 | apps = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO); |
3584 | places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); | 3642 | places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); |
3585 | apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); | 3643 | apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); |
3586 | places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); | 3644 | //places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); |
3587 | 3645 | ||
3588 | id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL); | 3646 | id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL); |
3589 | gns = GNUNET_GNS_connect (cfg); | 3647 | gns = GNUNET_GNS_connect (cfg); |