/soc/2012/michael/android: 4c9394617363: Added the missing DNS c...

Michael Zangl michael at soc.pidgin.im
Wed Jul 25 16:01:05 EDT 2012


Changeset: 4c9394617363322415573a863624fdfed8a12314
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-07-25 22:00 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/4c9394617363

Description:

Added the missing DNS classes.

diffstat:

 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQuery.java       |  28 ++++++++++
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryWorker.java |  26 +++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)

diffs (64 lines):

diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQuery.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQuery.java
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQuery.java
@@ -0,0 +1,28 @@
+package im.pidgin.libpurple.core.dns;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class DnsQuery {
+
+	private final DnsQueryData data;
+	private final DnsQueryResolvedCallback resolvedCallback;
+	private final DnsQueryFailedCallback failedCallback;
+
+	public DnsQuery(DnsQueryData data,
+			DnsQueryResolvedCallback resolvedCallback,
+			DnsQueryFailedCallback failedCallback) {
+		this.data = data;
+		this.resolvedCallback = resolvedCallback;
+		this.failedCallback = failedCallback;
+	}
+
+	public void execute() {
+		try {
+			InetAddress[] allByName = InetAddress.getAllByName(data.getHost());
+			resolvedCallback.call(allByName);
+		} catch (UnknownHostException e) {
+			failedCallback.call(e.getLocalizedMessage());
+		}
+	}
+}
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryWorker.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryWorker.java
new file mode 100644
--- /dev/null
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryWorker.java
@@ -0,0 +1,26 @@
+package im.pidgin.libpurple.core.dns;
+
+import java.util.concurrent.LinkedBlockingQueue;
+
+public class DnsQueryWorker implements Runnable {
+
+	private final LinkedBlockingQueue<DnsQuery> queries;
+
+	public DnsQueryWorker(LinkedBlockingQueue<DnsQuery> queries) {
+		this.queries = queries;
+	}
+
+	@Override
+	public void run() {
+		while(true) {
+			try {
+				DnsQuery query = queries.take();
+				query.execute();
+			} catch (Throwable e) {
+				// TODO: notify?
+				e.printStackTrace();
+			}
+		}
+	}
+
+}



More information about the Commits mailing list