summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2010-04-23 22:07:28 (GMT)
committerRemko Tronçon <git@el-tramo.be>2010-04-23 22:09:47 (GMT)
commit26c9854be9df706c550c0eec7e64708b5bf5cd81 (patch)
tree5cd595beae075efe70da64a147f5a03264ddbe34 /Swiften
parent839a7abd808cf7901f13bd71d8cb8dc6d101cd9b (diff)
downloadswift-contrib-26c9854be9df706c550c0eec7e64708b5bf5cd81.zip
swift-contrib-26c9854be9df706c550c0eec7e64708b5bf5cd81.tar.bz2
Add beginnings of LinkLocalTool.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Examples/LinkLocalTool/.gitignore1
-rw-r--r--Swiften/Examples/LinkLocalTool/SConscript16
-rw-r--r--Swiften/Examples/LinkLocalTool/main.cpp49
-rw-r--r--Swiften/Examples/SConscript3
-rw-r--r--Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h4
-rw-r--r--Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h2
-rw-r--r--Swiften/LinkLocal/DNSSD/DNSSDServiceID.h2
7 files changed, 72 insertions, 5 deletions
diff --git a/Swiften/Examples/LinkLocalTool/.gitignore b/Swiften/Examples/LinkLocalTool/.gitignore
new file mode 100644
index 0000000..684ef0b
--- /dev/null
+++ b/Swiften/Examples/LinkLocalTool/.gitignore
@@ -0,0 +1 @@
+LinkLocalTool
diff --git a/Swiften/Examples/LinkLocalTool/SConscript b/Swiften/Examples/LinkLocalTool/SConscript
new file mode 100644
index 0000000..0feceae
--- /dev/null
+++ b/Swiften/Examples/LinkLocalTool/SConscript
@@ -0,0 +1,16 @@
+Import("env")
+
+myenv = env.Clone()
+myenv.MergeFlags(myenv["SWIFTEN_FLAGS"])
+myenv.MergeFlags(myenv["LIBIDN_FLAGS"])
+myenv.MergeFlags(myenv["BOOST_FLAGS"])
+myenv.MergeFlags(myenv["SQLITE_FLAGS"])
+myenv.MergeFlags(myenv["ZLIB_FLAGS"])
+myenv.MergeFlags(myenv["OPENSSL_FLAGS"])
+myenv.MergeFlags(myenv.get("LIBXML_FLAGS", {}))
+myenv.MergeFlags(myenv.get("EXPAT_FLAGS", {}))
+myenv.MergeFlags(myenv.get("AVAHI_FLAGS", {}))
+
+linkLocalTool = myenv.Program("LinkLocalTool", [
+ "main.cpp"
+ ])
diff --git a/Swiften/Examples/LinkLocalTool/main.cpp b/Swiften/Examples/LinkLocalTool/main.cpp
new file mode 100644
index 0000000..ccecd1a
--- /dev/null
+++ b/Swiften/Examples/LinkLocalTool/main.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+// FIXME: This example is not complete yet
+
+#include <iostream>
+
+#include "Swiften/EventLoop/SimpleEventLoop.h"
+#include "Swiften/LinkLocal/DNSSD/PlatformDNSSDQuerierFactory.h"
+#include "Swiften/LinkLocal/DNSSD/DNSSDQuerier.h"
+#include "Swiften/LinkLocal/DNSSD/DNSSDBrowseQuery.h"
+#include "Swiften/LinkLocal/DNSSD/DNSSDResolveServiceQuery.h"
+
+using namespace Swift;
+
+int main(int argc, char* argv[]) {
+ if (argc < 2) {
+ std::cerr << "Invalid parameters" << std::endl;
+ return -1;
+ }
+
+ SimpleEventLoop eventLoop;
+ PlatformDNSSDQuerierFactory factory;
+ boost::shared_ptr<DNSSDQuerier> querier = factory.createQuerier();
+ querier->start();
+
+ if (String(argv[1]) == "browse") {
+ boost::shared_ptr<DNSSDBrowseQuery> browseQuery = querier->createBrowseQuery();
+ browseQuery->startBrowsing();
+ eventLoop.run();
+ browseQuery->stopBrowsing();
+ }
+ else if (String(argv[1]) == "resolve-service") {
+ if (argc < 5) {
+ std::cerr << "Invalid parameters" << std::endl;
+ return -1;
+ }
+ boost::shared_ptr<DNSSDResolveServiceQuery> resolveQuery = querier->createResolveServiceQuery(DNSSDServiceID(argv[2], argv[3], argv[4]));
+ resolveQuery->start();
+ eventLoop.run();
+ std::cerr << "Done running" << std::endl;
+ resolveQuery->stop();
+ }
+
+ querier->stop();
+}
diff --git a/Swiften/Examples/SConscript b/Swiften/Examples/SConscript
index 4c9b853..07e4e15 100644
--- a/Swiften/Examples/SConscript
+++ b/Swiften/Examples/SConscript
@@ -5,5 +5,6 @@ myenv = swiften_env.Clone()
if myenv["target"] == "native":
SConscript(dirs = [
"SendMessage",
- "ConnectivityTest"
+ "ConnectivityTest",
+ "LinkLocalTool",
])
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h
index 44a82ee..7b641c5 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiBrowseQuery.h
@@ -53,12 +53,12 @@ namespace Swift {
break;
case AVAHI_BROWSER_NEW: {
DNSSDServiceID service(name, domain, type, interfaceIndex);
- std::cout << "Service discovered " << name << " " << type << " " << domain << " " << interfaceIndex << std::endl;
+ std::cout << "Service discovered " << name << " " << domain << " " << type << " " << interfaceIndex << std::endl;
MainEventLoop::postEvent(boost::bind(boost::ref(onServiceAdded), service), shared_from_this());
break;
}
case AVAHI_BROWSER_REMOVE: {
- std::cout << "Service went away " << name << " " << type << " " << domain << std::endl;
+ std::cout << "Service went away " << name << " " << domain << " " << type << " " << interfaceIndex << std::endl;
DNSSDServiceID service(name, domain, type, interfaceIndex);
MainEventLoop::postEvent(boost::bind(boost::ref(onServiceRemoved), service), shared_from_this());
break;
diff --git a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h
index b173b9a..f86780a 100644
--- a/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h
+++ b/Swiften/LinkLocal/DNSSD/Avahi/AvahiResolveServiceQuery.h
@@ -21,7 +21,7 @@ namespace Swift {
}
void start() {
- std::cout << "Start resolving " << service.getName() << std::endl;
+ std::cout << "Start resolving " << service.getName() << " " << service.getType() << " " << service.getDomain() << std::endl;
avahi_threaded_poll_lock(querier->getThreadedPoll());
assert(!resolver);
resolver = avahi_service_resolver_new(querier->getClient(), service.getNetworkInterfaceID(), AVAHI_PROTO_UNSPEC, service.getName().getUTF8Data(), service.getType().getUTF8Data(), service.getDomain().getUTF8Data(), AVAHI_PROTO_UNSPEC, (AvahiLookupFlags) 0, handleServiceResolvedStatic, this);
diff --git a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h
index 58aafdf..1a720a0 100644
--- a/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h
+++ b/Swiften/LinkLocal/DNSSD/DNSSDServiceID.h
@@ -17,7 +17,7 @@ namespace Swift {
const String& name,
const String& domain,
const String& type = PresenceServiceType,
- int networkInterface = 0) :
+ int networkInterface = -1) :
name(name),
domain(domain),
type(type),