iface-modem-3gpp,ussd: let send_finish() return a newly allocated string

GTask integration will benefit from this change.
This commit is contained in:
Aleksander Morgado
2018-08-21 16:50:15 +00:00
committed by Dan Williams
parent 4ef3623e63
commit fc41c167ce
3 changed files with 13 additions and 12 deletions
+1 -4
View File
@@ -4970,10 +4970,7 @@ modem_3gpp_ussd_send_finish (MMIfaceModem3gppUssd *self,
if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
return NULL;
/* We can return the string as constant because it is owned by the async
* result, which will be valid during the whole call of its callback, which
* is when we're actually calling finish() */
return (const gchar *)g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res));
return g_strdup (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
}
static void modem_3gpp_ussd_context_step (Modem3gppUssdSendContext *ctx);
+9 -5
View File
@@ -194,15 +194,17 @@ handle_respond_ready (MMIfaceModem3gppUssd *self,
HandleRespondContext *ctx)
{
GError *error = NULL;
const gchar *reply;
gchar *reply;
reply = MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (self)->send_finish (self, res,&error);
reply = MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (self)->send_finish (self, res, &error);
if (!reply)
g_dbus_method_invocation_take_error (ctx->invocation, error);
else
else {
mm_gdbus_modem3gpp_ussd_complete_respond (ctx->skeleton,
ctx->invocation,
reply);
g_free (reply);
}
handle_respond_context_free (ctx);
}
@@ -298,15 +300,17 @@ handle_initiate_ready (MMIfaceModem3gppUssd *self,
HandleInitiateContext *ctx)
{
GError *error = NULL;
const gchar *reply;
gchar *reply;
reply = MM_IFACE_MODEM_3GPP_USSD_GET_INTERFACE (self)->send_finish (self, res, &error);
if (!reply)
g_dbus_method_invocation_take_error (ctx->invocation, error);
else
else {
mm_gdbus_modem3gpp_ussd_complete_initiate (ctx->skeleton,
ctx->invocation,
reply);
g_free (reply);
}
handle_initiate_context_free (ctx);
}
+3 -3
View File
@@ -93,9 +93,9 @@ struct _MMIfaceModem3gppUssd {
const gchar *command,
GAsyncReadyCallback callback,
gpointer user_data);
const gchar * (* send_finish) (MMIfaceModem3gppUssd *self,
GAsyncResult *res,
GError **error);
gchar * (* send_finish) (MMIfaceModem3gppUssd *self,
GAsyncResult *res,
GError **error);
/* Cancel */
void (* cancel) (MMIfaceModem3gppUssd *self,