X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=src%2Fsocial%2Fsocial_api.c;h=89843831be02164972b6c04c6877066d88156391;hb=0120859e1ea2f0591602f446d4bc054e9230c801;hp=db2a596744703650f02a9482fa6a62d9938126ca;hpb=525a60f69f4b95ef8055f1b17ec40e0a066553aa;p=oweals%2Fgnunet.git diff --git a/src/social/social_api.c b/src/social/social_api.c index db2a59674..89843831b 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c @@ -397,12 +397,9 @@ guest_cleanup (struct GNUNET_SOCIAL_Guest *gst) static void place_cleanup (struct GNUNET_SOCIAL_Place *plc) { - struct GNUNET_HashCode place_pub_hash; - - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "place_cleanup\n"); - - GNUNET_CRYPTO_hash (&plc->pub_key, sizeof (plc->pub_key), &place_pub_hash); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "cleaning up place %p\n", + plc); if (NULL != plc->tmit) { GNUNET_PSYC_transmit_destroy (plc->tmit); @@ -433,11 +430,6 @@ place_cleanup (struct GNUNET_SOCIAL_Place *plc) static void place_disconnect (struct GNUNET_SOCIAL_Place *plc) { - struct GNUNET_HashCode place_pub_hash; - - GNUNET_CRYPTO_hash (&plc->pub_key, - sizeof (plc->pub_key), - &place_pub_hash); place_cleanup (plc); } @@ -1515,8 +1507,9 @@ GNUNET_SOCIAL_host_announce (struct GNUNET_SOCIAL_Host *hst, void *notify_data_cls, enum GNUNET_SOCIAL_AnnounceFlags flags) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "PSYC_transmit_message for host\n"); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "PSYC_transmit_message for host, method: %s\n", + method_name); if (GNUNET_OK == GNUNET_PSYC_transmit_message (hst->plc.tmit, method_name, env, NULL, notify_data, notify_data_cls, flags)) @@ -1614,8 +1607,6 @@ GNUNET_SOCIAL_host_leave (struct GNUNET_SOCIAL_Host *hst, { struct GNUNET_MQ_Envelope *envelope; - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "sending _notice_place_closing\n"); GNUNET_SOCIAL_host_announce (hst, "_notice_place_closing", env, NULL, NULL, GNUNET_SOCIAL_ANNOUNCE_NONE); hst->plc.disconnect_cb = disconnect_cb; @@ -1912,6 +1903,64 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, } +struct ReconnectContext +{ + struct GNUNET_SOCIAL_Guest *guest; + int *result; + int64_t *max_message_id; + GNUNET_SOCIAL_GuestEnterCallback enter_cb; + void *enter_cls; +}; + + +static void +guest_enter_reconnect_cb (void *cls, + int result, + const struct GNUNET_CRYPTO_EddsaPublicKey *place_pub_key, + uint64_t max_message_id) +{ + struct ReconnectContext *reconnect_ctx = cls; + + GNUNET_assert (NULL != reconnect_ctx); + reconnect_ctx->result = GNUNET_new (int); + *(reconnect_ctx->result) = result; + reconnect_ctx->max_message_id = GNUNET_new (int64_t); + *(reconnect_ctx->max_message_id) = max_message_id; +} + + +static void +guest_entry_dcsn_reconnect_cb (void *cls, + int is_admitted, + const struct GNUNET_PSYC_Message *entry_resp) +{ + struct ReconnectContext *reconnect_ctx = cls; + struct GNUNET_SOCIAL_Guest *gst = reconnect_ctx->guest; + + GNUNET_assert (NULL != reconnect_ctx); + GNUNET_assert (NULL != reconnect_ctx->result); + GNUNET_assert (NULL != reconnect_ctx->max_message_id); + if (GNUNET_YES != is_admitted) + { + GNUNET_log (GNUNET_ERROR_TYPE_ERROR, + "Guest was rejected after calling " + "GNUNET_SOCIAL_guest_enter_reconnect ()\n"); + } + else if (NULL != reconnect_ctx->enter_cb) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "guest reconnected!\n"); + reconnect_ctx->enter_cb (reconnect_ctx->enter_cls, + *(reconnect_ctx->result), + &gst->plc.pub_key, + *(reconnect_ctx->max_message_id)); + } + GNUNET_free (reconnect_ctx->result); + GNUNET_free (reconnect_ctx->max_message_id); + GNUNET_free (reconnect_ctx); +} + + /** * Reconnect to an already entered place as guest. * @@ -1922,8 +1971,8 @@ GNUNET_SOCIAL_guest_enter_by_name (const struct GNUNET_SOCIAL_App *app, * Flags for the entry. * @param slicer * Slicer to use for processing incoming requests from guests. - * @param local_enter_cb - * Called upon connection established to the social service. + * @param enter_cb + * Called upon re-entering is complete. * @param entry_decision_cb * Called upon receiving entry decision. * @@ -1933,11 +1982,12 @@ struct GNUNET_SOCIAL_Guest * GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn, enum GNUNET_PSYC_SlaveJoinFlags flags, struct GNUNET_PSYC_Slicer *slicer, - GNUNET_SOCIAL_GuestEnterCallback local_enter_cb, + GNUNET_SOCIAL_GuestEnterCallback enter_cb, void *cls) { struct GNUNET_SOCIAL_Guest *gst = GNUNET_malloc (sizeof (*gst)); struct GNUNET_SOCIAL_Place *plc = &gst->plc; + struct ReconnectContext *reconnect_ctx; uint16_t app_id_size = strlen (gconn->app->id) + 1; struct GuestEnterRequest *greq; @@ -1956,10 +2006,15 @@ GNUNET_SOCIAL_guest_enter_reconnect (struct GNUNET_SOCIAL_GuestConnection *gconn plc->pub_key = gconn->plc_msg.place_pub_key; plc->ego_pub_key = gconn->plc_msg.ego_pub_key; - plc->op = GNUNET_OP_create (); + reconnect_ctx = GNUNET_new (struct ReconnectContext); + reconnect_ctx->guest = gst; + reconnect_ctx->enter_cb = enter_cb; + reconnect_ctx->enter_cls = cls; - gst->enter_cb = local_enter_cb; - gst->cb_cls = cls; + plc->op = GNUNET_OP_create (); + gst->enter_cb = &guest_enter_reconnect_cb; + gst->entry_dcsn_cb = &guest_entry_dcsn_reconnect_cb; + gst->cb_cls = reconnect_ctx; guest_connect (gst); return gst; @@ -1993,9 +2048,6 @@ GNUNET_SOCIAL_guest_talk (struct GNUNET_SOCIAL_Guest *gst, void *notify_data_cls, enum GNUNET_SOCIAL_TalkFlags flags) { - GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - "PSYC_transmit_message for guest\n"); - struct GNUNET_SOCIAL_Place *plc = &gst->plc; GNUNET_assert (NULL != plc->tmit); @@ -2721,6 +2773,8 @@ GNUNET_SOCIAL_app_disconnect (struct GNUNET_SOCIAL_App *app, GNUNET_ContinuationCallback disconnect_cb, void *disconnect_cls) { + if (NULL == app) return; + app->disconnect_cb = disconnect_cb; app->disconnect_cls = disconnect_cls;