summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/ui/dlgjabbersendraw.cpp
blob: c665847c468230c0c2c7d451d2a061ce7e79c883 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106

/***************************************************************************
                      dlgjabbersendraw.cpp  -  Raw XML dialog
                             -------------------
    begin                : Sun Aug 25 2002
    copyright            : (C) 2002-2003 by Till Gerken <till@tantalo.net>
    email                : kopete-devel@kde.org
 ***************************************************************************

 ***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include "dlgjabbersendraw.h"

#include <tqcombobox.h>
#include <tqpushbutton.h>
#include <tqtextedit.h>
#include <kdebug.h>
#include "jabberclient.h"

dlgJabberSendRaw::dlgJabberSendRaw ( JabberClient *client, TQWidget *parent, const char *name )
	: DlgSendRaw (parent, name)
{
	// Connect the GUI elements to things that do stuff
	connect (btnSend, TQ_SIGNAL (clicked ()), this, TQ_SLOT (slotSend ()));
	connect (btnClose, TQ_SIGNAL (clicked ()), this, TQ_SLOT (slotCancel ()));
	connect (btnClear, TQ_SIGNAL (clicked ()), this, TQ_SLOT (slotClear ()));
	connect (inputWidget, TQ_SIGNAL (activated (int)), this, TQ_SLOT (slotCreateMessage (int)));

	m_client = client;

	show();
}

dlgJabberSendRaw::~dlgJabberSendRaw ()
{
	// Nothing yet
}

void dlgJabberSendRaw::slotCancel ()
{
	close(true);
}

void dlgJabberSendRaw::slotClear ()
{
	inputWidget->setCurrentItem(0);
	tePacket->clear();
}

void dlgJabberSendRaw::slotCreateMessage(int index)
{
	switch (index) {
		case 1:
			tePacket->setText(TQString("<iq type='set' to='%1'>\n<query xmlns='jabber:iq:register'><remove/>\n</query>\n</iq>")
						.arg ( m_client->jid().domain () ) );
			break;
		case 2:
			tePacket->setText("<presence>\n<show>\?\?\?</show>\n<status>\?\?\?</status>\n</presence>");
			break;
		case 3:
			tePacket->setText("<iq type='get' to='USER@DOMAIN'>\n<query xmlns='jabber:iq:last'/></iq>");
			break;
		case 4:
			tePacket->setText(TQString("<message to='USER@DOMAIN' from='%1@%2/%3'>\n<body>Body text</body>\n</message>")
						.arg ( m_client->jid().node (), m_client->jid().domain (), m_client->jid().resource () ) );
			break;
		case 5:
			tePacket->setText(TQString("<message to='USER@DOMAIN' from='%1@%2/%3'>\n<subject>Subject</subject><body>Body text</body>\n</message>")
						.arg ( m_client->jid().node (), m_client->jid().domain (), m_client->jid().resource () ) );

			break;
		case 6:
			tePacket->setText("<iq type='set'>\n<query xmlns='jabber:iq:roster'>\n<item name='NAME' jid='USER@DOMAIN'>\n<group>GROUP</group>\n</item>\n</query>\n</iq>");
			break;
		case 7:
			tePacket->setText("<iq type='set'>\n<query xmlns='jabber:iq:roster'>\n<item jid='USER@DOMAIN' subscription='remove'/>\n</query>\n</iq>");
			break;
		case 8:
			tePacket->setText("<presence to='USER@DOMAIN' type='\?\?\?'/>");
			break;
		default:
			tePacket->clear();
			break;
	}
}

void dlgJabberSendRaw::slotSend()
{
	kdDebug (14130) << "[dlgJabberSendRaw] Sending RAW message" << endl;

	// Tell our engine to send
	m_client->send (tePacket->text ());

	// set temlapte combobox to "User Defined" and clear content
	inputWidget->setCurrentItem(0);
	tePacket->clear();
}

#include "dlgjabbersendraw.moc"