File indexing completed on 2024-05-05 04:47:30

0001 /****************************************************************************************
0002  * Copyright (c) 2007 Nikolaj Hald Nielsen <nhn@kde.org>                                *
0003  *                                                                                      *
0004  * This program is free software; you can redistribute it and/or modify it under        *
0005  * the terms of the GNU General Public License as published by the Free Software        *
0006  * Foundation; either version 2 of the License, or (at your option) any later           *
0007  * version.                                                                             *
0008  *                                                                                      *
0009  * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
0010  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
0011  * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
0012  *                                                                                      *
0013  * You should have received a copy of the GNU General Public License along with         *
0014  * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
0015  ****************************************************************************************/
0016 
0017 #ifndef INFOPROXY_H
0018 #define INFOPROXY_H
0019 
0020 #include "amarok_export.h"
0021 #include "InfoObserver.h"
0022 
0023 #include <QVariant>
0024 #include <QSet>
0025 
0026 class InfoProxy;
0027 
0028 namespace The {
0029     AMAROK_EXPORT InfoProxy* infoProxy();
0030 }
0031 
0032 /**
0033 A proxy class for relaying information from the currently active service to the ServiceEngine so it can be displayed in a plasma applet in the context view. It is a singleton and included in the "The" namespace for easy access
0034 
0035     @author Nikolaj Hald Nielsen <nhn@kde.org> 
0036 */
0037 class AMAROK_EXPORT InfoProxy
0038 {
0039     friend InfoProxy* infoProxy();
0040 
0041     public:
0042         static InfoProxy * instance();
0043         ~InfoProxy();
0044 
0045         void subscribe( InfoObserver *observer );
0046         void subscribeForCloud( InfoObserver *observer );
0047         void unsubscribe( InfoObserver *observer );
0048 
0049         void setInfo( const QVariantMap &infoMap );
0050         void setCloud( const QVariantMap &cloudMap );
0051 
0052         void loadHomePage();
0053         
0054         QVariantMap info(); // info about the service
0055         QVariantMap cloud(); //cloud view for the service
0056 
0057     private Q_SLOTS:
0058         void paletteChanged( const QPalette & palette );
0059     
0060     private:
0061         InfoProxy();
0062         void notifyObservers( const QVariantMap &infoMap ) const;
0063         void notifyCloudObservers( const QVariantMap &cloudMap ) const;
0064         QSet<InfoObserver *> m_observers;
0065         QSet<InfoObserver *> m_cloudObservers;
0066 
0067         static InfoProxy * m_instance;
0068 
0069         QVariantMap m_storedInfo;
0070         QVariantMap m_storedCloud;
0071 };
0072 
0073 #endif