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

#pragma once

#include <memory>
#include <string>

#include <boost/signals2.hpp>

namespace Swift {

    class Form;

    class FdpFormSubmitWindow {

        public:
            enum class NodeError {
                DomainNotFound,
                NoFdpNodesInDomain,
                NoError,
            };
            enum class TemplateError {
                CannotLocateForm,
                InvalidPayload,
                RequestFailed,
                NoError,
            };

            virtual ~FdpFormSubmitWindow() {}

            virtual void show() = 0;
            virtual void raise() = 0;
            virtual void addNode(const std::string& node, const std::string& nodeName) = 0;
            virtual void clearNodeData() = 0;
            virtual void setFormData(const std::shared_ptr<Form>& form) = 0;
            virtual void showNodePlaceholder(NodeError nodeError) = 0;
            virtual void showFormPlaceholder(TemplateError templateError) = 0;
            virtual void handleSubmitServerResponse(bool submissionSuccess) = 0;

            boost::signals2::signal<void ()> onCloseEvent;
            boost::signals2::signal<void (const std::string&)> onRequestPubSubNodeData;
            boost::signals2::signal<void (const std::string&)> onRequestTemplateForm;
            boost::signals2::signal<void (const std::shared_ptr<Form>&)> onSubmitForm;

        protected:

            std::string getNodeErrorText(NodeError nodeError) const;
            std::string getTemplateErrorText(TemplateError templateError) const;
    };
}