added Facebook links support, reworked Preferences
This commit is contained in:
@@ -38,6 +38,7 @@ import android.support.annotation.NonNull;
|
||||
|
||||
import org.sufficientlysecure.keychain.Constants;
|
||||
import org.sufficientlysecure.keychain.R;
|
||||
import org.sufficientlysecure.keychain.keyimport.FacebookKeyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.HkpKeyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.KeybaseKeyserver;
|
||||
import org.sufficientlysecure.keychain.keyimport.Keyserver;
|
||||
@@ -156,6 +157,7 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
double progSteps = 100.0 / num;
|
||||
|
||||
KeybaseKeyserver keybaseServer = null;
|
||||
FacebookKeyserver facebookServer = null;
|
||||
HkpKeyserver keyServer = null;
|
||||
|
||||
// iterate over all entries
|
||||
@@ -228,6 +230,12 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
byte[] data = keybaseServer.get(entry.mKeybaseName).getBytes();
|
||||
UncachedKeyRing keybaseKey = UncachedKeyRing.decodeFromData(data);
|
||||
|
||||
if (keybaseKey != null) {
|
||||
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_OK, 3);
|
||||
} else {
|
||||
log.add(LogType.MSG_IMPORT_FETCH_ERROR_DECODE, 3);
|
||||
}
|
||||
|
||||
// If there already is a key, merge the two
|
||||
if (key != null && keybaseKey != null) {
|
||||
log.add(LogType.MSG_IMPORT_MERGE, 3);
|
||||
@@ -247,6 +255,44 @@ public class ImportOperation extends BaseOperation<ImportKeyringParcel> {
|
||||
log.add(LogType.MSG_IMPORT_FETCH_ERROR_KEYSERVER, 3, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// if the key is from Facebook, fetch from there
|
||||
if (entry.mFbUsername != null) {
|
||||
// Make sure we have this cached
|
||||
if (facebookServer == null) {
|
||||
facebookServer = new FacebookKeyserver(proxy);
|
||||
}
|
||||
|
||||
try {
|
||||
log.add(LogType.MSG_IMPORT_FETCH_FACEBOOK, 2, entry.mFbUsername);
|
||||
byte[] data = facebookServer.get(entry.mFbUsername).getBytes();
|
||||
UncachedKeyRing facebookKey = UncachedKeyRing.decodeFromData(data);
|
||||
|
||||
if (facebookKey != null) {
|
||||
log.add(LogType.MSG_IMPORT_FETCH_KEYSERVER_OK, 3);
|
||||
} else {
|
||||
log.add(LogType.MSG_IMPORT_FETCH_ERROR_DECODE, 3);
|
||||
}
|
||||
|
||||
// If there already is a key, merge the two
|
||||
if (key != null && facebookKey != null) {
|
||||
log.add(LogType.MSG_IMPORT_MERGE, 3);
|
||||
facebookKey = key.merge(facebookKey, log, 4);
|
||||
// If the merge didn't fail, use the new merged key
|
||||
if (facebookKey != null) {
|
||||
key = facebookKey;
|
||||
} else {
|
||||
log.add(LogType.MSG_IMPORT_MERGE_ERROR, 4);
|
||||
}
|
||||
} else if (facebookKey != null) {
|
||||
key = facebookKey;
|
||||
}
|
||||
} catch (Keyserver.QueryFailedException e) {
|
||||
// download failed, too bad. just proceed
|
||||
Log.e(Constants.TAG, "query failed", e);
|
||||
log.add(LogType.MSG_IMPORT_FETCH_ERROR_KEYSERVER, 3, e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (key == null) {
|
||||
|
||||
@@ -233,6 +233,18 @@ public abstract class OperationResult implements Parcelable {
|
||||
dest.writeParcelable(mSubResult, 0);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<SubLogEntryParcel> CREATOR = new Parcelable.Creator<SubLogEntryParcel>() {
|
||||
@Override
|
||||
public SubLogEntryParcel createFromParcel(Parcel in) {
|
||||
return new SubLogEntryParcel(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SubLogEntryParcel[] newArray(int size) {
|
||||
return new SubLogEntryParcel[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
StringBuilder getPrintableLogEntry(Resources resources, int indent) {
|
||||
|
||||
@@ -757,6 +769,7 @@ public abstract class OperationResult implements Parcelable {
|
||||
MSG_IMPORT_FETCH_ERROR_KEYSERVER(LogLevel.ERROR, R.string.msg_import_fetch_error_keyserver),
|
||||
MSG_IMPORT_FETCH_ERROR_KEYSERVER_SECRET (LogLevel.ERROR, R.string.msg_import_fetch_error_keyserver_secret),
|
||||
MSG_IMPORT_FETCH_KEYBASE (LogLevel.INFO, R.string.msg_import_fetch_keybase),
|
||||
MSG_IMPORT_FETCH_FACEBOOK (LogLevel.INFO, R.string.msg_import_fetch_facebook),
|
||||
MSG_IMPORT_FETCH_KEYSERVER (LogLevel.INFO, R.string.msg_import_fetch_keyserver),
|
||||
MSG_IMPORT_FETCH_KEYSERVER_OK (LogLevel.DEBUG, R.string.msg_import_fetch_keyserver_ok),
|
||||
MSG_IMPORT_KEYSERVER (LogLevel.DEBUG, R.string.msg_import_keyserver),
|
||||
|
||||
Reference in New Issue
Block a user