/* * Copyright (C) 2014 Ash Hughes * * 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 . */ 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.Calendar; public class SaveKeyringParcel implements Parcelable { public ArrayList userIds; public ArrayList originalIDs; public ArrayList deletedIDs; public boolean[] newIDs; public boolean primaryIDChanged; public boolean[] moddedKeys; public ArrayList deletedKeys; public ArrayList keysExpiryDates; public ArrayList keysUsages; public String newPassphrase; public String oldPassphrase; public boolean[] newKeys; public ArrayList keys; public String originalPrimaryID; public SaveKeyringParcel() {} private SaveKeyringParcel(Parcel source) { userIds = (ArrayList) source.readSerializable(); originalIDs = (ArrayList) source.readSerializable(); deletedIDs = (ArrayList) source.readSerializable(); newIDs = source.createBooleanArray(); primaryIDChanged = source.readByte() != 0; moddedKeys = source.createBooleanArray(); byte[] tmp = source.createByteArray(); if (tmp == null) { deletedKeys = null; } else { deletedKeys = PgpConversionHelper.BytesToPGPSecretKeyList(tmp); } keysExpiryDates = (ArrayList) source.readSerializable(); keysUsages = source.readArrayList(Integer.class.getClassLoader()); newPassphrase = source.readString(); oldPassphrase = source.readString(); newKeys = source.createBooleanArray(); keys = PgpConversionHelper.BytesToPGPSecretKeyList(source.createByteArray()); originalPrimaryID = source.readString(); } @Override public void writeToParcel(Parcel destination, int flags) { destination.writeSerializable(userIds); //might not be the best method to store. destination.writeSerializable(originalIDs); destination.writeSerializable(deletedIDs); destination.writeBooleanArray(newIDs); destination.writeByte((byte) (primaryIDChanged ? 1 : 0)); destination.writeBooleanArray(moddedKeys); byte[] tmp = null; if (deletedKeys.size() != 0) { tmp = PgpConversionHelper.PGPSecretKeyArrayListToBytes(deletedKeys); } destination.writeByteArray(tmp); destination.writeSerializable(keysExpiryDates); destination.writeList(keysUsages); destination.writeString(newPassphrase); destination.writeString(oldPassphrase); destination.writeBooleanArray(newKeys); destination.writeByteArray(PgpConversionHelper.PGPSecretKeyArrayListToBytes(keys)); destination.writeString(originalPrimaryID); } public static final Creator CREATOR = new Creator() { 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; } }