not quite so much needs to be delayed to the init() function
[personal-kdebase.git] / workspace / plasma / dataengines / nowplaying / playerinterface / pollingwatcher.h
blob34446da942571119eb10f9912f3e0d689bc87777
1 /*
2 * Copyright 2008 Alex Merry <alex.merry@kdemail.net>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef POLLINGWATCHER_H
18 #define POLLINGWATCHER_H
21 #include <QObject>
22 #include <QSet>
23 #include <QString>
25 #include "player.h"
27 class QTimer;
29 class PollingPlayerFactory;
31 class PollingWatcher : public QObject
33 Q_OBJECT
35 public:
36 PollingWatcher(QObject* parent = 0);
38 QList<Player::Ptr> players();
40 /**
41 * Adds a service to watch for.
43 * @param factory the factory for the player
45 void addFactory(PollingPlayerFactory* factory);
47 Q_SIGNALS:
48 /**
49 * A new player is available
51 void newPlayer(Player::Ptr player);
52 /**
53 * A previously existing player is no longer available
55 * @param player the now-invalid player
57 void playerDisappeared(Player::Ptr player);
59 private Q_SLOTS:
60 void checkPlayers();
62 private:
63 // the factories we are waiting for player to appear on
64 QSet<PollingPlayerFactory*> m_polledFactories;
65 // the factories we have a player for
66 QSet<PollingPlayerFactory*> m_usedFactories;
67 QSet<Player::Ptr> m_players;
68 QTimer* m_timer;
71 #endif // POLLINGWATCHER_H