2014-07-05 12:47:01 -07:00
|
|
|
package org.whispersystems.textsecure.push;
|
|
|
|
|
|
|
|
import com.google.thoughtcrimegson.GsonBuilder;
|
|
|
|
|
|
|
|
import org.whispersystems.libaxolotl.IdentityKey;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
public class PreKeyState {
|
|
|
|
|
|
|
|
private IdentityKey identityKey;
|
|
|
|
private List<PreKeyEntity> preKeys;
|
|
|
|
private PreKeyEntity lastResortKey;
|
2014-07-11 10:35:41 -07:00
|
|
|
private SignedPreKeyEntity signedPreKey;
|
2014-07-05 12:47:01 -07:00
|
|
|
|
|
|
|
|
|
|
|
public PreKeyState(List<PreKeyEntity> preKeys, PreKeyEntity lastResortKey,
|
2014-07-11 10:35:41 -07:00
|
|
|
SignedPreKeyEntity signedPreKey, IdentityKey identityKey)
|
2014-07-05 12:47:01 -07:00
|
|
|
{
|
|
|
|
this.preKeys = preKeys;
|
|
|
|
this.lastResortKey = lastResortKey;
|
2014-07-11 10:35:41 -07:00
|
|
|
this.signedPreKey = signedPreKey;
|
2014-07-05 12:47:01 -07:00
|
|
|
this.identityKey = identityKey;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static String toJson(PreKeyState state) {
|
|
|
|
GsonBuilder builder = new GsonBuilder();
|
2014-07-11 10:35:41 -07:00
|
|
|
return SignedPreKeyEntity.forBuilder(builder)
|
2014-07-05 12:47:01 -07:00
|
|
|
.registerTypeAdapter(IdentityKey.class, new PreKeyResponse.IdentityKeyJsonAdapter())
|
|
|
|
.create().toJson(state);
|
|
|
|
}
|
|
|
|
}
|