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

#include <Swift/Controllers/Chat/Chattables.h>

namespace Swift {

const std::vector<JID>& Chattables::get() const {
    return list_;
}

const Chattables::State& Chattables::getState(const JID& jid) const {
    auto it = states_.find(jid);
    return it != states_.end() ? it->second : unknown_;
}

void Chattables::addJID(const JID& jid, State::Type type) {
    if (states_.find(jid) != states_.end()) {
        return;
    }
    State state;
    state.type = type;
    state.jid = jid;
    list_.push_back(jid);
    states_[jid] = state;
    onAdded(jid);
}

void Chattables::setState(const JID& jid, State state) {
    states_[jid] = state;
    onChanged(jid);
}

}