Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | package org.mozilla.gecko.fxa.login; |
michael@0 | 6 | |
michael@0 | 7 | import org.mozilla.gecko.fxa.login.FxAccountLoginStateMachine.ExecuteDelegate; |
michael@0 | 8 | import org.mozilla.gecko.sync.ExtendedJSONObject; |
michael@0 | 9 | import org.mozilla.gecko.sync.Utils; |
michael@0 | 10 | |
michael@0 | 11 | public abstract class State { |
michael@0 | 12 | public static final long CURRENT_VERSION = 2L; |
michael@0 | 13 | |
michael@0 | 14 | public enum StateLabel { |
michael@0 | 15 | Engaged, |
michael@0 | 16 | Cohabiting, |
michael@0 | 17 | Married, |
michael@0 | 18 | Separated, |
michael@0 | 19 | Doghouse, |
michael@0 | 20 | } |
michael@0 | 21 | |
michael@0 | 22 | public enum Action { |
michael@0 | 23 | NeedsUpgrade, |
michael@0 | 24 | NeedsPassword, |
michael@0 | 25 | NeedsVerification, |
michael@0 | 26 | None, |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | protected final StateLabel stateLabel; |
michael@0 | 30 | public final String email; |
michael@0 | 31 | public final String uid; |
michael@0 | 32 | public final boolean verified; |
michael@0 | 33 | |
michael@0 | 34 | public State(StateLabel stateLabel, String email, String uid, boolean verified) { |
michael@0 | 35 | Utils.throwIfNull(email, uid); |
michael@0 | 36 | this.stateLabel = stateLabel; |
michael@0 | 37 | this.email = email; |
michael@0 | 38 | this.uid = uid; |
michael@0 | 39 | this.verified = verified; |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | public StateLabel getStateLabel() { |
michael@0 | 43 | return this.stateLabel; |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | public ExtendedJSONObject toJSONObject() { |
michael@0 | 47 | ExtendedJSONObject o = new ExtendedJSONObject(); |
michael@0 | 48 | o.put("version", State.CURRENT_VERSION); |
michael@0 | 49 | o.put("email", email); |
michael@0 | 50 | o.put("uid", uid); |
michael@0 | 51 | o.put("verified", verified); |
michael@0 | 52 | return o; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | public State makeSeparatedState() { |
michael@0 | 56 | return new Separated(email, uid, verified); |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | public State makeDoghouseState() { |
michael@0 | 60 | return new Doghouse(email, uid, verified); |
michael@0 | 61 | } |
michael@0 | 62 | |
michael@0 | 63 | public abstract void execute(ExecuteDelegate delegate); |
michael@0 | 64 | |
michael@0 | 65 | public abstract Action getNeededAction(); |
michael@0 | 66 | } |