1 module webkit2.URISchemeRequest; 2 3 private import gio.InputStream; 4 private import glib.ErrorG; 5 private import glib.Str; 6 private import gobject.ObjectG; 7 private import webkit2.WebView; 8 private import webkit2.c.functions; 9 public import webkit2.c.types; 10 11 12 /** 13 * If you register a particular URI scheme in a #WebKitWebContext, 14 * using webkit_web_context_register_uri_scheme(), you have to provide 15 * a #WebKitURISchemeRequestCallback. After that, when a URI request 16 * is made with that particular scheme, your callback will be 17 * called. There you will be able to access properties such as the 18 * scheme, the URI and path, and the #WebKitWebView that initiated the 19 * request, and also finish the request with 20 * webkit_uri_scheme_request_finish(). 21 */ 22 public class URISchemeRequest : ObjectG 23 { 24 /** the main Gtk struct */ 25 protected WebKitURISchemeRequest* webKitURISchemeRequest; 26 27 /** Get the main Gtk struct */ 28 public WebKitURISchemeRequest* getURISchemeRequestStruct(bool transferOwnership = false) 29 { 30 if (transferOwnership) 31 ownedRef = false; 32 return webKitURISchemeRequest; 33 } 34 35 /** the main Gtk struct as a void* */ 36 protected override void* getStruct() 37 { 38 return cast(void*)webKitURISchemeRequest; 39 } 40 41 /** 42 * Sets our main struct and passes it to the parent class. 43 */ 44 public this (WebKitURISchemeRequest* webKitURISchemeRequest, bool ownedRef = false) 45 { 46 this.webKitURISchemeRequest = webKitURISchemeRequest; 47 super(cast(GObject*)webKitURISchemeRequest, ownedRef); 48 } 49 50 51 /** */ 52 public static GType getType() 53 { 54 return webkit_uri_scheme_request_get_type(); 55 } 56 57 /** 58 * Finish a #WebKitURISchemeRequest by setting the contents of the request and its mime type. 59 * 60 * Params: 61 * stream = a #GInputStream to read the contents of the request 62 * streamLength = the length of the stream or -1 if not known 63 * contentType = the content type of the stream or %NULL if not known 64 */ 65 public void finish(InputStream stream, long streamLength, string contentType) 66 { 67 webkit_uri_scheme_request_finish(webKitURISchemeRequest, (stream is null) ? null : stream.getInputStreamStruct(), streamLength, Str.toStringz(contentType)); 68 } 69 70 /** 71 * Finish a #WebKitURISchemeRequest with a #GError. 72 * 73 * Params: 74 * error = a #GError that will be passed to the #WebKitWebView 75 * 76 * Since: 2.2 77 */ 78 public void finishError(ErrorG error) 79 { 80 webkit_uri_scheme_request_finish_error(webKitURISchemeRequest, (error is null) ? null : error.getErrorGStruct()); 81 } 82 83 /** 84 * Get the URI path of @request 85 * 86 * Returns: the URI path of @request 87 */ 88 public string getPath() 89 { 90 return Str.toString(webkit_uri_scheme_request_get_path(webKitURISchemeRequest)); 91 } 92 93 /** 94 * Get the URI scheme of @request 95 * 96 * Returns: the URI scheme of @request 97 */ 98 public string getScheme() 99 { 100 return Str.toString(webkit_uri_scheme_request_get_scheme(webKitURISchemeRequest)); 101 } 102 103 /** 104 * Get the URI of @request 105 * 106 * Returns: the full URI of @request 107 */ 108 public string getUri() 109 { 110 return Str.toString(webkit_uri_scheme_request_get_uri(webKitURISchemeRequest)); 111 } 112 113 /** 114 * Get the #WebKitWebView that initiated the request. 115 * 116 * Returns: the #WebKitWebView that initiated @request. 117 */ 118 public WebView getWebView() 119 { 120 auto __p = webkit_uri_scheme_request_get_web_view(webKitURISchemeRequest); 121 122 if(__p is null) 123 { 124 return null; 125 } 126 127 return ObjectG.getDObject!(WebView)(cast(WebKitWebView*) __p); 128 } 129 }