2 kopeteaccountmanager.h - Kopete Account Manager
4 Copyright (c) 2002-2003 by Martijn Klingens <klingens@kde.org>
5 Copyright (c) 2003-2005 by Olivier Goffart <ogoffart@kde.org>
7 Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
9 *************************************************************************
11 * This library is free software; you can redistribute it and/or *
12 * modify it under the terms of the GNU Lesser General Public *
13 * License as published by the Free Software Foundation; either *
14 * version 2 of the License, or (at your option) any later version. *
16 *************************************************************************
19 #ifndef __kopeteaccountmanager_h__
20 #define __kopeteaccountmanager_h__
24 #include "kopete_export.h"
36 * AccountManager manages all defined accounts in Kopete. You can
37 * query them and globally set them all online or offline from here.
39 * AccountManager is a singleton, you may uses it with @ref AccountManager::self()
41 * @author Martijn Klingens <klingens@kde.org>
42 * @author Olivier Goffart <ogoffart\@kde.org>
44 class KOPETE_EXPORT AccountManager
: public QObject
50 * \brief Retrieve the instance of AccountManager.
52 * The account manager is a singleton class of which only a single
53 * instance will exist. If no manager exists yet this function will
56 * \return the instance of the AccountManager
58 static AccountManager
* self();
63 * \brief Retrieve the list of accounts
64 * \return a list of all the accounts
66 const QList
<Account
*> & accounts() const;
69 * \brief Retrieve a list of accounts per protocol
71 * Provides a list of accounts for a certain protocol. If there are
72 * no accounts for that protocol then the list is empty.
73 * \param protocol the protocol to get accounts for
74 * \return the list of accounts that belong to the @p protocol protocol
76 QList
<Account
*> accounts( Kopete::Protocol
* protocol
) const;
79 * \brief Return the account asked
80 * \param protocolId is the ID for the protocol
81 * \param accountId is the ID for the account you want
82 * \return the Account object found or NULL if no account was found
84 Account
* findAccount( const QString
&protocolId
, const QString
&accountId
);
87 * \brief Delete the account and clean the config data
89 * This is praticaly called by the account config page when you remove the account.
91 void removeAccount( Account
*account
);
94 * \brief Guess the color for a new account
96 * Guesses a color for the next account of a given protocol based on the already registered colors
97 * \return the color guessed for the account
99 QColor
guessColor( Protocol
*protocol
) const ;
102 * @brief Register the account.
104 * This adds the account in the manager's account list.
105 * It will check no accounts already exist with the same ID, if any, the account is deleted. and not added
107 * @return @p account, or 0L if the account was deleted because id collision
109 Account
*registerAccount( Account
*account
);
113 * Flag to be used in setOnlineStatus
115 * @c ConnectIfOffline : if set, this will connect offlines account with the status.
117 enum SetOnlineStatusFlag
{ ConnectIfOffline
=0x01 };
122 * @deprecated use setOnlineStatus
127 * @deprecated use setOnlineStatus
129 void disconnectAll();
132 * @brief Set all accounts a status in the specified category
134 * Account that are offline will not be connected, unless the ConnectIfOffline flag is set.
136 * @param category is one of the Kopete::OnlineStatusManager::Categories
137 * @param awayMessage is the new away message
138 * @param flags is a bitmask of SetOnlineStatusFlag
140 void setOnlineStatus( /*Kopete::OnlineStatusManager::Categories*/ uint category
,
141 const QString
& awayMessage
= QString::null
, uint flags
=0);
144 * @deprecated use setOnlineStatus
146 void setAwayAll( const QString
&awayReason
= QString::null
, bool away
=true );
149 * @deprecated use setOnlineStatus
151 void setAvailableAll( const QString
&awayReason
= QString::null
);
155 * Save the account data to KConfig
161 * Load the account data from KConfig
169 * \brief Signals when an account is ready for use
171 void accountRegistered( Kopete::Account
*account
);
174 * \brief Signals when an account has been unregistered
176 * At this state, we are already in the Account destructor.
178 void accountUnregistered( const Kopete::Account
*account
);
181 * \brief An account has changed its onlinestatus
182 * Technically this monitors Account::myself() onlinestatus changes
183 * \param account Account which changed its onlinestatus
184 * \param oldStatus The online status before the change
185 * \param newStatus The new online status
187 void accountOnlineStatusChanged(Kopete::Account
*account
,
188 const Kopete::OnlineStatus
&oldStatus
, const Kopete::OnlineStatus
&newStatus
);
192 * Private constructor, because we're a singleton
197 void slotPluginLoaded( Kopete::Plugin
*plugin
);
198 void slotAccountOnlineStatusChanged(Kopete::Contact
*c
,
199 const Kopete::OnlineStatus
&oldStatus
, const Kopete::OnlineStatus
&newStatus
);
203 * Unregister the account.
205 void unregisterAccount( const Kopete::Account
*account
);
208 bool isAnyAccountConnected();
209 static AccountManager
*s_self
;
214 } //END namespace Kopete