PageRenderTime 72ms CodeModel.GetById 30ms app.highlight 6ms RepoModel.GetById 34ms app.codeStats 0ms

/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
19#ifndef ZEROCONF_H
20#define ZEROCONF_H
21
22#include "sip/SipPlugin.h"
23#include "tomahawkzeroconf.h"
24
25#include "../sipdllmacro.h"
26
27#include <QtCore/QTimer>
28
29#define MYNAME "Local Network"
30
31class SIPDLLEXPORT ZeroconfFactory : public SipPluginFactory
32{
33    Q_OBJECT
34    Q_INTERFACES( SipPluginFactory )
35public:
36    ZeroconfFactory() {}
37    virtual ~ZeroconfFactory() {}
38
39    virtual QString factoryId() const { return "sipzeroconf"; }
40    virtual QString prettyName() const { return "Local Network"; }
41    virtual bool isUnique() const { return true; }
42#ifndef ENABLE_HEADLESS
43    virtual QIcon icon() const;
44#endif
45
46
47    virtual SipPlugin* createPlugin ( const QString& pluginId = QString() );
48};
49
50class SIPDLLEXPORT ZeroconfPlugin : public SipPlugin
51{
52    Q_OBJECT
53
54public:
55    ZeroconfPlugin();
56    ZeroconfPlugin( const QString& pluginId );
57
58    virtual ~ZeroconfPlugin();
59
60    virtual const QString name() const;
61    virtual const QString friendlyName() const;
62    virtual const QString accountName() const;
63    virtual ConnectionState connectionState() const;
64    virtual bool isValid() const { return true; }
65#ifndef ENABLE_HEADLESS
66    virtual QIcon icon() const;
67#endif
68    virtual void checkSettings() {}
69
70public slots:
71    virtual bool connectPlugin( bool startup );
72    void disconnectPlugin();
73
74    void advertise();
75
76    void sendMsg( const QString& , const QString&  ) {}
77    void broadcastMsg( const QString & ) {}
78    void addContact( const QString &, const QString&  ) {}
79
80private slots:
81    void lanHostFound( const QString& host, int port, const QString& name, const QString& nodeid );
82
83private:
84    TomahawkZeroconf* m_zeroconf;
85    ConnectionState m_state;
86    QVector<QStringList> m_cachedNodes;
87    QTimer m_advertisementTimer;
88};
89
90#endif