mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-17 14:25:08 -05:00
Merge branch 'master' of github.com:open-keychain/open-keychain
This commit is contained in:
commit
945764b30f
@ -24,8 +24,10 @@ import org.sufficientlysecure.keychain.pgp.PgpHelper;
|
|||||||
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
import java.io.DataOutputStream;
|
import java.io.BufferedWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@ -352,24 +354,35 @@ public class HkpKeyserver extends Keyserver {
|
|||||||
@Override
|
@Override
|
||||||
public void add(String armoredKey) throws AddKeyException {
|
public void add(String armoredKey) throws AddKeyException {
|
||||||
try {
|
try {
|
||||||
String query = getUrlPrefix() + mHost + ":" + mPort + "/pks/add";
|
String request = "/pks/add";
|
||||||
String params;
|
String params;
|
||||||
try {
|
try {
|
||||||
params = "keytext=" + URLEncoder.encode(armoredKey, "utf8");
|
params = "keytext=" + URLEncoder.encode(armoredKey, "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new AddKeyException();
|
throw new AddKeyException();
|
||||||
}
|
}
|
||||||
Log.d(Constants.TAG, "hkp keyserver add: " + query);
|
URL url = new URL(getUrlPrefix() + mHost + ":" + mPort + request);
|
||||||
|
|
||||||
HttpURLConnection connection = openConnection(new URL(query));
|
Log.d(Constants.TAG, "hkp keyserver add: " + url.toString());
|
||||||
connection.setRequestMethod("POST");
|
|
||||||
connection.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
HttpURLConnection conn = openConnection(url);
|
||||||
connection.setRequestProperty("Content-Length", Integer.toString(params.getBytes().length));
|
conn.setRequestMethod("POST");
|
||||||
connection.setDoOutput(true);
|
conn.addRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||||
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
|
conn.setRequestProperty("Content-Length", Integer.toString(params.getBytes().length));
|
||||||
wr.writeBytes(params);
|
conn.setDoInput(true);
|
||||||
wr.flush();
|
conn.setDoOutput(true);
|
||||||
wr.close();
|
|
||||||
|
OutputStream os = conn.getOutputStream();
|
||||||
|
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));
|
||||||
|
writer.write(params);
|
||||||
|
writer.flush();
|
||||||
|
writer.close();
|
||||||
|
os.close();
|
||||||
|
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
Log.d(Constants.TAG, "response code: " + conn.getResponseCode());
|
||||||
|
Log.d(Constants.TAG, "answer: " + readAll(conn.getInputStream(), conn.getContentEncoding()));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new AddKeyException();
|
throw new AddKeyException();
|
||||||
}
|
}
|
||||||
|
@ -1127,9 +1127,7 @@ public class ProviderHelper {
|
|||||||
|
|
||||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||||
String version = PgpHelper.getVersionForHeader(mContext);
|
String version = PgpHelper.getVersionForHeader(mContext);
|
||||||
if (version != null) {
|
keyRing.encodeArmored(bos, version);
|
||||||
keyRing.encodeArmored(bos, version);
|
|
||||||
}
|
|
||||||
String armoredKey = bos.toString("UTF-8");
|
String armoredKey = bos.toString("UTF-8");
|
||||||
|
|
||||||
Log.d(Constants.TAG, "armoredKey:" + armoredKey);
|
Log.d(Constants.TAG, "armoredKey:" + armoredKey);
|
||||||
|
@ -30,6 +30,7 @@ import org.sufficientlysecure.keychain.R;
|
|||||||
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
import org.sufficientlysecure.keychain.helper.ActionBarHelper;
|
||||||
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
import org.sufficientlysecure.keychain.provider.ProviderHelper;
|
||||||
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
import org.sufficientlysecure.keychain.remote.AccountSettings;
|
||||||
|
import org.sufficientlysecure.keychain.service.OperationResultParcel;
|
||||||
import org.sufficientlysecure.keychain.util.Log;
|
import org.sufficientlysecure.keychain.util.Log;
|
||||||
|
|
||||||
public class AccountSettingsActivity extends ActionBarActivity {
|
public class AccountSettingsActivity extends ActionBarActivity {
|
||||||
@ -106,4 +107,15 @@ public class AccountSettingsActivity extends ActionBarActivity {
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
// if a result has been returned, display a notify
|
||||||
|
if (data != null && data.hasExtra(OperationResultParcel.EXTRA_RESULT)) {
|
||||||
|
OperationResultParcel result = data.getParcelableExtra(OperationResultParcel.EXTRA_RESULT);
|
||||||
|
result.createNotify(this).show();
|
||||||
|
} else {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -155,10 +155,8 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
if ((resultType & OperationResultParcel.RESULT_ERROR) == 0) {
|
if ((resultType & OperationResultParcel.RESULT_ERROR) == 0) {
|
||||||
|
|
||||||
if (getLog().containsWarnings()) {
|
if (getLog().containsWarnings()) {
|
||||||
duration = 0;
|
|
||||||
color = Style.ORANGE;
|
color = Style.ORANGE;
|
||||||
} else {
|
} else {
|
||||||
duration = SuperToast.Duration.LONG;
|
|
||||||
color = Style.GREEN;
|
color = Style.GREEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,7 +165,6 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
duration = 0;
|
|
||||||
color = Style.RED;
|
color = Style.RED;
|
||||||
|
|
||||||
str = "operation failed";
|
str = "operation failed";
|
||||||
@ -180,8 +177,8 @@ public class OperationResultParcel implements Parcelable {
|
|||||||
button ? SuperToast.Type.BUTTON : SuperToast.Type.STANDARD,
|
button ? SuperToast.Type.BUTTON : SuperToast.Type.STANDARD,
|
||||||
Style.getStyle(color, SuperToast.Animations.POPUP));
|
Style.getStyle(color, SuperToast.Animations.POPUP));
|
||||||
toast.setText(str);
|
toast.setText(str);
|
||||||
toast.setDuration(duration);
|
toast.setDuration(SuperToast.Duration.EXTRA_LONG);
|
||||||
toast.setIndeterminate(duration == 0);
|
toast.setIndeterminate(false);
|
||||||
toast.setSwipeToDismiss(true);
|
toast.setSwipeToDismiss(true);
|
||||||
// If we have a log and it's non-empty, show a View Log button
|
// If we have a log and it's non-empty, show a View Log button
|
||||||
if (button) {
|
if (button) {
|
||||||
|
@ -92,7 +92,9 @@ public class FirstTimeActivity extends ActionBarActivity {
|
|||||||
prefs.setFirstTime(false);
|
prefs.setFirstTime(false);
|
||||||
Intent intent = new Intent(this, KeyListActivity.class);
|
Intent intent = new Intent(this, KeyListActivity.class);
|
||||||
// give intent through to display notify
|
// give intent through to display notify
|
||||||
intent.putExtras(srcData);
|
if (srcData != null) {
|
||||||
|
intent.putExtras(srcData);
|
||||||
|
}
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(intent, 0);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,8 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(getIntent().getAction())) {
|
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(getIntent().getAction())
|
||||||
|
|| ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN.equals(getIntent().getAction())) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(ImportKeyResult.EXTRA_RESULT, result);
|
intent.putExtra(ImportKeyResult.EXTRA_RESULT, result);
|
||||||
ImportKeysActivity.this.setResult(RESULT_OK, intent);
|
ImportKeysActivity.this.setResult(RESULT_OK, intent);
|
||||||
@ -475,11 +476,6 @@ public class ImportKeysActivity extends ActionBarActivity {
|
|||||||
ImportKeysActivity.this.finish();
|
ImportKeysActivity.this.finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN.equals(getIntent().getAction())) {
|
|
||||||
ImportKeysActivity.this.setResult(RESULT_OK);
|
|
||||||
ImportKeysActivity.this.finish();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
result.createNotify(ImportKeysActivity.this).show();
|
result.createNotify(ImportKeysActivity.this).show();
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,6 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
private Button mButtonEmptyCreate;
|
private Button mButtonEmptyCreate;
|
||||||
private Button mButtonEmptyImport;
|
private Button mButtonEmptyImport;
|
||||||
|
|
||||||
public static final int REQUEST_CODE_CREATE_OR_IMPORT_KEY = 0x00007012;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load custom layout with StickyListView from library
|
* Load custom layout with StickyListView from library
|
||||||
*/
|
*/
|
||||||
@ -108,7 +106,7 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(getActivity(), CreateKeyActivity.class);
|
Intent intent = new Intent(getActivity(), CreateKeyActivity.class);
|
||||||
startActivityForResult(intent, REQUEST_CODE_CREATE_OR_IMPORT_KEY);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
mButtonEmptyImport = (Button) view.findViewById(R.id.key_list_empty_button_import);
|
mButtonEmptyImport = (Button) view.findViewById(R.id.key_list_empty_button_import);
|
||||||
@ -118,7 +116,7 @@ public class KeyListFragment extends LoaderFragment
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(getActivity(), ImportKeysActivity.class);
|
Intent intent = new Intent(getActivity(), ImportKeysActivity.class);
|
||||||
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN);
|
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN);
|
||||||
startActivityForResult(intent, REQUEST_CODE_CREATE_OR_IMPORT_KEY);
|
startActivityForResult(intent, 0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user