The Battle for Wesnoth  1.15.2+dev
chat_events.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2006 - 2018 by Joerg Hinrichs <joerg.hinrichs@alice-dsl.de>
3  wesnoth playturn Copyright (C) 2003 by David White <dave@whitevine.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
18 class config;
19 #include <ctime>
20 #include <string>
21 
22 namespace events {
23 
25 {
26 public:
27  chat_handler();
28  virtual ~chat_handler();
29 
31 
32  void send_command(const std::string& cmd, const std::string& args="");
33 
34  virtual void send_to_server(const config& cfg) = 0;
35 protected:
36  void do_speak(const std::string& message, bool allies_only=false);
37 
38  //called from do_speak
39  virtual void add_chat_message(const std::time_t& time,
40  const std::string& speaker, int side, const std::string& message,
41  MESSAGE_TYPE type=MESSAGE_PRIVATE) = 0;
42  virtual void send_chat_message(const std::string& message, bool allies_only=false) = 0;
43 
44  //Why are these virtual?
45  virtual void send_whisper(const std::string& receiver, const std::string& message);
46 
47  virtual void add_whisper_sent(const std::string& receiver, const std::string& message);
48 
49  virtual void add_whisper_received(const std::string& sender, const std::string& message);
50 
51  virtual void send_chat_room_message(const std::string& room, const std::string& message);
52 
53  virtual void add_chat_room_message_sent(const std::string& room, const std::string& message);
54 
55  virtual void add_chat_room_message_received(const std::string& room,
56  const std::string& speaker, const std::string& message);
57 
58  /**
59  * Called when a processed command results in a relation (friend/ignore) change
60  * for a user whose name is passed as the 'name' arg
61  */
62  virtual void user_relation_changed(const std::string& name);
63 
64  void change_logging(const std::string& data);
65 
66  friend class chat_command_handler;
67 };
68 
69 }
virtual void add_chat_room_message_received(const std::string &room, const std::string &speaker, const std::string &message)
virtual void send_to_server(const config &cfg)=0
virtual void add_chat_room_message_sent(const std::string &room, const std::string &message)
void send_command(const std::string &cmd, const std::string &args="")
Definition: chat_events.cpp:86
virtual void add_whisper_received(const std::string &sender, const std::string &message)
virtual void send_chat_message(const std::string &message, bool allies_only=false)=0
virtual void send_whisper(const std::string &receiver, const std::string &message)
void do_speak(const std::string &message, bool allies_only=false)
void change_logging(const std::string &data)
Change the log level of a log domain.
Definition: chat_events.cpp:46
Handling of system events.
Definition: manager.hpp:41
virtual void add_whisper_sent(const std::string &receiver, const std::string &message)
virtual void user_relation_changed(const std::string &name)
Called when a processed command results in a relation (friend/ignore) change for a user whose name is...
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:68
virtual void send_chat_room_message(const std::string &room, const std::string &message)
virtual void add_chat_message(const std::time_t &time, const std::string &speaker, int side, const std::string &message, MESSAGE_TYPE type=MESSAGE_PRIVATE)=0