OpenCPN Partial API docs
Loading...
Searching...
No Matches
peer_client.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2022 David Register *
3 * Copyright (C) 2023 Alec Leamas *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, see <https://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
25#ifndef _PEERCLIENT_H
26#define _PEERCLIENT_H
27
28#include <functional>
29#include <string>
30#include <vector>
31
32#include "model/route.h"
33#include "model/track.h"
34#include "model/semantic_vers.h"
35
36#include "observable_evtvar.h"
37
38enum class PeerDlgResult { Ok, Cancel, HasPincode };
39
40enum class PeerDlg {
41 PinConfirm,
42 InvalidHttpResponse,
43 ErrorReturn, // Unexpected result code in json server reply.
44 TransferOk,
45 ActivateUnsupported,
46 JsonParseError,
47 BadPincode // User pincode not accepted by server
48};
49
50struct PeerData {
51 std::string dest_ip_address;
52 std::string server_name;
54 std::vector<Route*> routes;
55 std::vector<RoutePoint*> routepoints;
56 std::vector<Track*> tracks;
57 bool overwrite;
58 bool activate;
59
62
64 std::function<PeerDlgResult(PeerDlg, int)> run_status_dlg;
65
70 std::function<std::pair<PeerDlgResult, std::string>()> run_pincode_dlg;
71
73};
74
75void GetApiVersion(PeerData& peer_data);
76
78bool SendNavobjects(PeerData& peer_data);
79
84bool CheckNavObjects(PeerData& peer_data);
85
86#endif // guard
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
A common variable shared between producer and consumer which supports Listen() and Notify().
bool SendNavobjects(PeerData &peer_data)
Send data to server peer.
bool CheckNavObjects(PeerData &peer_data)
Check if server peer deems that writing these objects can be accepted i.
Route abstraction.
Semantic version encode/decode object.
bool activate
API parameter, activate route after transfer.
Definition peer_client.h:58
EventVar & progress
Notified with transfer percent progress (0-100).
Definition peer_client.h:61
std::function< std::pair< PeerDlgResult, std::string >()> run_pincode_dlg
Pin confirm dialog, returns new {0, user_pin} or {error_code, error msg)
Definition peer_client.h:70
SemanticVersion api_version
server API version
Definition peer_client.h:53
std::function< PeerDlgResult(PeerDlg, int)> run_status_dlg
Dialog displaying status (good, bad, ...)
Definition peer_client.h:64
bool overwrite
API parameter, force overwrite w/o server dialogs.
Definition peer_client.h:57
Versions uses a modified semantic versioning scheme: major.minor.revision.post-tag+build.
Recorded track abstraction.