Flutter Engine
fl_method_call.h File Reference
#include <glib-object.h>
#include "fl_method_response.h"
#include "fl_value.h"

Go to the source code of this file.

Functions

G_BEGIN_DECLS const gchar * fl_method_call_get_name (FlMethodCall *method_call)
 
FlValuefl_method_call_get_args (FlMethodCall *method_call)
 
gboolean fl_method_call_respond (FlMethodCall *method_call, FlMethodResponse *response, GError **error)
 
gboolean fl_method_call_respond_success (FlMethodCall *method_call, FlValue *result, GError **error)
 

Function Documentation

◆ fl_method_call_get_args()

FlValue* fl_method_call_get_args ( FlMethodCall *  method_call)

fl_method_call_get_args: : an #FlMethodCall.

Gets the arguments passed to the method.

Returns: an FlValue.

Definition at line 72 of file fl_method_call.cc.

Referenced by clipboard_get_data_async(), method_call_cb(), method_call_error_cb(), method_call_not_implemented_cb(), and method_call_success_cb().

72  {
73  g_return_val_if_fail(FL_IS_METHOD_CALL(self), nullptr);
74  return self->args;
75 }

◆ fl_method_call_get_name()

G_BEGIN_DECLS const gchar* fl_method_call_get_name ( FlMethodCall *  method_call)

FlMethodCall:

#FlMethodCall represents and incoming method call as returned by an #FlMethodChannel. fl_method_call_get_name: : an #FlMethodCall.

Gets the name of the method call.

Returns: a method name.

Definition at line 67 of file fl_method_call.cc.

Referenced by method_call_cb(), method_call_error_cb(), method_call_not_implemented_cb(), and method_call_success_cb().

67  {
68  g_return_val_if_fail(FL_IS_METHOD_CALL(self), nullptr);
69  return self->name;
70 }

◆ fl_method_call_respond()

gboolean fl_method_call_respond ( FlMethodCall *  method_call,
FlMethodResponse *  response,
GError **  error 
)

fl_method_call_respond: : an #FlMethodCall. : an #FlMethodResponse. : (allow-none): #GError location to store the error occurring, or NULL to ignore.

Responds to a method call.

Returns: TRUE on success.

Definition at line 77 of file fl_method_call.cc.

References fl_method_channel_respond(), and TRUE.

Referenced by method_call_cb(), and send_response().

79  {
80  g_return_val_if_fail(FL_IS_METHOD_CALL(self), FALSE);
81  g_return_val_if_fail(FL_IS_METHOD_RESPONSE(response), FALSE);
82 
83  g_autoptr(GError) local_error = nullptr;
84  if (!fl_method_channel_respond(self->channel, self->response_handle, response,
85  &local_error)) {
86  // If the developer chose not to handle the error then log it so it's not
87  // missed.
88  if (error == nullptr) {
89  g_warning("Failed to send method call response: %s",
90  local_error->message);
91  }
92 
93  g_propagate_error(error, local_error);
94  return FALSE;
95  }
96 
97  return TRUE;
98 }
gboolean fl_method_channel_respond(FlMethodChannel *self, FlBinaryMessengerResponseHandle *response_handle, FlMethodResponse *response, GError **error)
FlMethodResponse GError ** error
return TRUE
Definition: fl_view.cc:107

◆ fl_method_call_respond_success()

gboolean fl_method_call_respond_success ( FlMethodCall *  method_call,
FlValue result,
GError **  error 
)

fl_method_call_respond_success: : an #FlMethodCall.

Returns
: (allow-none): value to respond with, must match what the #FlMethodCodec supports. : (allow-none): #GError location to store the error occurring, or NULL to ignore.

Convenience method that responds to method call with #FlMethodSuccessResponse.

Returns: TRUE on success.

Definition at line 100 of file fl_method_call.cc.

References fl_method_channel_respond(), and fl_method_success_response_new().

Referenced by method_call_success_cb(), and method_call_success_error_cb().

102  {
103  g_return_val_if_fail(FL_IS_METHOD_CALL(self), FALSE);
104 
105  g_autoptr(FlMethodResponse) response =
106  FL_METHOD_RESPONSE(fl_method_success_response_new(result));
107  return fl_method_channel_respond(self->channel, self->response_handle,
108  response, error);
109 }
gboolean fl_method_channel_respond(FlMethodChannel *self, FlBinaryMessengerResponseHandle *response_handle, FlMethodResponse *response, GError **error)
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
FlMethodResponse GError ** error