Switch to unified view

a/src/ohplaylist.hxx b/src/ohplaylist.hxx
...
...
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
15
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
16
 */
16
 */
17
#ifndef _OHPLAYLIST_H_X_INCLUDED_
17
#ifndef _OHPLAYLIST_H_X_INCLUDED_
18
#define _OHPLAYLIST_H_X_INCLUDED_
18
#define _OHPLAYLIST_H_X_INCLUDED_
19
19
20
#include <string>                       // for string
20
#include <string>
21
#include <unordered_map>                // for unordered_map
21
#include <unordered_map>
22
#include <vector>                       // for vector
22
#include <vector>
23
23
24
#include "libupnpp/device/device.hxx"   // for UpnpService
24
#include "libupnpp/device/device.hxx"
25
#include "libupnpp/soaphelp.hxx"        // for SoapIncoming, SoapOutgoing
25
#include "libupnpp/soaphelp.hxx"
26
26
27
#include "mpdcli.hxx"
27
#include "mpdcli.hxx"
28
#include "ohservice.hxx"
28
#include "ohservice.hxx"
29
29
30
using namespace UPnPP;
30
using namespace UPnPP;
31
31
32
class OHPlaylist : public OHService {
32
class OHPlaylist : public OHService {
33
public:
33
public:
34
    OHPlaylist(UpMpd *dev, unsigned int cachesavesleep);
34
    OHPlaylist(UpMpd *dev, unsigned int cachesavesleep);
35
35
36
    // These are used by other services (ohreceiver etc.)
36
    bool cacheFind(const std::string& uri, std:: string& meta);
37
    bool cacheFind(const std::string& uri, std:: string& meta);
37
38
    // Internal non-soap versions of some of the interface for use by
39
    // e.g. ohreceiver
40
    bool insertUri(int afterid, const std::string& uri, 
41
                   const std::string& metadata, int *newid, bool nocheck);
42
    bool ireadList(const std::vector<int>&, std::vector<UpSong>&);
43
    bool iidArray(std::string& idarray, int *token);
44
    bool urlMap(std::unordered_map<int, std::string>& umap);
38
    bool urlMap(std::unordered_map<int, std::string>& umap);
45
46
    int iStop();
39
    int iStop();
47
    void refreshState();
40
    // When changing sources
48
49
    // Source active ?
50
    void setActive(bool onoff);
41
    void setActive(bool onoff);
51
42
52
protected:
43
protected:
53
    virtual bool makestate(std::unordered_map<std::string, std::string> &st);
44
    virtual bool makestate(std::unordered_map<std::string, std::string> &st);
45
54
private:
46
private:
55
    int play(const SoapIncoming& sc, SoapOutgoing& data);
47
    int play(const SoapIncoming& sc, SoapOutgoing& data);
56
    int pause(const SoapIncoming& sc, SoapOutgoing& data);
48
    int pause(const SoapIncoming& sc, SoapOutgoing& data);
57
    int stop(const SoapIncoming& sc, SoapOutgoing& data);
49
    int stop(const SoapIncoming& sc, SoapOutgoing& data);
58
    int next(const SoapIncoming& sc, SoapOutgoing& data);
50
    int next(const SoapIncoming& sc, SoapOutgoing& data);
...
...
75
    int tracksMax(const SoapIncoming& sc, SoapOutgoing& data);
67
    int tracksMax(const SoapIncoming& sc, SoapOutgoing& data);
76
    int idArray(const SoapIncoming& sc, SoapOutgoing& data);
68
    int idArray(const SoapIncoming& sc, SoapOutgoing& data);
77
    int idArrayChanged(const SoapIncoming& sc, SoapOutgoing& data);
69
    int idArrayChanged(const SoapIncoming& sc, SoapOutgoing& data);
78
    int protocolInfo(const SoapIncoming& sc, SoapOutgoing& data);
70
    int protocolInfo(const SoapIncoming& sc, SoapOutgoing& data);
79
71
72
    // Private internal non-soap versions of some of the interface +
73
    // utility methods
80
    bool makeIdArray(std::string&);
74
    bool makeIdArray(std::string&);
81
    void maybeWakeUp(bool ok);
75
    void maybeWakeUp(bool ok);
76
    void refreshState();
77
    bool insertUri(int afterid, const std::string& uri, 
78
                   const std::string& metadata, int *newid, bool nocheck);
79
    bool ireadList(const std::vector<int>&, std::vector<UpSong>&);
80
    bool iidArray(std::string& idarray, int *token);
81
    // Search the current mpd queue for a given uri and return the
82
    // corresponding id. This is used for mapping ids from our
83
    // previous active phase to the current ones (which changed when
84
    // the tracks were re-inserted on activation). Of course, this
85
    // does not work in the case of multiple identical Uris in the
86
    // playlist.
87
    int idFromOldId(int oldid);
82
88
83
    bool m_active;
89
    bool m_active;
90
    // Mpd state that we save/restore when becoming inactive/active
84
    MpdState m_mpdsavedstate;
91
    MpdState m_mpdsavedstate;
92
    // Frozen upnpstate (idarray etc.) which we use when inactive
93
    // (because we can't read from the mpd playlist which is used by
94
    // someone else. Could largely be rebuilt from m_mpdsavedstate,
95
    // but easier this way as we can just/use it in makestate().
96
    std::unordered_map<std::string, std::string> m_upnpstate;
85
    
97
    
86
    // Storage for song metadata, indexed by URL.  This used to be
98
    // Storage for song metadata, indexed by URL.  This used to be
87
    // indexed by song id, but this does not survive MPD restarts.
99
    // indexed by song id, but this does not survive MPD restarts.
88
    // The data is the DIDL XML string.
100
    // The data is the DIDL XML string.
89
    std::unordered_map<std::string, std::string> m_metacache;
101
    std::unordered_map<std::string, std::string> m_metacache;