• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdenetwork API Reference
  • KDE Home
  • Contact Us
 

kopete/libkopete

  • sources
  • kde-4.14
  • kdenetwork
  • kopete
  • libkopete
kopetepasswordedaccount.cpp
Go to the documentation of this file.
1 /*
2  kopetepasswordedaccount.cpp - Kopete Account with a password
3 
4  Copyright (c) 2004 by Richard Smith <kde@metafoo.co.uk>
5  Kopete (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>
6 
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  *************************************************************************
15 */
16 
17 #include "kopetepasswordedaccount.h"
18 #include "kopetepassword.h"
19 #include "kopeteprotocol.h"
20 #include "kopeteonlinestatus.h"
21 
22 #include <klocale.h>
23 
24 #include <qpixmap.h>
25 
26 struct Kopete::PasswordedAccount::Private
27 {
28  Private( const QString &group, bool allowBlankPassword ) :
29  password( group, allowBlankPassword ) {}
30  Kopete::Password password;
31  Kopete::OnlineStatus initialStatus;
32 };
33 
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 ) )
36 {
37 }
38 
39 Kopete::PasswordedAccount::~PasswordedAccount()
40 {
41  delete d;
42 }
43 
44 Kopete::Password &Kopete::PasswordedAccount::password()
45 {
46  return d->password;
47 }
48 
49 void Kopete::PasswordedAccount::connect( )
50 {
51  Kopete::OnlineStatus s(Kopete::OnlineStatus::Online);
52  connect( s );
53 }
54 
55 void Kopete::PasswordedAccount::connect( const Kopete::OnlineStatus& initialStatus )
56 {
57  // warn user somewhere
58  d->initialStatus = initialStatus;
59  QString cached = password().cachedValue();
60  if( !cached.isNull() || d->password.allowBlankPassword() )
61  {
62  connectWithPassword( cached );
63  return;
64  }
65 
66  QString prompt = passwordPrompt();
67  Kopete::Password::PasswordSource src = password().isWrong() ? Kopete::Password::FromUser : Kopete::Password::FromConfigOrUser;
68 
69  password().request( this, SLOT(connectWithPassword(QString)), accountIcon( Kopete::Password::preferredImageSize() ), prompt, src );
70 }
71 
72 QString Kopete::PasswordedAccount::passwordPrompt()
73 {
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() );
78 }
79 
80 Kopete::OnlineStatus Kopete::PasswordedAccount::initialStatus()
81 {
82  return d->initialStatus;
83 }
84 
85 bool Kopete::PasswordedAccount::removeAccount()
86 {
87  password().set(QString::null); //krazy:exclude=nullstrassign for old broken gcc
88  return Kopete::Account::removeAccount();
89 }
90 
91 void Kopete::PasswordedAccount::disconnected( Kopete::Account::DisconnectReason reason )
92 {
93  if(reason==Kopete::Account::BadPassword || reason==Kopete::Account::BadUserName)
94  {
95  password().setWrong(true);
96  }
97  Kopete::Account::disconnected(reason);
98 }
99 
100 
101 #include "kopetepasswordedaccount.moc"
102 
103 // vim: set noet ts=4 sts=4 sw=4:
Kopete::OnlineStatus
Definition: kopeteonlinestatus.h:68
Kopete::PasswordedAccount::connect
void connect()
Definition: kopetepasswordedaccount.cpp:49
Kopete::PasswordedAccount::removeAccount
virtual bool removeAccount()
Remove the account from the server.
Definition: kopetepasswordedaccount.cpp:85
Kopete::Account::BadPassword
connection failed because password was incorrect
Definition: kopeteaccount.h:97
Kopete::Password::PasswordSource
PasswordSource
Type of password request to perform: FromConfigOrUser : get the password from the config file...
Definition: kopetepassword.h:98
kopetepasswordedaccount.h
Kopete::Account::BadUserName
connection failed because user name was invalid / unknown
Definition: kopeteaccount.h:98
Kopete::Protocol
base class of every protocol.
Definition: kopeteprotocol.h:62
Kopete::Password::FromConfigOrUser
Definition: kopetepassword.h:98
Kopete::PasswordedAccount::~PasswordedAccount
virtual ~PasswordedAccount()
Definition: kopetepasswordedaccount.cpp:39
Kopete::PasswordedAccount::PasswordedAccount
PasswordedAccount(Protocol *parent, const QString &acctId, bool allowBlankPassword=false)
KopetePasswordedAccount constructor.
Definition: kopetepasswordedaccount.cpp:34
Kopete::Password::preferredImageSize
static int preferredImageSize()
Returns the preferred size for images passed to the retrieve and request functions.
Definition: kopetepassword.cpp:390
kopeteonlinestatus.h
Kopete::Password::FromUser
Definition: kopetepassword.h:98
Kopete::Account::removeAccount
virtual bool removeAccount()
Remove the account from the server.
Definition: kopeteaccount.cpp:662
Kopete::PasswordedAccount::disconnected
virtual void disconnected(Kopete::Account::DisconnectReason reason)
Definition: kopetepasswordedaccount.cpp:91
QString::isNull
bool isNull() const
Kopete::Account::disconnected
virtual void disconnected(Kopete::Account::DisconnectReason reason)
The service has been disconnected.
Definition: kopeteaccount.cpp:178
kopeteprotocol.h
QString
Kopete::OnlineStatus::Online
Refers to a true online state, i.e.
Definition: kopeteonlinestatus.h:129
Kopete::Password
Definition: kopetepassword.h:48
Kopete::PasswordedAccount::initialStatus
OnlineStatus initialStatus()
Get the initial status.
Definition: kopetepasswordedaccount.cpp:80
Kopete::PasswordedAccount::passwordPrompt
virtual QString passwordPrompt()
Returns the prompt shown to the user when requesting their password.
Definition: kopetepasswordedaccount.cpp:72
Kopete::PasswordedAccount::password
Password & password()
Returns a reference to the password object stored in this account.
Definition: kopetepasswordedaccount.cpp:44
kopetepassword.h
Kopete::Account::DisconnectReason
DisconnectReason
Describes how the account was disconnected.
Definition: kopeteaccount.h:95
Kopete::Account
The Kopete::Account class handles one account.
Definition: kopeteaccount.h:72
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:29:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal