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

#pragma once

#include <string>
#include <vector>

#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>

#include <Swift/Controllers/Highlighting/HighlightAction.h>

namespace Swift {

class HighlightConfiguration {
public:
    class ContactHighlight {
    public:
        friend class boost::serialization::access;
        template<class Archive> void serialize(Archive & ar, const unsigned int version);

    public:
        std::string name;
        HighlightAction action;
    };

    class KeywordHightlight {
    public:
        friend class boost::serialization::access;
        template<class Archive> void serialize(Archive & ar, const unsigned int version);

    public:
        std::string keyword;
        bool matchCaseSensitive = false;
        HighlightAction action;
    };

    friend class boost::serialization::access;
    template<class Archive> void serialize(Archive & ar, const unsigned int version);

public:
    std::vector<KeywordHightlight> keywordHighlights;
    std::vector<ContactHighlight> contactHighlights;
    HighlightAction ownMentionAction;
    bool playSoundOnIncomingDirectMessages = false;
    bool showNotificationOnIncomingDirectMessages = false;
    bool playSoundOnIncomingGroupchatMessages = false;
    bool showNotificationOnIncomingGroupchatMessages = false;
};

bool operator ==(HighlightConfiguration const& a, HighlightConfiguration const& b);

template<class Archive>
void HighlightConfiguration::ContactHighlight::serialize(Archive& ar, const unsigned int /*version*/) {
    ar & name;
    ar & action;
}

template<class Archive>
void HighlightConfiguration::KeywordHightlight::serialize(Archive& ar, const unsigned int /*version*/) {
    ar & keyword;
    ar & matchCaseSensitive;
    ar & action;
}

template<class Archive>
void HighlightConfiguration::serialize(Archive& ar, const unsigned int /*version*/) {
    ar & keywordHighlights;
    ar & contactHighlights;
    ar & ownMentionAction;
    ar & playSoundOnIncomingDirectMessages;
    ar & showNotificationOnIncomingDirectMessages;
    ar & playSoundOnIncomingGroupchatMessages;
    ar & showNotificationOnIncomingGroupchatMessages;
}

}