summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/kopetepasswordedaccount.h
blob: 4be220164a57be09acdf5eb1369fc5cf17aa3cb4 (plain)
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
/*
    kopetepasswordedaccount.h - Kopete Account with a password

    Copyright (c) 2004      by Richard Smith         <kde@metafoo.co.uk>
    Kopete    (c) 2002-2004 by the Kopete developers <kopete-devel@kde.org>

    *************************************************************************
    *                                                                       *
    * This library is free software; you can redistribute it and/or         *
    * modify it under the terms of the GNU Lesser General Public            *
    * License as published by the Free Software Foundation; either          *
    * version 2 of the License, or (at your option) any later version.      *
    *                                                                       *
    *************************************************************************
*/

#ifndef KOPETEPASSWORDEDACCOUNT_H
#define KOPETEPASSWORDEDACCOUNT_H

#include "kopeteaccount.h"

#include "kopete_export.h"

namespace Kopete
{

class Password;

/**
 * An account requiring a password to connect. Instead of reimplementing connect()
 * in your subclass, reimplement connectWithPassword.
 *
 * @author Richard Smith <kde@metafoo.co.uk>
 */
class KOPETE_EXPORT PasswordedAccount : public Account
{
	Q_OBJECT
  TQ_OBJECT

public:

	/**
	 * KopetePasswordedAccount constructor
	 * @param parent The protocol this account connects via
	 * @param acctId The ID of this account - should be unique within this protocol
	 * @param maxPasswordLength The maximum length for passwords for this account, or 0 for no limit
	 * @param name The name for this TQObject
	 *
	 * @deprecated Use the constructor that specifies if a blank password is allowed
	 */
	PasswordedAccount( Protocol *parent, const TQString &acctId, uint maxPasswordLength = 0, const char *name = 0 );

        /**
	 * KopetePasswordedAccount constructor
	 * @param parent The protocol this account connects via
	 * @param acctId The ID of this account - should be unique within this protocol
	 * @param maxPasswordLength The maximum length for passwords for this account, or 0 for no limit
	 * @param allowBlankPassword If this protocol allows blank passwords. Note that this will mean that
	 *
	 * @param name The name for this TQObject
	 */
	PasswordedAccount( Protocol *parent, const TQString &acctId, uint maxPasswordLength = 0,
		bool allowBlankPassword = false, const char *name = 0 );

	virtual ~PasswordedAccount();

	/**
	 * Returns a reference to the password object stored in this account.
	 */
	Password &password();

	void connect();

   	/**
	 * @brief Go online for this service.
	 *
	 * @param initialtqStatus is the status to connect with. If it is an invalid status for this
	 * account, the default online for the account should be used.
	 */
	void connect( const OnlineStatus& initialtqStatus );

	/**
	 * \brief Get the initial status
	 */
	OnlineStatus initialtqStatus();

	/**
	 * @brief Remove the account from the server.
	 *
	 * Reimplementation of Account::removeAccount() to remove the password from the wallet.
	 * if your protocol reimplements this function, this function should still be called.
	 *
	 * @return Always true
	 */
	virtual bool removeAccount();


public slots:
	/**
	 * Called when your account should attempt to connect.
	 * @param password The password to connect with, or TQString()
	 *        if the user wished to cancel the connection attempt.
	 */
	virtual void connectWithPassword( const TQString &password ) = 0;

protected:
	/**
	 * Returns the prompt shown to the user when requesting their password.
	 * The default implementation should be adequate in most cases; override
	 * if you have a custom message to show the user.
	 */
	virtual TQString passwordPrompt();

protected slots:
	/**
	 * @internal
	 * Reimplemented to set the password wrong if the reason is BadPassword
	 */
	virtual void disconnected( Kopete::Account::DisconnectReason reason );


private:
	class Private;
	Private *d;
};

}

#endif

// vim: set noet ts=4 sts=4 sw=4: