summaryrefslogtreecommitdiffstats
path: root/kopete/libkopete/kopetewalletmanager.h
blob: 7e91a3bba6a251f6aa9304095b6a74d096f36476 (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
/*
    kopetewalletmanager.h - Kopete Wallet Manager

    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 KOPETEWALLETMANAGER_H
#define KOPETEWALLETMANAGER_H

#include <tqobject.h>

#include <kdemacros.h>

#include "kopete_export.h"

namespace TDEWallet { class Wallet; }

namespace Kopete
{

/**
 * @author Richard Smith <kde@metafoo.co.uk>
 *
 * The Kopete::WalletManager class is a singleton, which looks after Kopete's
 * TDEWallet connection.
 */
class KOPETE_EXPORT WalletManager : public TQObject
{
	TQ_OBJECT
  

public:
	/**
	 * Retrieve the wallet manager instance
	 */
	static WalletManager *self();
	~WalletManager();

	/**
	 * @brief Attempt to open the TDEWallet asyncronously, then signal an
	 *        object to indicate the task is complete.
	 *
	 * @param object The object to call back to
	 * @param slot The slot on object to call; must have signature slot( TDEWallet::Wallet* )
	 *        The parameter to the slot will be the wallet that was opened if the call
	 *        succeeded, or NULL if the wallet failed to open or the Kopete folder was
	 *        inaccessible.
	 *
	 * For simplicity of client code, it is guaranteed that your slot
	 * will not be called during a call to this function.
	 */
	void openWallet( TQObject *object, const char *slot );
	
public slots:
	/**
	 * Close the connection to the wallet. Will cause walletLost() to be emitted.
	 */
	void closeWallet();

signals:
	/**
	 * Emitted when the connection to the wallet is lost.
	 */
	void walletLost();

private slots:
	/**
	 * Called by the stored wallet pointer when it is successfully opened or
	 * when it fails.
	 *
	 * Causes walletOpened to be emitted.
	 */
	void slotWalletChangedStatus();
	
	/**
	 * Called by a singleShot timer in the event that we are asked for a
	 * wallet when we already have one open and ready.
	 */
	void slotGiveExistingWallet();

private:
	void openWalletInner();
	void emitWalletOpened( TDEWallet::Wallet *wallet );

	class Private;
	Private *d;

	WalletManager();
};

}

/**
 * @internal
 */
class KopeteWalletSignal : public TQObject
{
	TQ_OBJECT
  
	friend class Kopete::WalletManager;
signals:
	void walletOpened( TDEWallet::Wallet *wallet );
};

#endif