network: Use g_autoptr for GError handling
This commit is contained in:
parent
072d5daf5c
commit
01190db349
18 changed files with 73 additions and 135 deletions
|
@ -860,7 +860,7 @@ cc_network_panel_class_init (CcNetworkPanelClass *klass)
|
|||
static void
|
||||
cc_network_panel_init (CcNetworkPanel *panel)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
GtkWidget *toplevel;
|
||||
GDBusConnection *system_bus;
|
||||
const GPtrArray *connections;
|
||||
|
@ -901,17 +901,14 @@ cc_network_panel_init (CcNetworkPanel *panel)
|
|||
if (system_bus == NULL) {
|
||||
g_warning ("Error connecting to system D-Bus: %s",
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
} else {
|
||||
panel->modem_manager = mm_manager_new_sync (system_bus,
|
||||
G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_NONE,
|
||||
NULL,
|
||||
&error);
|
||||
if (panel->modem_manager == NULL) {
|
||||
if (panel->modem_manager == NULL)
|
||||
g_warning ("Error connecting to ModemManager: %s",
|
||||
error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
g_object_unref (system_bus);
|
||||
}
|
||||
|
||||
|
|
|
@ -500,9 +500,8 @@ rfkill_proxy_acquired_cb (GObject *source_object,
|
|||
{
|
||||
CcWifiPanel *self;
|
||||
GDBusProxy *proxy;
|
||||
GError *error;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
error = NULL;
|
||||
proxy = cc_object_storage_create_dbus_proxy_finish (res, &error);
|
||||
|
||||
if (error)
|
||||
|
@ -510,7 +509,6 @@ rfkill_proxy_acquired_cb (GObject *source_object,
|
|||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_printerr ("Error creating rfkill proxy: %s\n", error->message);
|
||||
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ ce_page_new (GType type,
|
|||
const gchar *title)
|
||||
{
|
||||
CEPage *page;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
page = CE_PAGE (g_object_new (type,
|
||||
"connection", connection,
|
||||
|
@ -233,7 +233,6 @@ ce_page_new (GType type,
|
|||
if (ui_resource) {
|
||||
if (!gtk_builder_add_from_resource (page->builder, ui_resource, &error)) {
|
||||
g_warning ("Couldn't load builder file: %s", error->message);
|
||||
g_error_free (error);
|
||||
g_object_unref (page);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -265,7 +264,7 @@ ce_page_complete_init (CEPage *page,
|
|||
GVariant *secrets,
|
||||
GError *error)
|
||||
{
|
||||
GError *update_error = NULL;
|
||||
g_autoptr(GError) update_error = NULL;
|
||||
GVariant *setting_dict;
|
||||
gboolean ignore_error = FALSE;
|
||||
|
||||
|
@ -304,7 +303,6 @@ ce_page_complete_init (CEPage *page,
|
|||
secrets,
|
||||
&update_error)) {
|
||||
g_warning ("Couldn't update secrets: %s", update_error->message);
|
||||
g_error_free (update_error);
|
||||
/* Success */
|
||||
emit_initialized (page, NULL);
|
||||
return;
|
||||
|
|
|
@ -94,14 +94,13 @@ updated_connection_cb (GObject *source_object,
|
|||
gpointer user_data)
|
||||
{
|
||||
NetConnectionEditor *editor;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gboolean success = TRUE;
|
||||
|
||||
if (!nm_remote_connection_commit_changes_finish (NM_REMOTE_CONNECTION (source_object),
|
||||
res, &error)) {
|
||||
g_warning ("Failed to commit changes: %s", error->message);
|
||||
success = FALSE;
|
||||
g_error_free (error);
|
||||
//return; FIXME return if cancelled
|
||||
}
|
||||
|
||||
|
@ -117,13 +116,12 @@ added_connection_cb (GObject *source_object,
|
|||
gpointer user_data)
|
||||
{
|
||||
NetConnectionEditor *editor;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gboolean success = TRUE;
|
||||
|
||||
if (!nm_client_add_connection_finish (NM_CLIENT (source_object), res, &error)) {
|
||||
g_warning ("Failed to add connection: %s", error->message);
|
||||
success = FALSE;
|
||||
g_error_free (error);
|
||||
/* Leave the editor open */
|
||||
// return; FIXME return if cancelled
|
||||
}
|
||||
|
@ -244,7 +242,7 @@ static void
|
|||
net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *type)
|
||||
{
|
||||
gchar *cmdline;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (editor->is_new_connection) {
|
||||
cmdline = g_strdup_printf ("nm-connection-editor --type='%s' --create", type);
|
||||
|
@ -256,12 +254,10 @@ net_connection_editor_do_fallback (NetConnectionEditor *editor, const gchar *typ
|
|||
g_spawn_command_line_async (cmdline, &error);
|
||||
g_free (cmdline);
|
||||
|
||||
if (error) {
|
||||
if (error)
|
||||
net_connection_editor_error_dialog (editor,
|
||||
_("Unable to open connection editor"),
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_signal_emit (editor, signals[DONE], 0, FALSE);
|
||||
}
|
||||
|
@ -338,13 +334,12 @@ validate (NetConnectionEditor *editor)
|
|||
|
||||
valid = TRUE;
|
||||
for (l = editor->pages; l; l = l->next) {
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!ce_page_validate (CE_PAGE (l->data), editor->connection, &error)) {
|
||||
valid = FALSE;
|
||||
if (error) {
|
||||
g_debug ("Invalid setting %s: %s", ce_page_get_title (CE_PAGE (l->data)), error->message);
|
||||
g_error_free (error);
|
||||
} else {
|
||||
g_debug ("Invalid setting %s", ce_page_get_title (CE_PAGE (l->data)));
|
||||
}
|
||||
|
@ -830,14 +825,13 @@ forgotten_cb (GObject *source_object,
|
|||
{
|
||||
NMRemoteConnection *connection = NM_REMOTE_CONNECTION (source_object);
|
||||
NetConnectionEditor *editor = user_data;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!nm_remote_connection_delete_finish (connection, res, &error)) {
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("Failed to delete connection %s: %s",
|
||||
nm_connection_get_id (NM_CONNECTION (connection)),
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ vpn_get_plugins (void)
|
|||
plugins = NULL;
|
||||
while (p) {
|
||||
NMVpnPluginInfo *plugin_info = NM_VPN_PLUGIN_INFO (p->data);
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
/* load the editor plugin, and preserve only those NMVpnPluginInfo that can
|
||||
* successfully load the plugin. */
|
||||
|
@ -88,7 +88,6 @@ vpn_get_plugins (void)
|
|||
nm_vpn_plugin_info_get_filename (plugin_info),
|
||||
error->message);
|
||||
}
|
||||
g_clear_error (&error);
|
||||
g_object_unref (plugin_info);
|
||||
}
|
||||
p = g_slist_delete_link (p, p);
|
||||
|
@ -110,7 +109,7 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
|
|||
char *filename = NULL;
|
||||
ActionInfo *info = (ActionInfo *) user_data;
|
||||
NMConnection *connection = NULL;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
GSList *iter;
|
||||
|
||||
if (response != GTK_RESPONSE_ACCEPT)
|
||||
|
@ -147,7 +146,6 @@ import_vpn_from_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
|
|||
g_signal_connect (err_dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
|
||||
gtk_dialog_run (GTK_DIALOG (err_dialog));
|
||||
}
|
||||
g_clear_error (&error);
|
||||
g_free (filename);
|
||||
|
||||
out:
|
||||
|
@ -200,7 +198,7 @@ export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
|
|||
{
|
||||
NMConnection *connection = NM_CONNECTION (user_data);
|
||||
char *filename = NULL;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
NMVpnEditorPlugin *plugin;
|
||||
NMSettingConnection *s_con = NULL;
|
||||
NMSettingVpn *s_vpn = NULL;
|
||||
|
@ -279,8 +277,6 @@ done:
|
|||
}
|
||||
|
||||
out:
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
g_object_unref (connection);
|
||||
|
||||
gtk_widget_hide (dialog);
|
||||
|
|
|
@ -609,7 +609,7 @@ net_device_ethernet_class_init (NetDeviceEthernetClass *klass)
|
|||
static void
|
||||
net_device_ethernet_init (NetDeviceEthernet *device)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
device->builder = gtk_builder_new ();
|
||||
gtk_builder_add_from_resource (device->builder,
|
||||
|
@ -617,7 +617,6 @@ net_device_ethernet_init (NetDeviceEthernet *device)
|
|||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,12 +93,11 @@ connection_activate_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) {
|
||||
/* failed to activate */
|
||||
nm_device_mobile_refresh_ui (user_data);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -275,14 +274,13 @@ device_mobile_find_provider (NetDeviceMobile *device_mobile,
|
|||
GString *name = NULL;
|
||||
|
||||
if (device_mobile->mpd == NULL) {
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
/* Use defaults */
|
||||
device_mobile->mpd = nma_mobile_providers_database_new_sync (NULL, NULL, NULL, &error);
|
||||
if (device_mobile->mpd == NULL) {
|
||||
g_debug ("Couldn't load mobile providers database: %s",
|
||||
error ? error->message : "");
|
||||
g_clear_error (&error);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -487,7 +485,7 @@ device_mobile_device_got_modem_manager_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
GVariant *result = NULL;
|
||||
GDBusProxy *proxy;
|
||||
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
|
||||
|
@ -496,7 +494,6 @@ device_mobile_device_got_modem_manager_cb (GObject *source_object,
|
|||
if (!proxy) {
|
||||
g_warning ("Error creating ModemManager proxy: %s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -542,7 +539,7 @@ device_mobile_get_registration_info_cb (GObject *source_object,
|
|||
gpointer user_data)
|
||||
{
|
||||
gchar *operator_code = NULL;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
guint registration_status;
|
||||
GVariant *result = NULL;
|
||||
gchar *operator_name = NULL;
|
||||
|
@ -552,7 +549,6 @@ device_mobile_get_registration_info_cb (GObject *source_object,
|
|||
if (result == NULL) {
|
||||
g_warning ("Error getting registration info: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -619,14 +615,13 @@ device_mobile_device_got_modem_manager_gsm_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
|
||||
|
||||
device_mobile->gsm_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
|
||||
if (device_mobile->gsm_proxy == NULL) {
|
||||
g_warning ("Error creating ModemManager GSM proxy: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -654,7 +649,7 @@ device_mobile_get_serving_system_cb (GObject *source_object,
|
|||
{
|
||||
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
|
||||
GVariant *result = NULL;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
guint32 band_class;
|
||||
gchar *band;
|
||||
|
@ -665,7 +660,6 @@ device_mobile_get_serving_system_cb (GObject *source_object,
|
|||
if (result == NULL) {
|
||||
g_warning ("Error getting serving system: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -691,14 +685,13 @@ device_mobile_device_got_modem_manager_cdma_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
|
||||
|
||||
device_mobile->cdma_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
|
||||
if (device_mobile->cdma_proxy == NULL) {
|
||||
g_warning ("Error creating ModemManager CDMA proxy: %s\n",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -891,7 +884,7 @@ net_device_mobile_class_init (NetDeviceMobileClass *klass)
|
|||
static void
|
||||
net_device_mobile_init (NetDeviceMobile *device_mobile)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
GtkWidget *widget;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkComboBox *combobox;
|
||||
|
@ -902,7 +895,6 @@ net_device_mobile_init (NetDeviceMobile *device_mobile)
|
|||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -220,7 +220,7 @@ static void
|
|||
net_device_simple_init (NetDeviceSimple *device_simple)
|
||||
{
|
||||
NetDeviceSimplePrivate *priv = net_device_simple_get_instance_private (device_simple);
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
GtkWidget *widget;
|
||||
|
||||
priv->builder = gtk_builder_new ();
|
||||
|
@ -229,7 +229,6 @@ net_device_simple_init (NetDeviceSimple *device_simple)
|
|||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -266,13 +266,12 @@ get_secrets_cb (GObject *source_object,
|
|||
{
|
||||
NetDeviceWifi *device_wifi = data;
|
||||
GVariant *secrets;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
secrets = nm_remote_connection_get_secrets_finish (NM_REMOTE_CONNECTION (source_object), res, &error);
|
||||
if (!secrets) {
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("Could not get secrets: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -646,7 +645,7 @@ connection_add_activate_cb (GObject *source_object,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMActiveConnection *conn;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
conn = nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object), res, &error);
|
||||
if (!conn) {
|
||||
|
@ -657,7 +656,6 @@ connection_add_activate_cb (GObject *source_object,
|
|||
error->code,
|
||||
error->message);
|
||||
}
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -667,7 +665,7 @@ connection_activate_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) {
|
||||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
|
||||
|
@ -677,7 +675,6 @@ connection_activate_cb (GObject *source_object,
|
|||
error->code,
|
||||
error->message);
|
||||
}
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -791,14 +788,11 @@ get_hostname (void)
|
|||
GVariant *res;
|
||||
GVariant *inner;
|
||||
gchar *str;
|
||||
GError *error;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
error = NULL;
|
||||
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (bus == NULL) {
|
||||
g_warning ("Failed to get system bus connection: %s", error->message);
|
||||
g_error_free (error);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
res = g_dbus_connection_call_sync (bus,
|
||||
|
@ -816,10 +810,8 @@ get_hostname (void)
|
|||
&error);
|
||||
g_object_unref (bus);
|
||||
|
||||
if (res == NULL) {
|
||||
if (res == NULL)
|
||||
g_warning ("Getting pretty hostname failed: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
str = NULL;
|
||||
|
||||
|
@ -946,13 +938,12 @@ activate_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error) == NULL) {
|
||||
g_warning ("Failed to add new connection: (%d) %s",
|
||||
error->code,
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -966,7 +957,7 @@ activate_new_cb (GObject *source_object,
|
|||
gpointer user_data)
|
||||
{
|
||||
NMActiveConnection *conn;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
conn = nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object),
|
||||
res, &error);
|
||||
|
@ -974,7 +965,6 @@ activate_new_cb (GObject *source_object,
|
|||
g_warning ("Failed to add new connection: (%d) %s",
|
||||
error->code,
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1006,7 +996,7 @@ overwrite_ssid_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
NMClient *client;
|
||||
NMRemoteConnection *connection;
|
||||
NMDevice *device;
|
||||
|
@ -1020,7 +1010,6 @@ overwrite_ssid_cb (GObject *source_object,
|
|||
if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
g_warning ("Failed to save hotspot's settings to disk: %s",
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1436,7 +1425,7 @@ device_wifi_edit (NetObject *object)
|
|||
{
|
||||
const gchar *uuid;
|
||||
gchar *cmdline;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
NetDeviceWifi *device = NET_DEVICE_WIFI (object);
|
||||
NMClient *client;
|
||||
NMRemoteConnection *connection;
|
||||
|
@ -1450,10 +1439,8 @@ device_wifi_edit (NetObject *object)
|
|||
uuid = nm_connection_get_uuid (NM_CONNECTION (connection));
|
||||
cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid);
|
||||
g_debug ("Launching '%s'\n", cmdline);
|
||||
if (!g_spawn_command_line_async (cmdline, &error)) {
|
||||
if (!g_spawn_command_line_async (cmdline, &error))
|
||||
g_warning ("Failed to launch nm-connection-editor: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
g_free (cmdline);
|
||||
}
|
||||
|
||||
|
@ -1503,7 +1490,7 @@ really_forgotten (GObject *source_object,
|
|||
gpointer user_data)
|
||||
{
|
||||
CcWifiConnectionList *list = user_data;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
cc_wifi_connection_list_thaw (list);
|
||||
g_object_unref (list);
|
||||
|
@ -1512,7 +1499,6 @@ really_forgotten (GObject *source_object,
|
|||
g_warning ("failed to delete connection %s: %s",
|
||||
nm_object_get_path (NM_OBJECT (source_object)),
|
||||
error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1853,7 +1839,7 @@ ap_activated (GtkListBox *list, GtkListBoxRow *row, NetDeviceWifi *device_wifi)
|
|||
static void
|
||||
net_device_wifi_init (NetDeviceWifi *device_wifi)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
GtkWidget *widget;
|
||||
|
||||
device_wifi->builder = gtk_builder_new ();
|
||||
|
@ -1862,7 +1848,6 @@ net_device_wifi_init (NetDeviceWifi *device_wifi)
|
|||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ net_device_edit (NetObject *object)
|
|||
{
|
||||
const gchar *uuid;
|
||||
gchar *cmdline;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
NetDevice *device = NET_DEVICE (object);
|
||||
NMConnection *connection;
|
||||
|
||||
|
@ -199,10 +199,8 @@ net_device_edit (NetObject *object)
|
|||
uuid = nm_connection_get_uuid (connection);
|
||||
cmdline = g_strdup_printf ("nm-connection-editor --edit %s", uuid);
|
||||
g_debug ("Launching '%s'\n", cmdline);
|
||||
if (!g_spawn_command_line_async (cmdline, &error)) {
|
||||
if (!g_spawn_command_line_async (cmdline, &error))
|
||||
g_warning ("Failed to launch nm-connection-editor: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
g_free (cmdline);
|
||||
}
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ net_proxy_init (NetProxy *proxy)
|
|||
GSettings *settings_tmp;
|
||||
ProxyMode value;
|
||||
GtkWidget *widget;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
guint i;
|
||||
|
||||
proxy = net_proxy_get_instance_private (proxy);
|
||||
|
@ -302,7 +302,6 @@ net_proxy_init (NetProxy *proxy)
|
|||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -411,7 +411,7 @@ net_vpn_class_init (NetVpnClass *klass)
|
|||
static void
|
||||
net_vpn_init (NetVpn *vpn)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
GtkWidget *widget;
|
||||
|
||||
vpn = net_vpn_get_instance_private (vpn);
|
||||
|
@ -422,7 +422,6 @@ net_vpn_init (NetVpn *vpn)
|
|||
&error);
|
||||
if (error != NULL) {
|
||||
g_warning ("Could not load interface file: %s", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,12 +76,10 @@ activate_existing_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error)) {
|
||||
if (!nm_client_activate_connection_finish (NM_CLIENT (source_object), res, &error))
|
||||
g_warning ("Failed to activate connection: (%d) %s", error->code, error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -89,12 +87,10 @@ activate_new_cb (GObject *source_object,
|
|||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
if (!nm_client_add_and_activate_connection_finish (NM_CLIENT (source_object), res, &error)) {
|
||||
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
|
||||
|
|
|
@ -57,11 +57,10 @@ validate (EAPMethod *parent, GError **error)
|
|||
GtkTreeIter iter;
|
||||
EAPMethod *eap = NULL;
|
||||
gboolean valid = FALSE;
|
||||
GError *local = NULL;
|
||||
g_autoptr(GError) local_error = NULL;
|
||||
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_peap_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local)) {
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA certificate: %s"), local->message);
|
||||
g_clear_error (&local);
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_peap_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local_error)) {
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-PEAP CA certificate: %s"), local_error->message);
|
||||
return FALSE;
|
||||
}
|
||||
if (eap_method_ca_cert_required (parent->builder, "eap_peap_ca_cert_not_required_checkbox", "eap_peap_ca_cert_button")) {
|
||||
|
@ -145,7 +144,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
|
|||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
int peapver_active = 0;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gboolean ca_cert_error = FALSE;
|
||||
|
||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
|
@ -164,7 +163,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
|
|||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
|
||||
if (!nm_setting_802_1x_set_ca_cert (s_8021x, filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
|
||||
g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
ca_cert_error = TRUE;
|
||||
}
|
||||
eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);
|
||||
|
|
|
@ -57,7 +57,9 @@ validate (EAPMethod *parent, GError **error)
|
|||
NMSetting8021xCKFormat format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
||||
GtkWidget *widget;
|
||||
const char *password, *identity;
|
||||
GError *local = NULL;
|
||||
g_autoptr(GError) ca_cert_error = NULL;
|
||||
g_autoptr(GError) private_key_error = NULL;
|
||||
g_autoptr(GError) user_cert_error = NULL;
|
||||
gboolean ret = TRUE;
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry"));
|
||||
|
@ -71,13 +73,12 @@ validate (EAPMethod *parent, GError **error)
|
|||
widget_unset_error (widget);
|
||||
}
|
||||
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_tls_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local)) {
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_tls_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &ca_cert_error)) {
|
||||
widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_button")));
|
||||
if (ret) {
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS CA certificate: %s"), local->message);
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS CA certificate: %s"), ca_cert_error->message);
|
||||
ret = FALSE;
|
||||
}
|
||||
g_clear_error (&local);
|
||||
} else if (eap_method_ca_cert_required (parent->builder, "eap_tls_ca_cert_not_required_checkbox", "eap_tls_ca_cert_button")) {
|
||||
widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_ca_cert_button")));
|
||||
if (ret) {
|
||||
|
@ -95,22 +96,20 @@ validate (EAPMethod *parent, GError **error)
|
|||
TYPE_PRIVATE_KEY,
|
||||
password,
|
||||
&format,
|
||||
&local)) {
|
||||
&private_key_error)) {
|
||||
if (ret) {
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS private-key: %s"), local->message);
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS private-key: %s"), private_key_error->message);
|
||||
ret = FALSE;
|
||||
}
|
||||
g_clear_error (&local);
|
||||
widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_private_key_button")));
|
||||
}
|
||||
|
||||
if (format != NM_SETTING_802_1X_CK_FORMAT_PKCS12) {
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_tls_user_cert_button", TYPE_CLIENT_CERT, NULL, NULL, &local)) {
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_tls_user_cert_button", TYPE_CLIENT_CERT, NULL, NULL, &user_cert_error)) {
|
||||
if (ret) {
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS user-certificate: %s"), local->message);
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TLS user-certificate: %s"), user_cert_error->message);
|
||||
ret = FALSE;
|
||||
}
|
||||
g_clear_error (&local);
|
||||
widget_set_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_user_cert_button")));
|
||||
}
|
||||
}
|
||||
|
@ -166,7 +165,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
|
|||
GtkWidget *widget, *passwd_entry;
|
||||
char *ca_filename, *pk_filename, *cc_filename;
|
||||
const char *password = NULL;
|
||||
GError *error = NULL;
|
||||
gboolean ca_cert_error = FALSE;
|
||||
|
||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
|
@ -194,15 +192,13 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
|
|||
g_assert (pk_filename);
|
||||
|
||||
if (parent->phase2) {
|
||||
if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
|
||||
g_autoptr(GError) error = NULL;
|
||||
if (!nm_setting_802_1x_set_phase2_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error))
|
||||
g_warning ("Couldn't read phase2 private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
}
|
||||
} else {
|
||||
if (!nm_setting_802_1x_set_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
|
||||
g_autoptr(GError) error = NULL;
|
||||
if (!nm_setting_802_1x_set_private_key (s_8021x, pk_filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error))
|
||||
g_warning ("Couldn't read private key '%s': %s", pk_filename, error ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
g_free (pk_filename);
|
||||
|
||||
|
@ -229,15 +225,13 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
|
|||
|
||||
format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
||||
if (parent->phase2) {
|
||||
if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
|
||||
g_autoptr(GError) error = NULL;
|
||||
if (!nm_setting_802_1x_set_phase2_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error))
|
||||
g_warning ("Couldn't read phase2 client certificate '%s': %s", cc_filename, error ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
}
|
||||
} else {
|
||||
if (!nm_setting_802_1x_set_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
|
||||
g_autoptr(GError) error = NULL;
|
||||
if (!nm_setting_802_1x_set_client_cert (s_8021x, cc_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error))
|
||||
g_warning ("Couldn't read client certificate '%s': %s", cc_filename, error ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
g_free (cc_filename);
|
||||
}
|
||||
|
@ -249,15 +243,15 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
|
|||
|
||||
format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
|
||||
if (parent->phase2) {
|
||||
g_autoptr(GError) error = NULL;
|
||||
if (!nm_setting_802_1x_set_phase2_ca_cert (s_8021x, ca_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
|
||||
g_warning ("Couldn't read phase2 CA certificate '%s': %s", ca_filename, error ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
ca_cert_error = TRUE;
|
||||
}
|
||||
} else {
|
||||
g_autoptr(GError) error = NULL;
|
||||
if (!nm_setting_802_1x_set_ca_cert (s_8021x, ca_filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
|
||||
g_warning ("Couldn't read CA certificate '%s': %s", ca_filename, error ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
ca_cert_error = TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,11 +57,10 @@ validate (EAPMethod *parent, GError **error)
|
|||
GtkTreeIter iter;
|
||||
EAPMethod *eap = NULL;
|
||||
gboolean valid = FALSE;
|
||||
GError *local = NULL;
|
||||
g_autoptr(GError) local_error = NULL;
|
||||
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_ttls_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local)) {
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA certificate: %s"), local->message);
|
||||
g_clear_error (&local);
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_ttls_ca_cert_button", TYPE_CA_CERT, NULL, NULL, &local_error)) {
|
||||
g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid EAP-TTLS CA certificate: %s"), local_error->message);
|
||||
return FALSE;
|
||||
}
|
||||
if (eap_method_ca_cert_required (parent->builder, "eap_ttls_ca_cert_not_required_checkbox", "eap_ttls_ca_cert_button")) {
|
||||
|
@ -144,7 +143,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
|
|||
EAPMethod *eap = NULL;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
gboolean ca_cert_error = FALSE;
|
||||
|
||||
s_8021x = nm_connection_get_setting_802_1x (connection);
|
||||
|
@ -169,7 +168,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
|
|||
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
|
||||
if (!nm_setting_802_1x_set_ca_cert (s_8021x, filename, NM_SETTING_802_1X_CK_SCHEME_PATH, &format, &error)) {
|
||||
g_warning ("Couldn't read CA certificate '%s': %s", filename, error ? error->message : "(unknown)");
|
||||
g_clear_error (&error);
|
||||
ca_cert_error = TRUE;
|
||||
}
|
||||
eap_method_ca_cert_ignore_set (parent, connection, filename, ca_cert_error);
|
||||
|
|
|
@ -147,7 +147,7 @@ eap_method_init (gsize obj_size,
|
|||
gboolean phase2)
|
||||
{
|
||||
EAPMethod *method;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
g_return_val_if_fail (obj_size > 0, NULL);
|
||||
g_return_val_if_fail (ui_resource != NULL, NULL);
|
||||
|
@ -169,7 +169,6 @@ eap_method_init (gsize obj_size,
|
|||
if (!gtk_builder_add_from_resource (method->builder, ui_resource, &error)) {
|
||||
g_warning ("Couldn't load UI builder resource %s: %s",
|
||||
ui_resource, error->message);
|
||||
g_error_free (error);
|
||||
eap_method_unref (method);
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ wireless_security_init (gsize obj_size,
|
|||
const char *default_field)
|
||||
{
|
||||
WirelessSecurity *sec;
|
||||
GError *error = NULL;
|
||||
g_autoptr(GError) error = NULL;
|
||||
|
||||
g_return_val_if_fail (obj_size > 0, NULL);
|
||||
g_return_val_if_fail (ui_resource != NULL, NULL);
|
||||
|
@ -190,7 +190,6 @@ wireless_security_init (gsize obj_size,
|
|||
if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) {
|
||||
g_warning ("Couldn't load UI builder resource %s: %s",
|
||||
ui_resource, error->message);
|
||||
g_error_free (error);
|
||||
wireless_security_unref (sec);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue