Subversion Repositories tpanel

Rev

Rev 446 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
446 andreas 1
/*
2
 * Copyright (C) 2020, 2021 by Andreas Theofilu <andreas@theosys.at>
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 3 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 Foundation,
16
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
17
 */
18
 
19
#ifndef __TPRJRESOURCES_H__
20
#define __TPRJRESOURCES_H__
21
 
22
#include <string>
23
#include <vector>
24
 
25
#include "thttpclient.h"
26
 
27
typedef struct RESOURCE_T
28
{
29
    std::string name;           // Name of resource
30
    std::string protocol;       // With TP4 this is either HTTP of FTP
31
    std::string user;           // Optional: User name
32
    std::string password;       // Optional: Password (usualy encrypted)
33
    bool encrypted{false};      // If a password exist and this is TRUE the password is encrypted
34
    std::string host;           // The name of the the machine where the source is located (<host>:<port>)
35
    std::string path;           // Optional: The path of the URL
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
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.
40
 
41
    void clear()
42
    {
43
        name.clear();
44
        protocol.clear();
45
        user.clear();
46
        password.clear();
47
        encrypted = false;
48
        host.clear();
49
        path.clear();
50
        file.clear();
51
        refresh = 0;
52
        dynamo = false;
53
        preserve = false;
54
    }
55
}RESOURCE_T;
56
 
57
typedef struct RESOURCE_LIST_T
58
{
59
    std::string type;
60
    std::vector<RESOURCE_T> ressource;
61
}RESOURCE_LIST_T;
62
 
63
class TPrjResources
64
{
65
    public:
66
        TPrjResources(std::vector<RESOURCE_LIST_T>& list);
67
        ~TPrjResources();
68
 
69
        void setResourcesList(std::vector<RESOURCE_LIST_T>& list) { mResources = list; }
70
        RESOURCE_LIST_T findResourceType(const std::string& type);
71
        RESOURCE_T findResource(int idx, const std::string& name);
72
        RESOURCE_T findResource(const std::string& type, const std::string& name);
73
        RESOURCE_T findResource(const std::string& name);
74
        size_t getResourceIndex(const std::string& type);
75
        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);
76
        bool addResource(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);
459 andreas 77
        std::string decryptPassword(const std::string& pw);
446 andreas 78
        static const size_t npos = static_cast<size_t>(-1);
79
 
80
    private:
81
        std::vector<RESOURCE_LIST_T> mResources;
82
};
83
 
84
#endif