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

#pragma once

#include <map>
#include <string>

#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>

#include <Swiften/Base/Platform.h>
#include <Swiften/Client/ClientOptions.h>
#include <Swiften/EventLoop/Qt/QtEventLoop.h>
#include <Swiften/Network/BoostNetworkFactories.h>
#include <Swiften/TLS/PlatformTLSFactories.h>

#include <SwifTools/AutoUpdater/AutoUpdater.h>
#include <SwifTools/Idle/ActualIdleDetector.h>
#include <SwifTools/Idle/PlatformIdleQuerier.h>

#include <Swift/QtUI/QtSettingsProvider.h>

#if defined(SWIFTEN_PLATFORM_MACOSX)
#include <SwifTools/Application/CocoaApplication.h>
#include <CocoaApplicationActivateHelper.h>
#endif
#if defined(SWIFTEN_PLATFORM_WINDOWS)
#include <WindowsNotifier.h>
#endif

namespace po = boost::program_options;

class QSplitter;

namespace Swift {
    class ApplicationPathProvider;
    class AvatarStorage;
    class CapsStorage;
    class CertificateStorageFactory;
    class Dock;
    class EventLoop;
    class AccountController;
    class Notifier;
    class QtChatTabs;
    class QtChatWindowFactory;
    class QtLoginWindow;
    class QtMUCSearchWindowFactory;
    class QtSingleWindow;
    class QtSoundPlayer;
    class QtSystemTray;
    class QtUIFactory;
    class QtUserSearchWindowFactory;
    class SettingsProviderHierachy;
    class StatusCache;
    class StoragesFactory;
    class URIHandler;
    class XMLSettingsProvider;

    class QtSwift : public QObject {
        Q_OBJECT
        public:
            QtSwift(const po::variables_map& options);
            static po::options_description getOptionsDescription();
            ~QtSwift();

        private slots:
            void handleAboutToQuit();
            void handleAutoUpdaterStateChanged(AutoUpdater::State updatedState);
            void handleWantsToAddAccount();

        private:
            XMLSettingsProvider* loadSettingsFile(const QString& fileName);
            void loadEmoticonsFile(const QString& fileName, std::map<std::string, std::string>& emoticons);
            static const std::string& updateChannelToFeed(const std::string& channel);
            QtLoginWindow* addAccount();
            ClientOptions parseClientOptions(const std::string& optionString);
            void restoreAccounts();
            /**
            * Upgrades the config from pre-multi-account to post-multi-account format (added in 5.0).
            */
            void migrateLastLoginAccount();

        private:
            QtEventLoop clientMainThreadCaller_;
            PlatformTLSFactories tlsFactories_;
            BoostNetworkFactories networkFactories_;
            QtChatWindowFactory* chatWindowFactory_;
            std::vector<AccountController*> accountControllers_;
            std::vector<QtSystemTray*> systemTrays_;
            std::vector<QtUIFactory*> uiFactories_;
            QtSettingsProvider* qtSettings_;
            XMLSettingsProvider* xmlSettings_;
            SettingsProviderHierachy* settingsHierarchy_;
            QtSingleWindow* splitter_;
            QtSoundPlayer* soundPlayer_;
            Dock* dock_;
            URIHandler* uriHandler_;
            ApplicationPathProvider* applicationPathProvider_;
            StoragesFactory* storagesFactory_;
            CertificateStorageFactory* certificateStorageFactory_;
            AutoUpdater* autoUpdater_ = nullptr;
            Notifier* notifier_;
            StatusCache* statusCache_;
            PlatformIdleQuerier idleQuerier_;
            ActualIdleDetector idleDetector_;
            std::map<std::string, std::string> emoticons_;
            bool enableAdHocCommandOnJID_ = false;
            bool useDelayForLatency_;
#if defined(SWIFTEN_PLATFORM_MACOSX)
            CocoaApplication cocoaApplication_;
            CocoaApplicationActivateHelper cocoaApplicationActivateHelper_;
#endif
    };
}