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
|
//
// C++ Implementation:
//
// Description:
//
//
// Author: Kopete Developers <[email protected]>, (C) 2005
//
// Copyright: See COPYING file that comes with this distribution
//
//
#include <kmessagebox.h>
#include <klocale.h>
#include <kdebug.h>
#include <tqtable.h>
#include <tqlineedit.h>
#include <tqpushbutton.h>
#include <tqlabel.h>
#include "dlgjabberchatroomslist.h"
#include "jabberprotocol.h"
dlgJabberChatRoomsList::dlgJabberChatRoomsList(JabberAccount* account, const TQString& server, const TQString &nick, TQWidget *parent, const char *name) :
dlgChatRoomsList(parent, name),
m_account(account) , m_selectedRow(-1) , m_nick(nick)
{
if (!server.isNull())
leServer->setText(server);
else if(m_account->isConnected())
leServer->setText(m_account->server());
m_chatServer = leServer->text();
// locales
setCaption(i18n("List Chatrooms"));
tblChatRoomsList->setLeftMargin (0);
tblChatRoomsList->setColumnStretchable(0, true);
tblChatRoomsList->setColumnStretchable(1, true);
if (!server.isNull())
slotQuery();
}
dlgJabberChatRoomsList::~dlgJabberChatRoomsList()
{
}
/*$SPECIALIZATION$*/
void dlgJabberChatRoomsList::slotJoin()
{
if(!m_account->isConnected())
{
m_account->errorConnectFirst();
return;
}
if (m_selectedRow >= 0)
{
kdDebug (JABBER_DEBUG_GLOBAL) << "join chat room : " << m_account->client()->client()->user() << " @ " << tblChatRoomsList->text(m_selectedRow, 0) << " on " << m_chatServer << endl;
m_account->client()->joinGroupChat(m_chatServer, tblChatRoomsList->text(m_selectedRow, 0), m_nick);
}
}
void dlgJabberChatRoomsList::slotQuery()
{
if(!m_account->isConnected())
{
m_account->errorConnectFirst();
return;
}
tblChatRoomsList->setNumRows(0);
XMPP::JT_DiscoItems *discoTask = new XMPP::JT_DiscoItems(m_account->client()->rootTask());
connect (discoTask, TQT_SIGNAL(finished()), this, TQT_SLOT(slotQueryFinished()));
m_chatServer = leServer->text();
discoTask->get(leServer->text());
discoTask->go(true);
}
void dlgJabberChatRoomsList::slotQueryFinished()
{
XMPP::JT_DiscoItems *task = (XMPP::JT_DiscoItems*)sender();
if (!task->success())
{
KMessageBox::queuedMessageBox(this, KMessageBox::Error, i18n("Unable to retrieve the list of chat rooms."), i18n("Jabber Error"));
return;
}
const XMPP::DiscoList& items = task->items();
tblChatRoomsList->setNumRows(items.count());
int row = 0;
for (XMPP::DiscoList::const_iterator it = items.begin(); it != items.end(); ++it)
{
tblChatRoomsList->setText(row, 0, (*it).jid().user());
tblChatRoomsList->setText(row, 1, (*it).name());
++row;
}
}
void dlgJabberChatRoomsList::slotDoubleClick(int row, int /*col*/, int /*button*/, const TQPoint& /*mousePos*/)
{
m_selectedRow = row;
slotJoin();
}
void dlgJabberChatRoomsList::slotClick(int row, int /*col*/, int /*button*/, const TQPoint& /*mousePos*/)
{
m_selectedRow = row;
}
#include "dlgjabberchatroomslist.moc"
|