summaryrefslogtreecommitdiffstats
path: root/amarok/src/devicemanager.h
blob: 10ac9f5a3cae205069e9f78349c2e26f51e34119 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
//
// C++ Interface: devicemanager
//
// Description: Controls device/medium object handling, providing
//              helper functions for other objects
//
//
// Author: Jeff Mitchell <kde-dev@emailgoeshere.com>, (C) 2006
//         Maximilian Kossick <maximilian.kossick@googlemail.com>, (C) 2006
//
// Copyright: See COPYING file that comes with this distribution
//
//


#ifndef AMAROK_DEVICE_MANAGER_H
#define AMAROK_DEVICE_MANAGER_H

#include "medium.h"

#include <tqmap.h>

#include <dcopobject.h>

typedef TQMap<TQString, Medium*> MediumMap;


//this class provides support for MountPointManager and MediaDeviceManager
//the latter is responsible for handling mediadevices (e.g. ipod)
//unless you have special requirements you should use either MountPointManager or
//MediaDeviceManager instead of this class.
class DeviceManager : public TQObject
{

    Q_OBJECT
  
    public:
        DeviceManager();
        ~DeviceManager();
        static DeviceManager *instance();

        void mediumAdded( const TQString name );
        void mediumChanged( const TQString name);
        void mediumRemoved( const TQString name);

        MediumMap getMediumMap() { return m_mediumMap; }
        Medium* getDevice( const TQString name );
        // reconciles m_mediumMap to whatever kded has in it.
        void reconcileMediumMap();

        bool isValid() { return m_valid; }

        //only use getDeviceList to initialise clients
        Medium::List getDeviceList();

        //public so can be called from DCOP...but don't use this, see the
        //warning about getDeviceList()
        TQStringList getDeviceStringList();

        // Converts a media://media/hdc URL as provided by the KDE media
        // manager on CD insert to /dev/hdc so amarok can play it.
        // This method is safe to call with a device path, it returns it
        // unchanged.
        TQString convertMediaUrlToDevice( TQString url );

    signals:
        void mediumAdded( const Medium*, TQString );
        void mediumChanged( const Medium*, TQString );
        void mediumRemoved( const Medium*, TQString );

    private:

        DCOPClient *m_dc;
        bool m_valid;
        MediumMap m_mediumMap;

};

#endif