summaryrefslogtreecommitdiffstats
path: root/kopete/protocols/jabber/jabberresourcepool.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commitbcb704366cb5e333a626c18c308c7e0448a8e69f (patch)
treef0d6ab7d78ecdd9207cf46536376b44b91a1ca71 /kopete/protocols/jabber/jabberresourcepool.h
downloadtdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.tar.gz
tdenetwork-bcb704366cb5e333a626c18c308c7e0448a8e69f.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kopete/protocols/jabber/jabberresourcepool.h')
-rw-r--r--kopete/protocols/jabber/jabberresourcepool.h129
1 files changed, 129 insertions, 0 deletions
diff --git a/kopete/protocols/jabber/jabberresourcepool.h b/kopete/protocols/jabber/jabberresourcepool.h
new file mode 100644
index 00000000..a6cefcde
--- /dev/null
+++ b/kopete/protocols/jabber/jabberresourcepool.h
@@ -0,0 +1,129 @@
+ /*
+ * jabberresourcepool.h
+ *
+ * Copyright (c) 2004 by Till Gerken <[email protected]>
+ * Copyright (c) 2006 by Michaël Larouche <[email protected]>
+ *
+ * Kopete (c) by the Kopete developers <[email protected]>
+ *
+ * *************************************************************************
+ * * *
+ * * This program is free software; you can redistribute it and/or modify *
+ * * it under the terms of the GNU General Public License as published by *
+ * * the Free Software Foundation; either version 2 of the License, or *
+ * * (at your option) any later version. *
+ * * *
+ * *************************************************************************
+ */
+
+#ifndef JABBERRESOURCEPOOL_H
+#define JABBERRESOURCEPOOL_H
+
+#include <qobject.h>
+#include <im.h>
+
+class JabberResource;
+class JabberAccount;
+
+/**
+ * @author Till Gerken <[email protected]>
+ * @author Michaël Larouche <[email protected]>
+ */
+class JabberResourcePool : public QObject
+{
+ Q_OBJECT
+public:
+ static XMPP::Resource EmptyResource;
+
+ typedef QPtrList<JabberResource> ResourceList;
+
+ /**
+ * Default constructor
+ */
+ JabberResourcePool ( JabberAccount *account );
+
+ /**
+ * Default destructor
+ */
+ ~JabberResourcePool();
+
+ /**
+ * Notify all relevant contacts in case
+ * a resource has been added, updated or removed.
+ */
+ void notifyRelevantContacts ( const XMPP::Jid &jid );
+
+ /**
+ * Add a resource to the pool
+ */
+ void addResource ( const XMPP::Jid &jid, const XMPP::Resource &resource );
+
+ /**
+ * Remove a resource from the pool
+ */
+ void removeResource ( const XMPP::Jid &jid, const XMPP::Resource &resource );
+
+ /**
+ * Remove all resources for a given address from the pool
+ * NOTE: Since this method is mainly used for housekeeping,
+ * it does NOT notify any contacts.
+ */
+ void removeAllResources ( const XMPP::Jid &jid );
+
+ /**
+ * Remove all resources from the pool
+ */
+ void clear ();
+
+ /**
+ * Lock to a certain resource
+ */
+ void lockToResource ( const XMPP::Jid &jid, const XMPP::Resource &resource );
+
+ /**
+ * Remove a resource lock
+ */
+ void removeLock ( const XMPP::Jid &jid );
+
+ /**
+ * Return the JabberResource instance for the locked resource, if any.
+ */
+ JabberResource *lockedJabberResource( const XMPP::Jid &jid );
+
+ /**
+ * Return currently locked resource, if any
+ */
+ const XMPP::Resource &lockedResource ( const XMPP::Jid &jid );
+
+ /**
+ * Return a usable JabberResource for a given JID.
+ *
+ * @param jid Jid to look for the best resource.
+ * @param honourLock Honour the resource locked by the user.
+ *
+ * @return a JabberResource instance.
+ */
+ JabberResource *bestJabberResource( const XMPP::Jid &jid, bool honourLock = true );
+
+ /**
+ * Return usable resource for a given JID
+ * Matches by userHost(), honours locks for a JID by default
+ */
+ const XMPP::Resource &bestResource ( const XMPP::Jid &jid, bool honourLock = true );
+
+ /**
+ * Find all resources that exist for a given JID
+ */
+ void findResources ( const XMPP::Jid &jid, JabberResourcePool::ResourceList &resourceList );
+ void findResources ( const XMPP::Jid &jid, XMPP::ResourceList &resourceList );
+
+private slots:
+ void slotResourceDestroyed ( QObject *sender );
+ void slotResourceUpdated ( JabberResource *resource );
+
+private:
+ class Private;
+ Private *d;
+};
+
+#endif