/** * Insert a peer in our list */ void NetworkManager::putHelloSlot (QString helloUrl) { struct GNUNET_HELLO_Message *hello = NULL; const char *put_uri = helloUrl.toUtf8().constData(); GNUNET_CRYPTO_EddsaPublicKey mypublickey = theApp->gnunet()->myPeer()->public_key; int ret = GNUNET_HELLO_parse_uri(put_uri, &mypublickey, &hello, &m_gnunetTransportPlugins->GPI_plugins_find); if (NULL != hello) { // WARNING: this adds the address from URI WITHOUT verification! if (GNUNET_OK == ret) GNUNET_PEERINFO_add_peer (m_peerInfo, hello, &add_continuation, NULL); GNUNET_free (hello); } else { qWarning() << tr("Failed to process the url"); } }
/** * Parse the PUT URI given at the command line and add it to our peerinfo * database. * * @param put_uri URI string to parse * @return GNUNET_OK on success, GNUNET_SYSERR if the URI was invalid, GNUNET_NO on other errors */ static int parse_hello_uri (const char *put_uri) { struct GNUNET_HELLO_Message *hello; int ret = GNUNET_HELLO_parse_uri(put_uri, &my_public_key, &hello, &GPI_plugins_find); if (NULL != hello) { /* WARNING: this adds the address from URI WITHOUT verification! */ if (GNUNET_OK == ret) ac = GNUNET_PEERINFO_add_peer (peerinfo, hello, &add_continuation, NULL); else tt = GNUNET_SCHEDULER_add_now (&state_machine, NULL); GNUNET_free (hello); } /* wait 1s to give peerinfo operation a chance to succeed */ /* FIXME: current peerinfo API sucks to require this; not to mention that we get no feedback to determine if the operation actually succeeded */ return ret; }