1
/****************************************************************************
2
** adduserdlg.cpp - a dialog for adding a contact
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 program; if not, write to the Free Software
17
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
19
****************************************************************************/
21
#include"adduserdlg.h"
25
#include<qpushbutton.h>
28
#include<qmessagebox.h>
33
static AddUserDlg *add_ptr = 0;
35
AddUserDlg::AddUserDlg(const QStringList &_services, const QStringList &names, const QStringList &groups, int _localStatus, QWidget *parent, const char *name)
36
:AddUserUI(parent, name, FALSE, WDestructiveClose)
41
localStatus = _localStatus;
45
setCaption(CAP(tr("Add User")));
48
busy = new BusyWidget(this);
49
hb_bottom->insertWidget(0, busy);
51
QStringList::ConstIterator it1 = services.begin();
52
QStringList::ConstIterator it2 = names.begin();
53
for(; it1 != services.end(); ++it1, ++it2)
54
cb_service->insertItem(transport2icon(*it1, STATUS_ONLINE), *it2);
55
connect(cb_service, SIGNAL(activated(int)), SLOT(serviceActivated(int)));
57
QString str = tr("<None>");
58
cb_group->insertItem(str);
59
cb_group->insertStringList(groups);
60
cb_group->setAutoCompletion(TRUE);
62
pb_add->setDefault(TRUE);
63
connect(pb_add, SIGNAL(clicked()), SLOT(ok()));
64
connect(pb_close, SIGNAL(clicked()), SLOT(reject()));
65
connect(pb_transGet, SIGNAL(clicked()), SLOT(getTransID()));
66
//connect(le_transPrompt, SIGNAL(returnPressed()), SLOT(getTransID()));
68
cb_service->setFocus();
71
AddUserDlg::~AddUserDlg()
76
signalCancelTransaction(id);
79
/* static */ AddUserDlg *AddUserDlg::find()
86
if(le_jid->text().isEmpty()) {
87
QMessageBox::information(this, tr("Add User: Error"), tr("Please fill in the Jabber ID of the person you wish to add."));
90
if(le_jid->text().find('@') == -1) {
91
QMessageBox::information(this, tr("Add User: Error"), tr("The Jabber ID you entered does not contain a '@' symbol.\nMake sure you enter a fully qualified Jabber ID in the form \"user@hostname\"."));
96
info.jid = le_jid->text();
97
info.nick = le_nick->text();
99
QString gname = cb_group->currentText();
100
if(gname == tr("<None>"))
109
void AddUserDlg::serviceActivated(int x)
112
signalCancelTransaction(id);
116
gb_trans->setEnabled(FALSE);
117
le_transPrompt->setText("");
124
if(x >= 0 && x < (int)services.count()) {
125
//printf("Selected: [%s]\n", services[x].latin1());
126
signalGetGateway(services[x], &id);
132
void AddUserDlg::localUpdate(const JabRosterEntry &e)
134
localStatus = e.localStatus();
136
if(localStatus == STATUS_OFFLINE)
140
void AddUserDlg::slotGetGatewayResponse(const QString &_id, bool ok, const QString &desc)
149
gb_trans->setEnabled(TRUE);
150
lb_transDesc->setText(desc);
158
void AddUserDlg::slotSetGatewayResponse(const QString &_id, bool ok, const QString &jid)
164
cb_service->setEnabled(TRUE);
165
le_transPrompt->setEnabled(TRUE);
166
pb_transGet->setEnabled(TRUE);
171
le_jid->setText(jid);
172
le_nick->setText(le_transPrompt->text());
173
le_transPrompt->setText("");
174
le_jid->setCursorPosition(0);
175
le_nick->setCursorPosition(0);
178
le_nick->selectAll();
182
le_transPrompt->setFocus();
187
void AddUserDlg::getTransID()
189
cb_service->setEnabled(FALSE);
190
le_transPrompt->setEnabled(FALSE);
191
pb_transGet->setEnabled(FALSE);
193
signalSetGateway(services[cb_service->currentItem()-1], le_transPrompt->text(), &id);
198
void AddUserDlg::errorGateway()
200
QMessageBox::information(this, CAP(tr("Error")), tr("<qt>\n"
201
"There was an error getting the Service ID translation information. "
202
"The \"%1\" service may not support this feature. In this case you "
203
"will need to enter the Jabber ID manually for the contact you wish "
204
"to add. Examples:<br>\n"
206
" jabberuser@somehost.com<br>\n"
207
" aoluser@[Jabber ID of AIM Transport]<br>\n"
208
" 1234567@[Jabber ID of ICQ Transport]<br>\n"
209
" joe%hotmail.com@[Jabber ID of MSN Transport]<br>\n"
210
).arg(cb_service->currentText())