aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/thialfihar/android/apg/KeyServerQueryActivity.java
diff options
context:
space:
mode:
authorThialfihar <thialfihar@gmail.com>2010-08-17 14:51:39 +0000
committerThialfihar <thialfihar@gmail.com>2010-08-17 14:51:39 +0000
commite4dd80005c4839f74c76270b1f7c2668e8007305 (patch)
treee8be4f4633f217ed6ff7f0d17c07c0fb0a4f42c6 /src/org/thialfihar/android/apg/KeyServerQueryActivity.java
parent96162b660840c7bcfb6dec1bb6e3ade5f715c563 (diff)
downloadopen-keychain-e4dd80005c4839f74c76270b1f7c2668e8007305.tar.gz
open-keychain-e4dd80005c4839f74c76270b1f7c2668e8007305.tar.bz2
open-keychain-e4dd80005c4839f74c76270b1f7c2668e8007305.zip
gave HKP server proper error handling, going through all IPs of a pool until a response is received, reporting "too many responses", "no keys found", "insufficient query" correctly
Update issue 9 Proper error handling added.
Diffstat (limited to 'src/org/thialfihar/android/apg/KeyServerQueryActivity.java')
-rw-r--r--src/org/thialfihar/android/apg/KeyServerQueryActivity.java19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/org/thialfihar/android/apg/KeyServerQueryActivity.java b/src/org/thialfihar/android/apg/KeyServerQueryActivity.java
index e7f393756..1d3a476e1 100644
--- a/src/org/thialfihar/android/apg/KeyServerQueryActivity.java
+++ b/src/org/thialfihar/android/apg/KeyServerQueryActivity.java
@@ -1,11 +1,12 @@
package org.thialfihar.android.apg;
-import java.io.IOException;
-import java.net.MalformedURLException;
import java.util.List;
import java.util.Vector;
+import org.thialfihar.android.apg.KeyServer.InsufficientQuery;
import org.thialfihar.android.apg.KeyServer.KeyInfo;
+import org.thialfihar.android.apg.KeyServer.QueryException;
+import org.thialfihar.android.apg.KeyServer.TooManyResponses;
import android.app.Activity;
import android.content.Context;
@@ -65,14 +66,13 @@ public class KeyServerQueryActivity extends BaseActivity {
search(query);
}
});
-
- mQuery.setText("cartman");
}
private void search(String query) {
showDialog(Id.dialog.querying);
mQueryType = Id.query.search;
mQueryString = query;
+ mAdapter.setKeys(new Vector<KeyInfo>());
startThread();
}
@@ -90,16 +90,18 @@ public class KeyServerQueryActivity extends BaseActivity {
Message msg = new Message();
try {
- HkpKeyServer server = new HkpKeyServer("198.128.3.63");//"pool.sks-keyservers.net");
+ HkpKeyServer server = new HkpKeyServer("pool.sks-keyservers.net");
if (mQueryType == Id.query.search) {
mSearchResult = server.search(mQueryString);
} else if (mQueryType == Id.query.get) {
mKeyData = server.get(mQueryId);
}
- } catch (MalformedURLException e) {
- error = "" + e;
- } catch (IOException e) {
+ } catch (QueryException e) {
error = "" + e;
+ } catch (InsufficientQuery e) {
+ error = "Insufficient query.";
+ } catch (TooManyResponses e) {
+ error = "Too many responses.";
}
data.putInt(Apg.EXTRA_STATUS, Id.message.done);
@@ -127,6 +129,7 @@ public class KeyServerQueryActivity extends BaseActivity {
if (mQueryType == Id.query.search) {
if (mSearchResult != null) {
+ Toast.makeText(this, getString(R.string.keysFound, mSearchResult.size()), Toast.LENGTH_SHORT).show();
mAdapter.setKeys(mSearchResult);
}
} else if (mQueryType == Id.query.get) {