aboutsummaryrefslogtreecommitdiffstats
path: root/OpenPGP-Keychain/src/main/java/org/sufficientlysecure
diff options
context:
space:
mode:
authorAshley Hughes <spirit.returned@gmail.com>2014-03-02 20:34:28 +0000
committerAshley Hughes <spirit.returned@gmail.com>2014-03-02 20:34:28 +0000
commitd6b0975f9b666dc30edab36e6f2c68c0022790d1 (patch)
treecf6c023e5544401bef719c5b29f901de3b0a010d /OpenPGP-Keychain/src/main/java/org/sufficientlysecure
parentfa533dda325b5d56db16dee2f84152ec4807a2b2 (diff)
downloadopen-keychain-d6b0975f9b666dc30edab36e6f2c68c0022790d1.tar.gz
open-keychain-d6b0975f9b666dc30edab36e6f2c68c0022790d1.tar.bz2
open-keychain-d6b0975f9b666dc30edab36e6f2c68c0022790d1.zip
begin adding parcel for save intent
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure')
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java10
-rw-r--r--OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java90
2 files changed, 97 insertions, 3 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
index a6ff60442..a52f247c6 100644
--- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyOperation.java
@@ -29,6 +29,7 @@ import java.util.ArrayList;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Iterator;
+import java.util.List;
import java.util.TimeZone;
import org.spongycastle.bcpg.CompressionAlgorithmTags;
@@ -490,11 +491,14 @@ public class PgpKeyOperation {
masterKeyPair, mainUserId, sha1Calc, hashedPacketsGen.generate(),
unhashedPacketsGen.generate(), certificationSignerBuilder, keyEncryptor);
- //updating master is slightly different to updating the others
- if (modded_keys[0]) {
+ for (int i = 0; i < keys.size(); ++i) {
+ updateProgress(40 + 50 * (i - 1) / (keys.size() - 1), 100);
+ if (new_keys[i]) {
- }
+ } else {
+ }
+ }
updateProgress(R.string.progress_adding_sub_keys, 40, 100);
for (int i = 1; i < keys.size(); ++i) {
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java
new file mode 100644
index 000000000..bdabc70a2
--- /dev/null
+++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/service/SaveKeyringParcel.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2014 Ash Hughes <ashes-iontach@hotmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+package org.sufficientlysecure.keychain.service;
+
+import android.os.Parcel;
+import android.os.Parcelable;
+
+import org.spongycastle.openpgp.PGPSecretKey;
+import org.sufficientlysecure.keychain.pgp.PgpConversionHelper;
+
+import java.util.ArrayList;
+import java.util.GregorianCalendar;
+
+public class SaveKeyringParcel implements Parcelable {
+
+ public ArrayList<String> userIDs;
+ public ArrayList<String> originalIDs;
+ public ArrayList<String> deletedIDs;
+ public boolean primaryIDChanged;
+ public boolean[] moddedKeys;
+ public ArrayList<PGPSecretKey> deletedKeys;
+ public ArrayList<GregorianCalendar> keysExpiryDates;
+ public ArrayList<Integer> keysUsages;
+ public String newPassPhrase;
+ public String oldPassPhrase;
+ public boolean[] newKeys;
+ public ArrayList<PGPSecretKey> keys;
+
+ private SaveKeyringParcel(Parcel source)
+ {
+ byte[] tmpB;
+ userIDs = (ArrayList<String>)source.readSerializable();
+ originalIDs = (ArrayList<String>)source.readSerializable();
+ deletedIDs = (ArrayList<String>)source.readSerializable();
+ primaryIDChanged = source.readByte() != 0;
+ source.readBooleanArray(moddedKeys);
+ deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray());
+ keysExpiryDates = (ArrayList<GregorianCalendar>)source.readSerializable();
+ keysUsages = source.readArrayList(Integer.class.getClassLoader());
+ }
+
+ @Override
+ public void writeToParcel(Parcel destination, int flags)
+ {
+ destination.writeSerializable(userIDs);
+ destination.writeSerializable(originalIDs);
+ destination.writeSerializable(deletedIDs);
+ destination.writeByte((byte) (primaryIDChanged ? 1 : 0));
+ destination.writeBooleanArray(moddedKeys);
+ destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys));
+ destination.writeSerializable(keysExpiryDates);
+ destination.writeList(keysUsages);
+ destination.writeString(newPassPhrase);
+ destination.writeString(oldPassPhrase);
+ destination.writeBooleanArray(newKeys);
+ destination.writeByteArray();
+ }
+
+ public static final Creator<SaveKeyringParcel> CREATOR = new Creator<SaveKeyringParcel>() {
+ public SaveKeyringParcel createFromParcel(final Parcel source) {
+ return new SaveKeyringParcel(source);
+ }
+
+ public SaveKeyringParcel[] newArray(final int size) {
+ return new SaveKeyringParcel[size];
+ }
+ };
+
+ @Override
+ public int describeContents()
+ {
+ return 0;
+ }
+}