/src/libtomahawk/sip/SipHandler.h

http://github.com/tomahawk-player/tomahawk · C Header · 88 lines · 43 code · 18 blank · 27 comment · 0 complexity · d81acc9a94288674bd27ee139c4bac10 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. * Copyright 2010-2011, Leo Franchi <lfranchi@kde.org>
  5. * Copyright 2010-2011, Jeff Mitchell <jeff@tomahawk-player.org>
  6. *
  7. * Tomahawk is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation, either version 3 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * Tomahawk is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #ifndef SIPHANDLER_H
  21. #define SIPHANDLER_H
  22. #include "sip/SipPlugin.h"
  23. #include "DllMacro.h"
  24. #include <QObject>
  25. #include <QHash>
  26. #include <QString>
  27. #ifndef ENABLE_HEADLESS
  28. #include <QPixmap>
  29. #endif
  30. /**
  31. * Manages SIP plugins for connecting to friends. External interface to SIP plugins is
  32. * through AccountManager, this is an internal class.
  33. */
  34. class DLLEXPORT SipHandler : public QObject
  35. {
  36. Q_OBJECT
  37. public:
  38. static SipHandler* instance();
  39. SipHandler( QObject* parent );
  40. ~SipHandler();
  41. void loadFromAccountManager();
  42. #ifndef ENABLE_HEADLESS
  43. const QPixmap avatar( const QString& name ) const;
  44. #endif
  45. //TODO: implement a proper SipInfo class and maybe attach it to the source
  46. const SipInfo sipInfo( const QString& peerId ) const;
  47. const QString versionString( const QString& peerId ) const;
  48. void hookUpPlugin( SipPlugin* p );
  49. private slots:
  50. void onSipInfo( const QString& peerId, const SipInfo& info );
  51. void onSoftwareVersion( const QString& peerId, const QString& versionString );
  52. void onMessage( const QString&, const QString& );
  53. void onPeerOffline( const QString& );
  54. void onPeerOnline( const QString& );
  55. #ifndef ENABLE_HEADLESS
  56. // set data for local source
  57. void onAvatarReceived( const QPixmap& avatar );
  58. // set data for other sources
  59. void onAvatarReceived( const QString& from, const QPixmap& avatar );
  60. #endif
  61. private:
  62. static SipHandler *s_instance;
  63. //TODO: move this to source
  64. QHash<QString, SipInfo> m_peersSipInfos;
  65. QHash<QString, QString> m_peersSoftwareVersions;
  66. #ifndef ENABLE_HEADLESS
  67. QHash<QString, QPixmap> m_usernameAvatars;
  68. #endif
  69. };
  70. #endif