summaryrefslogtreecommitdiff
path: root/PlexServer.h
blob: 7bacb1b97f6764bc7ca03a2e0e1e034c92371314 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#ifndef PLEXSERVER_H
#define PLEXSERVER_H

#include <stdlib.h>
#include <string>
#include <sstream>
#include <iostream>
#include <vector>
#include <memory>
#include <map>

#include <Poco/String.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPSClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/Net/MessageHeader.h>
#include <Poco/URI.h>

namespace plexclient {

    class PlexServer {
        friend class plexgdm;

    public:
        PlexServer(std::string uri, std::string name, std::string uuid, std::string accessToken, bool owned,
                   bool local);

        ~PlexServer();

        int GetMaster() const {
            return m_nMaster;
        }

        int IsOwned() const {
            return m_nOwned;
        }

        const std::string &GetContentType() const {
            return m_sContentType;
        }

        const std::string &GetDiscovery() const {
            return m_sDiscovery;
        }

        const std::string &GetRole() const {
            return m_sRole;
        }

        const std::string &GetServerName() const {
            return m_sServerName;
        }

        long GetUpdated() const {
            return m_nUpdated;
        }

        const std::string &GetUuid() const {
            return m_sUuid;
        }

        const std::string &GetVersion() const {
            return m_sVersion;
        }

        const std::string &GetAuthToken() const {
            return m_authToken;
        }

        const bool &IsLocal() const {
            return m_bLocal;
        }

        void SetAuthToken(std::string token) {
            m_authToken = token;
        }

        std::shared_ptr<Poco::Net::HTTPClientSession> MakeRequest(bool &ok, std::string path,
                                                                  const std::map<std::string, std::string> &queryParameters = std::map<std::string, std::string>());

        std::string GetHost();

        int GetPort();

        std::string GetUri();

        std::shared_ptr<Poco::Net::HTTPClientSession> GetClientSession();

        bool Offline;

    protected:
        PlexServer(std::string data, std::string ip);

        PlexServer(std::string ip, int port);

        PlexServer() { };

        void ParseData(std::string data, std::string ip);

    private:
        std::string m_sDiscovery;

        int m_nOwned;
        bool m_bLocal;
        int m_nMaster;
        std::string m_sRole;
        std::string m_sContentType;
        std::string m_sUuid;
        std::string m_sServerName;
        std::string m_uri;
        std::string m_authToken;
        long m_nUpdated;
        std::string m_sVersion;
    };

}
#endif // PLEXSERVER_H