From 5f46963cf556d7e7e241e7d8e59d42b31474c74d Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 28 Jun 2019 16:48:42 +0200 Subject: QXmppClient: Add method to get index of extension --- src/client/QXmppClient.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/client') 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(); + /// if (index > 0) { + /// // extension found, do stuff... + /// } else { + /// // extension not found + /// } + /// \endcode + /// + template + int indexOfExtension() + { + int index = -1; + auto list = extensions(); + for (int i = 0; i < list.size(); ++i) { + if (qobject_cast(list.at(i)) != nullptr) + index = i; + } + return index; + } + bool isAuthenticated() const; bool isConnected() const; -- cgit v1.2.3