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

#pragma once

#include <map>
#include <vector>

#include <boost/signals2.hpp>

#include <Swiften/Elements/StatusShow.h>
#include <Swiften/JID/JID.h>

namespace Swift {
class Chattables {
    public:
        struct State {
            enum class Type {Room, Person};
            JID jid;
            /// Empty for no name
            std::string name;
            int unreadCount = 0;
            Type type;
            StatusShow::Type status = StatusShow::None;
            //avatar
            //status
        };
        const std::vector<JID>& get() const;
        const State& getState(const JID& jid) const;

        void addJID(const JID& jid, State::Type type);
        void setState(const JID& jid, State state);

        boost::signals2::signal<void (const JID&)> onAdded;
        boost::signals2::signal<void (const JID&)> onRemoved;
        boost::signals2::signal<void (const JID&)> onChanged;
        /// The UI has activated a chattable item (e.g. clicked in the roster)
        boost::signals2::signal<void (const JID&)> onActivated;
    private:
        std::vector<JID> list_;
        std::map<JID, State> states_;
        State unknown_;
};
}