1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files.git)
// from webkit2gtk-gir-files
// DO NOT EDIT
use crate::WebView;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
glib::wrapper! {
/// Represents a URI scheme request.
///
/// If you register a particular URI scheme in a [`WebContext`][crate::WebContext],
/// using [`WebContextExt::register_uri_scheme()`][crate::prelude::WebContextExt::register_uri_scheme()], you have to provide
/// a `WebKitURISchemeRequestCallback`. After that, when a URI request
/// is made with that particular scheme, your callback will be
/// called. There you will be able to access properties such as the
/// scheme, the URI and path, and the [`WebView`][crate::WebView] that initiated the
/// request, and also finish the request with
/// [`URISchemeRequestExt::finish()`][crate::prelude::URISchemeRequestExt::finish()].
///
/// # Implements
///
/// [`URISchemeRequestExt`][trait@crate::prelude::URISchemeRequestExt], [`trait@glib::ObjectExt`]
#[doc(alias = "WebKitURISchemeRequest")]
pub struct URISchemeRequest(Object<ffi::WebKitURISchemeRequest, ffi::WebKitURISchemeRequestClass>);
match fn {
type_ => || ffi::webkit_uri_scheme_request_get_type(),
}
}
impl URISchemeRequest {
pub const NONE: Option<&'static URISchemeRequest> = None;
}
/// Trait containing all [`struct@URISchemeRequest`] methods.
///
/// # Implementors
///
/// [`URISchemeRequest`][struct@crate::URISchemeRequest]
pub trait URISchemeRequestExt: 'static {
/// Finish a [`URISchemeRequest`][crate::URISchemeRequest] by setting the contents of the request and its mime type.
/// ## `stream`
/// a [`gio::InputStream`][crate::gio::InputStream] to read the contents of the request
/// ## `stream_length`
/// the length of the stream or -1 if not known
/// ## `content_type`
/// the content type of the stream or [`None`] if not known
#[doc(alias = "webkit_uri_scheme_request_finish")]
fn finish(
&self,
stream: &impl IsA<gio::InputStream>,
stream_length: i64,
content_type: Option<&str>,
);
/// Finish a [`URISchemeRequest`][crate::URISchemeRequest] with a [`glib::Error`][crate::glib::Error].
/// ## `error`
/// a [`glib::Error`][crate::glib::Error] that will be passed to the [`WebView`][crate::WebView]
#[cfg(any(feature = "v2_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_2")))]
#[doc(alias = "webkit_uri_scheme_request_finish_error")]
fn finish_error(&self, error: &mut glib::Error);
//#[cfg(any(feature = "v2_36", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
//#[doc(alias = "webkit_uri_scheme_request_finish_with_response")]
//fn finish_with_response(&self, response: /*Ignored*/&URISchemeResponse);
//#[cfg(any(feature = "v2_36", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
//#[doc(alias = "webkit_uri_scheme_request_get_http_headers")]
//#[doc(alias = "get_http_headers")]
//fn http_headers(&self) -> /*Ignored*/Option<soup::MessageHeaders>;
/// Get the HTTP method of the `self`.
///
/// # Returns
///
/// the HTTP method of the `self`
#[cfg(any(feature = "v2_36", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
#[doc(alias = "webkit_uri_scheme_request_get_http_method")]
#[doc(alias = "get_http_method")]
fn http_method(&self) -> Option<glib::GString>;
/// Get the URI path of `self`.
///
/// # Returns
///
/// the URI path of `self`
#[doc(alias = "webkit_uri_scheme_request_get_path")]
#[doc(alias = "get_path")]
fn path(&self) -> Option<glib::GString>;
/// Get the URI scheme of `self`.
///
/// # Returns
///
/// the URI scheme of `self`
#[doc(alias = "webkit_uri_scheme_request_get_scheme")]
#[doc(alias = "get_scheme")]
fn scheme(&self) -> Option<glib::GString>;
/// Get the URI of `self`.
///
/// # Returns
///
/// the full URI of `self`
#[doc(alias = "webkit_uri_scheme_request_get_uri")]
#[doc(alias = "get_uri")]
fn uri(&self) -> Option<glib::GString>;
/// Get the [`WebView`][crate::WebView] that initiated the request.
///
/// # Returns
///
/// the [`WebView`][crate::WebView] that initiated `self`.
#[doc(alias = "webkit_uri_scheme_request_get_web_view")]
#[doc(alias = "get_web_view")]
fn web_view(&self) -> Option<WebView>;
}
impl<O: IsA<URISchemeRequest>> URISchemeRequestExt for O {
fn finish(
&self,
stream: &impl IsA<gio::InputStream>,
stream_length: i64,
content_type: Option<&str>,
) {
unsafe {
ffi::webkit_uri_scheme_request_finish(
self.as_ref().to_glib_none().0,
stream.as_ref().to_glib_none().0,
stream_length,
content_type.to_glib_none().0,
);
}
}
#[cfg(any(feature = "v2_2", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_2")))]
fn finish_error(&self, error: &mut glib::Error) {
unsafe {
ffi::webkit_uri_scheme_request_finish_error(
self.as_ref().to_glib_none().0,
error.to_glib_none_mut().0,
);
}
}
//#[cfg(any(feature = "v2_36", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
//fn finish_with_response(&self, response: /*Ignored*/&URISchemeResponse) {
// unsafe { TODO: call ffi:webkit_uri_scheme_request_finish_with_response() }
//}
//#[cfg(any(feature = "v2_36", feature = "dox"))]
//#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
//fn http_headers(&self) -> /*Ignored*/Option<soup::MessageHeaders> {
// unsafe { TODO: call ffi:webkit_uri_scheme_request_get_http_headers() }
//}
#[cfg(any(feature = "v2_36", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v2_36")))]
fn http_method(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::webkit_uri_scheme_request_get_http_method(
self.as_ref().to_glib_none().0,
))
}
}
fn path(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::webkit_uri_scheme_request_get_path(
self.as_ref().to_glib_none().0,
))
}
}
fn scheme(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::webkit_uri_scheme_request_get_scheme(
self.as_ref().to_glib_none().0,
))
}
}
fn uri(&self) -> Option<glib::GString> {
unsafe {
from_glib_none(ffi::webkit_uri_scheme_request_get_uri(
self.as_ref().to_glib_none().0,
))
}
}
fn web_view(&self) -> Option<WebView> {
unsafe {
from_glib_none(ffi::webkit_uri_scheme_request_get_web_view(
self.as_ref().to_glib_none().0,
))
}
}
}
impl fmt::Display for URISchemeRequest {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("URISchemeRequest")
}
}