// Path: src/org/openintents/openpgp/keyserver/KeyServer.java
// static public class InsufficientQuery extends Exception {
//     private static final long serialVersionUID = 2703768928624654514L;
// }
// 
// Path: src/org/openintents/openpgp/keyserver/KeyServer.java
// static public class KeyInfo implements Serializable, Parcelable {
//     private static final long serialVersionUID = -7797972113284992662L;
//     public ArrayList<String> userIds;
//     public boolean isRevoked;
//     public Date creationDate;
//     public String fingerprint = null;
//     public long keyId = 0;
//     public int size;
//     public String algorithm;
// 
//     public static long keyIdFromFingerprint(String fingerprint) {
//         return new BigInteger(fingerprint, 16).longValue();
//     }
// 
//     public static String hexFromKeyId(long keyId) {
//         return String.format("%016x", keyId).toLowerCase(Locale.ENGLISH);
//     }
// 
//     public KeyInfo() {
//         userIds = new ArrayList<String>();
//     }
// 
//     public KeyInfo(Parcel in) {
//         this();
// 
//         in.readStringList(this.userIds);
//         this.isRevoked = in.readByte() != 0;
//         this.creationDate = (Date) in.readSerializable();
//         this.fingerprint = in.readString();
//         this.keyId = in.readLong();
//         this.size = in.readInt();
//         this.algorithm = in.readString();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeStringList(userIds);
//         dest.writeByte((byte) (isRevoked ? 1 : 0));
//         dest.writeSerializable(creationDate);
//         dest.writeString(fingerprint);
//         dest.writeLong(keyId);
//         dest.writeInt(size);
//         dest.writeString(algorithm);
//     }
// 
//     public void setFingerprint(String fingerprint) {
//         this.fingerprint = fingerprint.toLowerCase(Locale.ENGLISH);
//         this.keyId = keyIdFromFingerprint(fingerprint);
//     }
// }
// 
// Path: src/org/openintents/openpgp/keyserver/KeyServer.java
// static public class QueryException extends Exception {
//     private static final long serialVersionUID = 2703768928624654512L;
// 
//     public QueryException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/org/openintents/openpgp/keyserver/KeyServer.java
// static public class TooManyResponses extends Exception {
//     private static final long serialVersionUID = 2703768928624654513L;
// }


import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.openintents.openpgp.keyserver.HkpKeyServer;
import org.openintents.openpgp.keyserver.KeyServer.InsufficientQuery;
import org.openintents.openpgp.keyserver.KeyServer.KeyInfo;
import org.openintents.openpgp.keyserver.KeyServer.QueryException;
import org.openintents.openpgp.keyserver.KeyServer.TooManyResponses;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.content.AsyncTaskLoader;
import android.text.TextUtils;

package info.guardianproject.gpg;




public class KeyserverLoader extends AsyncTaskLoader<KeyserverResult<List<KeyInfo>>> {
    public static final String TAG = "KeyserverLoader";

    final Context mContext;
    String mSearchString;

    /**
     * Perform alphabetical comparison of application entry objects.
     */
    public static final Comparator<KeyInfo> ALPHA_COMPARATOR = new Comparator<KeyInfo>() {
        private final Collator sCollator = Collator.getInstance();

        @Override
        public int compare(KeyInfo object1, KeyInfo object2) {
            return sCollator.compare(object1.userIds.get(0), object2.userIds.get(0));
        }
    };

    public KeyserverLoader(Context context) {
        super(context);
        mContext = context;
    }

    @Override
    public void onStartLoading() {
        mSearchString = MainActivity.mCurrentSearchString;
    }

    @Override
    public KeyserverResult<List<KeyInfo>> loadInBackground() {
        KeyserverResult<List<KeyInfo>> result = new KeyserverResult<List<KeyInfo>>();
        try {
// Path: src/org/openintents/openpgp/keyserver/KeyServer.java
// static public class InsufficientQuery extends Exception {
//     private static final long serialVersionUID = 2703768928624654514L;
// }
// 
// Path: src/org/openintents/openpgp/keyserver/KeyServer.java
// static public class KeyInfo implements Serializable, Parcelable {
//     private static final long serialVersionUID = -7797972113284992662L;
//     public ArrayList<String> userIds;
//     public boolean isRevoked;
//     public Date creationDate;
//     public String fingerprint = null;
//     public long keyId = 0;
//     public int size;
//     public String algorithm;
// 
//     public static long keyIdFromFingerprint(String fingerprint) {
//         return new BigInteger(fingerprint, 16).longValue();
//     }
// 
//     public static String hexFromKeyId(long keyId) {
//         return String.format("%016x", keyId).toLowerCase(Locale.ENGLISH);
//     }
// 
//     public KeyInfo() {
//         userIds = new ArrayList<String>();
//     }
// 
//     public KeyInfo(Parcel in) {
//         this();
// 
//         in.readStringList(this.userIds);
//         this.isRevoked = in.readByte() != 0;
//         this.creationDate = (Date) in.readSerializable();
//         this.fingerprint = in.readString();
//         this.keyId = in.readLong();
//         this.size = in.readInt();
//         this.algorithm = in.readString();
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeStringList(userIds);
//         dest.writeByte((byte) (isRevoked ? 1 : 0));
//         dest.writeSerializable(creationDate);
//         dest.writeString(fingerprint);
//         dest.writeLong(keyId);
//         dest.writeInt(size);
//         dest.writeString(algorithm);
//     }
// 
//     public void setFingerprint(String fingerprint) {
//         this.fingerprint = fingerprint.toLowerCase(Locale.ENGLISH);
//         this.keyId = keyIdFromFingerprint(fingerprint);
//     }
// }
// 
// Path: src/org/openintents/openpgp/keyserver/KeyServer.java
// static public class QueryException extends Exception {
//     private static final long serialVersionUID = 2703768928624654512L;
// 
//     public QueryException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/org/openintents/openpgp/keyserver/KeyServer.java
// static public class TooManyResponses extends Exception {
//     private static final long serialVersionUID = 2703768928624654513L;
// }


// Path: src/info/guardianproject/gpg/KeyserverLoader.java
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.openintents.openpgp.keyserver.HkpKeyServer;
import org.openintents.openpgp.keyserver.KeyServer.InsufficientQuery;
import org.openintents.openpgp.keyserver.KeyServer.KeyInfo;
import org.openintents.openpgp.keyserver.KeyServer.QueryException;
import org.openintents.openpgp.keyserver.KeyServer.TooManyResponses;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.content.AsyncTaskLoader;
import android.text.TextUtils;


package info.guardianproject.gpg;




public class KeyserverLoader extends AsyncTaskLoader<KeyserverResult<List<KeyInfo>>> {
    public static final String TAG = "KeyserverLoader";

    final Context mContext;
    String mSearchString;

    /**
     * Perform alphabetical comparison of application entry objects.
     */
    public static final Comparator<KeyInfo> ALPHA_COMPARATOR = new Comparator<KeyInfo>() {
        private final Collator sCollator = Collator.getInstance();

        @Override
        public int compare(KeyInfo object1, KeyInfo object2) {
            return sCollator.compare(object1.userIds.get(0), object2.userIds.get(0));
        }
    };

    public KeyserverLoader(Context context) {
        super(context);
        mContext = context;
    }

    @Override
    public void onStartLoading() {
        mSearchString = MainActivity.mCurrentSearchString;
    }

    @Override
    public KeyserverResult<List<KeyInfo>> loadInBackground() {
        KeyserverResult<List<KeyInfo>> result = new KeyserverResult<List<KeyInfo>>();
        try {
            if(TextUtils.isEmpty(mSearchString))