OpenZWave Library
1.6.1392
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
class
Driver;
39
40
namespace
Internal
41
{
42
/* This is a abstract class you can implement if you wish to override the built in HTTP Client
43
* Code in OZW with your own code.
44
*
45
* The built in Code uses threads to download updated files to a temporary file
46
* and then this class moves the files into the correct place.
47
*
48
*/
49
50
struct
HttpDownload
51
{
52
string
filename
;
53
string
url
;
54
uint8
node
;
55
enum
DownloadType
56
{
57
None
,
58
File
,
59
Config
,
60
MFSConfig
,
61
Image
62
};
63
DownloadType
operation
;
64
enum
Status
65
{
66
Ok
,
67
Failed
68
};
69
Status
transferStatus
;
70
71
};
72
73
class
i_HttpClient
74
{
75
public
:
76
i_HttpClient
(
Driver
*);
77
virtual
~i_HttpClient
()
78
{
79
}
80
;
81
virtual
bool
StartDownload
(
HttpDownload
*transfer) = 0;
82
void
FinishDownload
(
HttpDownload
*transfer);
83
private
:
84
Driver
* m_driver;
85
};
86
87
/* this is OZW's implementation of a Http Client. It uses threads to download Config Files in the background.
88
*
89
*/
90
91
class
HttpClient
:
public
i_HttpClient
92
{
93
public
:
94
HttpClient
(
Driver
*);
95
~HttpClient
();
96
bool
StartDownload
(
HttpDownload
*transfer);
97
private
:
98
99
static
void
HttpThreadProc(
Internal::Platform::Event
* _exitEvent,
void
* _context);
100
//Driver* m_driver;
101
Internal::Platform::Event
* m_exitEvent;
102
103
Internal::Platform::Thread
* m_httpThread;
104
bool
m_httpThreadRunning;
105
Internal::Platform::Mutex
* m_httpMutex;
106
list<HttpDownload *> m_httpDownlist;
107
Internal::Platform::Event
* m_httpDownloadEvent;
108
109
};
110
111
}
// namespace Internal
112
}
/* namespace OpenZWave */
113
114
#endif
OpenZWave::Internal::Platform::Thread
Implements a platform-independent thread management class.
Definition:
Thread.h:48
OpenZWave::Internal::HttpDownload::Config
@ Config
Definition:
Http.h:59
OpenZWave::Internal::HttpDownload::DownloadType
DownloadType
Definition:
Http.h:56
OpenZWave::Internal::HttpClient
Definition:
Http.h:92
OpenZWave::Internal::HttpDownload::transferStatus
Status transferStatus
Definition:
Http.h:69
OpenZWave::Internal::HttpDownload::operation
DownloadType operation
Definition:
Http.h:63
OpenZWave::Internal::HttpDownload::File
@ File
Definition:
Http.h:58
uint8
unsigned char uint8
Definition:
Defs.h:85
OpenZWave::Internal::HttpDownload::None
@ None
Definition:
Http.h:57
OpenZWave::Internal::HttpDownload
Definition:
Http.h:51
OpenZWave::Internal::HttpClient::HttpClient
HttpClient(Driver *)
Definition:
Http.cpp:60
OpenZWave::Internal::HttpDownload::Image
@ Image
Definition:
Http.h:61
OpenZWave::Internal::HttpDownload::MFSConfig
@ MFSConfig
Definition:
Http.h:60
OpenZWave::Internal::i_HttpClient::~i_HttpClient
virtual ~i_HttpClient()
Definition:
Http.h:77
OpenZWave::Internal::Platform::Event
Platform-independent definition of event objects.
Definition:
Event.h:45
OpenZWave::Internal::HttpDownload::Status
Status
Definition:
Http.h:65
OpenZWave::Internal::HttpDownload::Failed
@ Failed
Definition:
Http.h:67
OpenZWave::Internal::Platform::Mutex
Implements a platform-independent mutex–for serializing access to a shared resource.
Definition:
Mutex.h:45
Thread.h
Event.h
OpenZWave::Internal::HttpDownload::url
string url
Definition:
Http.h:53
OpenZWave::Internal::i_HttpClient::FinishDownload
void FinishDownload(HttpDownload *transfer)
Definition:
Http.cpp:51
OpenZWave::Internal::i_HttpClient
Definition:
Http.h:74
OpenZWave::Internal::HttpDownload::node
uint8 node
Definition:
Http.h:54
Mutex.h
OpenZWave::Internal::i_HttpClient::StartDownload
virtual bool StartDownload(HttpDownload *transfer)=0
OpenZWave::Internal::HttpClient::StartDownload
bool StartDownload(HttpDownload *transfer)
Definition:
Http.cpp:75
OpenZWave::Driver
The Driver class handles communication between OpenZWave and a device attached via a serial port (typ...
Definition:
Driver.h:85
OpenZWave::Internal::HttpClient::~HttpClient
~HttpClient()
Definition:
Http.cpp:65
OpenZWave::Internal::HttpDownload::filename
string filename
Definition:
Http.h:52
Defs.h
OpenZWave::Internal::i_HttpClient::i_HttpClient
i_HttpClient(Driver *)
Definition:
Http.cpp:45
OpenZWave
Definition:
Bitfield.cpp:31
OpenZWave::Internal::HttpDownload::Ok
@ Ok
Definition:
Http.h:66
Generated on Thu Jul 30 2020 00:00:00 for OpenZWave Library by
1.8.20