2 kopeteidentitymanager.h - Kopete Identity Manager
4 Copyright (c) 2007 by Gustavo Pichorim Boiko <gustavo.boiko@kdemail.net>
6 Kopete (c) 2002-2007 by the Kopete developers <kopete-devel@kde.org>
8 *************************************************************************
10 * This library is free software; you can redistribute it and/or *
11 * modify it under the terms of the GNU Lesser General Public *
12 * License as published by the Free Software Foundation; either *
13 * version 2 of the License, or (at your option) any later version. *
15 *************************************************************************
18 #ifndef __kopeteidentitymanager_h__
19 #define __kopeteidentitymanager_h__
21 #include <QtCore/QObject>
23 #include "kopete_export.h"
24 #include "kopeteonlinestatus.h"
25 #include "kopeteidentity.h"
26 #include "kopetestatusmessage.h"
32 * IdentityManager manages all defined identities in Kopete. You can
33 * query them and globally set them all online or offline from here.
35 * IdentityManager is a singleton, you may uses it with @ref IdentityManager::self()
37 * @author Gustavo Pichorim Boiko <gustavo.boiko\@kdemail.net>
39 class KOPETE_EXPORT IdentityManager
: public QObject
45 * \brief Retrieve the instance of IdentityManager.
47 * The identity manager is a singleton class of which only a single
48 * instance will exist. If no manager exists yet this function will
51 * \return the instance of the IdentityManager
53 static IdentityManager
* self();
58 * \brief Retrieve the list of identities
59 * \return a list of all the identities
61 const Identity::List
& identities() const;
64 * \brief Return the identity asked
65 * \param identityId is the ID for the identity
66 * \return the Identity object found or NULL if no identity was found
68 Identity
* findIdentity( const QString
&identityId
);
72 * \brief Returs the default identity to be used
74 * This is the default identity configured in kopete. If no identity was created
75 * yet, this function will create a new identity, set it as the default identity
77 * If there are identities already created, but none of them was set as the default,
78 * it will return the first identity of the list.
79 * @return the default identity
81 Identity
* defaultIdentity();
84 * @brief Sets a new default identity
86 * By changing the default identity, you do NOT change the accounts' identity
87 * association. They are kept as if nothing has changed
89 void setDefaultIdentity(Identity
*ident
);
92 * \brief Delete the identity and clean the config data
94 * This will mostly be called when no account is assigned to an identity
96 void removeIdentity( Identity
*identity
);
99 * @brief Register the identity.
101 * This adds the identity in the manager's identity list.
102 * It will check no identities already exist with the same ID, if any, the identity is deleted. and not added
104 * @return @p identity, or 0L if the identity was deleted because id collision
106 Identity
*registerIdentity( Identity
*identity
);
111 * @brief Set all identities a status in the specified category
113 * @param category is one of the Kopete::OnlineStatusManager::Categories
114 * @param statusMessage is the new status message
115 * @param flags is a bitmask of SetOnlineStatusFlag
117 void setOnlineStatus( /*Kopete::OnlineStatusManager::Categories*/ uint category
,
118 const Kopete::StatusMessage
&statusMessage
= Kopete::StatusMessage(), uint flags
=0);
122 * Save the identity data to KConfig
128 * Load the identity data from KConfig
134 * \brief Signals when an identity is ready for use
136 void identityRegistered( Kopete::Identity
*identity
);
139 * \brief Signals when an identity has been unregistered
141 * At this state, we are already in the Identity destructor.
143 void identityUnregistered( const Kopete::Identity
*identity
);
146 * \brief Signals when the default identity has changed
148 void defaultIdentityChanged( Kopete::Identity
*identity
);
150 void identityOnlineStatusChanged( Kopete::Identity
*identity
);
154 * Private constructor, because we're a singleton
159 void slotIdentityOnlineStatusChanged( Kopete::Identity
*i
);
163 * Unregister the identity.
165 void unregisterIdentity( const Kopete::Identity
*identity
);
168 static IdentityManager
*s_self
;
173 } //END namespace Kopete