aboutsummaryrefslogtreecommitdiff
path: root/src/social/social_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/social/social_api.c')
-rw-r--r--src/social/social_api.c113
1 files changed, 9 insertions, 104 deletions
diff --git a/src/social/social_api.c b/src/social/social_api.c
index 8c6629432..73587598b 100644
--- a/src/social/social_api.c
+++ b/src/social/social_api.c
@@ -399,11 +399,6 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc)
399 struct GNUNET_HashCode place_pub_hash; 399 struct GNUNET_HashCode place_pub_hash;
400 400
401 GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); 401 GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash);
402 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
403 "%s place cleanup: %s\n",
404 GNUNET_YES == plc->is_host ? "host" : "guest",
405 GNUNET_h2s (&place_pub_hash));
406
407 if (NULL != plc->tmit) 402 if (NULL != plc->tmit)
408 { 403 {
409 GNUNET_PSYC_transmit_destroy (plc->tmit); 404 GNUNET_PSYC_transmit_destroy (plc->tmit);
@@ -416,8 +411,6 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc)
416 } 411 }
417 if (NULL != plc->mq) 412 if (NULL != plc->mq)
418 { 413 {
419 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
420 "destroying MQ (place_cleanup)\n");
421 GNUNET_MQ_destroy (plc->mq); 414 GNUNET_MQ_destroy (plc->mq);
422 plc->mq = NULL; 415 plc->mq = NULL;
423 } 416 }
@@ -441,9 +434,6 @@ place_disconnect (struct GNUNET_SOCIAL_Place *plc)
441 GNUNET_CRYPTO_hash (&plc->pub_key, 434 GNUNET_CRYPTO_hash (&plc->pub_key,
442 sizeof (plc->pub_key), 435 sizeof (plc->pub_key),
443 &place_pub_hash); 436 &place_pub_hash);
444 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
445 "place_disconnect, plc = %s\n",
446 GNUNET_h2s (&place_pub_hash));
447 place_cleanup (plc); 437 place_cleanup (plc);
448} 438}
449 439
@@ -505,7 +495,7 @@ host_recv_notice_place_leave_method (void *cls,
505 495
506 struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (&msg->slave_pub_key); 496 struct GNUNET_SOCIAL_Nym *nym = nym_get_or_create (&msg->slave_pub_key);
507 497
508 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 498 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
509 "Host received method for message ID %" PRIu64 " from nym %s: %s\n", 499 "Host received method for message ID %" PRIu64 " from nym %s: %s\n",
510 message_id, GNUNET_h2s (&nym->pub_key_hash), method_name); 500 message_id, GNUNET_h2s (&nym->pub_key_hash), method_name);
511 501
@@ -513,7 +503,7 @@ host_recv_notice_place_leave_method (void *cls,
513 hst->notice_place_leave_env = GNUNET_PSYC_env_create (); 503 hst->notice_place_leave_env = GNUNET_PSYC_env_create ();
514 504
515 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); 505 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key);
516 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 506 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
517 "_notice_place_leave: got method from nym %s (%s).\n", 507 "_notice_place_leave: got method from nym %s (%s).\n",
518 GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str); 508 GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str);
519 GNUNET_free (str); 509 GNUNET_free (str);
@@ -535,7 +525,7 @@ host_recv_notice_place_leave_modifier (void *cls,
535 if (NULL == hst->notice_place_leave_env) 525 if (NULL == hst->notice_place_leave_env)
536 return; 526 return;
537 527
538 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 528 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
539 "Host received modifier for _notice_place_leave message with ID %" PRIu64 ":\n" 529 "Host received modifier for _notice_place_leave message with ID %" PRIu64 ":\n"
540 "%c%s: %.*s\n", 530 "%c%s: %.*s\n",
541 message_id, oper, name, value_size, (const char *) value); 531 message_id, oper, name, value_size, (const char *) value);
@@ -562,7 +552,7 @@ host_recv_notice_place_leave_eom (void *cls,
562 return; 552 return;
563 553
564 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key); 554 char *str = GNUNET_CRYPTO_ecdsa_public_key_to_string (&hst->notice_place_leave_nym->pub_key);
565 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 555 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
566 "_notice_place_leave: got EOM from nym %s (%s).\n", 556 "_notice_place_leave: got EOM from nym %s (%s).\n",
567 GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str); 557 GNUNET_h2s (&hst->notice_place_leave_nym->pub_key_hash), str);
568 GNUNET_free (str); 558 GNUNET_free (str);
@@ -895,9 +885,6 @@ handle_host_enter_request (void *cls,
895{ 885{
896 struct GNUNET_SOCIAL_Host *hst = cls; 886 struct GNUNET_SOCIAL_Host *hst = cls;
897 887
898 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
899 "handle_host_enter_request\n");
900
901 if (NULL == hst->answer_door_cb) 888 if (NULL == hst->answer_door_cb)
902 return; 889 return;
903 890
@@ -1108,7 +1095,7 @@ handle_place_leave_ack (void *cls,
1108{ 1095{
1109 struct GNUNET_SOCIAL_Place *plc = cls; 1096 struct GNUNET_SOCIAL_Place *plc = cls;
1110 1097
1111 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 1098 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1112 "%s left place %p\n", 1099 "%s left place %p\n",
1113 plc->is_host ? "host" : "guest", 1100 plc->is_host ? "host" : "guest",
1114 plc); 1101 plc);
@@ -1151,8 +1138,6 @@ host_disconnected (void *cls, enum GNUNET_MQ_Error error)
1151 } 1138 }
1152 if (NULL != plc->mq) 1139 if (NULL != plc->mq)
1153 { 1140 {
1154 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1155 "destroying MQ (host_disconnected)\n");
1156 GNUNET_MQ_destroy (plc->mq); 1141 GNUNET_MQ_destroy (plc->mq);
1157 plc->mq = NULL; 1142 plc->mq = NULL;
1158 } 1143 }
@@ -1599,32 +1584,6 @@ GNUNET_SOCIAL_host_disconnect (struct GNUNET_SOCIAL_Host *hst,
1599 1584
1600 1585
1601/** 1586/**
1602 * Closure for #host_leave_cont.
1603 */
1604struct HostLeaveContext
1605{
1606 struct GNUNET_SOCIAL_Host *hst;
1607 GNUNET_ContinuationCallback disconnect_cb;
1608 void *disconnect_cb_cls;
1609};
1610
1611
1612/**
1613 * FIXME.
1614 */
1615static void
1616host_leave_cont (void *cls)
1617{
1618 struct HostLeaveContext *hlc = cls;
1619
1620 GNUNET_SOCIAL_host_disconnect (hlc->hst,
1621 hlc->disconnect_cb,
1622 hlc->disconnect_cb_cls);
1623 GNUNET_free (hlc);
1624}
1625
1626
1627/**
1628 * Stop hosting the home. 1587 * Stop hosting the home.
1629 * 1588 *
1630 * Sends a _notice_place_closing announcement to the home. 1589 * Sends a _notice_place_closing announcement to the home.
@@ -1649,21 +1608,13 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst,
1649{ 1608{
1650 struct GNUNET_MessageHeader *msg; 1609 struct GNUNET_MessageHeader *msg;
1651 struct GNUNET_MQ_Envelope *envelope; 1610 struct GNUNET_MQ_Envelope *envelope;
1652 struct HostLeaveContext *hlc;
1653 1611
1654 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1655 "GNUNET_SOCIAL_host_leave\n");
1656 GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, 1612 GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL,
1657 GNUNET_SOCIAL_ANNOUNCE_NONE); 1613 GNUNET_SOCIAL_ANNOUNCE_NONE);
1614 hst->plc.disconnect_cb = disconnect_cb;
1615 hst->plc.disconnect_cls = cls;
1658 envelope = GNUNET_MQ_msg (msg, 1616 envelope = GNUNET_MQ_msg (msg,
1659 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); 1617 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
1660 hlc = GNUNET_new (struct HostLeaveContext);
1661 hlc->hst = hst;
1662 hlc->disconnect_cb = disconnect_cb;
1663 hlc->disconnect_cb_cls = cls;
1664 GNUNET_MQ_notify_sent (envelope,
1665 &host_leave_cont,
1666 hlc);
1667 GNUNET_MQ_send (hst->plc.mq, 1618 GNUNET_MQ_send (hst->plc.mq,
1668 envelope); 1619 envelope);
1669} 1620}
@@ -1704,8 +1655,6 @@ guest_disconnected (void *cls, enum GNUNET_MQ_Error error)
1704 } 1655 }
1705 if (NULL != plc->mq) 1656 if (NULL != plc->mq)
1706 { 1657 {
1707 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
1708 "destroying MQ (guest_disconnected)\n");
1709 GNUNET_MQ_destroy (plc->mq); 1658 GNUNET_MQ_destroy (plc->mq);
1710 plc->mq = NULL; 1659 plc->mq = NULL;
1711 } 1660 }
@@ -2091,9 +2040,6 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
2091{ 2040{
2092 struct GNUNET_SOCIAL_Place *plc = &gst->plc; 2041 struct GNUNET_SOCIAL_Place *plc = &gst->plc;
2093 2042
2094 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2095 "GNUNET_SOCIAL_guest_disconnect, gst = %p\n",
2096 gst);
2097 plc->disconnect_cb = disconnect_cb; 2043 plc->disconnect_cb = disconnect_cb;
2098 plc->disconnect_cls = cls; 2044 plc->disconnect_cls = cls;
2099 place_disconnect (plc); 2045 place_disconnect (plc);
@@ -2101,37 +2047,6 @@ GNUNET_SOCIAL_guest_disconnect (struct GNUNET_SOCIAL_Guest *gst,
2101 2047
2102 2048
2103/** 2049/**
2104 * Closure for #leave_done_cont.
2105 */
2106struct LeaveContext
2107{
2108 struct GNUNET_SOCIAL_Guest *gst;
2109 GNUNET_ContinuationCallback disconnect_cb;
2110 void *disconnect_cb_cls;
2111};
2112
2113
2114/**
2115 * The leave message was transmitted, now complete the
2116 * disconnection process.
2117 *
2118 * @param cls a `struct LeaveContext`
2119 */
2120static void
2121leave_done_cont (void *cls)
2122{
2123 struct LeaveContext *lc = cls;
2124
2125 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2126 "social_api: guest's place_leave message sent!\n");
2127 GNUNET_SOCIAL_guest_disconnect (lc->gst,
2128 lc->disconnect_cb,
2129 lc->disconnect_cb_cls);
2130 GNUNET_free (lc);
2131}
2132
2133
2134/**
2135 * Leave a place temporarily or permanently. 2050 * Leave a place temporarily or permanently.
2136 * 2051 *
2137 * Notifies the owner of the place about leaving, and destroys the place handle. 2052 * Notifies the owner of the place about leaving, and destroys the place handle.
@@ -2155,23 +2070,13 @@ GNUNET_SOCIAL_guest_leave (struct GNUNET_SOCIAL_Guest *gst,
2155{ 2070{
2156 struct GNUNET_MessageHeader *msg; 2071 struct GNUNET_MessageHeader *msg;
2157 struct GNUNET_MQ_Envelope *envelope; 2072 struct GNUNET_MQ_Envelope *envelope;
2158 struct LeaveContext *lc;
2159 2073
2160 GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL, 2074 GNUNET_SOCIAL_guest_talk (gst, "_notice_place_leave", env, NULL, NULL,
2161 GNUNET_SOCIAL_TALK_NONE); 2075 GNUNET_SOCIAL_TALK_NONE);
2162 2076 gst->plc.disconnect_cb = disconnect_cb;
2163 2077 gst->plc.disconnect_cls = cls;
2164 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
2165 "social_api: place_leave\n");
2166 envelope = GNUNET_MQ_msg (msg, 2078 envelope = GNUNET_MQ_msg (msg,
2167 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE); 2079 GNUNET_MESSAGE_TYPE_SOCIAL_PLACE_LEAVE);
2168 lc = GNUNET_new (struct LeaveContext);
2169 lc->gst = gst;
2170 lc->disconnect_cb = disconnect_cb;
2171 lc->disconnect_cb_cls = cls;
2172 GNUNET_MQ_notify_sent (envelope,
2173 &leave_done_cont,
2174 lc);
2175 GNUNET_MQ_send (gst->plc.mq, 2080 GNUNET_MQ_send (gst->plc.mq,
2176 envelope); 2081 envelope);
2177} 2082}