convert fs publish to MQ
[oweals/gnunet.git] / src / peerinfo-tool / gnunet-peerinfo.c
index 53c2293d8a8e326b91f30678c6eb8ff526eca764..b6aa224fd3ac54e0a0bfc3824886d9da8b0b0cbd 100644 (file)
@@ -1,6 +1,6 @@
 /*
      This file is part of GNUnet.
-     Copyright (C) 2001-2014 Christian Grothoff (and other contributing authors)
+     Copyright (C) 2001-2014 GNUnet e.V.
 
      GNUnet is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published
@@ -32,7 +32,7 @@
 #include "gnunet-peerinfo_plugins.h"
 
 /**
- * How long until we time out during peerinfo iterations?
+ * How long until we time out during address lookup?
  */
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 
@@ -210,7 +210,7 @@ static struct PrintContext *pc_tail;
 /**
  * Handle to current #GNUNET_PEERINFO_add_peer() operation.
  */
-static struct GNUNET_PEERINFO_AddContext *ac;
+static struct GNUNET_MQ_Envelope *ac;
 
 /**
  * Hello of this peer (if initialized).
@@ -223,11 +223,9 @@ static struct GNUNET_HELLO_Message *my_hello;
  * runs the next requested function.
  *
  * @param cls unused
- * @param tc unused
  */
 static void
-state_machine (void *cls,
-              const struct GNUNET_SCHEDULER_TaskContext *tc);
+state_machine (void *cls);
 
 
 /* ********************* 'get_info' ******************* */
@@ -563,17 +561,11 @@ print_my_uri (void *cls,
  * Continuation called from #GNUNET_PEERINFO_add_peer()
  *
  * @param cls closure, NULL
- * @param emsg error message, NULL on success
  */
 static void
-add_continuation (void *cls,
-                 const char *emsg)
+add_continuation (void *cls)
 {
   ac = NULL;
-  if (NULL != emsg)
-    fprintf (stderr,
-            _("Failure adding HELLO: %s\n"),
-            emsg);
   tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
 }
 
@@ -601,7 +593,8 @@ parse_hello_uri (const char *put_uri)
   {
     /* WARNING: this adds the address from URI WITHOUT verification! */
     if (GNUNET_OK == ret)
-      ac = GNUNET_PEERINFO_add_peer (peerinfo, hello,
+      ac = GNUNET_PEERINFO_add_peer (peerinfo,
+                                     hello,
                                      &add_continuation,
                                      NULL);
     else
@@ -620,11 +613,9 @@ parse_hello_uri (const char *put_uri)
  * runs the next requested function.
  *
  * @param cls unused
- * @param tc scheduler context
  */
 static void
-shutdown_task (void *cls,
-              const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
 {
   struct PrintContext *pc;
   struct AddressRecord *ar;
@@ -632,7 +623,7 @@ shutdown_task (void *cls,
 
   if (NULL != ac)
   {
-    GNUNET_PEERINFO_add_peer_cancel (ac);
+    GNUNET_MQ_send_cancel (ac);
     ac = NULL;
   }
   if (NULL != tt)
@@ -761,9 +752,8 @@ testservice_task (void *cls,
   {
     tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL);
   }
-  GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL,
-                                &shutdown_task,
-                                NULL);
+  GNUNET_SCHEDULER_add_shutdown (&shutdown_task,
+                                NULL);
 }
 
 
@@ -809,11 +799,9 @@ run (void *cls,
  * runs the next requested function.
  *
  * @param cls unused
- * @param tc scheduler context
  */
 static void
-state_machine (void *cls,
-              const struct GNUNET_SCHEDULER_TaskContext *tc)
+state_machine (void *cls)
 {
   tt = NULL;
 
@@ -837,7 +825,6 @@ state_machine (void *cls,
     pic = GNUNET_PEERINFO_iterate (peerinfo,
                                    include_friend_only,
                                    NULL,
-                                  TIMEOUT,
                                   &print_peer_info, NULL);
   }
   else if (GNUNET_YES == get_self)
@@ -857,7 +844,6 @@ state_machine (void *cls,
     pic = GNUNET_PEERINFO_iterate (peerinfo,
                                    include_friend_only,
                                    &my_peer_identity,
-                                  TIMEOUT,
                                    &print_my_uri, NULL);
     get_uri = GNUNET_NO;
   }