/src/sip/zeroconf/zeroconf.h

http://github.com/tomahawk-player/tomahawk · C Header · 90 lines · 54 code · 19 blank · 17 comment · 0 complexity · b79ebd5c3643f2f0b9657d4c576e1ca4 MD5 · raw file

  1. /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
  2. *
  3. * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
  4. *
  5. * Tomahawk is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * Tomahawk is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef ZEROCONF_H
  19. #define ZEROCONF_H
  20. #include "sip/SipPlugin.h"
  21. #include "tomahawkzeroconf.h"
  22. #include "../sipdllmacro.h"
  23. #include <QtCore/QTimer>
  24. #define MYNAME "Local Network"
  25. class SIPDLLEXPORT ZeroconfFactory : public SipPluginFactory
  26. {
  27. Q_OBJECT
  28. Q_INTERFACES( SipPluginFactory )
  29. public:
  30. ZeroconfFactory() {}
  31. virtual ~ZeroconfFactory() {}
  32. virtual QString factoryId() const { return "sipzeroconf"; }
  33. virtual QString prettyName() const { return "Local Network"; }
  34. virtual bool isUnique() const { return true; }
  35. #ifndef ENABLE_HEADLESS
  36. virtual QIcon icon() const;
  37. #endif
  38. virtual SipPlugin* createPlugin ( const QString& pluginId = QString() );
  39. };
  40. class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin
  41. {
  42. Q_OBJECT
  43. public:
  44. ZeroconfPlugin();
  45. ZeroconfPlugin( const QString& pluginId );
  46. virtual ~ZeroconfPlugin();
  47. virtual const QString name() const;
  48. virtual const QString friendlyName() const;
  49. virtual const QString accountName() const;
  50. virtual ConnectionState connectionState() const;
  51. virtual bool isValid() const { return true; }
  52. #ifndef ENABLE_HEADLESS
  53. virtual QIcon icon() const;
  54. #endif
  55. virtual void checkSettings() {}
  56. public slots:
  57. virtual bool connectPlugin( bool startup );
  58. void disconnectPlugin();
  59. void advertise();
  60. void sendMsg( const QString& , const QString& ) {}
  61. void broadcastMsg( const QString & ) {}
  62. void addContact( const QString &, const QString& ) {}
  63. private slots:
  64. void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid );
  65. private:
  66. TomahawkZeroconf* m_zeroconf;
  67. ConnectionState m_state;
  68. QVector<QStringList> m_cachedNodes;
  69. QTimer m_advertisementTimer;
  70. };
  71. #endif