summaryrefslogtreecommitdiffstats
blob: b9d45396d5ed81445cd88ef7a5bcf5346458d352 (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
/*
 * Copyright (c) 2012 Maciej Niedzielski
 * Licensed under the simplified BSD license.
 * See Documentation/Licenses/BSD-simplified.txt for more information.
 */

/*
 * Copyright (c) 2014-2015 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#pragma once

#include <string>

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

namespace Swift {

    class HighlightRule;

    class HighlightAction {
        public:
            HighlightAction() : highlightWholeMessage_(false), playSound_(false) {}

            /**
            * Gets the flag that indicates the entire message should be highlighted.
            */
            bool highlightWholeMessage() const { return highlightWholeMessage_; }
            void setHighlightWholeMessage(bool highlightText);

            /**
            * Gets the foreground highlight color.
            */
            const std::string& getTextColor() const { return textColor_; }
            void setTextColor(const std::string& textColor) { textColor_ = textColor; }

            /**
            * Gets the background highlight color.
            */
            const std::string& getTextBackground() const { return textBackground_; }
            void setTextBackground(const std::string& textBackground) { textBackground_ = textBackground; }

            bool playSound() const { return playSound_; }
            void setPlaySound(bool playSound);

            /**
            * Gets the sound filename. If the string is empty, assume a default sound file.
            */
            const std::string& getSoundFile() const { return soundFile_; }
            void setSoundFile(const std::string& soundFile) { soundFile_ = soundFile; }

            bool isEmpty() const { return !highlightWholeMessage_ && !playSound_; }

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

            bool highlightWholeMessage_;
            std::string textColor_;
            std::string textBackground_;

            bool playSound_;
            std::string soundFile_;
    };

    bool operator ==(HighlightAction const& a, HighlightAction const& b);
    bool operator !=(HighlightAction const& a, HighlightAction const& b);

    template<class Archive>
    void HighlightAction::serialize(Archive& ar, const unsigned int /*version*/)
    {
        ar & highlightWholeMessage_;
        ar & textColor_;
        ar & textBackground_;
        ar & playSound_;
        ar & soundFile_;
    }

}