| 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
 | /*
 * Copyright (c) 2010-2016 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */
#pragma once
#include <map>
#include <memory>
#include <string>
#include <vector>
#include <boost/signals2.hpp>
#include <Swiften/Elements/DiscoInfo.h>
#include <Swiften/Elements/DiscoItems.h>
#include <Swiften/Elements/ErrorPayload.h>
#include <Swiften/JID/JID.h>
#include <Swift/Controllers/ProfileSettingsProvider.h>
#include <Swift/Controllers/UIEvents/UIEvent.h>
namespace Swift {
    class UIEventStream;
    class MUCSearchWindow;
    class MUCSearchWindowFactory;
    class IQRouter;
    class DiscoServiceWalker;
    class NickResolver;
    class MUCService {
        public:
            class MUCRoom {
                public:
                    MUCRoom(const std::string& node, const std::string& name, int occupants) : node_(node), name_(name), occupants_(occupants) {}
                    std::string getNode() {return node_;}
                    std::string getName() {return name_;}
                    int getOccupantCount() {return occupants_;}
                private:
                    std::string node_;
                    std::string name_;
                    int occupants_;
            };
            MUCService() {error_ = false; complete_ = false;}
            void setComplete(bool complete) {
                complete_ = complete;
            }
            void setName(const std::string& name) {
                name_ = name;
            }
            void setJID(const JID& jid) {
                jid_ = jid;
            }
            bool getComplete() const {
                return complete_;
            }
            JID getJID() const {
                return jid_;
            }
            std::string getName() const {
                return name_;
            }
            void setError(const std::string& errorText) {error_ = true; errorText_ = errorText;}
            void clearRooms() {rooms_.clear();}
            void addRoom(const MUCRoom& room) {rooms_.push_back(room);}
            std::vector<MUCRoom> getRooms() const {return rooms_;}
        private:
            std::string name_;
            JID jid_;
            std::vector<MUCRoom> rooms_;
            bool complete_;
            bool error_;
            std::string errorText_;
    };
    class MUCSearchController {
        public:
            MUCSearchController(const JID& jid, MUCSearchWindowFactory* mucSearchWindowFactory, IQRouter* iqRouter, ProfileSettingsProvider* settings);
            ~MUCSearchController();
            void openSearchWindow();
        public:
            boost::signals2::signal<void (const JID&)> onMUCSelected;
        private:
            void handleSearchService(const JID& jid);
            void handleRoomsItemsResponse(std::shared_ptr<DiscoItems> items, ErrorPayload::ref error, const JID& jid);
            void handleDiscoError(const JID& jid, ErrorPayload::ref error);
            void handleDiscoServiceFound(const JID&, std::shared_ptr<DiscoInfo>);
            void handleDiscoWalkFinished();
            void handleMUCSearchFinished(const boost::optional<JID>& result);
            void removeService(const JID& jid);
            void refreshView();
            void loadSavedServices();
            void addToSavedServices(const JID& jid);
            void updateInProgressness();
        private:
            JID jid_;
            MUCSearchWindowFactory* factory_;
            IQRouter* iqRouter_;
            ProfileSettingsProvider* settings_;
            MUCSearchWindow* window_;
            DiscoServiceWalker* walker_;
            std::list<JID> services_;
            std::list<JID> savedServices_;
            std::map<JID, MUCService> serviceDetails_;
            std::vector<DiscoServiceWalker*> walksInProgress_;
            int itemsInProgress_;
    };
}
 |