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
|
/***************************************************************************
Change the password of a Jabber account
-------------------
begin : Tue May 31 2005
copyright : (C) 2005 by Till Gerken <[email protected]>
Kopete (C) 2001-2005 Kopete developers <[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 "dlgjabberchangepassword.h"
#include <kdebug.h>
#include <tdelocale.h>
#include <kpassdlg.h>
#include <tdemessagebox.h>
#include <tqlabel.h>
#include <tqlineedit.h>
#include <kopetepassword.h>
#include <xmpp_tasks.h>
#include "jabberaccount.h"
#include "dlgchangepassword.h"
DlgJabberChangePassword::DlgJabberChangePassword ( JabberAccount *account, TQWidget *parent, const char *name )
: KDialogBase ( parent, name, true, i18n("Change Jabber Password"),
KDialogBase::Ok | KDialogBase::Cancel, KDialogBase::Ok, true )
{
m_account = account;
m_mainWidget = new DlgChangePassword ( this );
setMainWidget ( m_mainWidget );
}
DlgJabberChangePassword::~DlgJabberChangePassword()
{
}
void DlgJabberChangePassword::slotOk ()
{
if ( m_mainWidget->peCurrentPassword->password().length() == 0
|| ( m_account->password().cachedValue () != m_mainWidget->peCurrentPassword->password () ) )
{
KMessageBox::queuedMessageBox ( this, KMessageBox::Sorry,
i18n ( "You entered your current password incorrectly." ),
i18n ( "Password Incorrect" ) );
return;
}
if ( m_mainWidget->peNewPassword1->password() != m_mainWidget->peNewPassword2->password() )
{
KMessageBox::queuedMessageBox ( this, KMessageBox::Sorry,
i18n ( "Your new passwords do not match. Please enter them again." ),
i18n ( "Password Incorrect" ) );
return;
}
if ( !m_mainWidget->peNewPassword1->password().length() )
{
KMessageBox::queuedMessageBox ( this, KMessageBox::Sorry,
i18n ( "For security reasons, you are not allowed to set an empty password." ),
i18n ( "Password Incorrect" ) );
return;
}
if ( !m_account->isConnected () )
{
if ( KMessageBox::questionYesNo ( this,
i18n ( "Your account needs to be connected before the password can be changed. Do you want to try to connect now?" ),
i18n ( "Jabber Password Change" ), i18n("Connect"), i18n("Stay Offline") ) == KMessageBox::Yes )
{
connect ( m_account, TQT_SIGNAL ( isConnectedChanged () ), this, TQT_SLOT ( slotChangePassword () ) );
m_account->connect ();
}
}
else
{
slotChangePassword ();
}
}
void DlgJabberChangePassword::slotCancel ()
{
deleteLater ();
}
void DlgJabberChangePassword::slotChangePassword ()
{
XMPP::JT_Register *task = new XMPP::JT_Register ( m_account->client()->rootTask () );
TQObject::connect ( task, TQT_SIGNAL ( finished () ), this, TQT_SLOT ( slotChangePasswordDone () ) );
task->changepw ( m_mainWidget->peNewPassword1->password () );
task->go ( true );
}
void DlgJabberChangePassword::slotChangePasswordDone ()
{
XMPP::JT_Register *task = (XMPP::JT_Register *) sender ();
if ( task->success () )
{
KMessageBox::queuedMessageBox ( dynamic_cast<TQWidget*>(parent()), KMessageBox::Information,
i18n ( "Your password has been changed successfully. Please note that the change may not be instantaneous. If you have problems logging in with your new password, please contact the administrator." ),
i18n ( "Jabber Password Change" ) );
m_account->password().set ( m_mainWidget->peNewPassword1->password () );
}
else
{
KMessageBox::queuedMessageBox ( dynamic_cast<TQWidget*>(parent()), KMessageBox::Sorry,
i18n ( "Your password could not be changed. Either your server does not support this feature or the administrator does not allow you to change your password." ) );
}
deleteLater();
}
#include "dlgjabberchangepassword.moc"
|