1
/****************************************************************************************
2
 * Copyright (c) 2007 Jeff Mitchell <kde-dev@emailgoeshere.com>                         *
3
 *                                                                                      *
4
 * This program is free software; you can redistribute it and/or modify it under        *
5
 * the terms of the GNU General Public License as published by the Free Software        *
6
 * Foundation; either version 2 of the License, or (at your option) any later           *
7
 * version.                                                                             *
8
 *                                                                                      *
9
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY      *
10
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A      *
11
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.             *
12
 *                                                                                      *
13
 * You should have received a copy of the GNU General Public License along with         *
14
 * this program.  If not, see <http://www.gnu.org/licenses/>.                           *
15
 ****************************************************************************************/
16
17
#ifndef AMAROK_MEDIADEVICECACHE_H
18
#define AMAROK_MEDIADEVICECACHE_H
19
20
#include "amarok_export.h"
21
22
#include <QObject>
23
#include <QMap>
24
#include <QString>
25
#include <QStringList>
26
27
namespace Solid {
28
    class Device;
29
}
30
31
class AMAROK_EXPORT MediaDeviceCache : public QObject
32
{
33
    Q_OBJECT
34
35
    public:
36
37
        enum DeviceType { SolidPMPType, SolidVolumeType, ManualType, SolidAudioCdType, SolidGenericType, InvalidType };
38
39
        static MediaDeviceCache* instance() { return s_instance ? s_instance : new MediaDeviceCache(); }
40
41
        /**
42
        * Creates a new MediaDeviceCache.
43
        * 
44
        */
45
        MediaDeviceCache();
46
        ~MediaDeviceCache();
47
48
        void refreshCache();
49
        const QStringList getAll() const { return m_type.keys(); }
50
        MediaDeviceCache::DeviceType deviceType( const QString &udi ) const;
51
        const QString deviceName( const QString &udi ) const;
52
        bool isGenericEnabled( const QString &udi ) const;
53
        const QString volumeMountPoint( const QString &udi ) const;
54
55
    signals:
56
        void deviceAdded( const QString &udi );
57
        void deviceRemoved( const QString &udi );
58
        void accessibilityChanged( bool accessible, const QString &udi );
59
60
    public slots:
61
        void slotAddSolidDevice( const QString &udi );
62
        void slotRemoveSolidDevice( const QString &udi );
63
        void slotAccessibilityChanged( bool accessible, const QString &udi );
64
65
    private:
66
        QMap<QString, MediaDeviceCache::DeviceType> m_type;
67
        QMap<QString, QString> m_name;
68
        QStringList m_volumes;
69
        static MediaDeviceCache* s_instance;
70
};
71
72
#endif /* AMAROK_MEDIADEVICECACHE_H */