summaryrefslogtreecommitdiffstats
blob: c0885b622e3a7a8510414dc126489eaa125cf85b (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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * Copyright (c) 2010 Kevin Smith
 * Licensed under the GNU General Public License v3.
 * See Documentation/Licenses/GPLv3.txt for more information.
 */

#pragma once

#include "Swiften/Base/boost_bsignals.h"
#include <boost/shared_ptr.hpp>
#include <vector>

#include "Swiften/Network/BoostIOServiceThread.h"
#include "Swiften/Network/BoostTimerFactory.h"
#include "SwifTools/Idle/PlatformIdleQuerier.h"
#include "SwifTools/Idle/ActualIdleDetector.h"
#include "Swiften/Base/String.h"
#include "Swiften/Client/ClientError.h"
#include "Swiften/JID/JID.h"
#include "Swiften/Elements/VCard.h"
#include "Swiften/Elements/DiscoInfo.h"
#include "Swiften/Elements/ErrorPayload.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/Settings/SettingsProvider.h"
#include "Swift/Controllers/ProfileSettingsProvider.h"
#include "Swiften/Elements/CapsInfo.h"
#include "Swift/Controllers/XMPPEvents/ErrorEvent.h"
#include "Swiften/Roster/XMPPRoster.h"

namespace Swift {
	class AvatarStorage;
	class CapsStorage;
	class VCardStorage;
	class VCardManager;
	class Application;
	class Client;
	class ChatWindowFactory;
	class ChatController;
	class ChatsManager;
	class ChatListWindowFactory;
	class EventController;
	class MainWindowFactory;
	class MainWindow;
	class NickResolver;
	class RosterController;
	class XMPPRosterController;
	class PresenceSender;
	class DiscoInfoResponder;
	class AvatarManager;
	class CapsManager;
	class EntityCapsManager;
	class LoginWindow;
	class EventLoop;
	class SoftwareVersionResponder;
	class LoginWindowFactory;
	class MUCController;
	class Notifier;
	class PresenceOracle;
	class PresenceNotifier;
	class EventNotifier;
	class SystemTray;
	class SystemTrayController;
	class SoundEventController;
	class SoundPlayer;
	class XMLConsoleController;
	class UIEventStream;
	class XMLConsoleWidgetFactory;
	class EventWindowFactory;
	class EventWindowController;
	class MUCSearchController;
	class MUCSearchWindowFactory;
	class StatusTracker;
	class VCardStorageFactory;
	class MUCRegistry;
	class Dock;

	class MainController {
		public:
			MainController(
					ChatWindowFactory* chatWindowFactory,
					MainWindowFactory *mainWindowFactory,
					LoginWindowFactory *loginWindowFactory,
					EventWindowFactory* eventWindowFactory,
					SettingsProvider *settings,
					SystemTray* systemTray,
					SoundPlayer* soundPlayer,
					XMLConsoleWidgetFactory* xmlConsoleWidgetFactory,
					ChatListWindowFactory* chatListWindowFactory_,
					MUCSearchWindowFactory* mucSearchWindowFactory,
					AvatarStorage* avatarStorage,
					CapsStorage* capsStorage,
					VCardStorageFactory* vcardStorageFactory,
					Dock* dock,
					Notifier* notifier,
					bool useDelayForLatency);
			~MainController();


		private:
			void resetClient();
			void handleConnected();
			void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember, bool loginAutomatically);
			void handleCancelLoginRequest();
			void handleChangeStatusRequest(StatusShow::Type show, const String &statusText);
			void handleError(const ClientError& error);
			void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo>, const boost::optional<ErrorPayload>&);
			void handleEventQueueLengthChange(int count);
			void handleVCardReceived(const JID& j, VCard::ref vCard);
			void sendPresence(boost::shared_ptr<Presence> presence);
			void handleInputIdleChanged(bool);
			void logout();
			void signOut();
			void setReconnectTimer();
			void resetPendingReconnects();
			void resetCurrentError();
	
			void performLoginFromCachedCredentials();
			void reconnectAfterError();
			void setManagersEnabled(bool enabled);
			void handleNotificationClicked(const JID& jid);

			VCardStorage* getVCardStorageForProfile(const JID& jid);

		private:
			BoostIOServiceThread boostIOServiceThread_;
			BoostTimerFactory timerFactory_;
			PlatformIdleQuerier idleQuerier_;
			ActualIdleDetector idleDetector_;
			Client* client_;
			PresenceSender* presenceSender_;
			ChatWindowFactory* chatWindowFactory_;
			MainWindowFactory* mainWindowFactory_;
			LoginWindowFactory* loginWindowFactory_;
			EventWindowFactory* eventWindowFactory_;
			SettingsProvider *settings_;
			ProfileSettingsProvider* profileSettings_;
			AvatarStorage* avatarStorage_;
			CapsStorage* capsStorage_;
			VCardStorageFactory* vcardStorageFactory_;
			VCardManager* vcardManager_;
			Dock* dock_;
			Notifier* notifier_;
			PresenceNotifier* presenceNotifier_;
			EventNotifier* eventNotifier_;
			XMPPRosterController* xmppRosterController_;
			RosterController* rosterController_;
			EventController* eventController_;
			EventWindowController* eventWindowController_;
			LoginWindow* loginWindow_;
			SoftwareVersionResponder* clientVersionResponder_;
			NickResolver* nickResolver_;
			DiscoInfoResponder* discoResponder_;
			UIEventStream* uiEventStream_;
			XMLConsoleController* xmlConsoleController_;
			ChatsManager* chatsManager_;
			boost::shared_ptr<CapsInfo> capsInfo_;
			boost::shared_ptr<DiscoInfo> serverDiscoInfo_;
			XMPPRoster* xmppRoster_;;
			JID jid_;
			PresenceOracle* presenceOracle_;
			SystemTrayController* systemTrayController_;
			SoundEventController* soundEventController_;
			AvatarManager* avatarManager_;
			CapsManager* capsManager_;
			EntityCapsManager* entityCapsManager_;
			String vCardPhotoHash_;
			String password_;
			String certificateFile_;
			ChatListWindowFactory* chatListWindowFactory_;
			boost::shared_ptr<ErrorEvent> lastDisconnectError_;
			bool useDelayForLatency_;
			MUCSearchController* mucSearchController_;
			MUCSearchWindowFactory* mucSearchWindowFactory_;
			int timeBeforeNextReconnect_;
			Timer::ref reconnectTimer_;
			StatusTracker* statusTracker_;
			MUCRegistry* mucRegistry_;

			typedef std::map<String, VCardStorage*> VCardStorageMap;
			VCardStorageMap vcardStorages_;
	};
}