static void added_cb (GObject *client, GAsyncResult *result, gpointer user_data) { GMainLoop *loop = user_data; NMRemoteConnection *remote; GError *error; /* NM responded to our request; either handle the resulting error or * print out the object path of the connection we just added. */ remote = nm_client_add_connection_finish (NM_CLIENT (client), result, &error); if (error) { g_print ("Error adding connection: %s", error->message); g_error_free (error); } else { g_print ("Added: %s\n", nm_connection_get_path (NM_CONNECTION (remote))); g_object_unref (remote); } /* Tell the mainloop we're done and we can quit now */ g_main_loop_quit (loop); }
static void hostname_set (GObject *object, GAsyncResult *result, gpointer op) { GError *error = NULL; nm_client_save_hostname_finish (NM_CLIENT (object), result, &error); nmt_sync_op_complete_boolean (op, error == NULL, error); g_clear_error (&error); }
static void activate_new_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) { GError *error = NULL; if (!nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object), res, &error)) { g_warning ("Failed to add new connection: (%d) %s", error->code, error->message); g_error_free (error); } }
static void save_hostname_cb (GObject *object, GAsyncResult *result, gpointer user_data) { NmCli *nmc = (NmCli *) user_data; GError *error = NULL; nm_client_save_hostname_finish (NM_CLIENT (object), result, &error); if (error) { g_string_printf (nmc->return_text, _("Error: failed to set hostname: %s"), error->message); nmc->return_value = NMC_RESULT_ERROR_UNKNOWN; g_error_free (error); } quit (); }
static void activate_callback (GObject *client, GAsyncResult *result, gpointer user_data) { NmtSyncOp *op = user_data; NMActiveConnection *ac; GError *error = NULL; ac = nm_client_activate_connection_finish (NM_CLIENT (client), result, &error); if (error) nmt_sync_op_complete_pointer (op, NULL, error); else nmt_sync_op_complete_pointer (op, ac, NULL); }
static void client_properties_changed (GObject *object, GParamSpec *pspec, gpointer loop) { NMClient *client = NM_CLIENT (object); NMState state; gboolean wait_startup = GPOINTER_TO_UINT (g_object_get_data (object, WAIT_STARTUP_TAG)); if (!nm_client_get_nm_running (client)) return; if (wait_startup) { if (!nm_client_get_startup (client)) g_main_loop_quit (loop); } else { state = nm_client_get_state (client); if ( state == NM_STATE_CONNECTED_LOCAL || state == NM_STATE_CONNECTED_SITE || state == NM_STATE_CONNECTED_GLOBAL) g_main_loop_quit (loop); } }
static void added_connection_cb (GObject *client, GAsyncResult *result, gpointer user_data) { NMConnectionEditor *self = user_data; NMRemoteConnection *connection; GError *error = NULL; nm_connection_editor_set_busy (self, FALSE); connection = nm_client_add_connection_finish (NM_CLIENT (client), result, &error); if (error) { nm_connection_editor_error (self->parent_window, _("Connection add failed"), "%s", error->message); /* Leave the editor open */ return; } g_clear_object (&connection); g_clear_error (&error); g_signal_emit (self, editor_signals[EDITOR_DONE], 0, GTK_RESPONSE_OK); }