Make Dropdown menus at least as wide as the button
[ardour.git] / gtk2_ardour / ardour_http.h
1 /*
2  * Copyright (C) 2016 Robin Gareus <robin@gareus.org>
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17  */
18
19 #ifndef __gtk_ardour_http_h__
20 #define __gtk_ardour_http_h__
21
22 #include <curl/curl.h>
23 #include <string>
24
25 namespace ArdourCurl {
26
27 class HttpGet {
28         public:
29         HttpGet (bool persist = false, bool ssl = true);
30         ~HttpGet ();
31
32         struct MemStruct {
33                 MemStruct () : data (0), size (0) {}
34                 char*  data;
35                 size_t size;
36         };
37
38         char* get (const char* url);
39
40         std::string get (const std::string& url) {
41                 char *rv = get (url.c_str ());
42                 return rv ? std::string (rv) : std::string ("");
43         }
44
45         char* data () const { return mem.data; }
46         size_t data_size () const { return mem.size; }
47
48         long int status () const { return _status; }
49
50         char* escape (const char* s, int l) const {
51                 return curl_easy_escape (_curl, s, l);
52         }
53
54         char* unescape (const char* s, int l, int *o) const {
55                 return curl_easy_unescape (_curl, s, l, o);
56         }
57
58         void free (void *p) const {
59                 curl_free (p);
60         }
61
62         std::string error () const;
63
64         CURL* curl () const { return _curl; }
65
66         // called from fixup_bundle_environment
67         static void setup_certificate_paths ();
68
69         private:
70         CURL* _curl;
71         bool  persist;
72
73         long int _status;
74         long int _result;
75
76         char error_buffer[CURL_ERROR_SIZE];
77
78         struct MemStruct mem;
79
80         static const char* ca_path;
81         static const char* ca_info;
82 };
83
84 char* http_get (const char* url, int* status);
85
86 std::string http_get (const std::string& url);
87
88 } // namespace
89
90 #endif /* __gtk_ardour_http_h__ */