1 // Copyright (C) 2007 Mark Pustjens <pustjens@dds.nl>
2 // Copyright (C) 2010-2015 Petr Pavlu <setup@dagobah.cz>
4 // This file is part of CenterIM.
6 // CenterIM 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.
11 // CenterIM is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with CenterIM. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CONVERSATION_H
20 #define CONVERSATION_H
22 #include "ConversationRoomList.h"
25 #include <cppconsui/AbstractLine.h>
26 #include <cppconsui/TextEdit.h>
27 #include <cppconsui/TextView.h>
28 #include <cppconsui/VerticalLine.h>
29 #include <cppconsui/Window.h>
30 #include <libpurple/purple.h>
32 class Conversation
: public CppConsUI::Window
{
34 explicit Conversation(PurpleConversation
*conv
);
35 virtual ~Conversation() override
;
38 virtual bool processInput(const TermKeyKey
&key
) override
;
41 virtual void moveResize(int newx
, int newy
, int neww
, int newh
) override
;
42 virtual bool restoreFocus() override
;
43 virtual void ungrabFocus() override
;
46 virtual void show() override
;
47 virtual void close() override
;
48 virtual void onScreenResized() override
;
50 void write(const char *name
, const char *alias
, const char *message
,
51 PurpleMessageFlags flags
, time_t mtime
);
53 PurpleConversation
*getPurpleConversation() const { return conv_
; };
55 ConversationRoomList
*getRoomList() const { return room_list_
; };
58 class ConversationLine
: public CppConsUI::AbstractLine
{
60 ConversationLine(const char *text
);
61 virtual ~ConversationLine() override
;
65 CppConsUI::Curses::ViewPort area
, CppConsUI::Error
&error
) override
;
69 std::size_t text_width_
;
72 CONSUI_DISABLE_COPY(ConversationLine
);
75 CppConsUI::TextView
*view_
;
76 CppConsUI::TextEdit
*input_
;
77 ConversationLine
*line_
;
79 PurpleConversation
*conv_
;
84 std::size_t input_text_length_
;
86 // Only PURPLE_CONV_TYPE_CHAT have a room list.
87 ConversationRoomList
*room_list_
;
88 CppConsUI::VerticalLine
*room_list_line_
;
90 char *stripHTML(const char *str
) const;
91 void destroyPurpleConversation(PurpleConversation
*conv
);
92 void buildLogFilename();
93 char *extractTime(time_t sent_time
, time_t show_time
) const;
95 bool processCommand(const char *raw
, const char *html
);
96 void onInputTextChange(CppConsUI::TextEdit
&activator
);
101 CONSUI_DISABLE_COPY(Conversation
);
103 void declareBindables();
106 #endif // CONVERSATION_H
108 // vim: set tabstop=2 shiftwidth=2 textwidth=80 expandtab: