diff options
Diffstat (limited to 'src/social')
-rw-r--r-- | src/social/gnunet-service-social.c | 16 | ||||
-rw-r--r-- | src/social/social.h | 19 | ||||
-rw-r--r-- | src/social/social_api.c | 43 |
3 files changed, 34 insertions, 44 deletions
diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index c75589811..d297a153b 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c | |||
@@ -467,17 +467,17 @@ client_send_msg (const struct Place *plc, | |||
467 | * Called after a PSYC master is started. | 467 | * Called after a PSYC master is started. |
468 | */ | 468 | */ |
469 | static void | 469 | static void |
470 | psyc_master_started (void *cls, uint64_t max_message_id) | 470 | psyc_master_started (void *cls, int result, uint64_t max_message_id) |
471 | { | 471 | { |
472 | struct Host *hst = cls; | 472 | struct Host *hst = cls; |
473 | struct Place *plc = &hst->plc; | 473 | struct Place *plc = &hst->plc; |
474 | plc->max_message_id = max_message_id; | 474 | plc->max_message_id = max_message_id; |
475 | plc->is_ready = GNUNET_YES; | 475 | plc->is_ready = GNUNET_YES; |
476 | 476 | ||
477 | struct CountersResult res; | 477 | struct GNUNET_PSYC_CountersResultMessage res; |
478 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); | 478 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); |
479 | res.header.size = htons (sizeof (res)); | 479 | res.header.size = htons (sizeof (res)); |
480 | res.result_code = htonl (GNUNET_OK); | 480 | res.result_code = htonl (result - INT32_MIN); |
481 | res.max_message_id = GNUNET_htonll (plc->max_message_id); | 481 | res.max_message_id = GNUNET_htonll (plc->max_message_id); |
482 | 482 | ||
483 | client_send_msg (plc, &res.header); | 483 | client_send_msg (plc, &res.header); |
@@ -507,17 +507,17 @@ psyc_recv_join_request (void *cls, | |||
507 | * Called after a PSYC slave is connected. | 507 | * Called after a PSYC slave is connected. |
508 | */ | 508 | */ |
509 | static void | 509 | static void |
510 | psyc_slave_connected (void *cls, uint64_t max_message_id) | 510 | psyc_slave_connected (void *cls, int result, uint64_t max_message_id) |
511 | { | 511 | { |
512 | struct Guest *gst = cls; | 512 | struct Guest *gst = cls; |
513 | struct Place *plc = &gst->plc; | 513 | struct Place *plc = &gst->plc; |
514 | plc->max_message_id = max_message_id; | 514 | plc->max_message_id = max_message_id; |
515 | plc->is_ready = GNUNET_YES; | 515 | plc->is_ready = GNUNET_YES; |
516 | 516 | ||
517 | struct CountersResult res; | 517 | struct GNUNET_PSYC_CountersResultMessage res; |
518 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); | 518 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); |
519 | res.header.size = htons (sizeof (res)); | 519 | res.header.size = htons (sizeof (res)); |
520 | res.result_code = htonl (GNUNET_OK); | 520 | res.result_code = htonl (result - INT32_MIN); |
521 | res.max_message_id = GNUNET_htonll (plc->max_message_id); | 521 | res.max_message_id = GNUNET_htonll (plc->max_message_id); |
522 | 522 | ||
523 | client_send_msg (plc, &res.header); | 523 | client_send_msg (plc, &res.header); |
@@ -608,7 +608,7 @@ client_recv_host_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
608 | { | 608 | { |
609 | plc = &hst->plc; | 609 | plc = &hst->plc; |
610 | 610 | ||
611 | struct CountersResult res; | 611 | struct GNUNET_PSYC_CountersResultMessage res; |
612 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); | 612 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK); |
613 | res.header.size = htons (sizeof (res)); | 613 | res.header.size = htons (sizeof (res)); |
614 | res.result_code = htonl (GNUNET_OK); | 614 | res.result_code = htonl (GNUNET_OK); |
@@ -724,7 +724,7 @@ client_recv_guest_enter (void *cls, struct GNUNET_SERVER_Client *client, | |||
724 | { | 724 | { |
725 | plc = &gst->plc; | 725 | plc = &gst->plc; |
726 | 726 | ||
727 | struct CountersResult res; | 727 | struct GNUNET_PSYC_CountersResultMessage res; |
728 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); | 728 | res.header.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK); |
729 | res.header.size = htons (sizeof (res)); | 729 | res.header.size = htons (sizeof (res)); |
730 | res.result_code = htonl (GNUNET_OK); | 730 | res.result_code = htonl (GNUNET_OK); |
diff --git a/src/social/social.h b/src/social/social.h index 00edaefd1..5de1e5e80 100644 --- a/src/social/social.h +++ b/src/social/social.h | |||
@@ -88,25 +88,6 @@ struct GuestEnterRequest | |||
88 | /**** service -> library ****/ | 88 | /**** service -> library ****/ |
89 | 89 | ||
90 | 90 | ||
91 | struct CountersResult | ||
92 | { | ||
93 | /** | ||
94 | * Type: GNUNET_MESSAGE_TYPE_PSYC_RESULT_COUNTERS | ||
95 | */ | ||
96 | struct GNUNET_MessageHeader header; | ||
97 | |||
98 | /** | ||
99 | * Status code for the operation. | ||
100 | */ | ||
101 | int32_t result_code GNUNET_PACKED; | ||
102 | |||
103 | /** | ||
104 | * Last message ID sent to the channel. | ||
105 | */ | ||
106 | uint64_t max_message_id; | ||
107 | }; | ||
108 | |||
109 | |||
110 | #if REMOVE | 91 | #if REMOVE |
111 | struct NymEnterRequest | 92 | struct NymEnterRequest |
112 | { | 93 | { |
diff --git a/src/social/social_api.c b/src/social/social_api.c index 76fd0f9f9..dfcf18883 100644 --- a/src/social/social_api.c +++ b/src/social/social_api.c | |||
@@ -640,8 +640,9 @@ host_recv_enter_ack (void *cls, | |||
640 | 640 | ||
641 | struct GNUNET_PSYC_CountersResultMessage * | 641 | struct GNUNET_PSYC_CountersResultMessage * |
642 | cres = (struct GNUNET_PSYC_CountersResultMessage *) msg; | 642 | cres = (struct GNUNET_PSYC_CountersResultMessage *) msg; |
643 | int32_t result = ntohl (cres->result_code) + INT32_MIN; | ||
643 | if (NULL != hst->enter_cb) | 644 | if (NULL != hst->enter_cb) |
644 | hst->enter_cb (hst->cb_cls, GNUNET_ntohll (cres->max_message_id)); | 645 | hst->enter_cb (hst->cb_cls, result, GNUNET_ntohll (cres->max_message_id)); |
645 | } | 646 | } |
646 | 647 | ||
647 | 648 | ||
@@ -704,9 +705,9 @@ guest_recv_enter_ack (void *cls, | |||
704 | 705 | ||
705 | struct GNUNET_PSYC_CountersResultMessage * | 706 | struct GNUNET_PSYC_CountersResultMessage * |
706 | cres = (struct GNUNET_PSYC_CountersResultMessage *) msg; | 707 | cres = (struct GNUNET_PSYC_CountersResultMessage *) msg; |
708 | int32_t result = ntohl (cres->result_code) + INT32_MIN; | ||
707 | if (NULL != gst->enter_cb) | 709 | if (NULL != gst->enter_cb) |
708 | gst->enter_cb (gst->cb_cls, ntohl (cres->result_code), | 710 | gst->enter_cb (gst->cb_cls, result, GNUNET_ntohll (cres->max_message_id)); |
709 | GNUNET_ntohll (cres->max_message_id)); | ||
710 | } | 711 | } |
711 | 712 | ||
712 | 713 | ||
@@ -734,7 +735,7 @@ static struct GNUNET_CLIENT_MANAGER_MessageHandler host_handlers[] = | |||
734 | { | 735 | { |
735 | { &host_recv_enter_ack, NULL, | 736 | { &host_recv_enter_ack, NULL, |
736 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK, | 737 | GNUNET_MESSAGE_TYPE_SOCIAL_HOST_ENTER_ACK, |
737 | sizeof (struct CountersResult), GNUNET_NO }, | 738 | sizeof (struct GNUNET_PSYC_CountersResultMessage), GNUNET_NO }, |
738 | 739 | ||
739 | { &host_recv_enter_request, NULL, | 740 | { &host_recv_enter_request, NULL, |
740 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, | 741 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, |
@@ -758,7 +759,7 @@ static struct GNUNET_CLIENT_MANAGER_MessageHandler guest_handlers[] = | |||
758 | { | 759 | { |
759 | { &guest_recv_enter_ack, NULL, | 760 | { &guest_recv_enter_ack, NULL, |
760 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK, | 761 | GNUNET_MESSAGE_TYPE_SOCIAL_GUEST_ENTER_ACK, |
761 | sizeof (struct CountersResult), GNUNET_NO }, | 762 | sizeof (struct GNUNET_PSYC_CountersResultMessage), GNUNET_NO }, |
762 | 763 | ||
763 | { &host_recv_enter_request, NULL, | 764 | { &host_recv_enter_request, NULL, |
764 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, | 765 | GNUNET_MESSAGE_TYPE_PSYC_JOIN_REQUEST, |
@@ -1598,18 +1599,22 @@ struct GNUNET_SOCIAL_WatchHandle; | |||
1598 | /** | 1599 | /** |
1599 | * Watch a place for changed objects. | 1600 | * Watch a place for changed objects. |
1600 | * | 1601 | * |
1601 | * @param place Place to watch. | 1602 | * @param place |
1602 | * @param object_filter Object prefix to match. | 1603 | * Place to watch. |
1603 | * @param state_cb Function to call when an object/state changes. | 1604 | * @param object_filter |
1604 | * @param state_cb_cls Closure for callback. | 1605 | * Object prefix to match. |
1606 | * @param state_var_cb | ||
1607 | * Function to call when an object/state var changes. | ||
1608 | * @param cls | ||
1609 | * Closure for callback. | ||
1605 | * | 1610 | * |
1606 | * @return Handle that can be used to cancel watching. | 1611 | * @return Handle that can be used to cancel watching. |
1607 | */ | 1612 | */ |
1608 | struct GNUNET_SOCIAL_WatchHandle * | 1613 | struct GNUNET_SOCIAL_WatchHandle * |
1609 | GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place, | 1614 | GNUNET_SOCIAL_place_watch (struct GNUNET_SOCIAL_Place *place, |
1610 | const char *object_filter, | 1615 | const char *object_filter, |
1611 | GNUNET_PSYC_StateCallback state_cb, | 1616 | GNUNET_PSYC_StateVarCallback state_var_cb, |
1612 | void *state_cb_cls) | 1617 | void *cls) |
1613 | { | 1618 | { |
1614 | return NULL; | 1619 | return NULL; |
1615 | } | 1620 | } |
@@ -1633,18 +1638,22 @@ struct GNUNET_SOCIAL_LookHandle; | |||
1633 | /** | 1638 | /** |
1634 | * Look at objects in the place with a matching name prefix. | 1639 | * Look at objects in the place with a matching name prefix. |
1635 | * | 1640 | * |
1636 | * @param place The place to look its objects at. | 1641 | * @param place |
1637 | * @param name_prefix Look at objects with names beginning with this value. | 1642 | * The place to look its objects at. |
1638 | * @param state_cb Function to call for each object found. | 1643 | * @param name_prefix |
1639 | * @param state_cb_cls Closure for callback function. | 1644 | * Look at objects with names beginning with this value. |
1645 | * @param state_var_cb | ||
1646 | * Function to call for each object found. | ||
1647 | * @param cls | ||
1648 | * Closure for callback function. | ||
1640 | * | 1649 | * |
1641 | * @return Handle that can be used to stop looking at objects. | 1650 | * @return Handle that can be used to stop looking at objects. |
1642 | */ | 1651 | */ |
1643 | struct GNUNET_SOCIAL_LookHandle * | 1652 | struct GNUNET_SOCIAL_LookHandle * |
1644 | GNUNET_SOCIAL_place_look (struct GNUNET_SOCIAL_Place *place, | 1653 | GNUNET_SOCIAL_place_look (struct GNUNET_SOCIAL_Place *place, |
1645 | const char *name_prefix, | 1654 | const char *name_prefix, |
1646 | GNUNET_PSYC_StateCallback state_cb, | 1655 | GNUNET_PSYC_StateVarCallback state_var_cb, |
1647 | void *state_cb_cls) | 1656 | void *cls) |
1648 | { | 1657 | { |
1649 | return NULL; | 1658 | return NULL; |
1650 | } | 1659 | } |