diff options
| -rw-r--r-- | src/client/QXmppClient.cpp | 10 | ||||
| -rw-r--r-- | src/client/QXmppClient.h | 8 | ||||
| -rw-r--r-- | tests/TestClient.h | 8 |
3 files changed, 18 insertions, 8 deletions
diff --git a/src/client/QXmppClient.cpp b/src/client/QXmppClient.cpp index 0e37a4f9..e1808445 100644 --- a/src/client/QXmppClient.cpp +++ b/src/client/QXmppClient.cpp @@ -195,6 +195,16 @@ QXmppClient::~QXmppClient() delete d; } +/// +/// \fn QXmppClient::addNewExtension() +/// +/// Creates a new extension and adds it to the client. +/// +/// \returns the newly created extension +/// +/// \since QXmpp 1.5 +/// + /// Registers a new \a extension with the client. /// /// \param extension diff --git a/src/client/QXmppClient.h b/src/client/QXmppClient.h index 3337c5b1..a6502305 100644 --- a/src/client/QXmppClient.h +++ b/src/client/QXmppClient.h @@ -140,6 +140,14 @@ public: ~QXmppClient() override; bool addExtension(QXmppClientExtension *extension); + template<typename T, typename... Args> + T *addNewExtension(Args... args) + { + // it's impossible that addExtension() returns false: ext is a new object + auto *ext = new T(args...); + addExtension(ext); + return ext; + } bool insertExtension(int index, QXmppClientExtension *extension); bool removeExtension(QXmppClientExtension *extension); diff --git a/tests/TestClient.h b/tests/TestClient.h index 6dcec3de..662694c5 100644 --- a/tests/TestClient.h +++ b/tests/TestClient.h @@ -52,14 +52,6 @@ public: { } - template<typename T, typename ...Args> - T *addNewExtension(Args... args) - { - auto *ext = new T(args...); - addExtension(ext); - return ext; - } - void inject(const QByteArray &xml) { d->stream->handleIqResponse(xmlToDom(xml)); |
