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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
/***************************************************************************
dlgjabberbrowse.cpp - description
-------------------
begin : Wed Dec 11 2002
copyright : (C) 2002-2003 by Till Gerken <[email protected]>
email : [email protected]
***************************************************************************/
/***************************************************************************
* *
* 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 <kpushbutton.h>
#include <qgroupbox.h>
#include <qtable.h>
#include <qlabel.h>
#include <kmessagebox.h>
#include <klocale.h>
#include "jabberaccount.h"
#include "jabberprotocol.h"
#include "jabberclient.h"
#include "jabberformtranslator.h"
#include "dlgjabberbrowse.h"
dlgJabberBrowse::dlgJabberBrowse (JabberAccount *account, const XMPP::Jid & jid, QWidget * parent, const char *name):dlgBrowse (parent, name)
{
m_account = account;
// disable the left margin
tblResults->setLeftMargin (0);
// no content for now
tblResults->setNumRows (0);
// disable user selections
tblResults->setSelectionMode (QTable::NoSelection);
XMPP::JT_Search * task = new XMPP::JT_Search (m_account->client()->rootTask ());
connect (task, SIGNAL (finished ()), this, SLOT (slotGotForm ()));
task->get (jid);
task->go (true);
}
void dlgJabberBrowse::slotGotForm ()
{
XMPP::JT_Search * task = (XMPP::JT_Search *) sender ();
// delete the wait message
delete lblWait;
if (!task->success ())
{
KMessageBox::queuedMessageBox(this, KMessageBox::Information, i18n ("Unable to retrieve search form."), i18n ("Jabber Error"));
return;
}
// translate the form and create it inside the display widget
translator = new JabberFormTranslator (task->form (), dynamicForm);
dynamicForm->layout()->add( translator );
translator->show();
// enable the send button
btnSearch->setEnabled (true);
// adjust table
tblResults->setNumCols (5);
for (int i = 0; i < 5; i++)
{
// allow autostretching
tblResults->setColumnStretchable (i, true);
}
connect (btnSearch, SIGNAL (clicked ()), this, SLOT (slotSendForm ()));
}
void dlgJabberBrowse::slotSendForm ()
{
XMPP::JT_Search * task = new XMPP::JT_Search (m_account->client()->rootTask ());
connect (task, SIGNAL (finished ()), this, SLOT (slotSentForm ()));
task->set (translator->resultData ());
task->go (true);
btnSearch->setEnabled (false);
btnClose->setEnabled (false);
}
void dlgJabberBrowse::slotSentForm ()
{
XMPP::JT_Search * task = (XMPP::JT_Search *) sender ();
btnSearch->setEnabled (true);
btnClose->setEnabled (true);
if (!task->success ())
{
KMessageBox::queuedMessageBox (this, KMessageBox::Error, i18n ("The Jabber server declined the search."), i18n ("Jabber Search"));
return;
}
tblResults->setNumRows (task->results ().count ());
int row = 0;
for (QValueList < XMPP::SearchResult >::const_iterator it = task->results ().begin (); it != task->results ().end (); ++it)
{
tblResults->setText (row, 0, (*it).jid ().userHost ());
tblResults->setText (row, 1, (*it).first ());
tblResults->setText (row, 2, (*it).last ());
tblResults->setText (row, 3, (*it).nick ());
tblResults->setText (row, 4, (*it).email ());
row++;
}
for (int i = 0; i < 5; i++)
{
tblResults->setColumnStretchable (i, false);
tblResults->adjustColumn (i);
}
}
dlgJabberBrowse::~dlgJabberBrowse ()
{
}
#include "dlgjabberbrowse.moc"
|