make webinterface translatable. there are around 20 short strings, all with context...
[kdenetwork.git] / kopete / libkopete / kopetepasswordedaccount.cpp
blob54266a249fb98c86491ee8cb9dd53c4a3859c49a
1 /*
2 kopetepasswordedaccount.cpp - Kopete Account with a password
4 Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
5 Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
7 *************************************************************************
8 * *
9 * This library is free software; you can redistribute it and/or *
10 * modify it under the terms of the GNU Lesser General Public *
11 * License as published by the Free Software Foundation; either *
12 * version 2 of the License, or (at your option) any later version. *
13 * *
14 *************************************************************************
17 #include "kopetepasswordedaccount.h"
18 #include "kopetepassword.h"
19 #include "kopeteprotocol.h"
20 #include "kopeteonlinestatus.h"
22 #include <klocale.h>
24 #include <qpixmap.h>
26 struct Kopete::PasswordedAccount::Private
28 Private( const QString &group, bool allowBlankPassword ) :
29 password( group, allowBlankPassword ) {}
30 Kopete::Password password;
31 Kopete::OnlineStatus initialStatus;
34 Kopete::PasswordedAccount::PasswordedAccount( Kopete::Protocol *parent, const QString &acctId, bool allowBlankPassword )
35 : Kopete::Account( parent, acctId ), d( new Private( QString::fromLatin1("Account_")+ parent->pluginId() + QString::fromLatin1("_") + acctId , allowBlankPassword ) )
39 Kopete::PasswordedAccount::~PasswordedAccount()
41 delete d;
44 Kopete::Password &Kopete::PasswordedAccount::password()
46 return d->password;
49 void Kopete::PasswordedAccount::connect( )
51 Kopete::OnlineStatus s(Kopete::OnlineStatus::Online);
52 connect( s );
55 void Kopete::PasswordedAccount::connect( const Kopete::OnlineStatus& initialStatus )
57 // warn user somewhere
58 d->initialStatus = initialStatus;
59 QString cached = password().cachedValue();
60 if( !cached.isNull() || d->password.allowBlankPassword() )
62 connectWithPassword( cached );
63 return;
66 QString prompt = passwordPrompt();
67 Kopete::Password::PasswordSource src = password().isWrong() ? Kopete::Password::FromUser : Kopete::Password::FromConfigOrUser;
69 password().request( this, SLOT( connectWithPassword( const QString & ) ), accountIcon( Kopete::Password::preferredImageSize() ), prompt, src );
72 QString Kopete::PasswordedAccount::passwordPrompt()
74 if ( password().isWrong() )
75 return i18n( "<qt><b>The password was wrong.</b> Please re-enter your password for %1 account <b>%2</b></qt>", protocol()->displayName(), accountId() );
76 else
77 return i18n( "<qt>Please enter your password for %1 account <b>%2</b></qt>", protocol()->displayName(), accountId() );
80 Kopete::OnlineStatus Kopete::PasswordedAccount::initialStatus()
82 return d->initialStatus;
85 bool Kopete::PasswordedAccount::removeAccount()
87 password().set(QString::null); //krazy:exclude=nullstrassign for old broken gcc
88 return Kopete::Account::removeAccount();
91 void Kopete::PasswordedAccount::disconnected( Kopete::Account::DisconnectReason reason )
93 if(reason==Kopete::Account::BadPassword || reason==Kopete::Account::BadUserName)
95 password().setWrong(true);
97 Kopete::Account::disconnected(reason);
101 #include "kopetepasswordedaccount.moc"
103 // vim: set noet ts=4 sts=4 sw=4: