OpenCPN Partial API docs
Loading...
Searching...
No Matches
peer_client.h
1/***************************************************************************
2 *
3 * Project: OpenCPN
4 * Purpose:
5 * Author: David Register
6 *
7 ***************************************************************************
8 * Copyright (C) 2022 David Register *
9 * Copyright (C) 2023 Alec Leamas *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * GNU General Public License for more details. *
20 * *
21 * You should have received a copy of the GNU General Public License *
22 * along with this program; if not, write to the *
23 * Free Software Foundation, Inc., *
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
25 **************************************************************************/
26
27#ifndef _PEERCLIENT_H
28#define _PEERCLIENT_H
29
30#include <functional>
31#include <string>
32#include <vector>
33
34#include "model/route.h"
35#include "model/track.h"
36#include "model/semantic_vers.h"
37
38#include "observable_evtvar.h"
39
40enum class PeerDlgResult { Ok, Cancel, HasPincode };
41
42enum class PeerDlg {
43 PinConfirm,
44 InvalidHttpResponse,
45 ErrorReturn, // Unexpected result code in json server reply.
46 TransferOk,
47 ActivateUnsupported,
48 JsonParseError,
49 BadPincode // User pincode not accepted by server
50};
51
52struct PeerData {
53 std::string dest_ip_address;
54 std::string server_name;
56 std::vector<Route*> routes;
57 std::vector<RoutePoint*> routepoints;
58 std::vector<Track*> tracks;
59 bool overwrite;
60 bool activate;
61
64
66 std::function<PeerDlgResult(PeerDlg, int)> run_status_dlg;
67
72 std::function<std::pair<PeerDlgResult, std::string>()> run_pincode_dlg;
73
75};
76
77void GetApiVersion(PeerData& peer_data);
78
80bool SendNavobjects(PeerData& peer_data);
81
86bool CheckNavObjects(PeerData& peer_data);
87
88#endif // guard
Generic event handling between MVC Model and Controller based on a shared EventVar variable.
bool activate
API parameter, activate route after transfer.
Definition peer_client.h:60
EventVar & progress
Notified with transfer percent progress (0-100).
Definition peer_client.h:63
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:72
SemanticVersion api_version
server API version
Definition peer_client.h:55
std::function< PeerDlgResult(PeerDlg, int)> run_status_dlg
Dialog displaying status (good, bad, ...)
Definition peer_client.h:66
bool overwrite
API parameter, force overwrite w/o server dialogs.
Definition peer_client.h:59
Versions uses a modified semantic versioning scheme: major.minor.revision.post-tag+build.