aboutsummaryrefslogtreecommitdiffstats
path: root/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/service/OperationResults.java
blob: e08b5050013f8516dc25f74c7086df8a29daedcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package org.sufficientlysecure.keychain.service;

import android.os.Parcel;

public abstract class OperationResults {

    public static class ImportResult extends OperationResultParcel {

        public final int mNewKeys, mUpdatedKeys, mBadKeys;

        // Operation ok, at least one new key (no warnings)
        public static final int RESULT_OK_NEWKEYS = 1;
        // Operation ok, at least one new and one updated key (no warnings)
        public static final int RESULT_OK_BOTHKEYS = 2;
        // Operation ok, no new keys but upated ones (no warnings)
        public static final int RESULT_OK_UPDATED = 3;
        // Operation ok, but with warnings
        public static final int RESULT_OK_WITH_WARNINGS = 4;

        // Operation partially ok, but at least one key failed!
        public static final int RESULT_PARTIAL_WITH_ERRORS = 50;

        // Operation failed, errors thrown and no new keys imported
        public static final int RESULT_FAIL_ERROR = 100;
        // Operation failed, no keys to import...
        public static final int RESULT_FAIL_NOTHING = 101;

        public ImportResult(Parcel source) {
            super(source);
            mNewKeys = source.readInt();
            mUpdatedKeys = source.readInt();
            mBadKeys = source.readInt();
        }

        public ImportResult(int result, OperationLog log,
                            int newKeys, int updatedKeys, int badKeys) {
            super(result, log);
            mNewKeys = newKeys;
            mUpdatedKeys = updatedKeys;
            mBadKeys = badKeys;
        }

        @Override
        public void writeToParcel(Parcel dest, int flags) {
            super.writeToParcel(dest, flags);
            dest.writeInt(mNewKeys);
            dest.writeInt(mUpdatedKeys);
            dest.writeInt(mBadKeys);
        }

        public static Creator<ImportResult> CREATOR = new Creator<ImportResult>() {
            public ImportResult createFromParcel(final Parcel source) {
                return new ImportResult(source);
            }

            public ImportResult[] newArray(final int size) {
                return new ImportResult[size];
            }
        };

    }

}