Plasma
pollingwatcher.h
Go to the documentation of this file.00001 /* 00002 * Copyright 2008 Alex Merry <alex.merry@kdemail.net> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Lesser General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2.1 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Lesser General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Lesser General Public 00015 * License along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 #ifndef POLLINGWATCHER_H 00018 #define POLLINGWATCHER_H 00019 00020 00021 #include <QObject> 00022 #include <QSet> 00023 #include <QString> 00024 00025 #include "player.h" 00026 00027 class QTimer; 00028 00029 class PollingPlayerFactory; 00030 00031 class PollingWatcher : public QObject 00032 { 00033 Q_OBJECT 00034 00035 public: 00036 PollingWatcher(QObject* parent = 0); 00037 00038 QList<Player::Ptr> players(); 00039 00045 void addFactory(PollingPlayerFactory* factory); 00046 00047 Q_SIGNALS: 00051 void newPlayer(Player::Ptr player); 00057 void playerDisappeared(Player::Ptr player); 00058 00059 private Q_SLOTS: 00060 void checkPlayers(); 00061 00062 private: 00063 // the factories we are waiting for player to appear on 00064 QSet<PollingPlayerFactory*> m_polledFactories; 00065 // the factories we have a player for 00066 QSet<PollingPlayerFactory*> m_usedFactories; 00067 QSet<Player::Ptr> m_players; 00068 QTimer* m_timer; 00069 }; 00070 00071 #endif // POLLINGWATCHER_H