1//
2// This file is part of the aMule Project.
3//
4// Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5// Copyright (c) 2002-2011 Merkur ( devs@emule-project.net / http://www.emule-project.net )
6//
7// Any parts of this program derived from the xMule, lMule or eMule project,
8// or contributed by third-party developers are copyrighted by their
9// respective authors.
10//
11// This program is free software; you can redistribute it and/or modify
12// it under the terms of the GNU General Public License as published by
13// the Free Software Foundation; either version 2 of the License, or
14// (at your option) any later version.
15//
16// This program is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19// GNU General Public License for more details.
20//
21// You should have received a copy of the GNU General Public License
22// along with this program; if not, write to the Free Software
23// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
24//
25
26#ifndef CHATSELECTOR_H
27#define CHATSELECTOR_H
28
29#include "MuleTextCtrl.h"
30#include "MuleNotebook.h"
31#include "Types.h"				// Needed for uint16
32
33class CClientRef;
34class CFriend;
35
36
37/**
38 * This class is used to display chat sessions.
39 */
40class CChatSession : public CMuleTextCtrl
41{
42public:
43	CChatSession(wxWindow *parent, wxWindowID id = -1, const wxString& value = wxT(""), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr );
44	~CChatSession();
45
46	uint64	m_client_id;
47	bool	m_active;
48
49	/**
50	 * Appends the specified text.
51	 *
52	 * @param text The text to add.
53	 * @param style The style of the new text.
54	 * @param newline If a newline should be added to the end of the line.
55	 *
56	 * If newline is false, then no newlines will be at the end of added text,
57	 * even if the passed string ends with newlines. Multiline strings are
58	 * broken into indivudual lines and each are timestamped with the same date.
59	 */
60	void AddText( const wxString& text, const wxTextAttr& style, bool newline = true );
61};
62
63
64class CChatSelector : public CMuleNotebook
65{
66public:
67	CChatSelector(wxWindow* parent, wxWindowID id, const wxPoint& pos, wxSize siz, long style);
68	virtual			~CChatSelector() {};
69	CChatSession*	StartSession(uint64 client_id, const wxString& client_name, bool show = true);
70	void			EndSession(uint64 client_id = 0);
71	CChatSession*	GetPageByClientID(uint64 client_id);
72	int				GetTabByClientID(uint64 client_id);
73	bool			ProcessMessage(uint64 sender_id, const wxString& message);
74	bool			SendMessage(const wxString& message, const wxString& client_name = wxEmptyString, uint64 to_id = 0);
75	void			ConnectionResult(bool success, const wxString& message, uint64 id);
76	void			RefreshFriend(uint64 toupdate_id, const wxString& new_name);
77	void			ShowCaptchaResult(uint64 id, bool ok);
78	bool			GetCurrentClient(CClientRef&) const;
79};
80
81#endif
82// File_checked_for_headers
83