summaryrefslogtreecommitdiffstats
blob: 6aea1944209437cf6c15f92fcfa6476f4d15705c (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
/*
 * Copyright (c) 2010-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <memory>
#include <string>

#include <boost/signals2.hpp>

#include <Swiften/Base/ByteArray.h>
#include <Swiften/JID/JID.h>
#include <Swiften/Network/Connection.h>
#include <Swiften/Session/Session.h>

namespace Swift {
    class ProtocolHeader;
    class ToplevelElement;
    class Stanza;
    class PayloadParserFactoryCollection;
    class PayloadSerializerCollection;
    class StreamStack;
    class UserRegistry;
    class XMPPLayer;
    class ConnectionLayer;
    class Connection;
    class XMLParserFactory;

    class ServerFromClientSession : public Session {
        public:
            ServerFromClientSession(
                    const std::string& id,
                    std::shared_ptr<Connection> connection,
                    PayloadParserFactoryCollection* payloadParserFactories,
                    PayloadSerializerCollection* payloadSerializers,
                    XMLParserFactory* xmlParserFactory,
                    UserRegistry* userRegistry);

            boost::signals2::signal<void ()> onSessionStarted;
            void setAllowSASLEXTERNAL();

        private:
            void handleElement(std::shared_ptr<ToplevelElement>);
            void handleStreamStart(const ProtocolHeader& header);

            void setInitialized();
            bool isInitialized() const {
                return initialized;
            }

        private:
            std::string id_;
            UserRegistry* userRegistry_;
            bool authenticated_;
            bool initialized;
            bool allowSASLEXTERNAL;
            std::string user_;
    };
}