PageRenderTime 102ms CodeModel.GetById 41ms app.highlight 4ms RepoModel.GetById 56ms app.codeStats 0ms

/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
21#ifndef SIPHANDLER_H
22#define SIPHANDLER_H
23
24#include "sip/SipPlugin.h"
25#include "DllMacro.h"
26
27#include <QObject>
28#include <QHash>
29#include <QString>
30
31#ifndef ENABLE_HEADLESS
32    #include <QPixmap>
33#endif
34
35/**
36 * Manages SIP plugins for connecting to friends. External interface to SIP plugins is
37 * through AccountManager, this is an internal class.
38 */
39
40class DLLEXPORT SipHandler : public QObject
41{
42    Q_OBJECT
43
44public:
45    static SipHandler* instance();
46
47    SipHandler( QObject* parent );
48    ~SipHandler();
49
50    void loadFromAccountManager();
51
52#ifndef ENABLE_HEADLESS
53    const QPixmap avatar( const QString& name ) const;
54#endif
55
56    //TODO: implement a proper SipInfo class and maybe attach it to the source
57    const SipInfo sipInfo( const QString& peerId ) const;
58    const QString versionString( const QString& peerId ) const;
59
60    void hookUpPlugin( SipPlugin* p );
61
62private slots:
63    void onSipInfo( const QString& peerId, const SipInfo& info );
64    void onSoftwareVersion( const QString& peerId, const QString& versionString );
65    void onMessage( const QString&, const QString& );
66    void onPeerOffline( const QString& );
67    void onPeerOnline( const QString& );
68
69#ifndef ENABLE_HEADLESS
70    // set data for local source
71    void onAvatarReceived( const QPixmap& avatar );
72
73    // set data for other sources
74    void onAvatarReceived( const QString& from, const QPixmap& avatar );
75#endif
76
77private:
78    static SipHandler *s_instance;
79
80    //TODO: move this to source
81    QHash<QString, SipInfo> m_peersSipInfos;
82    QHash<QString, QString> m_peersSoftwareVersions;
83#ifndef ENABLE_HEADLESS
84    QHash<QString, QPixmap> m_usernameAvatars;
85#endif
86};
87
88#endif