void *value)
{
struct Place *plc = value;
-
+
cleanup_place (plc);
return GNUNET_YES;
}
cleanup_place (void *cls)
{
struct Place *plc = cls;
-
+
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"%p Cleaning up place %s\n",
plc, GNUNET_h2s (&plc->pub_key_hash));
}
+void
+app_notify_place_end (struct GNUNET_SERVER_Client *client)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "%p Sending end of place list notification to client\n",
+ client);
+
+ struct GNUNET_MessageHeader msg;
+ msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END);
+ msg.size = htons (sizeof (msg));
+
+ client_send_msg (client, &msg);
+}
+
+
void
app_notify_ego (struct Ego *ego, struct GNUNET_SERVER_Client *client)
{
}
+void
+app_notify_ego_end (struct GNUNET_SERVER_Client *client)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "%p Sending end of ego list notification to client\n",
+ client);
+
+ struct GNUNET_MessageHeader msg;
+ msg.type = htons (GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END);
+ msg.size = htons (sizeof (msg));
+
+ client_send_msg (client, &msg);
+}
+
+
int
app_place_entry_notify (void *cls, const struct GNUNET_HashCode *key, void *value)
{
GNUNET_CRYPTO_hash (app_id, app_id_size, &app_id_hash);
GNUNET_CONTAINER_multihashmap_iterate (egos, ego_entry, client);
+ app_notify_ego_end (client);
struct GNUNET_CONTAINER_MultiHashMap *
app_places = GNUNET_CONTAINER_multihashmap_get (apps_places, &app_id_hash);
if (NULL != app_places)
GNUNET_CONTAINER_multihashmap_iterate (app_places, app_place_entry_notify, client);
+ app_notify_place_end (client);
struct ClientListItem *cli = GNUNET_new (struct ClientListItem);
cli->client = client;
GNUNET_SOCIAL_AppEgoCallback ego_cb;
GNUNET_SOCIAL_AppHostPlaceCallback host_cb;
GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb;
+ GNUNET_SOCIAL_AppConnectedCallback connected_cb;
void *cb_cls;
};
}
+static void
+app_recv_ego_end (void *cls,
+ struct GNUNET_CLIENT_MANAGER_Connection *client,
+ const struct GNUNET_MessageHeader *msg)
+{
+ struct GNUNET_SOCIAL_App *
+ app = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (*app));
+}
+
+
static void
app_recv_place (void *cls,
struct GNUNET_CLIENT_MANAGER_Connection *client,
struct GNUNET_SOCIAL_HostConnection *hconn = GNUNET_malloc (sizeof (*hconn));
hconn->app = app;
hconn->plc_msg = *pmsg;
- app->host_cb (app->cb_cls, hconn, ego, &pmsg->place_pub_key, pmsg->place_state);
+ if (NULL != app->host_cb)
+ app->host_cb (app->cb_cls, hconn, ego, &pmsg->place_pub_key, pmsg->place_state);
}
else
{
struct GNUNET_SOCIAL_GuestConnection *gconn = GNUNET_malloc (sizeof (*gconn));
gconn->app = app;
gconn->plc_msg = *pmsg;
- app->guest_cb (app->cb_cls, gconn, ego, &pmsg->place_pub_key, pmsg->place_state);
+ if (NULL != app->guest_cb)
+ app->guest_cb (app->cb_cls, gconn, ego, &pmsg->place_pub_key, pmsg->place_state);
}
}
+static void
+app_recv_place_end (void *cls,
+ struct GNUNET_CLIENT_MANAGER_Connection *client,
+ const struct GNUNET_MessageHeader *msg)
+{
+ struct GNUNET_SOCIAL_App *
+ app = GNUNET_CLIENT_MANAGER_get_user_context_ (client, sizeof (*app));
+
+ if (NULL != app->connected_cb)
+ app->connected_cb (app->cb_cls);
+}
+
+
static struct GNUNET_CLIENT_MANAGER_MessageHandler host_handlers[] =
{
{ host_recv_enter_ack, NULL,
GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO,
sizeof (struct AppEgoMessage), GNUNET_YES },
+ { app_recv_ego_end, NULL,
+ GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END,
+ sizeof (struct GNUNET_MessageHeader), GNUNET_NO },
+
{ app_recv_place, NULL,
GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE,
sizeof (struct AppPlaceMessage), GNUNET_NO },
+ { app_recv_place_end, NULL,
+ GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END,
+ sizeof (struct GNUNET_MessageHeader), GNUNET_NO },
+
{ app_recv_result, NULL,
GNUNET_MESSAGE_TYPE_PSYC_RESULT_CODE,
sizeof (struct GNUNET_OperationResultMessage), GNUNET_YES },
GNUNET_SOCIAL_AppEgoCallback ego_cb,
GNUNET_SOCIAL_AppHostPlaceCallback host_cb,
GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb,
+ GNUNET_SOCIAL_AppConnectedCallback connected_cb,
void *cls)
{
uint16_t app_id_size = strnlen (id, GNUNET_SOCIAL_APP_MAX_ID_SIZE);
app->ego_cb = ego_cb;
app->host_cb = host_cb;
app->guest_cb = guest_cb;
+ app->connected_cb = connected_cb;
app->cb_cls = cls;
app->egos = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_NO);
app->client = GNUNET_CLIENT_MANAGER_connect (cfg, "social",