/soc/2012/michael/android: ca24c4479a21: Commented dns classes

Michael Zangl michael at soc.pidgin.im
Mon Aug 20 10:15:53 EDT 2012


Changeset: ca24c4479a210f2427f0600609d56a8fe25a1e0d
Author:	 Michael Zangl <michael at soc.pidgin.im>
Date:	 2012-08-20 15:50 +0200
Branch:	 soc.2012.android
URL: http://hg.pidgin.im/soc/2012/michael/android/rev/ca24c4479a21

Description:

Commented dns classes

diffstat:

 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsExeption.java                        |    7 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQuery.java                           |   25 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryData.java                       |   15 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryResolvedCallback.java           |   10 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryUiOps.java                      |   31 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryWorker.java                     |   13 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsResolver.java                        |  123 ++++++++-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/srvtxt/DnsSrvResolver.java              |   17 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/srvtxt/DnsTxtResolver.java              |   19 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/srvtxt/SrvTxtQuery.java                 |   19 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/srvtxt/SrvTxtQueryData.java             |   24 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/srvtxt/SrvTxtQueryFailedCallback.java   |   11 +
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/srvtxt/SrvTxtQueryResolvedCallback.java |   16 +-
 android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/srvtxt/TxtResponse.java                 |   12 +-
 14 files changed, 284 insertions(+), 58 deletions(-)

diffs (truncated from 739 to 300 lines):

diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsExeption.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsExeption.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsExeption.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsExeption.java
@@ -1,8 +1,13 @@
 package im.pidgin.libpurple.core.dns;
 
+/**
+ * An exception that happened somewhere inside the DNS system.
+ *
+ * @author michael
+ */
 public class DnsExeption extends Exception {
 	/**
-	 * 
+	 *
 	 */
 	private static final long serialVersionUID = 5291599486666218676L;
 
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
--- 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
@@ -3,15 +3,36 @@ package im.pidgin.libpurple.core.dns;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 
+/**
+ * This is a normal DNS Query runner to resolve a host name to an IP address.
+ *
+ * @author michael
+ */
 public class DnsQuery implements Runnable {
 
+	/**
+	 * The data we use for this query.
+	 */
 	private final DnsQueryData data;
+	/**
+	 * A callback to call when we resolved the host.
+	 */
 	private final DnsQueryResolvedCallback resolvedCallback;
+	/**
+	 * A callback to call when we failed.
+	 */
 	private final DnsQueryFailedCallback failedCallback;
 
+	/**
+	 * Creates a new query object.
+	 *
+	 * @param data
+	 * @param resolvedCallback
+	 * @param failedCallback
+	 */
 	public DnsQuery(DnsQueryData data,
-			DnsQueryResolvedCallback resolvedCallback,
-			DnsQueryFailedCallback failedCallback) {
+	        DnsQueryResolvedCallback resolvedCallback,
+	        DnsQueryFailedCallback failedCallback) {
 		this.data = data;
 		this.resolvedCallback = resolvedCallback;
 		this.failedCallback = failedCallback;
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryData.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryData.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryData.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryData.java
@@ -4,8 +4,8 @@ import im.pidgin.libpurple.peering.Peere
 
 /**
  * This is the data of a dns query.
+ *
  * @author michaelz
- *
  */
 public class DnsQueryData extends Peered {
 
@@ -16,21 +16,26 @@ public class DnsQueryData extends Peered
 		register_native();
 		host = getHost_native();
 	}
-	
+
 	private native void register_native();
 
+	/**
+	 * Gets the host that should be queried.
+	 *
+	 * @return The host name.
+	 */
 	public synchronized String getHost() {
 		ensureNotDestroyed();
 		return host;
 	}
 
 	private native String getHost_native();
-	
+
 	@Override
 	protected synchronized void nativeObjectFreed() {
 		super.nativeObjectFreed();
 	}
-	
+
 	@Override
 	protected void ensureNotDestroyed() {
 		super.ensureNotDestroyed();
@@ -39,6 +44,6 @@ public class DnsQueryData extends Peered
 	@Override
 	public String toString() {
 		return "DnsQueryData [getHost()=" + getHost() + ", getNativePointer()="
-				+ getNativePointer() + "]";
+		        + getNativePointer() + "]";
 	}
 }
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryResolvedCallback.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryResolvedCallback.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryResolvedCallback.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryResolvedCallback.java
@@ -7,9 +7,8 @@ import java.net.InetAddress;
 /**
  * Contains a callback function that should be called when the dns query as
  * successful.
- * 
+ *
  * @author michaelz
- * 
  */
 public class DnsQueryResolvedCallback extends Peered {
 
@@ -20,6 +19,13 @@ public class DnsQueryResolvedCallback ex
 		this.data = data;
 	}
 
+	/**
+	 * Calls this callback.
+	 *
+	 * @param allByName
+	 *            An Array of {@link InetAddress}es that represents the
+	 *            responses.
+	 */
 	public void call(InetAddress[] allByName) {
 		byte[][] addresses = new byte[allByName.length][];
 		for (int i = 0; i < allByName.length; i++) {
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryUiOps.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryUiOps.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryUiOps.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsQueryUiOps.java
@@ -12,12 +12,12 @@ import java.util.concurrent.LinkedBlocki
  * <p>
  * DNS querys are not provided by android native interface, so they need to be
  * made with java.
- * 
+ *
  * @author michaelz
- * 
  */
 public class DnsQueryUiOps {
-	private final LinkedBlockingQueue<Runnable> queries = new LinkedBlockingQueue<Runnable>();
+	private final LinkedBlockingQueue<Runnable> queries =
+	        new LinkedBlockingQueue<Runnable>();
 
 	public void register() {
 		register_native();
@@ -28,7 +28,7 @@ public class DnsQueryUiOps {
 
 	/**
 	 * Starts a nds query.
-	 * 
+	 *
 	 * @param data
 	 *            The data that contains information on what to query.
 	 * @param resolvedCallback
@@ -38,22 +38,33 @@ public class DnsQueryUiOps {
 	 * @return <code>true</code>
 	 */
 	public boolean resolveHost(long queryData, long resolvedCallback,
-			long failedCallback) {
+	        long failedCallback) {
 		DnsQueryData data = new DnsQueryData(queryData);
 
 		queries.add(new DnsQuery(data, new DnsQueryResolvedCallback(data,
-				resolvedCallback), new DnsQueryFailedCallback(data,
-				failedCallback)));
+		        resolvedCallback), new DnsQueryFailedCallback(data,
+		        failedCallback)));
 		return true;
 	}
 
+	/**
+	 * Starts an srv or txt query.
+	 *
+	 * @param queryData
+	 *            The data to use for the query.
+	 * @param resolvedCallback
+	 *            A callback to be called when the query was resolved.
+	 * @param failedCallback
+	 *            A callback to be called on failure.
+	 * @return <code>true</code>
+	 */
 	public boolean resolveSrvTxt(long queryData, long resolvedCallback,
-			long failedCallback) {
+	        long failedCallback) {
 		SrvTxtQueryData data = new SrvTxtQueryData(queryData);
 
 		queries.add(new SrvTxtQuery(data, new SrvTxtQueryResolvedCallback(data,
-				resolvedCallback), new SrvTxtQueryFailedCallback(data,
-				failedCallback)));
+		        resolvedCallback), new SrvTxtQueryFailedCallback(data,
+		        failedCallback)));
 		return true;
 	}
 }
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
--- 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
@@ -2,17 +2,28 @@ package im.pidgin.libpurple.core.dns;
 
 import java.util.concurrent.LinkedBlockingQueue;
 
+/**
+ * This class is used to run all the queries that come in.
+ *
+ * @author michael
+ */
 public class DnsQueryWorker implements Runnable {
 
 	private final LinkedBlockingQueue<Runnable> queries;
 
+	/**
+	 * Creates a new query runner.
+	 *
+	 * @param queries
+	 *            The queries to run.
+	 */
 	public DnsQueryWorker(LinkedBlockingQueue<Runnable> queries) {
 		this.queries = queries;
 	}
 
 	@Override
 	public void run() {
-		while(true) {
+		while (true) {
 			try {
 				Runnable query = queries.take();
 				query.run();
diff --git a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsResolver.java b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsResolver.java
--- a/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsResolver.java
+++ b/android/workspace/im.pidgin.libpurple/src/im/pidgin/libpurple/core/dns/DnsResolver.java
@@ -22,17 +22,23 @@ public abstract class DnsResolver<T> {
 	public DnsResolver() {
 	}
 
-	private ArrayList<String> getDnsServers() {
+	/**
+	 * Gets a list of DNS Servers from the system.
+	 *
+	 * @return The list of DNS servers.
+	 */
+	private static ArrayList<String> getDnsServers() {
 		ArrayList<String> results = new ArrayList<String>();
 		try {
-			Class<?> systemProperties = Class
-					.forName("android.os.SystemProperties");
-			Method getMethod = systemProperties.getMethod("get",
-					new Class[] { String.class });
+			Class<?> systemProperties =
+			        Class.forName("android.os.SystemProperties");
+			Method getMethod = systemProperties.getMethod("get", new Class[] {
+				String.class
+			});
 			for (int i = 1; i <= MAX_DNS_ENTRY; i++) {
 				String result = (String) getMethod.invoke(null, "net.dns" + i);
 				if (result != null && !result.isEmpty()
-						&& !results.contains(result)) {
+				        && !results.contains(result)) {
 					results.add(result);
 				}
 			}
@@ -40,13 +46,20 @@ public abstract class DnsResolver<T> {
 			System.err.println("Could not find android.os.SystemProperties");
 		} catch (NoSuchMethodException e) {
 			System.err
-					.println("Could not find android.os.SystemProperties.get(String)");
+			        .println("Could not find android.os.SystemProperties.get(String)");
 		} catch (Exception e) {
 			e.printStackTrace();
 		}
 		return results;
 	}
 
+	/**
+	 * Gets the address of the default DNS server.
+	 *
+	 * @return The dns address.
+	 * @throws DnsExeption
+	 *             If the address could not be found.
+	 */
 	private InetSocketAddress getServerAddress() throws DnsExeption {
 		ArrayList<String> servers = getDnsServers();
 		if (servers.isEmpty()) {
@@ -60,14 +73,22 @@ public abstract class DnsResolver<T> {
 			}
 		}
 		throw new DnsExeption("No DNS server could be reached. Tryed "
-				+ servers.toString());



More information about the Commits mailing list