Subversion Repositories tpanel

Rev

Rev 8 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8 Rev 21
Line 1... Line 1...
1
/*
1
/*
2
 * Copyright (C) 2020 by Andreas Theofilu <andreas@theosys.at>
2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
3
 *
3
 *
4
 * This program is free software; you can redistribute it and/or modify
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
5
 * it under the terms of the GNU General Public License as published by
6
 * the Free Software Foundation; either version 3 of the License, or
6
 * the Free Software Foundation; either version 3 of the License, or
7
 * (at your option) any later version.
7
 * (at your option) any later version.
Line 20... Line 20...
20
#define __TPRJRESOURCES_H__
20
#define __TPRJRESOURCES_H__
21
 
21
 
22
#include <string>
22
#include <string>
23
#include <vector>
23
#include <vector>
24
 
24
 
-
 
25
#include "thttpclient.h"
-
 
26
 
25
typedef struct RESOURCE_T
27
typedef struct RESOURCE_T
26
{
28
{
27
    std::string name;
29
    std::string name;           // Name of resource
28
    std::string protocol;
30
    std::string protocol;       // With TP4 this is either HTTP of FTP
29
    std::string user;
31
    std::string user;           // Optional: User name
30
    std::string password;
32
    std::string password;       // Optional: Password (usualy encrypted)
31
    bool encrypted{false};
33
    bool encrypted{false};      // If a password exist and this is TRUE the password is encrypted
32
    std::string host;
34
    std::string host;           // The name of the the machine where the source is located (<host>:<port>)
33
    std::string path;
35
    std::string path;           // Optional: The path of the URL
34
    std::string file;
36
    std::string file;           // The file or path and file of the URL
-
 
37
    int refresh{0};             // if > 0 then it defines the time in seconds to reread the source
35
    int refresh{0};
38
    bool dynamo{false};         // If this is TRUE the source is a MJPEG
-
 
39
    bool preserve{false};       // If this is TRUE the source is read only once at startup.
36
 
40
 
37
    void clear()
41
    void clear()
38
    {
42
    {
39
        name.clear();
43
        name.clear();
40
        protocol.clear();
44
        protocol.clear();
Line 43... Line 47...
43
        encrypted = false;
47
        encrypted = false;
44
        host.clear();
48
        host.clear();
45
        path.clear();
49
        path.clear();
46
        file.clear();
50
        file.clear();
47
        refresh = 0;
51
        refresh = 0;
-
 
52
        dynamo = false;
-
 
53
        preserve = false;
48
    }
54
    }
49
}RESOURCE_T;
55
}RESOURCE_T;
50
 
56
 
51
typedef struct RESOURCE_LIST_T
57
typedef struct RESOURCE_LIST_T
52
{
58
{
53
    std::string type;
59
    std::string type;
54
    std::vector<RESOURCE_T> ressource;
60
    std::vector<RESOURCE_T> ressource;
55
}RESOURCE_LIST_T;
61
}RESOURCE_LIST_T;
56
 
62
 
57
class TPrjResources
63
class TPrjResources : public THTTPClient
58
{
64
{
59
    public:
65
    public:
60
        TPrjResources(std::vector<RESOURCE_LIST_T>& list);
66
        TPrjResources(std::vector<RESOURCE_LIST_T>& list);
61
        ~TPrjResources();
67
        ~TPrjResources();
62
 
68
 
63
        void setResourcesList(std::vector<RESOURCE_LIST_T>& list) { mResources = list; }
69
        void setResourcesList(std::vector<RESOURCE_LIST_T>& list) { mResources = list; }
64
        RESOURCE_LIST_T findResourceType(const std::string& type);
70
        RESOURCE_LIST_T findResourceType(const std::string& type);
-
 
71
        RESOURCE_T findResource(int idx, const std::string& name);
65
        RESOURCE_T findResource(const std::string& type, const std::string& name);
72
        RESOURCE_T findResource(const std::string& type, const std::string& name);
66
        RESOURCE_T findResource(const std::string& name);
73
        RESOURCE_T findResource(const std::string& name);
-
 
74
        bool setResource(const std::string& name, const std::string& scheme, const std::string& host, const std::string& path, const std::string& file, const std::string& user, const std::string& pw, int refresh=-1);
67
 
75
 
68
    private:
76
    private:
69
        std::vector<RESOURCE_LIST_T> mResources;
77
        std::vector<RESOURCE_LIST_T> mResources;
70
};
78
};
71
 
79