gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r37130 - in gnunet/src: include social


From: gnunet
Subject: [GNUnet-SVN] r37130 - in gnunet/src: include social
Date: Thu, 5 May 2016 13:33:41 +0200

Author: tg
Date: 2016-05-05 13:33:40 +0200 (Thu, 05 May 2016)
New Revision: 37130

Modified:
   gnunet/src/include/gnunet_protocols.h
   gnunet/src/include/gnunet_social_service.h
   gnunet/src/social/gnunet-service-social.c
   gnunet/src/social/social_api.c
   gnunet/src/social/test_social.c
Log:
social: app connected callback

Modified: gnunet/src/include/gnunet_protocols.h
===================================================================
--- gnunet/src/include/gnunet_protocols.h       2016-05-05 10:35:48 UTC (rev 
37129)
+++ gnunet/src/include/gnunet_protocols.h       2016-05-05 11:33:40 UTC (rev 
37130)
@@ -2643,9 +2643,15 @@
 /** S->C: notify about an existing ego */
 #define GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO 853
 
+/** S->C: end of ego list */
+#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_EGO_END 854
+
 /** S->C: notify about an existing place */
-#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE 854
+#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE 855
 
+/** S->C: end of place list */
+#define GNUNET_MESSAGE_TYPE_SOCIAL_APP_PLACE_END 856
+
 /** C->S: set message processing flags */
 #define GNUNET_MESSAGE_TYPE_SOCIAL_MSG_PROC_SET 860
 

Modified: gnunet/src/include/gnunet_social_service.h
===================================================================
--- gnunet/src/include/gnunet_social_service.h  2016-05-05 10:35:48 UTC (rev 
37129)
+++ gnunet/src/include/gnunet_social_service.h  2016-05-05 11:33:40 UTC (rev 
37130)
@@ -334,6 +334,13 @@
 
 
 /**
+ * Called after receiving initial list of egos and places.
+ */
+typedef void
+(*GNUNET_SOCIAL_AppConnectedCallback) (void *cls);
+
+
+/**
  * Notification about a home.
  *
  * @param cls
@@ -402,6 +409,7 @@
                            GNUNET_SOCIAL_AppEgoCallback ego_cb,
                            GNUNET_SOCIAL_AppHostPlaceCallback host_cb,
                            GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb,
+                           GNUNET_SOCIAL_AppConnectedCallback connected_cb,
                            void *cls);
 
 

Modified: gnunet/src/social/gnunet-service-social.c
===================================================================
--- gnunet/src/social/gnunet-service-social.c   2016-05-05 10:35:48 UTC (rev 
37129)
+++ gnunet/src/social/gnunet-service-social.c   2016-05-05 11:33:40 UTC (rev 
37130)
@@ -432,7 +432,7 @@
                      void *value)
 {
   struct Place *plc = value;
-  
+
   cleanup_place (plc);
   return GNUNET_YES;
 }
@@ -538,7 +538,7 @@
 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));
@@ -1945,6 +1945,21 @@
 
 
 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)
 {
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1964,6 +1979,21 @@
 }
 
 
+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)
 {
@@ -2008,11 +2038,13 @@
   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;

Modified: gnunet/src/social/social_api.c
===================================================================
--- gnunet/src/social/social_api.c      2016-05-05 10:35:48 UTC (rev 37129)
+++ gnunet/src/social/social_api.c      2016-05-05 11:33:40 UTC (rev 37130)
@@ -102,6 +102,7 @@
   GNUNET_SOCIAL_AppEgoCallback ego_cb;
   GNUNET_SOCIAL_AppHostPlaceCallback host_cb;
   GNUNET_SOCIAL_AppGuestPlaceCallback guest_cb;
+  GNUNET_SOCIAL_AppConnectedCallback connected_cb;
   void *cb_cls;
 };
 
@@ -925,6 +926,16 @@
 
 
 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,
                 const struct GNUNET_MessageHeader *msg)
@@ -955,7 +966,8 @@
     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
   {
@@ -962,11 +974,25 @@
     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,
@@ -1049,10 +1075,18 @@
     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 },
@@ -2426,6 +2460,7 @@
                            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);
@@ -2438,6 +2473,7 @@
   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",

Modified: gnunet/src/social/test_social.c
===================================================================
--- gnunet/src/social/test_social.c     2016-05-05 10:35:48 UTC (rev 37129)
+++ gnunet/src/social/test_social.c     2016-05-05 11:33:40 UTC (rev 37130)
@@ -50,7 +50,7 @@
 /**
  * Handle for task for timeout termination.
  */
-struct GNUNET_SCHEDULER_Task * end_badly_task;
+struct GNUNET_SCHEDULER_Task *end_badly_task;
 
 const struct GNUNET_CONFIGURATION_Handle *cfg;
 
@@ -400,6 +400,14 @@
 
 
 static void
+app_connected (void *cls)
+{
+  GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+              "App connected: %p\n", cls);
+}
+
+
+static void
 app_recv_host (void *cls,
                struct GNUNET_SOCIAL_HostConnection *hconn,
                struct GNUNET_SOCIAL_Ego *ego,
@@ -492,6 +500,7 @@
                                    app_recv_ego,
                                    app_recv_host,
                                    app_recv_guest,
+                                   app_connected,
                                    NULL);
 }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]