Fixes and temporary fixes for returning results

This commit is contained in:
Dominik Schürmann 2014-08-20 19:46:44 +02:00
parent c3b12bb3c2
commit f46f2b6895
7 changed files with 30 additions and 19 deletions

View File

@ -415,7 +415,7 @@ public class OpenPgpService extends RemoteService {
// If signature is unknown we return an _additional_ PendingIntent // If signature is unknown we return an _additional_ PendingIntent
// to retrieve the missing key // to retrieve the missing key
Intent intent = new Intent(getBaseContext(), ImportKeysActivity.class); Intent intent = new Intent(getBaseContext(), ImportKeysActivity.class);
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN); intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE);
intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, signatureResult.getKeyId()); intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, signatureResult.getKeyId());
intent.putExtra(ImportKeysActivity.EXTRA_PENDING_INTENT_DATA, data); intent.putExtra(ImportKeysActivity.EXTRA_PENDING_INTENT_DATA, data);
@ -481,7 +481,7 @@ public class OpenPgpService extends RemoteService {
// If keys are not in db we return an additional PendingIntent // If keys are not in db we return an additional PendingIntent
// to retrieve the missing key // to retrieve the missing key
Intent intent = new Intent(getBaseContext(), ImportKeysActivity.class); Intent intent = new Intent(getBaseContext(), ImportKeysActivity.class);
intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN); intent.setAction(ImportKeysActivity.ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE);
intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, masterKeyId); intent.putExtra(ImportKeysActivity.EXTRA_KEY_ID, masterKeyId);
intent.putExtra(ImportKeysActivity.EXTRA_PENDING_INTENT_DATA, data); intent.putExtra(ImportKeysActivity.EXTRA_PENDING_INTENT_DATA, data);

View File

@ -181,8 +181,6 @@ public class KeychainIntentService extends IntentService
// export // export
public static final String RESULT_EXPORT = "exported"; public static final String RESULT_EXPORT = "exported";
public static final String RESULT_IMPORT = "result";
public static final String RESULT_CONSOLIDATE = "consolidate_result"; public static final String RESULT_CONSOLIDATE = "consolidate_result";
Messenger mMessenger; Messenger mMessenger;

View File

@ -442,8 +442,10 @@ public class OperationResultParcel implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mResult); dest.writeInt(mResult);
if (mLog != null) {
dest.writeTypedList(mLog.toList()); dest.writeTypedList(mLog.toList());
} }
}
public static final Creator<OperationResultParcel> CREATOR = new Creator<OperationResultParcel>() { public static final Creator<OperationResultParcel> CREATOR = new Creator<OperationResultParcel>() {
public OperationResultParcel createFromParcel(final Parcel source) { public OperationResultParcel createFromParcel(final Parcel source) {

View File

@ -54,6 +54,7 @@ import org.sufficientlysecure.keychain.provider.KeychainContract.UserIds;
import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.service.OperationResultParcel; import org.sufficientlysecure.keychain.service.OperationResultParcel;
import org.sufficientlysecure.keychain.service.OperationResults;
import org.sufficientlysecure.keychain.service.PassphraseCacheService; import org.sufficientlysecure.keychain.service.PassphraseCacheService;
import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter; import org.sufficientlysecure.keychain.ui.adapter.UserIdsAdapter;
import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment; import org.sufficientlysecure.keychain.ui.dialog.PassphraseDialogFragment;
@ -311,8 +312,14 @@ public class CertifyKeyActivity extends ActionBarActivity implements LoaderManag
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
Notify.showNotify(CertifyKeyActivity.this, R.string.key_certify_success, // Notify.showNotify(CertifyKeyActivity.this, R.string.key_certify_success,
Notify.Style.INFO); // Notify.Style.INFO);
OperationResultParcel result = new OperationResultParcel(OperationResultParcel.RESULT_OK, null);
Intent intent = new Intent();
intent.putExtra(OperationResults.ImportKeyResult.EXTRA_RESULT, result);
CertifyKeyActivity.this.setResult(RESULT_OK, intent);
CertifyKeyActivity.this.finish();
// check if we need to send the key to the server or not // check if we need to send the key to the server or not
if (mUploadKeyCheckbox.isChecked()) { if (mUploadKeyCheckbox.isChecked()) {
@ -364,13 +371,14 @@ public class CertifyKeyActivity extends ActionBarActivity implements LoaderManag
super.handleMessage(message); super.handleMessage(message);
if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) { if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
Intent intent = new Intent(); //Notify.showNotify(CertifyKeyActivity.this, R.string.key_send_success,
intent.putExtra(OperationResultParcel.EXTRA_RESULT, message.getData()); //Notify.Style.INFO);
Notify.showNotify(CertifyKeyActivity.this, R.string.key_send_success,
Notify.Style.INFO);
setResult(RESULT_OK); OperationResultParcel result = new OperationResultParcel(OperationResultParcel.RESULT_OK, null);
finish(); Intent intent = new Intent();
intent.putExtra(OperationResults.ImportKeyResult.EXTRA_RESULT, result);
CertifyKeyActivity.this.setResult(RESULT_OK, intent);
CertifyKeyActivity.this.finish();
} }
} }
}; };

View File

@ -45,6 +45,7 @@ import org.sufficientlysecure.keychain.keyimport.ParcelableKeyRing;
import org.sufficientlysecure.keychain.pgp.PgpKeyHelper; import org.sufficientlysecure.keychain.pgp.PgpKeyHelper;
import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler; import org.sufficientlysecure.keychain.service.KeychainIntentServiceHandler;
import org.sufficientlysecure.keychain.service.OperationResultParcel;
import org.sufficientlysecure.keychain.service.OperationResults.ImportKeyResult; import org.sufficientlysecure.keychain.service.OperationResults.ImportKeyResult;
import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter; import org.sufficientlysecure.keychain.ui.adapter.PagerTabStripAdapter;
import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout; import org.sufficientlysecure.keychain.ui.widget.SlidingTabLayout;
@ -64,7 +65,7 @@ public class ImportKeysActivity extends ActionBarActivity {
+ "IMPORT_KEY_FROM_KEYSERVER"; + "IMPORT_KEY_FROM_KEYSERVER";
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT = public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT =
Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN_RESULT"; Constants.INTENT_PREFIX + "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN_RESULT";
public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN = Constants.INTENT_PREFIX public static final String ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE = Constants.INTENT_PREFIX
+ "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN"; + "IMPORT_KEY_FROM_KEY_SERVER_AND_RETURN";
public static final String ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN = Constants.INTENT_PREFIX public static final String ACTION_IMPORT_KEY_FROM_FILE_AND_RETURN = Constants.INTENT_PREFIX
+ "IMPORT_KEY_FROM_FILE_AND_RETURN"; + "IMPORT_KEY_FROM_FILE_AND_RETURN";
@ -87,7 +88,7 @@ public class ImportKeysActivity extends ActionBarActivity {
public static final String EXTRA_KEY_ID = "key_id"; public static final String EXTRA_KEY_ID = "key_id";
public static final String EXTRA_FINGERPRINT = "fingerprint"; public static final String EXTRA_FINGERPRINT = "fingerprint";
// only used by ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN when used from OpenPgpService // only used by ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE when used from OpenPgpService
public static final String EXTRA_PENDING_INTENT_DATA = "data"; public static final String EXTRA_PENDING_INTENT_DATA = "data";
private Intent mPendingIntentData; private Intent mPendingIntentData;
@ -170,7 +171,7 @@ public class ImportKeysActivity extends ActionBarActivity {
startListFragment(savedInstanceState, importData, null, null); startListFragment(savedInstanceState, importData, null, null);
} }
} else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action) } else if (ACTION_IMPORT_KEY_FROM_KEYSERVER.equals(action)
|| ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(action) || ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE.equals(action)
|| ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(action)) { || ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_RESULT.equals(action)) {
// only used for OpenPgpService // only used for OpenPgpService
@ -456,8 +457,9 @@ public class ImportKeysActivity extends ActionBarActivity {
return; return;
} }
final ImportKeyResult result = final ImportKeyResult result =
returnData.getParcelable(KeychainIntentService.RESULT_IMPORT); returnData.getParcelable(OperationResultParcel.EXTRA_RESULT);
if (result == null) { if (result == null) {
Log.e(Constants.TAG, "result == null");
return; return;
} }
@ -468,7 +470,7 @@ public class ImportKeysActivity extends ActionBarActivity {
ImportKeysActivity.this.finish(); ImportKeysActivity.this.finish();
return; return;
} }
if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN.equals(getIntent().getAction())) { if (ACTION_IMPORT_KEY_FROM_KEYSERVER_AND_RETURN_TO_SERVICE.equals(getIntent().getAction())) {
ImportKeysActivity.this.setResult(RESULT_OK, mPendingIntentData); ImportKeysActivity.this.setResult(RESULT_OK, mPendingIntentData);
ImportKeysActivity.this.finish(); ImportKeysActivity.this.finish();
return; return;

View File

@ -179,6 +179,7 @@ public class LogDisplayFragment extends ListFragment implements OnTouchListener
(Integer) entry.mParameters[0], (Integer) entry.mParameters[0],
entry.mParameters)); entry.mParameters));
} else { } else {
Log.d(Constants.TAG, "entry.mType.getMsgId() "+entry.mType.name());
ih.mText.setText(getResources().getString(entry.mType.getMsgId(), ih.mText.setText(getResources().getString(entry.mType.getMsgId(),
entry.mParameters)); entry.mParameters));
} }

View File

@ -421,7 +421,7 @@
<string name="msg_ip_encode_fail">Die Anwendung ist wegen Kodierungsfehler fehlgeschlagen</string> <string name="msg_ip_encode_fail">Die Anwendung ist wegen Kodierungsfehler fehlgeschlagen</string>
<string name="msg_ip_fail_io_exc">Die Anwendung ist wegen eines Eingabe/Ausgabe-Fehlers fehlgeschlagen</string> <string name="msg_ip_fail_io_exc">Die Anwendung ist wegen eines Eingabe/Ausgabe-Fehlers fehlgeschlagen</string>
<string name="msg_ip_fail_remote_ex">Die Anwendung ist wegen internen Fehler fehlgeschlagen</string> <string name="msg_ip_fail_remote_ex">Die Anwendung ist wegen internen Fehler fehlgeschlagen</string>
<string name="msg_ip">Importiere öffentlichen Schlüsselbund %s%</string> <string name="msg_ip">Importiere öffentlichen Schlüsselbund %s</string>
<string name="msg_ip_insert_keyring">Schlüsselbund-daten werden kodiert</string> <string name="msg_ip_insert_keyring">Schlüsselbund-daten werden kodiert</string>
<string name="msg_ip_prepare">Datenbank-Transaktionen werden vorbereitet</string> <string name="msg_ip_prepare">Datenbank-Transaktionen werden vorbereitet</string>
<string name="msg_ip_master">Hauptschlüssel %s wird verarbeitet</string> <string name="msg_ip_master">Hauptschlüssel %s wird verarbeitet</string>