QXmppClientExtension.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (C) 2008-2012 The QXmpp developers
  3. *
  4. * Author:
  5. * Jeremy Lainé
  6. *
  7. * Source:
  8. * http://code.google.com/p/qxmpp
  9. *
  10. * This file is a part of QXmpp library.
  11. *
  12. * This library is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU Lesser General Public
  14. * License as published by the Free Software Foundation; either
  15. * version 2.1 of the License, or (at your option) any later version.
  16. *
  17. * This library is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. * Lesser General Public License for more details.
  21. *
  22. */
  23. #ifndef QXMPPCLIENTEXTENSION_H
  24. #define QXMPPCLIENTEXTENSION_H
  25. #include "QXmppDiscoveryIq.h"
  26. #include "QXmppLogger.h"
  27. class QDomElement;
  28. class QStringList;
  29. class QXmppClient;
  30. class QXmppClientExtensionPrivate;
  31. class QXmppStream;
  32. /// \brief The QXmppClientExtension class is the base class for QXmppClient
  33. /// extensions.
  34. ///
  35. /// If you want to extend QXmppClient, for instance to support an IQ type
  36. /// which is not natively supported, you can subclass QXmppClientExtension
  37. /// and implement handleStanza(). You can then add your extension to the
  38. /// client instance using QXmppClient::addExtension().
  39. ///
  40. /// \ingroup Core
  41. class QXMPP_EXPORT QXmppClientExtension : public QXmppLoggable
  42. {
  43. Q_OBJECT
  44. public:
  45. QXmppClientExtension();
  46. virtual ~QXmppClientExtension();
  47. virtual QStringList discoveryFeatures() const;
  48. virtual QList<QXmppDiscoveryIq::Identity> discoveryIdentities() const;
  49. /// \brief You need to implement this method to process incoming XMPP
  50. /// stanzas.
  51. ///
  52. /// You should return true if the stanza was handled and no further
  53. /// processing should occur, or false to let other extensions process
  54. /// the stanza.
  55. virtual bool handleStanza(const QDomElement &stanza) = 0;
  56. protected:
  57. QXmppClient *client();
  58. virtual void setClient(QXmppClient *client);
  59. private:
  60. QXmppClientExtensionPrivate * const d;
  61. friend class QXmppClient;
  62. };
  63. #endif