OpenZWave Library
1.6.0
cpp
src
Http.h
Go to the documentation of this file.
1
//-----------------------------------------------------------------------------
2
//
3
// Http.h
4
//
5
// Simple HTTP Client Interface to download updated config files
6
//
7
// Copyright (c) 2015 Justin Hammond <Justin@dynam.ac>
8
//
9
// SOFTWARE NOTICE AND LICENSE
10
//
11
// This file is part of OpenZWave.
12
//
13
// OpenZWave is free software: you can redistribute it and/or modify
14
// it under the terms of the GNU Lesser General Public License as published
15
// by the Free Software Foundation, either version 3 of the License,
16
// or (at your option) any later version.
17
//
18
// OpenZWave is distributed in the hope that it will be useful,
19
// but WITHOUT ANY WARRANTY; without even the implied warranty of
20
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
// GNU Lesser General Public License for more details.
22
//
23
// You should have received a copy of the GNU Lesser General Public License
24
// along with OpenZWave. If not, see <http://www.gnu.org/licenses/>.
25
//
26
//-----------------------------------------------------------------------------
27
28
#ifndef _Http_H
29
#define _Http_H
30
31
#include "
Defs.h
"
32
#include "
platform/Event.h
"
33
#include "
platform/Thread.h
"
34
#include "
platform/Mutex.h
"
35
36
namespace
OpenZWave
37
{
38
39
/* This is a abstract class you can implement if you wish to override the built in HTTP Client
40
* Code in OZW with your own code.
41
*
42
* The built in Code uses threads to download updated files to a temporary file
43
* and then this class moves the files into the correct place.
44
*
45
*/
46
47
struct
HttpDownload
{
48
string
filename
;
49
string
url
;
50
uint8
node
;
51
enum
DownloadType
52
{
53
None
,
54
File
,
55
Config
,
56
MFSConfig
57
};
58
DownloadType
operation
;
59
enum
Status
60
{
61
Ok
,
62
Failed
63
};
64
Status
transferStatus
;
65
66
};
67
68
class
Driver
;
69
70
class
i_HttpClient
{
71
public
:
72
i_HttpClient
(
Driver
*);
73
virtual
~i_HttpClient
() {};
74
virtual
bool
StartDownload
(
HttpDownload
*transfer) = 0;
75
void
FinishDownload
(
HttpDownload
*transfer);
76
private
:
77
Driver
* m_driver;
78
};
79
80
81
/* this is OZW's implementation of a Http Client. It uses threads to download Config Files in the background.
82
*
83
*/
84
85
86
87
88
class
HttpClient
:
public
i_HttpClient
{
89
public
:
90
HttpClient
(
Driver
*);
91
~HttpClient
();
92
bool
StartDownload
(
HttpDownload
*transfer);
93
private
:
94
95
static
void
HttpThreadProc(
Event
* _exitEvent,
void
* _context);
96
//Driver* m_driver;
97
Event
* m_exitEvent;
98
99
Thread
* m_httpThread;
100
bool
m_httpThreadRunning;
101
Mutex
* m_httpMutex;
102
list<HttpDownload *> m_httpDownlist;
103
Event
* m_httpDownloadEvent;
104
105
};
106
107
108
109
}
/* namespace OpenZWave */
110
111
112
113
#endif
OpenZWave::HttpDownload::url
string url
Definition:
Http.h:49
uint8
unsigned char uint8
Definition:
Defs.h:89
OpenZWave::HttpDownload::transferStatus
Status transferStatus
Definition:
Http.h:64
OpenZWave::i_HttpClient::i_HttpClient
i_HttpClient(Driver *)
Definition:
Http.cpp:43
OpenZWave::Mutex
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition:
Mutex.h:41
OpenZWave::i_HttpClient::FinishDownload
void FinishDownload(HttpDownload *transfer)
Definition:
Http.cpp:50
OpenZWave::i_HttpClient::~i_HttpClient
virtual ~i_HttpClient()
Definition:
Http.h:73
OpenZWave::HttpClient
Definition:
Http.h:88
OpenZWave::HttpDownload::File
@ File
Definition:
Http.h:54
OpenZWave::HttpDownload::Config
@ Config
Definition:
Http.h:55
OpenZWave::HttpDownload::Failed
@ Failed
Definition:
Http.h:62
OpenZWave::HttpDownload
Definition:
Http.h:47
Thread.h
OpenZWave::HttpDownload::Ok
@ Ok
Definition:
Http.h:61
OpenZWave::HttpClient::~HttpClient
~HttpClient()
Definition:
Http.cpp:74
Event.h
OpenZWave::HttpDownload::MFSConfig
@ MFSConfig
Definition:
Http.h:56
OpenZWave::HttpClient::HttpClient
HttpClient(Driver *)
Definition:
Http.cpp:61
OpenZWave::HttpClient::StartDownload
bool StartDownload(HttpDownload *transfer)
Definition:
Http.cpp:83
Mutex.h
OpenZWave::i_HttpClient
Definition:
Http.h:70
OpenZWave::HttpDownload::operation
DownloadType operation
Definition:
Http.h:58
OpenZWave::HttpDownload::node
uint8 node
Definition:
Http.h:50
OpenZWave::Driver
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition:
Driver.h:65
OpenZWave::Event
Platform-independent definition of event objects.
Definition:
Event.h:41
OpenZWave::HttpDownload::filename
string filename
Definition:
Http.h:48
Defs.h
OpenZWave::HttpDownload::DownloadType
DownloadType
Definition:
Http.h:52
OpenZWave::Thread
Implements a platform-independent thread management class.
Definition:
Thread.h:44
OpenZWave::i_HttpClient::StartDownload
virtual bool StartDownload(HttpDownload *transfer)=0
OpenZWave
Definition:
Bitfield.h:35
OpenZWave::HttpDownload::Status
Status
Definition:
Http.h:60
OpenZWave::HttpDownload::None
@ None
Definition:
Http.h:53
Generated on Wed Nov 11 2020 16:02:47 for OpenZWave Library by
1.8.20