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
|
/***************************************************************************
dlgjabberchatjoin.cpp - description
-------------------
begin : Fri Dec 13 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 <kdebug.h>
#include <tdelocale.h>
#include <tqlineedit.h>
#include <tqpushbutton.h>
#include "jabberaccount.h"
#include "jabberclient.h"
#include "dlgjabberchatroomslist.h"
#include "dlgjabberchatjoin.h"
dlgJabberChatJoin::dlgJabberChatJoin(JabberAccount *account, TQWidget* parent, const char* name) :
dlgChatJoin(parent, name),
m_account(account)
{
setCaption(i18n("Join Jabber Groupchat"));
leNick->setText(m_account->client()->client()->user());
checkDefaultChatroomServer();
}
dlgJabberChatJoin::~dlgJabberChatJoin()
{
}
/*$SPECIALIZATION$*/
void dlgJabberChatJoin::slotJoin()
{
if(!m_account->isConnected())
{
m_account->errorConnectFirst();
return;
}
m_account->client()->joinGroupChat(leServer->text(), leRoom->text(), leNick->text());
accept();
}
void dlgJabberChatJoin::slotBowse()
{
if(!m_account->isConnected())
{
m_account->errorConnectFirst();
return;
}
dlgJabberChatRoomsList *crl = new dlgJabberChatRoomsList(m_account, leServer->text() , leNick->text());
crl->show();
accept();
}
/*
TODO : Used to look for the default chat server,
this is duplicate with dlgjabberservices.cpp
should be merged elsewhere !
*/
// JabberAccount *m_account;
// XMPP::JT_GetServices * serviceTask;
void dlgJabberChatJoin::checkDefaultChatroomServer()
{
XMPP::JT_GetServices *serviceTask = new XMPP::JT_GetServices(m_account->client()->rootTask());
connect(serviceTask, TQT_SIGNAL (finished()), this, TQT_SLOT (slotQueryFinished()));
serviceTask->get(m_account->server());
serviceTask->go(true);
}
void dlgJabberChatJoin::slotQueryFinished()
{
XMPP::JT_GetServices *task = (XMPP::JT_GetServices*)sender();
if (!task->success ())
return;
if(!leServer->text().isEmpty())
{ //the user already started to type the server manyally. abort auto-detect
return;
}
for (XMPP::AgentList::const_iterator it = task->agents().begin(); it != task->agents().end(); ++it)
{
XMPP::JT_DiscoInfo *discoTask = new XMPP::JT_DiscoInfo(m_account->client()->rootTask());
connect(discoTask, TQT_SIGNAL (finished()), this, TQT_SLOT (slotDiscoFinished()));
discoTask->get((*it).jid().full());
discoTask->go(true);
}
}
void dlgJabberChatJoin::slotDiscoFinished()
{
XMPP::JT_DiscoInfo *task = (XMPP::JT_DiscoInfo*)sender();
if (!task->success())
return;
if(!leServer->text().isEmpty())
{ //the user already started to type the server manyally. abort auto-detect
return;
}
if (task->item().features().canGroupchat() && !task->item().features().isGateway())
{
leServer->setText(task->item().jid().full());
}
}
// end todo
#include "dlgjabberchatjoin.moc"
|