| bridges/rest.vapi |
| 1 | | /* rest.vapi |
| 2 | | * |
| 3 | | * Copyright (C) 2009 Adrien Bustany |
| 4 | | * |
| 5 | | * This library is free software; you can redistribute it and/or |
| 6 | | * modify it under the terms of the GNU Lesser General Public |
| 7 | | * License as published by the Free Software Foundation; either |
| 8 | | * version 2.1 of the License, or (at your option) any later version. |
| 9 | | |
| 10 | | * This library 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 GNU |
| 13 | | * Lesser General Public License for more details. |
| 14 | | |
| 15 | | * You should have received a copy of the GNU Lesser General Public |
| 16 | | * License along with this library; if not, write to the Free Software |
| 17 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | | * |
| 19 | | * Author: |
| 20 | | * Adrien Bustany <madcat@mymadcat.com> |
| 21 | | */ |
| 22 | | |
| 23 | | using GLib; |
| 24 | | |
| 25 | | [CCode (lower_case_cprefix = "rest_", cheader_filename = "rest/rest-proxy.h,rest/rest-xml-parser.h")] |
| 26 | | namespace Rest { |
| 27 | | class ProxyCall : Object { |
| 28 | | Quark error_quark (); |
| 29 | | |
| 30 | | public unowned string method {get; set;} |
| 31 | | public void set_function (string function); |
| 32 | | |
| 33 | | public void add_header (string header, string value); |
| 34 | | public void add_headers (...); |
| 35 | | public unowned string lookup_header (string header); |
| 36 | | public void remove_header (string header); |
| 37 | | |
| 38 | | public void add_param (string param, string value); |
| 39 | | public void add_params (...); |
| 40 | | public unowned string lookup_param (string param); |
| 41 | | public void remove_param (string param); |
| 42 | | public HashTable<string, string> get_params (); |
| 43 | | |
| 44 | | public bool run (out MainLoop loop) throws Error; |
| 45 | | |
| 46 | | public delegate void AsyncCallback (Object weak_object, void *user_data); |
| 47 | | |
| 48 | | public bool call_async (AsyncCallback callback, Object weak_object, void *user_data) throws Error; |
| 49 | | |
| 50 | | public bool cancel () throws Error; |
| 51 | | |
| 52 | | public unowned string lookup_response_header (string header); |
| 53 | | public HashTable<string, string> get_response_headers (); |
| 54 | | public long get_payload_length (); |
| 55 | | public unowned string get_payload (); |
| 56 | | public uint get_status_code (); |
| 57 | | public unowned string get_status_message (); |
| 58 | | } |
| 59 | | |
| 60 | | class Proxy : Object { |
| 61 | | [CCode (cname = "RestProxyError", cprefix = "REST_PROXY_ERROR_")] |
| 62 | | enum Error { |
| 63 | | CANCELLED = 1, |
| 64 | | RESOLUTION, |
| 65 | | CONNECTION, |
| 66 | | SSL, |
| 67 | | IO, |
| 68 | | FAILED, |
| 69 | | |
| 70 | | HTTP_MULTIPLE_CHOICES = 300, |
| 71 | | HTTP_MOVED_PERMANENTLY = 301, |
| 72 | | HTTP_FOUND = 302, |
| 73 | | HTTP_SEE_OTHER = 303, |
| 74 | | HTTP_NOT_MODIFIED = 304, |
| 75 | | HTTP_USE_PROXY = 305, |
| 76 | | HTTP_THREEOHSIX = 306, |
| 77 | | HTTP_TEMPORARY_REDIRECT = 307, |
| 78 | | HTTP_BAD_REQUEST = 400, |
| 79 | | HTTP_UNAUTHORIZED = 401, |
| 80 | | HTTP_FOUROHTWO = 402, |
| 81 | | HTTP_FORBIDDEN = 403, |
| 82 | | HTTP_NOT_FOUND = 404, |
| 83 | | HTTP_METHOD_NOT_ALLOWED = 405, |
| 84 | | HTTP_NOT_ACCEPTABLE = 406, |
| 85 | | HTTP_PROXY_AUTHENTICATION_REQUIRED = 407, |
| 86 | | HTTP_REQUEST_TIMEOUT = 408, |
| 87 | | HTTP_CONFLICT = 409, |
| 88 | | HTTP_GONE = 410, |
| 89 | | HTTP_LENGTH_REQUIRED = 411, |
| 90 | | HTTP_PRECONDITION_FAILED = 412, |
| 91 | | HTTP_REQUEST_ENTITY_TOO_LARGE = 413, |
| 92 | | HTTP_REQUEST_URI_TOO_LONG = 414, |
| 93 | | HTTP_UNSUPPORTED_MEDIA_TYPE = 415, |
| 94 | | HTTP_REQUESTED_RANGE_NOT_SATISFIABLE = 416, |
| 95 | | HTTP_EXPECTATION_FAILED = 417, |
| 96 | | HTTP_INTERNAL_SERVER_ERROR = 500, |
| 97 | | HTTP_NOT_IMPLEMENTED = 501, |
| 98 | | HTTP_BAD_GATEWAY = 502, |
| 99 | | HTTP_SERVICE_UNAVAILABLE = 503, |
| 100 | | HTTP_GATEWAY_TIMEOUT = 504, |
| 101 | | HTTP_HTTP_VERSION_NOT_SUPPORTED = 505, |
| 102 | | } |
| 103 | | |
| 104 | | public Quark error_quark (); |
| 105 | | |
| 106 | | Proxy (string url_format, bool binding_required); |
| 107 | | public bool bind (...); |
| 108 | | public unowned string set_user_agent {get; set; } |
| 109 | | public ProxyCall new_call (); |
| 110 | | public bool simple_run (string[] payload, long len, ...) throws Error; |
| 111 | | } |
| 112 | | |
| 113 | | class XmlNode { |
| 114 | | XmlNode (); |
| 115 | | |
| 116 | | public string name; |
| 117 | | public string content; |
| 118 | | public HashTable<string, XmlNode> children; |
| 119 | | public HashTable<string, string> attrs; |
| 120 | | public unowned XmlNode next; |
| 121 | | |
| 122 | | public unowned string get_attr (string attr_name); |
| 123 | | public weak XmlNode find (string tag); |
| 124 | | } |
| 125 | | |
| 126 | | class XmlParser : Object { |
| 127 | | XmlParser (); |
| 128 | | |
| 129 | | public unowned XmlNode parse_from_data (string data, long len); |
| 130 | | } |
| 131 | | } |