/src/libtomahawk/network/PortFwdThread.h

http://github.com/tomahawk-player/tomahawk · C Header · 75 lines · 40 code · 18 blank · 17 comment · 0 complexity · e502749483c2ee880e58abd3d4200541 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 PORTFWDTHREAD_H
  19. #define PORTFWDTHREAD_H
  20. #include <QThread>
  21. #include <QMutex>
  22. #include <QHostAddress>
  23. #include <QPointer>
  24. class Portfwd;
  25. class PortFwdWorker : public QObject
  26. {
  27. Q_OBJECT
  28. public:
  29. explicit PortFwdWorker( unsigned int port );
  30. ~PortFwdWorker();
  31. unsigned int externalPort() const { return m_externalPort; }
  32. void unregister();
  33. signals:
  34. void externalAddressDetected( QHostAddress ha, unsigned int port );
  35. public slots:
  36. void work();
  37. private:
  38. Portfwd* m_portfwd;
  39. QHostAddress m_externalAddress;
  40. unsigned int m_externalPort, m_port;
  41. };
  42. class PortFwdThread : public QThread
  43. {
  44. Q_OBJECT
  45. public:
  46. explicit PortFwdThread( unsigned int port );
  47. ~PortFwdThread();
  48. QPointer< PortFwdWorker > worker() const;
  49. signals:
  50. void externalAddressDetected( QHostAddress ha, unsigned int port );
  51. protected:
  52. void run();
  53. private:
  54. QPointer< PortFwdWorker > m_worker;
  55. unsigned int m_port;
  56. };
  57. #endif // PORTFWDTHREAD_H