| 1 | /* |
| 2 | Starbook mount driver |
| 3 | |
| 4 | Copyright (C) 2018 Norbert Szulc (not7cd) |
| 5 | |
| 6 | This library is free software; you can redistribute it and/or |
| 7 | modify it under the terms of the GNU Lesser General Public |
| 8 | License as published by the Free Software Foundation; either |
| 9 | version 2.1 of the License, or (at your option) any later version. |
| 10 | |
| 11 | This library is distributed in the hope that it will be useful, |
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | Lesser General Public License for more details. |
| 15 | |
| 16 | You should have received a copy of the GNU Lesser General Public |
| 17 | License along with this library; if not, write to the Free Software |
| 18 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | |
| 20 | */ |
| 21 | |
| 22 | #pragma once |
| 23 | |
| 24 | #include <connectionplugins/connectioninterface.h> |
| 25 | #include <string> |
| 26 | #include <cstdlib> |
| 27 | #include <curl/curl.h> |
| 28 | #include <inditelescope.h> |
| 29 | |
| 30 | |
| 31 | namespace Connectioncxx . . $ Connection/ { |
| 32 | class Curlcxx . . $ Connection/Curl# : public Interfacecxx . . $ Connection/Interface# { |
| 33 | public: |
| 34 | explicit Curlcxx . . $ Connection/Curl#Curl(f564e40e963aa208).(INDIcxx . . $ INDI/::DefaultDevicecxx . . $ INDI/DefaultDevice# *dev); |
| 35 | |
| 36 | ~cxx . . $ Connection/Curl#`~Curl`(49f6e7a06ebc5aa8).Curlcxx . . $ Connection/Curl#() override; |
| 37 | |
| 38 | bool Connectcxx . . $ Connection/Curl#Connect(c9857a73d68e59ba).() override; |
| 39 | |
| 40 | bool Disconnectcxx . . $ Connection/Curl#Disconnect(c9857a73d68e59ba).() override; |
| 41 | |
| 42 | void Activatedcxx . . $ Connection/Curl#Activated(49f6e7a06ebc5aa8).() override; |
| 43 | |
| 44 | void Deactivatedcxx . . $ Connection/Curl#Deactivated(49f6e7a06ebc5aa8).() override; |
| 45 | |
| 46 | stdcxx . . $ std/::stringcxx . . $ std/string# namecxx . . $ Connection/Curl#name(efd28698952f529a).() override { returncxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f). "CONNECTION_OTHER"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; } |
| 47 | |
| 48 | stdcxx . . $ std/::stringcxx . . $ std/string# labelcxx . . $ Connection/Curl#label(efd28698952f529a).() override { returncxx . . $ std/__cxx11/basic_string#basic_string(3bc0f77cdfbaa67f). "HTTP"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).; } |
| 49 | |
| 50 | const char *hostcxx . . $ Connection/Curl#host(a9f41ea0e82d88cf).() const { return AddressTcxx . . $ Connection/Curl#AddressT.[0].textcxx . . $ _IText#text.; } |
| 51 | |
| 52 | uint32_tcxx . . $ uint32_t# portcxx . . $ Connection/Curl#port(ddd8539a2fcdd4ce).() const { return static_cast<uint32_tcxx . . $ uint32_t#>(atoi(AddressTcxx . . $ Connection/Curl#AddressT.[1].textcxx . . $ _IText#text.)); } |
| 53 | |
| 54 | bool ISNewTextcxx . . $ Connection/Curl#ISNewText(1f3dbebc116ed926).(const char *dev, const char *name, char *texts[], char *names[], int n) override; |
| 55 | |
| 56 | bool saveConfigItemscxx . . $ Connection/Curl#saveConfigItems(dc9e5a301483124c).(FILEcxx . . $ FILE# *fp) override; |
| 57 | |
| 58 | void setDefaultHostcxx . . $ Connection/Curl#setDefaultHost(85c52e162fed56f9).(const char *addressHost); |
| 59 | |
| 60 | void setDefaultPortcxx . . $ Connection/Curl#setDefaultPort(cb2f890c2fdad230).(uint32_tcxx . . $ uint32_t# addressPort); |
| 61 | |
| 62 | CURL *getHandlecxx . . $ Connection/Curl#getHandle(45a5c5ac6be858a8).() const { |
| 63 | if (handlecxx . . $ Connection/Curl#handle. == nullptr) throw stdcxx . . $ std/runtime_error#runtime_error(6be18eeaba0abf21).::runtime_errorcxx . . $ std/runtime_error#("connection error, no handle"); |
| 64 | return handlecxx . . $ Connection/Curl#handle.; |
| 65 | } |
| 66 | |
| 67 | protected: |
| 68 | ITextVectorPropertycxx . . $ ITextVectorProperty# AddressTPcxx . . $ Connection/Curl#AddressTP.; |
| 69 | ITextcxx . . $ IText# AddressTcxx . . $ Connection/Curl#AddressT.[2]{}; |
| 70 | |
| 71 | const unsigned long HANDLE_TIMEOUTcxx . . $ Connection/Curl#HANDLE_TIMEOUT. = 2; |
| 72 | |
| 73 | CURL *handlecxx . . $ Connection/Curl#handle. = nullptr; |
| 74 | |
| 75 | void SetupHandlecxx . . $ Connection/Curl#SetupHandle(83f5f38750778ac8).() const; |
| 76 | }; |
| 77 | |
| 78 | } |