forked from kismetwireless/kismet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpsweb.h
83 lines (64 loc) · 2.59 KB
/
gpsweb.h
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
/*
This file is part of Kismet
Kismet is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Kismet is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Kismet; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __GPSWEB_H__
#define __GPSWEB_H__
#include "config.h"
#include "kis_gps.h"
#include "timetracker.h"
#include "globalregistry.h"
#include "kis_net_microhttpd.h"
// GPS WEB
//
// Accept GPS location from HTTP POST, allows using a phone browser as a
// GPS source
class GPSWeb : public KisGps, public Kis_Net_Httpd_CPPStream_Handler {
public:
GPSWeb(GlobalRegistry *in_globalreg, SharedGpsBuilder in_builder);
virtual ~GPSWeb();
virtual bool open_gps(string in_opts);
virtual bool get_location_valid();
virtual bool get_device_connected();
// HTTP api
virtual bool Httpd_VerifyPath(const char *path, const char *method);
virtual void Httpd_CreateStreamResponse(Kis_Net_Httpd *httpd,
Kis_Net_Httpd_Connection *connection,
const char *url, const char *method, const char *upload_data,
size_t *upload_data_size, std::stringstream &stream);
virtual int Httpd_PostIterator(void *coninfo_cls, enum MHD_ValueKind kind,
const char *key, const char *filename, const char *content_type,
const char *transfer_encoding, const char *data,
uint64_t off, size_t size);
protected:
// Last time we calculated the heading, don't do it more than once every
// few seconds or we get nasty noise
time_t last_heading_time;
};
class GPSWebBuilder : public KisGpsBuilder {
public:
GPSWebBuilder(GlobalRegistry *in_globalreg) : KisGpsBuilder(in_globalreg, 0) {
initialize();
}
virtual void initialize() {
set_int_gps_class("web");
set_int_gps_class_description("Web-based GPS using client browser");
set_int_gps_priority(0);
set_int_default_name("web");
set_int_singleton(true);
}
virtual SharedGps build_gps(SharedGpsBuilder in_builder) {
return SharedGps(new GPSWeb(globalreg, in_builder));
}
};
#endif