summaryrefslogtreecommitdiffstats
blob: 41442149df5068c001574dcbd8e80ad17f8af732 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * Copyright (c) 2011-2012 Isode Limited, London, England.
 * All rights reserved.
 */
/*
 * Copyright (c) 2011 Remko Tronçon.
 * All rights reserved.
 */
package com.isode.stroke.client;

/**
 * Options for a client connection
 */
public class ClientOptions {
    /**
     * Whether ZLib stream compression should be used when available.
     *
     * Default: true
     */
    public boolean useStreamCompression;
    /**
     * Sets whether TLS encryption should be used.
     *
     * Default: UseTLSWhenAvailable
     */
    public UseTLS useTLS;
    /**
     * Sets whether plaintext authentication is
     * allowed over non-TLS-encrypted connections.
     *
     * Default: false
     */
    public boolean allowPLAINWithoutTLS;
    /**
     * Use XEP-198 stream resumption when available.
     *
     * Default: false
     */
    public boolean useStreamResumption;
    
    /**
     * Use XEP-0198 acks in the stream when available.
     * Default: true
     */
    public boolean useAcks;

    /**
     * The hostname to connect to.
     * Leave this empty for standard XMPP connection, based on the JID domain.
     */
    public String manualHostname;

    /**
     * The port to connect to.
     * Leave this to -1 to use the port discovered by SRV lookups, and 5222 as a
     * fallback.
     */
    public int manualPort;


    public enum UseTLS {
        NeverUseTLS,
        UseTLSWhenAvailable,
        RequireTLS
    }

    public ClientOptions() {
        useStreamCompression = true;
        useTLS = UseTLS.UseTLSWhenAvailable;
        useStreamResumption = false;
        allowPLAINWithoutTLS = false;
        useAcks = true;
        manualHostname = "";
        manualPort = -1;
    }

    @Override
    public String toString() {
        return
            "useStreamCompression:" + useStreamCompression +
            "; useStreamResumption:" + useStreamResumption +
            "; " + useTLS;
    }
}