summaryrefslogtreecommitdiffstats
blob: c902388479a44b7343dd921aa7ba769c1291047a (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * Copyright (c) 2011-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <boost/shared_ptr.hpp>

#include <Swiften/Base/API.h>
#include <Swiften/Base/SafeString.h>
#include <Swiften/Base/URL.h>
#include <Swiften/TLS/TLSOptions.h>

namespace Swift {
    class HTTPTrafficFilter;

    struct SWIFTEN_API ClientOptions {
        enum UseTLS {
            NeverUseTLS,
            UseTLSWhenAvailable,
            RequireTLS
        };

        enum ProxyType {
            NoProxy,
            SystemConfiguredProxy,
            SOCKS5Proxy,
            HTTPConnectProxy
        };

        ClientOptions() :
                useStreamCompression(true),
                useTLS(UseTLSWhenAvailable),
                allowPLAINWithoutTLS(false),
                useStreamResumption(false),
                forgetPassword(false),
                useAcks(true),
                singleSignOn(false),
                manualHostname(""),
                manualPort(-1),
                proxyType(SystemConfiguredProxy),
                manualProxyHostname(""),
                manualProxyPort(-1),
                boshHTTPConnectProxyAuthID(""),
                boshHTTPConnectProxyAuthPassword("") {
        }

        /**
         * Whether ZLib stream compression should be used when available.
         *
         * Default: true
         */
        bool useStreamCompression;

        /**
         * Sets whether TLS encryption should be used.
         *
         * Default: UseTLSWhenAvailable
         */
        UseTLS useTLS;

        /**
         * Sets whether plaintext authentication is
         * allowed over non-TLS-encrypted connections.
         *
         * Default: false
         */
        bool allowPLAINWithoutTLS;

        /**
         * Use XEP-196 stream resumption when available.
         *
         * Default: false
         */
        bool useStreamResumption;

        /**
         * Forget the password once it's used.
         * This makes the Client useless after the first login attempt.
         *
         * FIXME: This is a temporary workaround.
         *
         * Default: false
         */
        bool forgetPassword;

        /**
         * Use XEP-0198 acks in the stream when available.
         * Default: true
         */
        bool useAcks;

        /**
         * Use Single Sign On.
         * Default: false
         */
        bool singleSignOn;

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

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

        /**
         * The type of proxy to use for connecting to the XMPP
         * server.
         */
        ProxyType proxyType;

        /**
         * Override the system-configured proxy hostname.
         */
        std::string manualProxyHostname;

        /**
         * Override the system-configured proxy port.
         */
        int manualProxyPort;

        /**
         * If non-empty, use BOSH instead of direct TCP, with the given URL.
         * Default: empty (no BOSH)
         */
        URL boshURL;

        /**
         * If non-empty, BOSH connections will try to connect over this HTTP CONNECT
         * proxy instead of directly.
         * Default: empty (no proxy)
         */
        URL boshHTTPConnectProxyURL;

        /**
         * If this and matching Password are non-empty, BOSH connections over
         * HTTP CONNECT proxies will use these credentials for proxy access.
         * Default: empty (no authentication needed by the proxy)
         */
        SafeString boshHTTPConnectProxyAuthID;
        SafeString boshHTTPConnectProxyAuthPassword;

        /**
         * This can be initialized with a custom HTTPTrafficFilter, which allows HTTP CONNECT
         * proxy initialization to be customized.
         */
        boost::shared_ptr<HTTPTrafficFilter> httpTrafficFilter;

        /**
         * Options passed to the TLS stack
         */
        TLSOptions tlsOptions;
    };
}