aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2019-06-28 16:48:42 +0200
committerLNJ <lnj@kaidan.im>2020-01-13 17:16:36 +0100
commit5f46963cf556d7e7e241e7d8e59d42b31474c74d (patch)
tree23de3b37493cb1f11c0fe5286290ff0ebda601fe /src
parent411cf3b9c06ec6e0b9af1b57c3370dae4640d460 (diff)
downloadqxmpp-5f46963cf556d7e7e241e7d8e59d42b31474c74d.tar.gz
QXmppClient: Add method to get index of extension
Diffstat (limited to 'src')
-rw-r--r--src/client/QXmppClient.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/client/QXmppClient.h b/src/client/QXmppClient.h
index 3e5df394..dd73ffff 100644
--- a/src/client/QXmppClient.h
+++ b/src/client/QXmppClient.h
@@ -135,6 +135,30 @@ public:
return nullptr;
}
+ /// \brief Returns the index of an extension
+ ///
+ /// Usage example:
+ /// \code
+ /// int index = client->indexOfExtension<QXmppDiscoveryManager>();
+ /// if (index > 0) {
+ /// // extension found, do stuff...
+ /// } else {
+ /// // extension not found
+ /// }
+ /// \endcode
+ ///
+ template<typename T>
+ int indexOfExtension()
+ {
+ int index = -1;
+ auto list = extensions();
+ for (int i = 0; i < list.size(); ++i) {
+ if (qobject_cast<T *>(list.at(i)) != nullptr)
+ index = i;
+ }
+ return index;
+ }
+
bool isAuthenticated() const;
bool isConnected() const;