summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2017-01-31 14:57:22 (GMT)
committerEdwin Mons <edwin.mons@isode.com>2017-02-27 14:07:13 (GMT)
commitfc8f5b31c22ed7af4f0e2473f269601a87a0438c (patch)
tree0c59a9debf72247c7409947a3a4cccb6c616dd06 /Swift/Controllers/HighlightRule.h
parentabd81d4a3cf08ffaa1e5265d204cdd80c8c0583b (diff)
downloadswift-fc8f5b31c22ed7af4f0e2473f269601a87a0438c.zip
swift-fc8f5b31c22ed7af4f0e2473f269601a87a0438c.tar.bz2
Redesign highlight logic and processing
The new highlight logic follows a simpler model. It supports: * highlighting of whole words in a message * highlighting messages by sender name * highlighting if the user’s name is mentioned Possible actions for these highlights are text colouring, sound playback of WAV files, and system notifications. In addition the user can decide to receive sound and system notification on general incoming direct and group messages. Redesigned the highlight configuration UI dialog for this new model. ChatMessageParser class now deals with all parsing and marking up the chat message with the matching HighlightActions. Highlighter class has been extended to deal with all sound and system notification highlights that should be emitted by a specified chat message. Moved some tests over to gtest in the process. Test-Information: Tested UI on macOS 10.12.3 with Qt 5.7.1. Manually tested that correct system notification are emitted on mentions, keyword highlights and general messages. Added new unit tests to cover new highlighting behaviour. Change-Id: I1c89e29d81022174187fb44af0d384036ec51594
Diffstat (limited to 'Swift/Controllers/HighlightRule.h')
-rw-r--r--Swift/Controllers/HighlightRule.h103
1 files changed, 0 insertions, 103 deletions
diff --git a/Swift/Controllers/HighlightRule.h b/Swift/Controllers/HighlightRule.h
deleted file mode 100644
index bffdc41..0000000
--- a/Swift/Controllers/HighlightRule.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2012 Maciej Niedzielski
- * Licensed under the simplified BSD license.
- * See Documentation/Licenses/BSD-simplified.txt for more information.
- */
-
-/*
- * Copyright (c) 2014-2016 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 <boost/regex.hpp>
-
-#include <Swift/Controllers/HighlightAction.h>
-
-namespace Swift {
-
- class HighlightRule {
- public:
- HighlightRule();
-
- enum MessageType { ChatMessage, MUCMessage };
-
- bool isMatch(const std::string& body, const std::string& sender, const std::string& nick, MessageType) const;
-
- const HighlightAction& getAction() const { return action_; }
- HighlightAction& getAction() { return action_; }
-
- const std::vector<std::string>& getSenders() const { return senders_; }
- void setSenders(const std::vector<std::string>&);
- const std::vector<boost::regex>& getSenderRegex() const { return senderRegex_; }
-
- const std::vector<std::string>& getKeywords() const { return keywords_; }
- void setKeywords(const std::vector<std::string>&);
- std::vector<boost::regex> getKeywordRegex(const std::string& nick) const;
-
- bool getNickIsKeyword() const { return nickIsKeyword_; }
- void setNickIsKeyword(bool);
-
- bool getMatchCase() const { return matchCase_; }
- void setMatchCase(bool);
-
- bool getMatchWholeWords() const { return matchWholeWords_; }
- void setMatchWholeWords(bool);
-
- bool getMatchChat() const { return matchChat_; }
- void setMatchChat(bool);
-
- bool getMatchMUC() const { return matchMUC_; }
- void setMatchMUC(bool);
-
- bool isEmpty() const;
-
- private:
- friend class boost::serialization::access;
- template<class Archive> void serialize(Archive & ar, const unsigned int version);
-
- static std::string boolToString(bool);
- static bool boolFromString(const std::string&);
-
- std::vector<std::string> senders_;
- std::vector<std::string> keywords_;
- bool nickIsKeyword_;
-
- mutable std::vector<boost::regex> senderRegex_;
- mutable std::vector<boost::regex> keywordRegex_;
- void updateRegex() const;
- boost::regex regexFromString(const std::string&) const;
-
- bool matchCase_;
- bool matchWholeWords_;
-
- bool matchChat_;
- bool matchMUC_;
-
- HighlightAction action_;
- };
-
- bool operator ==(HighlightRule const& a, HighlightRule const& b);
-
- template<class Archive>
- void HighlightRule::serialize(Archive& ar, const unsigned int /*version*/)
- {
- ar & senders_;
- ar & keywords_;
- ar & nickIsKeyword_;
- ar & matchChat_;
- ar & matchMUC_;
- ar & matchCase_;
- ar & matchWholeWords_;
- ar & action_;
- updateRegex();
- }
-
-}