1
/****************************************************************************
2
** infodlg.cpp - show contact info
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
****************************************************************************/
23
#include<qtabwidget.h>
24
#include<qpushbutton.h>
26
#include<qmessagebox.h>
29
InfoDlg::InfoDlg(int _type, const QString &jid, const VCard &_vcard, int _localStatus, QWidget *parent, const char *name)
30
:InfoUI(parent, name, FALSE, WDestructiveClose), UniqueWindow(TRUE, "InfoDlg", this, cleanJid(jid))
37
QWidget *w = new QWidget(this);
38
busy = new BusyWidget(w);
39
QHBoxLayout *hb1 = new QHBoxLayout(w);
43
int n = InfoDialog1Layout->findWidget(tabwidget);
44
InfoDialog1Layout->insertWidget(n+1, w);
49
if(_localStatus == STATUS_OFFLINE) {
50
pb_refresh->setEnabled(FALSE);
51
pb_submit->setEnabled(FALSE);
54
connect(pb_refresh, SIGNAL(clicked()), this, SLOT(doRefresh()));
55
connect(te_desc, SIGNAL(textChanged()), this, SLOT(textChanged()));
58
if(type == INFODLG_USER) {
59
connect(pb_submit, SIGNAL(clicked()), this, SLOT(doSubmit()));
69
void InfoDlg::closeEvent(QCloseEvent *e)
71
// don't close if submitting
72
if(isBusy && actionType == 1) {
77
if(type == INFODLG_USER && edited()) {
78
bool x = QMessageBox::information(this, tr("Warning"), tr("You have not published your account information changes.\nAre you sure you want to discard them?"), tr("Close and discard"), tr("Don't close"));
85
// cancel active transaction (refresh only)
86
if(isBusy && actionType == 0) {
87
signalCancelTransaction(id);
93
void InfoDlg::localUpdate(const JabRosterEntry &e)
95
int localStatus = e.localStatus();
97
// if the user goes offline then cancel the request
98
if(localStatus == STATUS_OFFLINE) {
103
// if(actionType == 1)
104
// QMessageBox::critical(this, tr("Error"), QString(tr("Disconnected")));
106
pb_refresh->setEnabled(FALSE);
107
pb_submit->setEnabled(FALSE);
112
pb_refresh->setEnabled(TRUE);
113
pb_submit->setEnabled(TRUE);
117
pb_close->setEnabled(TRUE);
120
void InfoDlg::updateVCard(const VCard &_vcard)
128
pb_refresh->setEnabled(TRUE);
129
pb_submit->setEnabled(TRUE);
130
pb_close->setEnabled(TRUE);
135
void InfoDlg::error()
140
if(type == INFODLG_USER)
141
QMessageBox::critical(this, tr("Error"), QString(tr("Unable to retrieve your account information. Perhaps you haven't entered any yet.")));
143
QMessageBox::critical(this, tr("Error"), QString(tr("Unable to retrieve information about this contact.")));
144
pb_refresh->setEnabled(TRUE);
145
pb_submit->setEnabled(TRUE);
146
pb_close->setEnabled(TRUE);
151
void InfoDlg::result(bool x)
160
QMessageBox::information(this, tr("Success"), QString(tr("Your account information has been published.")));
161
vcard = submit_vcard;
162
setData(submit_vcard);
165
QMessageBox::critical(this, tr("Error"), QString(tr("Unable to publish your account information.")));
168
pb_refresh->setEnabled(TRUE);
169
pb_submit->setEnabled(TRUE);
170
pb_close->setEnabled(TRUE);
174
void InfoDlg::setData(const VCard &i)
176
le_fullname->setText(i.field[vFullname]);
177
le_nickname->setText(i.field[vNickname]);
178
le_bday->setText(i.field[vBday]);
179
le_email->setText(i.field[vEmail]);
180
le_homepage->setText(i.field[vHomepage]);
181
le_phone->setText(i.field[vPhone]);
182
le_street->setText(i.field[vStreet]);
183
le_ext->setText(i.field[vExt]);
184
le_city->setText(i.field[vCity]);
185
le_state->setText(i.field[vState]);
186
le_pcode->setText(i.field[vPcode]);
187
le_country->setText(i.field[vCountry]);
188
le_orgName->setText(i.field[vOrgName]);
189
le_orgUnit->setText(i.field[vOrgUnit]);
190
le_title->setText(i.field[vTitle]);
191
le_role->setText(i.field[vRole]);
192
te_desc->setText(i.field[vDesc]);
197
void InfoDlg::fieldsEnable(bool x)
199
le_fullname->setEnabled(x);
200
le_nickname->setEnabled(x);
201
le_bday->setEnabled(x);
202
le_email->setEnabled(x);
203
le_homepage->setEnabled(x);
204
le_phone->setEnabled(x);
206
le_street->setEnabled(x);
207
le_ext->setEnabled(x);
208
le_city->setEnabled(x);
209
le_state->setEnabled(x);
210
le_pcode->setEnabled(x);
211
le_country->setEnabled(x);
213
le_orgName->setEnabled(x);
214
le_orgUnit->setEnabled(x);
215
le_title->setEnabled(x);
216
le_role->setEnabled(x);
217
te_desc->setEnabled(x);
222
void InfoDlg::setEdited(bool x)
224
le_fullname->setEdited(x);
225
le_nickname->setEdited(x);
226
le_bday->setEdited(x);
227
le_email->setEdited(x);
228
le_homepage->setEdited(x);
229
le_phone->setEdited(x);
230
le_street->setEdited(x);
231
le_ext->setEdited(x);
232
le_city->setEdited(x);
233
le_state->setEdited(x);
234
le_pcode->setEdited(x);
235
le_country->setEdited(x);
236
le_orgName->setEdited(x);
237
le_orgUnit->setEdited(x);
238
le_title->setEdited(x);
239
le_role->setEdited(x);
244
bool InfoDlg::edited()
248
if(le_fullname->edited()) x = TRUE;
249
if(le_nickname->edited()) x = TRUE;
250
if(le_bday->edited()) x = TRUE;
251
if(le_email->edited()) x = TRUE;
252
if(le_homepage->edited()) x = TRUE;
253
if(le_phone->edited()) x = TRUE;
254
if(le_street->edited()) x = TRUE;
255
if(le_ext->edited()) x = TRUE;
256
if(le_city->edited()) x = TRUE;
257
if(le_state->edited()) x = TRUE;
258
if(le_pcode->edited()) x = TRUE;
259
if(le_country->edited()) x = TRUE;
260
if(le_orgName->edited()) x = TRUE;
261
if(le_orgUnit->edited()) x = TRUE;
262
if(le_title->edited()) x = TRUE;
263
if(le_role->edited()) x = TRUE;
264
if(te_edited) x = TRUE;
269
void InfoDlg::setReadOnly(bool x)
271
le_fullname->setReadOnly(x);
272
le_nickname->setReadOnly(x);
273
le_bday->setReadOnly(x);
274
le_email->setReadOnly(x);
275
le_homepage->setReadOnly(x);
276
le_phone->setReadOnly(x);
277
le_street->setReadOnly(x);
278
le_ext->setReadOnly(x);
279
le_city->setReadOnly(x);
280
le_state->setReadOnly(x);
281
le_pcode->setReadOnly(x);
282
le_country->setReadOnly(x);
283
le_orgName->setReadOnly(x);
284
le_orgUnit->setReadOnly(x);
285
le_title->setReadOnly(x);
286
le_role->setReadOnly(x);
287
te_desc->setReadOnly(x);
290
void InfoDlg::doRefresh()
292
if(!pb_refresh->isEnabled())
297
pb_submit->setEnabled(FALSE);
298
pb_refresh->setEnabled(FALSE);
301
signalGetVCard(v_jid, &id);
307
void InfoDlg::doSubmit()
309
if(!pb_submit->isEnabled())
314
pb_submit->setEnabled(FALSE);
315
pb_refresh->setEnabled(FALSE);
316
pb_close->setEnabled(FALSE);
321
signalSetVCard(submit_vcard, &id);
327
void InfoDlg::makeVCard()
329
VCard *v = &submit_vcard;
331
v->field[vFullname] = le_fullname->text();
332
v->field[vNickname] = le_nickname->text();
333
v->field[vBday] = le_bday->text();
334
v->field[vEmail] = le_email->text();
335
v->field[vHomepage] = le_homepage->text();
336
v->field[vPhone] = le_phone->text();
338
v->field[vStreet] = le_street->text();
339
v->field[vExt] = le_ext->text();
340
v->field[vCity] = le_city->text();
341
v->field[vState] = le_state->text();
342
v->field[vPcode] = le_pcode->text();
343
v->field[vCountry] = le_country->text();
345
v->field[vOrgName] = le_orgName->text();
346
v->field[vOrgUnit] = le_orgUnit->text();
347
v->field[vTitle] = le_title->text();
348
v->field[vRole] = le_role->text();
349
v->field[vDesc] = te_desc->text();
352
void InfoDlg::textChanged()
358
/*static*/ InfoDlg * InfoDlg::find(const QString &xjid)
360
return (InfoDlg *)UniqueWindowBank::find("InfoDlg", cleanJid(xjid));