source: appstream-generator/build/girepo/gio/DBusError.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 3 years ago

Initial release

File size: 7.3 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software 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 Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module gio.DBusError;
22
23private import gi.gio;
24public  import gi.giotypes;
25private import glib.ErrorG;
26private import glib.Str;
27
28
29/** */
30public struct DBusError
31{
32
33        /**
34         * Creates a D-Bus error name to use for @error. If @error matches
35         * a registered error (cf. g_dbus_error_register_error()), the corresponding
36         * D-Bus error name will be returned.
37         *
38         * Otherwise the a name of the form
39         * `org.gtk.GDBus.UnmappedGError.Quark._ESCAPED_QUARK_NAME.Code_ERROR_CODE`
40         * will be used. This allows other GDBus applications to map the error
41         * on the wire back to a #GError using g_dbus_error_new_for_dbus_error().
42         *
43         * This function is typically only used in object mappings to put a
44         * #GError on the wire. Regular applications should not use it.
45         *
46         * Params:
47         *     error = A #GError.
48         *
49         * Returns: A D-Bus error name (never %NULL). Free with g_free().
50         *
51         * Since: 2.26
52         */
53        public static string encodeGerror(ErrorG error)
54        {
55                auto retStr = g_dbus_error_encode_gerror((error is null) ? null : error.getErrorGStruct());
56               
57                scope(exit) Str.freeString(retStr);
58                return Str.toString(retStr);
59        }
60
61        /**
62         * Gets the D-Bus error name used for @error, if any.
63         *
64         * This function is guaranteed to return a D-Bus error name for all
65         * #GErrors returned from functions handling remote method calls
66         * (e.g. g_dbus_connection_call_finish()) unless
67         * g_dbus_error_strip_remote_error() has been used on @error.
68         *
69         * Params:
70         *     error = a #GError
71         *
72         * Returns: an allocated string or %NULL if the D-Bus error name
73         *     could not be found. Free with g_free().
74         *
75         * Since: 2.26
76         */
77        public static string getRemoteError(ErrorG error)
78        {
79                auto retStr = g_dbus_error_get_remote_error((error is null) ? null : error.getErrorGStruct());
80               
81                scope(exit) Str.freeString(retStr);
82                return Str.toString(retStr);
83        }
84
85        /**
86         * Checks if @error represents an error received via D-Bus from a remote peer. If so,
87         * use g_dbus_error_get_remote_error() to get the name of the error.
88         *
89         * Params:
90         *     error = A #GError.
91         *
92         * Returns: %TRUE if @error represents an error from a remote peer,
93         *     %FALSE otherwise.
94         *
95         * Since: 2.26
96         */
97        public static bool isRemoteError(ErrorG error)
98        {
99                return g_dbus_error_is_remote_error((error is null) ? null : error.getErrorGStruct()) != 0;
100        }
101
102        /**
103         * Creates a #GError based on the contents of @dbus_error_name and
104         * @dbus_error_message.
105         *
106         * Errors registered with g_dbus_error_register_error() will be looked
107         * up using @dbus_error_name and if a match is found, the error domain
108         * and code is used. Applications can use g_dbus_error_get_remote_error()
109         * to recover @dbus_error_name.
110         *
111         * If a match against a registered error is not found and the D-Bus
112         * error name is in a form as returned by g_dbus_error_encode_gerror()
113         * the error domain and code encoded in the name is used to
114         * create the #GError. Also, @dbus_error_name is added to the error message
115         * such that it can be recovered with g_dbus_error_get_remote_error().
116         *
117         * Otherwise, a #GError with the error code %G_IO_ERROR_DBUS_ERROR
118         * in the #G_IO_ERROR error domain is returned. Also, @dbus_error_name is
119         * added to the error message such that it can be recovered with
120         * g_dbus_error_get_remote_error().
121         *
122         * In all three cases, @dbus_error_name can always be recovered from the
123         * returned #GError using the g_dbus_error_get_remote_error() function
124         * (unless g_dbus_error_strip_remote_error() hasn't been used on the returned error).
125         *
126         * This function is typically only used in object mappings to prepare
127         * #GError instances for applications. Regular applications should not use
128         * it.
129         *
130         * Params:
131         *     dbusErrorName = D-Bus error name.
132         *     dbusErrorMessage = D-Bus error message.
133         *
134         * Returns: An allocated #GError. Free with g_error_free().
135         *
136         * Since: 2.26
137         */
138        public static ErrorG newForDbusError(string dbusErrorName, string dbusErrorMessage)
139        {
140                auto p = g_dbus_error_new_for_dbus_error(Str.toStringz(dbusErrorName), Str.toStringz(dbusErrorMessage));
141               
142                if(p is null)
143                {
144                        return null;
145                }
146               
147                return new ErrorG(cast(GError*) p, true);
148        }
149
150        /** */
151        public static GQuark quark()
152        {
153                return g_dbus_error_quark();
154        }
155
156        /**
157         * Creates an association to map between @dbus_error_name and
158         * #GErrors specified by @error_domain and @error_code.
159         *
160         * This is typically done in the routine that returns the #GQuark for
161         * an error domain.
162         *
163         * Params:
164         *     errorDomain = A #GQuark for a error domain.
165         *     errorCode = An error code.
166         *     dbusErrorName = A D-Bus error name.
167         *
168         * Returns: %TRUE if the association was created, %FALSE if it already
169         *     exists.
170         *
171         * Since: 2.26
172         */
173        public static bool registerError(GQuark errorDomain, int errorCode, string dbusErrorName)
174        {
175                return g_dbus_error_register_error(errorDomain, errorCode, Str.toStringz(dbusErrorName)) != 0;
176        }
177
178        /**
179         * Helper function for associating a #GError error domain with D-Bus error names.
180         *
181         * Params:
182         *     errorDomainQuarkName = The error domain name.
183         *     quarkVolatile = A pointer where to store the #GQuark.
184         *     entries = A pointer to @num_entries #GDBusErrorEntry struct items.
185         *     numEntries = Number of items to register.
186         *
187         * Since: 2.26
188         */
189        public static void registerErrorDomain(string errorDomainQuarkName, size_t* quarkVolatile, GDBusErrorEntry* entries, uint numEntries)
190        {
191                g_dbus_error_register_error_domain(Str.toStringz(errorDomainQuarkName), quarkVolatile, entries, numEntries);
192        }
193
194        /**
195         * Looks for extra information in the error message used to recover
196         * the D-Bus error name and strips it if found. If stripped, the
197         * message field in @error will correspond exactly to what was
198         * received on the wire.
199         *
200         * This is typically used when presenting errors to the end user.
201         *
202         * Params:
203         *     error = A #GError.
204         *
205         * Returns: %TRUE if information was stripped, %FALSE otherwise.
206         *
207         * Since: 2.26
208         */
209        public static bool stripRemoteError(ErrorG error)
210        {
211                return g_dbus_error_strip_remote_error((error is null) ? null : error.getErrorGStruct()) != 0;
212        }
213
214        /**
215         * Destroys an association previously set up with g_dbus_error_register_error().
216         *
217         * Params:
218         *     errorDomain = A #GQuark for a error domain.
219         *     errorCode = An error code.
220         *     dbusErrorName = A D-Bus error name.
221         *
222         * Returns: %TRUE if the association was destroyed, %FALSE if it wasn't found.
223         *
224         * Since: 2.26
225         */
226        public static bool unregisterError(GQuark errorDomain, int errorCode, string dbusErrorName)
227        {
228                return g_dbus_error_unregister_error(errorDomain, errorCode, Str.toStringz(dbusErrorName)) != 0;
229        }
230}
Note: See TracBrowser for help on using the repository browser.