2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
* list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
2019-03-15 12:14:23 +01:00
|
|
|
#pragma once
|
|
|
|
|
2020-02-06 20:33:02 +01:00
|
|
|
#include <LibGUI/Widget.h>
|
2020-03-07 10:32:51 +01:00
|
|
|
#include <LibWeb/Forward.h>
|
2019-03-15 12:14:23 +01:00
|
|
|
|
2019-03-16 01:45:49 +01:00
|
|
|
class IRCChannel;
|
2019-03-15 13:07:04 +01:00
|
|
|
class IRCClient;
|
2019-03-16 01:45:49 +01:00
|
|
|
class IRCQuery;
|
2019-03-15 13:07:04 +01:00
|
|
|
class IRCLogBuffer;
|
|
|
|
|
2020-02-02 15:07:41 +01:00
|
|
|
class IRCWindow : public GUI::Widget {
|
2019-07-25 19:49:28 +02:00
|
|
|
C_OBJECT(IRCWindow)
|
2019-03-15 12:14:23 +01:00
|
|
|
public:
|
2019-06-07 17:13:23 +02:00
|
|
|
enum Type {
|
2019-03-15 13:07:04 +01:00
|
|
|
Server,
|
|
|
|
Channel,
|
|
|
|
Query,
|
|
|
|
};
|
|
|
|
|
2019-03-16 01:15:19 +01:00
|
|
|
virtual ~IRCWindow() override;
|
2019-03-15 12:14:23 +01:00
|
|
|
|
|
|
|
String name() const { return m_name; }
|
|
|
|
void set_name(const String& name) { m_name = name; }
|
|
|
|
|
2019-03-15 13:07:04 +01:00
|
|
|
Type type() const { return m_type; }
|
|
|
|
|
|
|
|
void set_log_buffer(const IRCLogBuffer&);
|
|
|
|
|
2019-03-16 02:14:53 +01:00
|
|
|
bool is_active() const;
|
|
|
|
|
|
|
|
int unread_count() const;
|
|
|
|
void clear_unread_count();
|
|
|
|
|
2020-03-26 20:11:23 +01:00
|
|
|
void did_add_message(const String& name = {}, const String& message = {});
|
2019-03-16 02:14:53 +01:00
|
|
|
|
2019-03-16 01:45:49 +01:00
|
|
|
IRCChannel& channel() { return *(IRCChannel*)m_owner; }
|
|
|
|
const IRCChannel& channel() const { return *(const IRCChannel*)m_owner; }
|
|
|
|
|
|
|
|
IRCQuery& query() { return *(IRCQuery*)m_owner; }
|
|
|
|
const IRCQuery& query() const { return *(const IRCQuery*)m_owner; }
|
|
|
|
|
2019-03-15 12:14:23 +01:00
|
|
|
private:
|
2020-02-23 12:07:13 +01:00
|
|
|
IRCWindow(IRCClient&, void* owner, Type, const String& name);
|
|
|
|
|
2020-03-26 20:18:22 +01:00
|
|
|
void post_notification_if_needed(const String& name, const String& message);
|
|
|
|
|
2019-03-15 13:07:04 +01:00
|
|
|
IRCClient& m_client;
|
2019-03-16 01:45:49 +01:00
|
|
|
void* m_owner { nullptr };
|
2019-03-15 13:07:04 +01:00
|
|
|
Type m_type;
|
2019-03-15 12:14:23 +01:00
|
|
|
String m_name;
|
2020-03-07 10:27:02 +01:00
|
|
|
RefPtr<Web::HtmlView> m_html_view;
|
2020-05-27 14:25:13 -04:00
|
|
|
RefPtr<GUI::TextBox> m_text_box;
|
2019-06-21 18:37:47 +02:00
|
|
|
RefPtr<IRCLogBuffer> m_log_buffer;
|
2020-04-07 17:14:28 +00:00
|
|
|
RefPtr<GUI::Menu> m_context_menu;
|
2019-03-16 02:14:53 +01:00
|
|
|
int m_unread_count { 0 };
|
2019-03-15 12:14:23 +01:00
|
|
|
};
|