1 | /* |
2 | kopetepasswordedaccount.h - 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 | #ifndef KOPETEPASSWORDEDACCOUNT_H |
18 | #define KOPETEPASSWORDEDACCOUNT_H |
19 | |
20 | #include "kopeteaccount.h" |
21 | |
22 | #include "kopete_export.h" |
23 | |
24 | |
25 | namespace Kopete |
26 | { |
27 | |
28 | class Password; |
29 | |
30 | /** |
31 | * An account requiring a password to connect. Instead of reimplementing connect() |
32 | * in your subclass, reimplement connectWithPassword. |
33 | * |
34 | * @author Richard Smith <kde@metafoo.co.uk> |
35 | */ |
36 | class KOPETE_EXPORT PasswordedAccount : public Account |
37 | { |
38 | Q_OBJECT |
39 | |
40 | public: |
41 | |
42 | /** |
43 | * KopetePasswordedAccount constructor |
44 | * @param parent The protocol this account connects via |
45 | * @param acctId The ID of this account - should be unique within this protocol |
46 | * @param maxPasswordLength The maximum length for passwords for this account, or 0 for no limit |
47 | * @param allowBlankPassword If this protocol allows blank passwords. Note that this will mean that |
48 | * |
49 | * @param name The name for this QObject |
50 | */ |
51 | PasswordedAccount( Protocol *parent, const QString &acctId, bool allowBlankPassword = false ); |
52 | |
53 | virtual ~PasswordedAccount(); |
54 | |
55 | /** |
56 | * Returns a reference to the password object stored in this account. |
57 | */ |
58 | Password &password(); |
59 | |
60 | void connect(); |
61 | |
62 | /** |
63 | * @brief Go online for this service. |
64 | * |
65 | * @param initialStatus is the status to connect with. If it is an invalid status for this |
66 | * account, the default online for the account should be used. |
67 | */ |
68 | void connect( const OnlineStatus& initialStatus ); |
69 | |
70 | /** |
71 | * \brief Get the initial status |
72 | */ |
73 | OnlineStatus initialStatus(); |
74 | |
75 | /** |
76 | * @brief Remove the account from the server. |
77 | * |
78 | * Reimplementation of Account::removeAccount() to remove the password from the wallet. |
79 | * if your protocol reimplements this function, this function should still be called. |
80 | * |
81 | * @return Always true |
82 | */ |
83 | virtual bool removeAccount(); |
84 | |
85 | |
86 | public slots: |
87 | /** |
88 | * Called when your account should attempt to connect. |
89 | * @param password The password to connect with, or QString() |
90 | * if the user wished to cancel the connection attempt. |
91 | */ |
92 | virtual void connectWithPassword( const QString &password ) = 0; |
93 | |
94 | protected: |
95 | /** |
96 | * Returns the prompt shown to the user when requesting their password. |
97 | * The default implementation should be adequate in most cases; override |
98 | * if you have a custom message to show the user. |
99 | */ |
100 | virtual QString passwordPrompt(); |
101 | |
102 | protected slots: |
103 | /** |
104 | * @internal |
105 | * Reimplemented to set the password wrong if the reason is BadPassword |
106 | */ |
107 | virtual void disconnected( Kopete::Account::DisconnectReason reason ); |
108 | |
109 | |
110 | private: |
111 | struct Private; |
112 | Private * const d; |
113 | }; |
114 | |
115 | } |
116 | |
117 | #endif |
118 | |
119 | // vim: set noet ts=4 sts=4 sw=4: |
120 | |