Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
fl_method_response.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_METHOD_RESPONSE_H_
6#define FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_METHOD_RESPONSE_H_
7
8#if !defined(__FLUTTER_LINUX_INSIDE__) && !defined(FLUTTER_LINUX_COMPILATION)
9#error "Only <flutter_linux/flutter_linux.h> can be included directly."
10#endif
11
12#include <glib-object.h>
13#include <gmodule.h>
14
15#include "fl_value.h"
16
17G_BEGIN_DECLS
18
19/**
20 * FlMethodResponseError:
21 * @FL_METHOD_RESPONSE_ERROR_FAILED: Call failed due to an unspecified error.
22 * @FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR: An error was returned by the other
23 * side of the channel.
24 * @FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED: The requested method is not
25 * implemented.
26 *
27 * Errors set by `fl_method_response_get_result` when the method call response
28 * is not #FlMethodSuccessResponse.
29 */
30#define FL_METHOD_RESPONSE_ERROR fl_method_response_error_quark()
31
32typedef enum {
33 // NOLINTBEGIN(readability-identifier-naming)
37 // NOLINTEND(readability-identifier-naming)
39
40G_MODULE_EXPORT
41GQuark fl_method_response_error_quark(void) G_GNUC_CONST;
42
43G_MODULE_EXPORT
44G_DECLARE_DERIVABLE_TYPE(FlMethodResponse,
45 fl_method_response,
46 FL,
47 METHOD_RESPONSE,
48 GObject)
49
50struct _FlMethodResponseClass {
51 GObjectClass parent_class;
52};
53
54G_MODULE_EXPORT
55G_DECLARE_FINAL_TYPE(FlMethodSuccessResponse,
56 fl_method_success_response,
57 FL,
58 METHOD_SUCCESS_RESPONSE,
59 FlMethodResponse)
60
61G_MODULE_EXPORT
62G_DECLARE_FINAL_TYPE(FlMethodErrorResponse,
66 FlMethodResponse)
67
68G_MODULE_EXPORT
69G_DECLARE_FINAL_TYPE(FlMethodNotImplementedResponse,
71 FL,
72 METHOD_NOT_IMPLEMENTED_RESPONSE,
73 FlMethodResponse)
74
75/**
76 * FlMethodResponse:
77 *
78 * #FlMethodResponse contains the information returned when an #FlMethodChannel
79 * method call returns. If you expect the method call to be successful use
80 * fl_method_response_get_result(). If you want to handle error cases then you
81 * should use code like:
82 *
83 * |[<!-- language="C" -->
84 * if (FL_IS_METHOD_SUCCESS_RESPONSE (response)) {
85 * FlValue *result =
86 * fl_method_success_response_get_result(
87 * FL_METHOD_SUCCESS_RESPONSE (response));
88 * handle_result (result);
89 * } else if (FL_IS_METHOD_ERROR_RESPONSE (response)) {
90 * FlMethodErrorResponse *error_response =
91 * FL_METHOD_ERROR_RESPONSE (response);
92 * handle_error (fl_method_error_response_get_code (error_response),
93 * fl_method_error_response_get_message (error_response),
94 * fl_method_error_response_get_details (error_response));
95 * }
96 * else if (FL_IS_METHOD_NOT_IMPLEMENTED_RESPONSE (response)) {
97 * handle_not_implemented ();
98 * }
99 * }
100 * ]|
101 */
102
103/**
104 * FlMethodSuccessResponse:
105 *
106 * #FlMethodSuccessResponse is the #FlMethodResponse returned when a method call
107 * has successfully completed. The result of the method call is obtained using
108 * `fl_method_success_response_get_result`.
109 */
110
111/**
112 * FlMethodErrorResponse:
113 *
114 * #FlMethodErrorResponse is the #FlMethodResponse returned when a method call
115 * results in an error. The error details are obtained using
116 * `fl_method_error_response_get_code`, `fl_method_error_response_get_message`
117 * and `fl_method_error_response_get_details`.
118 */
119
120/**
121 * FlMethodNotImplementedResponse:
122 *
123 * #FlMethodNotImplementedResponse is the #FlMethodResponse returned when a
124 * method call is not implemented.
125 */
126
127/**
128 * fl_method_response_get_result:
129 * @response: an #FlMethodResponse.
130 * @error: (allow-none): #GError location to store the error occurring, or %NULL
131 * to ignore.
132 *
133 * Gets the result of a method call, or an error if the response wasn't
134 * successful.
135 *
136 * Returns: an #FlValue or %NULL on error.
137 */
138FlValue* fl_method_response_get_result(FlMethodResponse* response,
139 GError** error);
140
141/**
142 * fl_method_success_response_new:
143 * @result: (allow-none): the #FlValue returned by the method call or %NULL.
144 *
145 * Creates a response to a method call when that method has successfully
146 * completed.
147 *
148 * Returns: a new #FlMethodResponse.
149 */
150FlMethodSuccessResponse* fl_method_success_response_new(FlValue* result);
151
152/**
153 * fl_method_success_response_get_result:
154 * @response: an #FlMethodSuccessResponse.
155 *
156 * Gets the result of the method call.
157 *
158 * Returns: an #FlValue.
159 */
161 FlMethodSuccessResponse* response);
162
163/**
164 * fl_method_error_response_new:
165 * @result: an #FlValue.
166 * @code: an error code.
167 * @message: (allow-none): an error message.
168 * @details: (allow-none): error details.
169 *
170 * Creates a response to a method call when that method has returned an error.
171 *
172 * Returns: a new #FlMethodErrorResponse.
173 */
174FlMethodErrorResponse* fl_method_error_response_new(const gchar* code,
175 const gchar* message,
176 FlValue* details);
177
178/**
179 * fl_method_error_response_get_code:
180 * @response: an #FlMethodErrorResponse.
181 *
182 * Gets the error code reported.
183 *
184 * Returns: an error code.
185 */
186const gchar* fl_method_error_response_get_code(FlMethodErrorResponse* response);
187
188/**
189 * fl_method_error_response_get_message:
190 * @response: an #FlMethodErrorResponse.
191 *
192 * Gets the error message reported.
193 *
194 * Returns: an error message or %NULL if no error message provided.
195 */
197 FlMethodErrorResponse* response);
198
199/**
200 * fl_method_error_response_get_details:
201 * @response: an #FlMethodErrorResponse.
202 *
203 * Gets the details provided with this error.
204 *
205 * Returns: an #FlValue or %NULL if no details provided.
206 */
207FlValue* fl_method_error_response_get_details(FlMethodErrorResponse* response);
208
209/**
210 * fl_method_not_implemented_response_new:
211 *
212 * Creates a response to a method call when that method does not exist.
213 *
214 * Returns: a new #FlMethodNotImplementedResponse.
215 */
216FlMethodNotImplementedResponse* fl_method_not_implemented_response_new();
217
218G_END_DECLS
219
220#endif // FLUTTER_SHELL_PLATFORM_LINUX_PUBLIC_FLUTTER_LINUX_FL_METHOD_RESPONSE_H_
fl_method_not_implemented_response
G_MODULE_EXPORT FlValue * fl_method_response_get_result(FlMethodResponse *self, GError **error)
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new(const gchar *code, const gchar *message, FlValue *details)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_message(FlMethodErrorResponse *self)
G_MODULE_EXPORT FlValue * fl_method_error_response_get_details(FlMethodErrorResponse *self)
G_MODULE_EXPORT const gchar * fl_method_error_response_get_code(FlMethodErrorResponse *self)
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new()
G_MODULE_EXPORT FL
G_MODULE_EXPORT FlMethodResponse G_MODULE_EXPORT GError ** error
G_MODULE_EXPORT G_DECLARE_FINAL_TYPE(FlMethodSuccessResponse, fl_method_success_response, FL, METHOD_SUCCESS_RESPONSE, FlMethodResponse) G_MODULE_EXPORT G_DECLARE_FINAL_TYPE(FlMethodErrorResponse
FlMethodResponseError
@ FL_METHOD_RESPONSE_ERROR_NOT_IMPLEMENTED
@ FL_METHOD_RESPONSE_ERROR_FAILED
@ FL_METHOD_RESPONSE_ERROR_REMOTE_ERROR
FlValue * fl_method_success_response_get_result(FlMethodSuccessResponse *response)
G_MODULE_EXPORT GQuark fl_method_response_error_quark(void) G_GNUC_CONST
G_MODULE_EXPORT fl_method_error_response
G_MODULE_EXPORT METHOD_ERROR_RESPONSE
G_MODULE_EXPORT G_DECLARE_DERIVABLE_TYPE(FlMethodResponse, fl_method_response, FL, METHOD_RESPONSE, GObject) struct _FlMethodResponseClass
FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
GAsyncResult * result
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition fl_value.h:42
Win32Message message