diff options
Diffstat (limited to 'src/client/QXmppClient.h')
| -rw-r--r-- | src/client/QXmppClient.h | 24 |
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; |
