summaryrefslogtreecommitdiffstats
blob: 1fd7c4c77e87688fbf8aec81f2915cec2524749e (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
#ifndef SWIFTEN_MainController_H
#define SWIFTEN_MainController_H

#include <boost/signals.hpp>
#include <boost/shared_ptr.hpp>
#include <vector>

#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/Error.h"
#include "Swiften/Elements/Presence.h"
#include "Swiften/Elements/Message.h"
#include "Swiften/Settings/SettingsProvider.h"
#include "Swiften/Elements/CapsInfo.h"
#include "Swiften/MUC/MUCRegistry.h"

namespace Swift {
	class AvatarStorage;
	class Application;
	class Client;
	class ChatWindowFactory;
	class ChatController;
	class EventController;
	class MainWindowFactory;
	class MainWindow;
	class NickResolver;
	class RosterController;
	class XMPPRosterController;
	class DiscoInfoResponder;
	class AvatarManager;
	class LoginWindow;
	class EventLoop;
	class SoftwareVersionResponder;
	class LoginWindowFactory;
	class TreeWidgetFactory;
	class MUCController;
	class PresenceOracle;
	class SystemTray;
	class SystemTrayController;
	class SoundEventController;
	class SoundPlayer;

	class MainController : public MUCRegistry {
		public:
			MainController(ChatWindowFactory* chatWindowFactory, MainWindowFactory *mainWindowFactory, LoginWindowFactory *loginWindowFactory, TreeWidgetFactory* treeWidgetFactory, SettingsProvider *settings, Application* application, SystemTray* systemTray, SoundPlayer* soundPlayer);
			~MainController();


		private:
			void handleConnected();
			void handleLoginRequest(const String& username, const String& password, const String& certificateFile, bool remember);
			void handleChatRequest(const String& contact);
			void handleJoinMUCRequest(const JID& muc, const String& nick);
			void handleIncomingPresence(boost::shared_ptr<Presence> presence);
			void handleChatControllerJIDChanged(const JID& from, const JID& to);
			void handleIncomingMessage(boost::shared_ptr<Message> message);
			void handleChangeStatusRequest(StatusShow::Type show, const String &statusText);
			void handleError(const ClientError& error);
			void handleServerDiscoInfoResponse(boost::shared_ptr<DiscoInfo>, const boost::optional<Error>&);
			void handleEventQueueLengthChange(int count);
			void handleOwnVCardReceived(boost::shared_ptr<VCard> vCard, const boost::optional<Error>& error);
			ChatController* getChatController(const JID &contact);
			void sendPresence(boost::shared_ptr<Presence> presence);
			void logout();

			virtual bool isMUC(const JID& muc) const;
	
		private:	
			Client* client_;
			ChatWindowFactory* chatWindowFactory_;
			MainWindowFactory* mainWindowFactory_;
			LoginWindowFactory* loginWindowFactory_;
			TreeWidgetFactory* treeWidgetFactory_;
			SettingsProvider *settings_;
			Application* application_;
			AvatarStorage* avatarStorage_;
			ChatController* chatController_;
			XMPPRosterController* xmppRosterController_;
			RosterController* rosterController_;
			EventController* eventController_;
			LoginWindow* loginWindow_;
			SoftwareVersionResponder* clientVersionResponder_;
			NickResolver* nickResolver_;
			DiscoInfoResponder* discoResponder_;
			boost::shared_ptr<CapsInfo> capsInfo_;
			std::map<JID, MUCController*> mucControllers_;
			std::map<JID, ChatController*> chatControllers_;
			boost::shared_ptr<DiscoInfo> serverDiscoInfo_;
			JID jid_;
			PresenceOracle* presenceOracle_;
			SystemTrayController* systemTrayController_;
			SoundEventController* soundEventController_;
			AvatarManager* avatarManager_;
			boost::shared_ptr<Presence> lastSentPresence_;
			String vCardPhotoHash_;
	};
}
#endif