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
5
 *  it under the terms of the GNU General Public License as published by
6
 *  the Free Software Foundation; either version 2 of the License, or
7
 *  (at your option) any later version.
8
 *
9
 *  This program 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
12
 *  GNU General Public License for more details.
13
 *
14
 *  You should have received a copy of the GNU General Public License
15
 *  along with this program; if not, write to the Free Software
16
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
 */
18
#ifndef AMAROK_MEDIADEVICECACHE_H
19
#define AMAROK_MEDIADEVICECACHE_H
20
21
#include "amarok_export.h"
22
23
#include <QObject>
24
#include <QMap>
25
#include <QString>
26
#include <QStringList>
27
28
namespace Solid {
29
    class Device;
30
}
31
32
class AMAROK_EXPORT MediaDeviceCache : public QObject
33
{
34
    Q_OBJECT
35
36
    public:
37
38
        enum DeviceType { SolidPMPType, SolidVolumeType, ManualType, SolidAudioCdType,  InvalidType };
39
40
        static MediaDeviceCache* instance() { return s_instance ? s_instance : new MediaDeviceCache(); }
41
42
        /**
43
        * Creates a new MediaDeviceCache.
44
        * 
45
        */
46
        MediaDeviceCache();
47
        ~MediaDeviceCache();
48
49
        void refreshCache();
50
        const QStringList getAll() const { return m_type.keys(); }
51
        MediaDeviceCache::DeviceType deviceType( const QString &udi ) const;
52
        const QString deviceName( const QString &udi ) const;
53
        bool isGenericEnabled( const QString &udi ) const;
54
        const QString volumeMountPoint( const QString &udi ) const;
55
56
    signals:
57
        void deviceAdded( const QString &udi );
58
        void deviceRemoved( const QString &udi );
59
	void accessibilityChanged( bool accessible, const QString &udi );
60
61
    public slots:
62
        void slotAddSolidDevice( const QString &udi );
63
        void slotRemoveSolidDevice( const QString &udi );
64
        void slotAccessibilityChanged( bool accessible, const QString &udi );
65
66
    private:
67
        QMap<QString, MediaDeviceCache::DeviceType> m_type;
68
        QMap<QString, QString> m_name;
69
        QStringList m_volumes;
70
        static MediaDeviceCache* s_instance;
71
};
72
73
#endif /* AMAROK_MEDIADEVICECACHE_H */