On Tue, May 12, 2015 at 12:47 PM, Christophe Fergeau <cfergeau@xxxxxxxxxx> wrote: > On Thu, May 07, 2015 at 05:36:38PM +0100, Zeeshan Ali (Khattak) wrote: >> Add variant of osinfo_install_script_generate_for_media*() that >> generates the script into a file. >> --- >> osinfo/libosinfo.syms | 4 + >> osinfo/osinfo_install_script.c | 250 +++++++++++++++++++++++++++++++++-------- >> osinfo/osinfo_install_script.h | 17 +++ >> 3 files changed, 224 insertions(+), 47 deletions(-) >> >> diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms >> index ba4c020..3906f89 100644 >> --- a/osinfo/libosinfo.syms >> +++ b/osinfo/libosinfo.syms >> @@ -511,6 +511,10 @@ LIBOSINFO_0.2.12 { >> osinfo_install_script_generate_for_media_async; >> osinfo_install_script_generate_for_media_finish; >> >> + osinfo_install_script_generate_output_for_media; >> + osinfo_install_script_generate_output_for_media_async; >> + osinfo_install_script_generate_output_for_media_finish; >> + >> osinfo_media_get_volume_size; >> } LIBOSINFO_0.2.11; >> >> diff --git a/osinfo/osinfo_install_script.c b/osinfo/osinfo_install_script.c >> index 621c56f..a251557 100644 >> --- a/osinfo/osinfo_install_script.c >> +++ b/osinfo/osinfo_install_script.c >> @@ -1061,6 +1061,25 @@ GFile *osinfo_install_script_generate_output_finish(OsinfoInstallScript *script, >> error); >> } >> >> +/** >> + * osinfo_install_script_generate_output_for_media_finish: >> + * @script: the install script >> + * @res: a #GAsyncResult >> + * @error: The location where to store any error, or NULL >> + * >> + * Returns: (transfer full): a file containing the script, or NULL on error. >> + * >> + * Since: 0.2.12 >> + */ >> +GFile *osinfo_install_script_generate_output_for_media_finish(OsinfoInstallScript *script, >> + GAsyncResult *res, >> + GError **error) >> +{ >> + return osinfo_install_script_generate_finish_common(script, >> + res, >> + error); >> +} >> + >> struct _OsinfoInstallScriptGenerateSyncData { >> GMainLoop *loop; >> GError *error; >> @@ -1081,6 +1100,19 @@ static void osinfo_install_script_generate_output_done(GObject *src, >> g_main_loop_quit(data->loop); >> } >> >> +static void osinfo_install_script_generate_output_for_media_done(GObject *src, >> + GAsyncResult *res, >> + gpointer user_data) >> +{ >> + OsinfoInstallScriptGenerateSyncData *data = user_data; >> + >> + data->file = >> + osinfo_install_script_generate_output_for_media_finish(OSINFO_INSTALL_SCRIPT(src), >> + res, >> + &data->error); >> + g_main_loop_quit(data->loop); >> +} >> + >> static void osinfo_install_script_generate_output_close_file(GObject *src, >> GAsyncResult *res, >> gpointer user_data) >> @@ -1279,28 +1311,14 @@ static void osinfo_install_script_generate_output_write_file(GObject *src, >> } >> } >> >> -/** >> - * osinfo_install_script_generate_output_async: >> - * @script: the install script >> - * @os: the os >> - * @config: the install script config >> - * @output_dir: the directory where file containing the output script >> - * will be written >> - * @cancellable: (allow-none): a #GCancellable, or %NULL >> - * @callback: Function to call when result of this call is ready >> - * @user_data: The user data to pass to @callback, or %NULL >> - * >> - * Asynchronous variant of #osinfo_install_script_generate_output(). From the >> - * callback, call #osinfo_install_script_generate_output_finish() to conclude >> - * this call and get the generated script. >> - */ >> -void osinfo_install_script_generate_output_async(OsinfoInstallScript *script, >> - OsinfoOs *os, >> - OsinfoInstallConfig *config, >> - GFile *output_dir, >> - GCancellable *cancellable, >> - GAsyncReadyCallback callback, >> - gpointer user_data) >> +static void osinfo_install_script_generate_output_async_common(OsinfoInstallScript *script, >> + OsinfoOs *os, >> + OsinfoMedia *media, >> + OsinfoInstallConfig *config, >> + GFile *output_dir, >> + GCancellable *cancellable, >> + GAsyncReadyCallback callback, >> + gpointer user_data) >> { >> const gchar *filename; >> const gchar *prefix; >> @@ -1312,15 +1330,23 @@ void osinfo_install_script_generate_output_async(OsinfoInstallScript *script, >> data->res = g_simple_async_result_new(G_OBJECT(script), >> callback, >> user_data, >> - osinfo_install_script_generate_output_async); >> + osinfo_install_script_generate_output_async_common); >> >> data->cancellable = cancellable; >> data->error = data_sync->error; >> - data->output = osinfo_install_script_generate(script, >> - os, >> - config, >> - cancellable, >> - &data->error); >> + if (media != NULL) { >> + data->output = osinfo_install_script_generate_for_media (script, >> + media, >> + config, >> + cancellable, >> + &data->error); >> + } else { >> + data->output = osinfo_install_script_generate(script, >> + os, >> + config, >> + cancellable, >> + &data->error); >> + } > > This is preexisting, but having an async function call into a sync > function while an async variant exists is unexpected. Indeed. Do you think its worth it to change already or its ok to correct that later. -- Regards, Zeeshan Ali (Khattak) ________________________________________ Befriend GNOME: http://www.gnome.org/friends/ _______________________________________________ Libosinfo mailing list Libosinfo@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libosinfo