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 this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef CONVERSATION_H
20 #define CONVERSATION_H
23 #include "ConversationRoomList.h"
25 #include <cppconsui/AbstractLine.h>
26 #include <cppconsui/VerticalLine.h>
27 #include <cppconsui/TextEdit.h>
28 #include <cppconsui/TextView.h>
29 #include <cppconsui/Window.h>
30 #include <libpurple/purple.h>
32 class Conversation
: public CppConsUI::Window
{
34 Conversation(PurpleConversation
*conv
);
35 virtual ~Conversation();
38 virtual bool processInput(const TermKeyKey
&key
);
41 virtual void moveResize(int newx
, int newy
, int neww
, int newh
);
42 virtual bool restoreFocus();
43 virtual void ungrabFocus();
48 virtual void onScreenResized();
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();
64 virtual int draw(CppConsUI::Curses::ViewPort area
, CppConsUI::Error
&error
);
71 CONSUI_DISABLE_COPY(ConversationLine
);
74 CppConsUI::TextView
*view_
;
75 CppConsUI::TextEdit
*input_
;
76 ConversationLine
*line_
;
78 PurpleConversation
*conv_
;
83 size_t input_text_length_
;
85 // Only PURPLE_CONV_TYPE_CHAT have a room list.
86 ConversationRoomList
*room_list_
;
87 CppConsUI::VerticalLine
*room_list_line_
;
89 char *stripHTML(const char *str
) const;
90 void destroyPurpleConversation(PurpleConversation
*conv
);
91 void buildLogFilename();
92 char *extractTime(time_t sent_time
, time_t show_time
) const;
94 bool processCommand(const char *raw
, const char *html
);
95 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: