2
* xmlconsole.cpp - dialog for interacting manually with Jabber
3
* Copyright (C) 2001, 2002 Justin Karneges
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this library; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#include"xmlconsole.h"
24
#include<qpushbutton.h>
28
#include"psiaccount.h"
32
//----------------------------------------------------------------------------
34
//----------------------------------------------------------------------------
35
XmlConsole::XmlConsole(PsiAccount *_pa, QWidget *parent, const char *name)
36
:QWidget(parent, name)
39
pa->dialogRegister(this);
40
connect(pa, SIGNAL(updatedAccount()), SLOT(updateCaption()));
41
connect(pa->client(), SIGNAL(xmlIncoming(const QString &)), SLOT(client_xmlIncoming(const QString &)));
42
connect(pa->client(), SIGNAL(xmlOutgoing(const QString &)), SLOT(client_xmlOutgoing(const QString &)));
45
QVBoxLayout *vb1 = new QVBoxLayout(this, 8);
49
te = new QTextEdit(this);
50
te->setUndoRedoEnabled(false);
51
te->setReadOnly(true);
52
te->setTextFormat(PlainText);
54
te->setPaper(QBrush(Qt::black));
57
QHBoxLayout *hb1 = new QHBoxLayout(vb1);
58
ck_enable = new QCheckBox(tr("Enable"), this);
59
hb1->addWidget(ck_enable);
63
pb = new QPushButton(tr("Clear"), this);
64
pb->setMinimumWidth(80);
65
connect(pb, SIGNAL(clicked()), te, SLOT(clear()));
68
pb = new QPushButton(tr("&XML Input..."), this);
69
pb->setMinimumWidth(80);
70
connect(pb, SIGNAL(clicked()), SLOT(insertXml()));
73
pb = new QPushButton(tr("&Close"), this);
74
pb->setMinimumWidth(80);
75
connect(pb, SIGNAL(clicked()), SLOT(close()));
81
XmlConsole::~XmlConsole()
83
pa->dialogUnregister(this);
86
void XmlConsole::updateCaption()
88
setCaption(pa->name() + ": " + tr("XML Console"));
91
void XmlConsole::enable()
93
ck_enable->setChecked(true);
96
void XmlConsole::client_xmlIncoming(const QString &str)
98
if(ck_enable->isChecked()) {
99
te->setColor(Qt::yellow);
100
te->append(str + '\n');
104
void XmlConsole::client_xmlOutgoing(const QString &str)
106
if(ck_enable->isChecked()) {
107
te->setColor(Qt::red);
108
te->append(str + '\n');
112
void XmlConsole::insertXml()
115
bringToFront(prompt);
117
prompt = new XmlPrompt(this);
118
connect(prompt, SIGNAL(textReady(const QString &)), SLOT(xml_textReady(const QString &)));
123
void XmlConsole::xml_textReady(const QString &str)
125
pa->client()->send(str);
129
//----------------------------------------------------------------------------
131
//----------------------------------------------------------------------------
132
XmlPrompt::XmlPrompt(QWidget *parent, const char *name)
133
:QDialog(parent, name, false, WDestructiveClose)
135
setCaption(tr("XML Input"));
137
QVBoxLayout *vb1 = new QVBoxLayout(this, 8);
139
te = new QTextEdit(this);
142
QHBoxLayout *hb1 = new QHBoxLayout(vb1);
145
pb = new QPushButton(tr("&Transmit"), this);
146
pb->setDefault(TRUE);
147
connect(pb, SIGNAL(clicked()), SLOT(doTransmit()));
151
pb = new QPushButton(tr("&Close"), this);
152
connect(pb, SIGNAL(clicked()), SLOT(close()));
158
XmlPrompt::~XmlPrompt()
162
void XmlPrompt::doTransmit()
164
QString str = te->text();