network: Use g_autoptr for unref code

This commit is contained in:
Robert Ancell 2019-09-12 11:53:42 +12:00
parent 1083368008
commit e70610fe74
29 changed files with 165 additions and 274 deletions

View file

@ -175,7 +175,7 @@ cc_network_panel_set_property (GObject *object,
parameters = g_value_get_variant (value); parameters = g_value_get_variant (value);
if (parameters) { if (parameters) {
GPtrArray *array; g_autoptr(GPtrArray) array = NULL;
const gchar **args; const gchar **args;
array = variant_av_to_string_array (parameters); array = variant_av_to_string_array (parameters);
args = (const gchar **) array->pdata; args = (const gchar **) array->pdata;
@ -191,10 +191,8 @@ cc_network_panel_set_property (GObject *object,
if (verify_argv (self, (const char **) args) == FALSE) { if (verify_argv (self, (const char **) args) == FALSE) {
reset_command_line_args (self); reset_command_line_args (self);
g_ptr_array_unref (array);
return; return;
} }
g_ptr_array_unref (array);
g_debug ("Calling handle_argv() after setting property"); g_debug ("Calling handle_argv() after setting property");
handle_argv (self); handle_argv (self);
} }
@ -368,20 +366,21 @@ handle_argv (CcNetworkPanel *panel)
for (i = 0; i < panel->devices->len; i++) { for (i = 0; i < panel->devices->len; i++) {
GObject *object_tmp; GObject *object_tmp;
NMDevice *device;
NMConnection *connection;
gboolean done = FALSE; gboolean done = FALSE;
object_tmp = g_ptr_array_index (panel->devices, i); object_tmp = g_ptr_array_index (panel->devices, i);
if (NET_IS_DEVICE (object_tmp)) { if (NET_IS_DEVICE (object_tmp)) {
NMDevice *device = NULL; /* Autoptr macro not available: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/270 */
g_object_get (object_tmp, "nm-device", &device, NULL); g_object_get (object_tmp, "nm-device", &device, NULL);
done = handle_argv_for_device (panel, device); done = handle_argv_for_device (panel, device);
g_object_unref (device); g_object_unref (device);
} else if (NET_IS_VPN (object_tmp)) { } else if (NET_IS_VPN (object_tmp)) {
g_autoptr(NMConnection) connection = NULL;
g_object_get (object_tmp, "connection", &connection, NULL); g_object_get (object_tmp, "connection", &connection, NULL);
done = handle_argv_for_connection (panel, connection); done = handle_argv_for_connection (panel, connection);
g_object_unref (connection);
} }
if (done) if (done)
@ -502,7 +501,7 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
if (type == NM_DEVICE_TYPE_MODEM && if (type == NM_DEVICE_TYPE_MODEM &&
g_str_has_prefix (nm_device_get_udi (device), "/org/freedesktop/ModemManager1/Modem/")) { g_str_has_prefix (nm_device_get_udi (device), "/org/freedesktop/ModemManager1/Modem/")) {
GDBusObject *modem_object; g_autoptr(GDBusObject) modem_object;
if (panel->modem_manager == NULL) { if (panel->modem_manager == NULL) {
g_warning ("Cannot grab information for modem at %s: No ModemManager support", g_warning ("Cannot grab information for modem at %s: No ModemManager support",
@ -522,7 +521,6 @@ panel_add_device (CcNetworkPanel *panel, NMDevice *device)
g_object_set (net_device, g_object_set (net_device,
"mm-object", modem_object, "mm-object", modem_object,
NULL); NULL);
g_object_unref (modem_object);
} }
/* add as a panel */ /* add as a panel */
@ -858,7 +856,7 @@ cc_network_panel_init (CcNetworkPanel *panel)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
GtkWidget *toplevel; GtkWidget *toplevel;
GDBusConnection *system_bus; g_autoptr(GDBusConnection) system_bus = NULL;
const GPtrArray *connections; const GPtrArray *connections;
guint i; guint i;
@ -875,9 +873,8 @@ cc_network_panel_init (CcNetworkPanel *panel)
/* Create and store a NMClient instance if it doesn't exist yet */ /* Create and store a NMClient instance if it doesn't exist yet */
if (!cc_object_storage_has_object (CC_OBJECT_NMCLIENT)) { if (!cc_object_storage_has_object (CC_OBJECT_NMCLIENT)) {
NMClient *client = nm_client_new (NULL, NULL); g_autoptr(NMClient) client = nm_client_new (NULL, NULL);
cc_object_storage_add_object (CC_OBJECT_NMCLIENT, client); cc_object_storage_add_object (CC_OBJECT_NMCLIENT, client);
g_object_unref (client);
} }
/* use NetworkManager client */ /* use NetworkManager client */
@ -905,7 +902,6 @@ cc_network_panel_init (CcNetworkPanel *panel)
if (panel->modem_manager == NULL) if (panel->modem_manager == NULL)
g_warning ("Error connecting to ModemManager: %s", g_warning ("Error connecting to ModemManager: %s",
error->message); error->message);
g_object_unref (system_bus);
} }
/* add remote settings such as VPN settings as virtual devices */ /* add remote settings such as VPN settings as virtual devices */

View file

@ -121,16 +121,15 @@ update_panel_visibility (NMClient *client)
void void
cc_wifi_panel_static_init_func (void) cc_wifi_panel_static_init_func (void)
{ {
NMClient *client; g_autoptr(NMClient) client = NULL;
g_debug ("Monitoring NetworkManager for Wi-Fi devices"); g_debug ("Monitoring NetworkManager for Wi-Fi devices");
/* Create and store a NMClient instance if it doesn't exist yet */ /* Create and store a NMClient instance if it doesn't exist yet */
if (!cc_object_storage_has_object (CC_OBJECT_NMCLIENT)) if (!cc_object_storage_has_object (CC_OBJECT_NMCLIENT))
{ {
client = nm_client_new (NULL, NULL); g_autoptr(NMClient) new_client = nm_client_new (NULL, NULL);
cc_object_storage_add_object (CC_OBJECT_NMCLIENT, client); cc_object_storage_add_object (CC_OBJECT_NMCLIENT, new_client);
g_object_unref (client);
} }
client = cc_object_storage_get_object (CC_OBJECT_NMCLIENT); client = cc_object_storage_get_object (CC_OBJECT_NMCLIENT);
@ -141,8 +140,6 @@ cc_wifi_panel_static_init_func (void)
g_signal_connect (client, "device-removed", G_CALLBACK (update_panel_visibility), NULL); g_signal_connect (client, "device-removed", G_CALLBACK (update_panel_visibility), NULL);
update_panel_visibility (client); update_panel_visibility (client);
g_object_unref (client);
} }
/* Auxiliary methods */ /* Auxiliary methods */
@ -649,7 +646,7 @@ cc_wifi_panel_set_property (GObject *object,
if (parameters) if (parameters)
{ {
GPtrArray *array; g_autoptr(GPtrArray) array = NULL;
const gchar **args; const gchar **args;
array = variant_av_to_string_array (parameters); array = variant_av_to_string_array (parameters);
@ -677,12 +674,9 @@ cc_wifi_panel_set_property (GObject *object,
if (!verify_argv (self, (const char **) args)) if (!verify_argv (self, (const char **) args))
{ {
reset_command_line_args (self); reset_command_line_args (self);
g_ptr_array_unref (array);
return; return;
} }
g_ptr_array_unref (array);
handle_argv (self); handle_argv (self);
} }
break; break;
@ -737,9 +731,8 @@ cc_wifi_panel_init (CcWifiPanel *self)
/* Create and store a NMClient instance if it doesn't exist yet */ /* Create and store a NMClient instance if it doesn't exist yet */
if (!cc_object_storage_has_object (CC_OBJECT_NMCLIENT)) if (!cc_object_storage_has_object (CC_OBJECT_NMCLIENT))
{ {
NMClient *client = nm_client_new (NULL, NULL); g_autoptr(NMClient) client = nm_client_new (NULL, NULL);
cc_object_storage_add_object (CC_OBJECT_NMCLIENT, client); cc_object_storage_add_object (CC_OBJECT_NMCLIENT, client);
g_object_unref (client);
} }
/* Load NetworkManager */ /* Load NetworkManager */

View file

@ -120,12 +120,12 @@ validate (CEPage *cepage, NMConnection *connection, GError **error)
gboolean valid = TRUE; gboolean valid = TRUE;
if (gtk_switch_get_active (page->enabled)) { if (gtk_switch_get_active (page->enabled)) {
NMConnection *tmp_connection;
NMSetting *s_8021x; NMSetting *s_8021x;
/* FIXME: get failed property and error out of wireless security objects */ /* FIXME: get failed property and error out of wireless security objects */
valid = wireless_security_validate (page->security, error); valid = wireless_security_validate (page->security, error);
if (valid) { if (valid) {
g_autoptr(NMConnection) tmp_connection = NULL;
NMSetting *s_con; NMSetting *s_con;
/* Here's a nice hack to work around the fact that ws_802_1x_fill_connection needs wireless setting. */ /* Here's a nice hack to work around the fact that ws_802_1x_fill_connection needs wireless setting. */
@ -142,8 +142,6 @@ validate (CEPage *cepage, NMConnection *connection, GError **error)
s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X); s_8021x = nm_connection_get_setting (tmp_connection, NM_TYPE_SETTING_802_1X);
nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x))); nm_connection_add_setting (connection, NM_SETTING (g_object_ref (s_8021x)));
g_object_unref (tmp_connection);
} }
} else { } else {
nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X); nm_connection_remove_setting (connection, NM_TYPE_SETTING_802_1X);

View file

@ -80,8 +80,8 @@ static void
update_last_used (CEPageDetails *page, NMConnection *connection) update_last_used (CEPageDetails *page, NMConnection *connection)
{ {
g_autofree gchar *last_used = NULL; g_autofree gchar *last_used = NULL;
GDateTime *now = NULL; g_autoptr(GDateTime) now = NULL;
GDateTime *then = NULL; g_autoptr(GDateTime) then = NULL;
gint days; gint days;
GTimeSpan diff; GTimeSpan diff;
guint64 timestamp; guint64 timestamp;
@ -110,10 +110,6 @@ update_last_used (CEPageDetails *page, NMConnection *connection)
last_used = g_strdup_printf (ngettext ("%i day ago", "%i days ago", days), days); last_used = g_strdup_printf (ngettext ("%i day ago", "%i days ago", days), days);
out: out:
panel_set_device_widget_details (CE_PAGE (page)->builder, "last_used", last_used); panel_set_device_widget_details (CE_PAGE (page)->builder, "last_used", last_used);
if (now != NULL)
g_date_time_unref (now);
if (then != NULL)
g_date_time_unref (then);
} }
static void static void

View file

@ -125,7 +125,7 @@ security_combo_changed (GtkComboBox *combo,
CEPageSecurity *page = CE_PAGE_SECURITY (user_data); CEPageSecurity *page = CE_PAGE_SECURITY (user_data);
GtkWidget *vbox; GtkWidget *vbox;
GList *l, *children; GList *l, *children;
WirelessSecurity *sec; g_autoptr(WirelessSecurity) sec = NULL;
wsec_size_group_clear (page->group); wsec_size_group_clear (page->group);
@ -150,7 +150,6 @@ security_combo_changed (GtkComboBox *combo,
wireless_security_add_to_size_group (sec, page->group); wireless_security_add_to_size_group (sec, page->group);
gtk_container_add (GTK_CONTAINER (vbox), sec_widget); gtk_container_add (GTK_CONTAINER (vbox), sec_widget);
wireless_security_unref (sec);
} }
ce_page_changed (CE_PAGE (page)); ce_page_changed (CE_PAGE (page));
@ -204,7 +203,7 @@ finish_setup (CEPageSecurity *page)
NMSettingWireless *sw; NMSettingWireless *sw;
NMSettingWirelessSecurity *sws; NMSettingWirelessSecurity *sws;
gboolean is_adhoc = FALSE; gboolean is_adhoc = FALSE;
GtkListStore *sec_model; g_autoptr(GtkListStore) sec_model = NULL;
GtkTreeIter iter; GtkTreeIter iter;
const gchar *mode; const gchar *mode;
guint32 dev_caps = 0; guint32 dev_caps = 0;
@ -345,7 +344,6 @@ finish_setup (CEPageSecurity *page)
gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer, set_sensitive, &page->adhoc, NULL); gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer, set_sensitive, &page->adhoc, NULL);
gtk_combo_box_set_active (combo, active < 0 ? 0 : (guint32) active); gtk_combo_box_set_active (combo, active < 0 ? 0 : (guint32) active);
g_object_unref (G_OBJECT (sec_model));
page->security_combo = combo; page->security_combo = combo;
@ -360,7 +358,7 @@ validate (CEPage *page,
GError **error) GError **error)
{ {
NMSettingWireless *sw; NMSettingWireless *sw;
WirelessSecurity *sec; g_autoptr(WirelessSecurity) sec = NULL;
gboolean valid = FALSE; gboolean valid = FALSE;
const char *mode; const char *mode;
@ -393,8 +391,6 @@ validate (CEPage *page,
valid = FALSE; valid = FALSE;
} }
} }
wireless_security_unref (sec);
} else { } else {
/* No security, unencrypted */ /* No security, unencrypted */
nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY); nm_connection_remove_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY);

View file

@ -93,7 +93,7 @@ connect_wifi_page (CEPageWifi *page)
static void static void
ui_to_setting (CEPageWifi *page) ui_to_setting (CEPageWifi *page)
{ {
GBytes *ssid; g_autoptr(GBytes) ssid = NULL;
const gchar *utf8_ssid, *bssid; const gchar *utf8_ssid, *bssid;
GtkWidget *entry; GtkWidget *entry;
GtkComboBoxText *combo; GtkComboBoxText *combo;
@ -122,9 +122,6 @@ ui_to_setting (CEPageWifi *page)
NM_SETTING_WIRELESS_MAC_ADDRESS, device_mac, NM_SETTING_WIRELESS_MAC_ADDRESS, device_mac,
NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, cloned_mac, NM_SETTING_WIRELESS_CLONED_MAC_ADDRESS, cloned_mac,
NULL); NULL);
if (ssid)
g_bytes_unref (ssid);
} }
static gboolean static gboolean

View file

@ -221,7 +221,7 @@ ce_page_new (GType type,
const gchar *ui_resource, const gchar *ui_resource,
const gchar *title) const gchar *title)
{ {
CEPage *page; g_autoptr(CEPage) page = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
page = CE_PAGE (g_object_new (type, page = CE_PAGE (g_object_new (type,
@ -233,20 +233,18 @@ ce_page_new (GType type,
if (ui_resource) { if (ui_resource) {
if (!gtk_builder_add_from_resource (page->builder, ui_resource, &error)) { if (!gtk_builder_add_from_resource (page->builder, ui_resource, &error)) {
g_warning ("Couldn't load builder file: %s", error->message); g_warning ("Couldn't load builder file: %s", error->message);
g_object_unref (page);
return NULL; return NULL;
} }
page->page = GTK_WIDGET (gtk_builder_get_object (page->builder, "page")); page->page = GTK_WIDGET (gtk_builder_get_object (page->builder, "page"));
if (!page->page) { if (!page->page) {
g_warning ("Couldn't load page widget from %s", ui_resource); g_warning ("Couldn't load page widget from %s", ui_resource);
g_object_unref (page);
return NULL; return NULL;
} }
g_object_ref_sink (page->page); g_object_ref_sink (page->page);
} }
return page; return g_steal_pointer (&page);
} }
static void static void
@ -265,7 +263,7 @@ ce_page_complete_init (CEPage *page,
GError *error) GError *error)
{ {
g_autoptr(GError) update_error = NULL; g_autoptr(GError) update_error = NULL;
GVariant *setting_dict; g_autoptr(GVariant) setting_dict = NULL;
gboolean ignore_error = FALSE; gboolean ignore_error = FALSE;
g_return_if_fail (page != NULL); g_return_if_fail (page != NULL);
@ -295,7 +293,6 @@ ce_page_complete_init (CEPage *page,
emit_initialized (page, NULL); emit_initialized (page, NULL);
return; return;
} }
g_variant_unref (setting_dict);
/* Update the connection with the new secrets */ /* Update the connection with the new secrets */
if (nm_connection_update_secrets (page->connection, if (nm_connection_update_secrets (page->connection,

View file

@ -111,6 +111,8 @@ gchar * ce_page_get_next_available_name (const GPtrArray *connections,
const gchar *type_name); const gchar *type_name);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (CEPage, g_object_unref)
G_END_DECLS G_END_DECLS

View file

@ -73,11 +73,10 @@ cancel_clicked_cb (NetConnectionEditor *editor)
static void static void
update_connection (NetConnectionEditor *editor) update_connection (NetConnectionEditor *editor)
{ {
GVariant *settings; g_autoptr(GVariant) settings = NULL;
settings = nm_connection_to_dbus (editor->connection, NM_CONNECTION_SERIALIZE_ALL); settings = nm_connection_to_dbus (editor->connection, NM_CONNECTION_SERIALIZE_ALL);
nm_connection_replace_settings (editor->orig_connection, settings, NULL); nm_connection_replace_settings (editor->orig_connection, settings, NULL);
g_variant_unref (settings);
} }
static void static void
@ -843,11 +842,10 @@ net_connection_editor_forget (NetConnectionEditor *editor)
void void
net_connection_editor_reset (NetConnectionEditor *editor) net_connection_editor_reset (NetConnectionEditor *editor)
{ {
GVariant *settings; g_autoptr(GVariant) settings = NULL;
settings = nm_connection_to_dbus (editor->orig_connection, NM_CONNECTION_SERIALIZE_ALL); settings = nm_connection_to_dbus (editor->orig_connection, NM_CONNECTION_SERIALIZE_ALL);
nm_connection_replace_settings (editor->connection, settings, NULL); nm_connection_replace_settings (editor->connection, settings, NULL);
g_variant_unref (settings);
} }
void void

View file

@ -64,13 +64,13 @@ vpn_get_plugins (void)
p = nm_vpn_plugin_info_list_load (); p = nm_vpn_plugin_info_list_load ();
plugins = NULL; plugins = NULL;
while (p) { while (p) {
NMVpnPluginInfo *plugin_info = NM_VPN_PLUGIN_INFO (p->data); g_autoptr(NMVpnPluginInfo) plugin_info = NM_VPN_PLUGIN_INFO (p->data);
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
/* load the editor plugin, and preserve only those NMVpnPluginInfo that can /* load the editor plugin, and preserve only those NMVpnPluginInfo that can
* successfully load the plugin. */ * successfully load the plugin. */
if (nm_vpn_plugin_info_load_editor_plugin (plugin_info, &error)) if (nm_vpn_plugin_info_load_editor_plugin (plugin_info, &error))
plugins = g_slist_prepend (plugins, plugin_info); plugins = g_slist_prepend (plugins, g_steal_pointer (&plugin_info));
else { else {
if ( !nm_vpn_plugin_info_get_plugin (plugin_info) if ( !nm_vpn_plugin_info_get_plugin (plugin_info)
&& nm_vpn_plugin_info_lookup_property (plugin_info, NM_VPN_PLUGIN_INFO_KF_GROUP_GNOME, "properties")) { && nm_vpn_plugin_info_lookup_property (plugin_info, NM_VPN_PLUGIN_INFO_KF_GROUP_GNOME, "properties")) {
@ -88,7 +88,6 @@ vpn_get_plugins (void)
nm_vpn_plugin_info_get_filename (plugin_info), nm_vpn_plugin_info_get_filename (plugin_info),
error->message); error->message);
} }
g_object_unref (plugin_info);
} }
p = g_slist_delete_link (p, p); p = g_slist_delete_link (p, p);
} }
@ -194,7 +193,7 @@ vpn_import (GtkWindow *parent, VpnImportCallback callback, gpointer user_data)
static void static void
export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data) export_vpn_to_file_cb (GtkWidget *dialog, gint response, gpointer user_data)
{ {
NMConnection *connection = NM_CONNECTION (user_data); g_autoptr(NMConnection) connection = NM_CONNECTION (user_data);
char *filename = NULL; char *filename = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
NMVpnEditorPlugin *plugin; NMVpnEditorPlugin *plugin;
@ -273,8 +272,6 @@ done:
} }
out: out:
g_object_unref (connection);
gtk_widget_hide (dialog); gtk_widget_hide (dialog);
gtk_widget_destroy (dialog); gtk_widget_destroy (dialog);
} }

View file

@ -107,9 +107,8 @@ add_details_row (GtkWidget *details, gint top, const gchar *heading, const gchar
static gchar * static gchar *
get_last_used_string (NMConnection *connection) get_last_used_string (NMConnection *connection)
{ {
gchar *last_used = NULL; g_autoptr(GDateTime) now = NULL;
GDateTime *now = NULL; g_autoptr(GDateTime) then = NULL;
GDateTime *then = NULL;
gint days; gint days;
GTimeSpan diff; GTimeSpan diff;
guint64 timestamp; guint64 timestamp;
@ -117,12 +116,10 @@ get_last_used_string (NMConnection *connection)
s_con = nm_connection_get_setting_connection (connection); s_con = nm_connection_get_setting_connection (connection);
if (s_con == NULL) if (s_con == NULL)
goto out; return NULL;
timestamp = nm_setting_connection_get_timestamp (s_con); timestamp = nm_setting_connection_get_timestamp (s_con);
if (timestamp == 0) { if (timestamp == 0)
last_used = g_strdup (_("never")); return g_strdup (_("never"));
goto out;
}
/* calculate the amount of time that has elapsed */ /* calculate the amount of time that has elapsed */
now = g_date_time_new_now_utc (); now = g_date_time_new_now_utc ();
@ -130,18 +127,11 @@ get_last_used_string (NMConnection *connection)
diff = g_date_time_difference (now, then); diff = g_date_time_difference (now, then);
days = diff / G_TIME_SPAN_DAY; days = diff / G_TIME_SPAN_DAY;
if (days == 0) if (days == 0)
last_used = g_strdup (_("today")); return g_strdup (_("today"));
else if (days == 1) else if (days == 1)
last_used = g_strdup (_("yesterday")); return g_strdup (_("yesterday"));
else else
last_used = g_strdup_printf (ngettext ("%i day ago", "%i days ago", days), days); return g_strdup_printf (ngettext ("%i day ago", "%i days ago", days), days);
out:
if (now != NULL)
g_date_time_unref (now);
if (then != NULL)
g_date_time_unref (then);
return last_used;
} }
static void static void

View file

@ -480,8 +480,8 @@ device_mobile_device_got_modem_manager_cb (GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
GVariant *result = NULL; g_autoptr(GVariant) result = NULL;
GDBusProxy *proxy; g_autoptr(GDBusProxy) proxy = NULL;
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data; NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
proxy = g_dbus_proxy_new_for_bus_finish (res, &error); proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
@ -496,16 +496,13 @@ device_mobile_device_got_modem_manager_cb (GObject *source_object,
"EquipmentIdentifier"); "EquipmentIdentifier");
/* save */ /* save */
if (result) { if (result)
g_object_set_data_full (G_OBJECT (device_mobile), g_object_set_data_full (G_OBJECT (device_mobile),
"ControlCenter::EquipmentIdentifier", "ControlCenter::EquipmentIdentifier",
g_variant_dup_string (result, NULL), g_variant_dup_string (result, NULL),
g_free); g_free);
g_variant_unref (result);
}
device_mobile_refresh_equipment_id (device_mobile); device_mobile_refresh_equipment_id (device_mobile);
g_object_unref (proxy);
} }
static void static void
@ -535,7 +532,7 @@ device_mobile_get_registration_info_cb (GObject *source_object,
g_autofree gchar *operator_code = NULL; g_autofree gchar *operator_code = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
guint registration_status; guint registration_status;
GVariant *result = NULL; g_autoptr(GVariant) result = NULL;
g_autofree gchar *operator_name = NULL; g_autofree gchar *operator_name = NULL;
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data; NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
@ -562,8 +559,6 @@ device_mobile_get_registration_info_cb (GObject *source_object,
device_mobile_save_operator_name (device_mobile, device_mobile_save_operator_name (device_mobile,
"ControlCenter::OperatorNameGsm", "ControlCenter::OperatorNameGsm",
operator_name); operator_name);
g_variant_unref (result);
} }
static void static void
@ -637,7 +632,7 @@ device_mobile_get_serving_system_cb (GObject *source_object,
gpointer user_data) gpointer user_data)
{ {
NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data; NetDeviceMobile *device_mobile = (NetDeviceMobile *)user_data;
GVariant *result = NULL; g_autoptr(GVariant) result = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
guint32 band_class; guint32 band_class;
@ -664,8 +659,6 @@ device_mobile_get_serving_system_cb (GObject *source_object,
device_mobile_save_operator_name (device_mobile, device_mobile_save_operator_name (device_mobile,
"ControlCenter::OperatorNameCdma", "ControlCenter::OperatorNameCdma",
operator_name); operator_name);
g_variant_unref (result);
} }
static void static void

View file

@ -199,7 +199,7 @@ static NMConnection *
find_connection_for_device (NetDeviceWifi *device_wifi, find_connection_for_device (NetDeviceWifi *device_wifi,
NMDevice *device) NMDevice *device)
{ {
NetDevice *tmp; g_autoptr(NetDevice) tmp = NULL;
NMConnection *connection; NMConnection *connection;
NMClient *client; NMClient *client;
@ -209,7 +209,6 @@ find_connection_for_device (NetDeviceWifi *device_wifi,
"nm-device", device, "nm-device", device,
NULL); NULL);
connection = net_device_get_find_connection (tmp); connection = net_device_get_find_connection (tmp);
g_object_unref (tmp);
return connection; return connection;
} }
@ -382,8 +381,8 @@ static void
update_last_used (NetDeviceWifi *device_wifi, NMConnection *connection) update_last_used (NetDeviceWifi *device_wifi, NMConnection *connection)
{ {
g_autofree gchar *last_used = NULL; g_autofree gchar *last_used = NULL;
GDateTime *now = NULL; g_autoptr(GDateTime) now = NULL;
GDateTime *then = NULL; g_autoptr(GDateTime) then = NULL;
gint days; gint days;
GTimeSpan diff; GTimeSpan diff;
guint64 timestamp; guint64 timestamp;
@ -413,10 +412,6 @@ out:
panel_set_device_widget_details (device_wifi->builder, panel_set_device_widget_details (device_wifi->builder,
"last_used", "last_used",
last_used); last_used);
if (now != NULL)
g_date_time_unref (now);
if (then != NULL)
g_date_time_unref (then);
} }
static void static void
@ -705,14 +700,14 @@ wireless_try_to_connect (NetDeviceWifi *device_wifi,
GCancellable *cancellable; GCancellable *cancellable;
if (device_wifi->updating_device) if (device_wifi->updating_device)
goto out; return;
if (ap_object_path == NULL || ap_object_path[0] == 0) if (ap_object_path == NULL || ap_object_path[0] == 0)
goto out; return;
device = net_device_get_nm_device (NET_DEVICE (device_wifi)); device = net_device_get_nm_device (NET_DEVICE (device_wifi));
if (device == NULL) if (device == NULL)
goto out; return;
ssid_target = nm_utils_escape_ssid ((gpointer) g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); ssid_target = nm_utils_escape_ssid ((gpointer) g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid));
g_debug ("try to connect to WIFI network %s [%s]", g_debug ("try to connect to WIFI network %s [%s]",
@ -723,16 +718,14 @@ wireless_try_to_connect (NetDeviceWifi *device_wifi,
cancellable = net_object_get_cancellable (NET_OBJECT (device_wifi)); cancellable = net_object_get_cancellable (NET_OBJECT (device_wifi));
if (!is_8021x (device, ap_object_path)) { if (!is_8021x (device, ap_object_path)) {
GPermission *permission; g_autoptr(GPermission) permission = NULL;
gboolean allowed_to_share = FALSE; gboolean allowed_to_share = FALSE;
NMConnection *partial = NULL; g_autoptr(NMConnection) partial = NULL;
permission = polkit_permission_new_sync ("org.freedesktop.NetworkManager.settings.modify.system", permission = polkit_permission_new_sync ("org.freedesktop.NetworkManager.settings.modify.system",
NULL, NULL, NULL); NULL, NULL, NULL);
if (permission) { if (permission)
allowed_to_share = g_permission_get_allowed (permission); allowed_to_share = g_permission_get_allowed (permission);
g_object_unref (permission);
}
if (!allowed_to_share) { if (!allowed_to_share) {
NMSettingConnection *s_con; NMSettingConnection *s_con;
@ -751,11 +744,9 @@ wireless_try_to_connect (NetDeviceWifi *device_wifi,
cancellable, cancellable,
connection_add_activate_cb, connection_add_activate_cb,
device_wifi); device_wifi);
if (!allowed_to_share)
g_object_unref (partial);
} else { } else {
CcNetworkPanel *panel; CcNetworkPanel *panel;
GVariantBuilder *builder; g_autoptr(GVariantBuilder) builder = NULL;
GVariant *parameters; GVariant *parameters;
g_debug ("no existing connection found for %s, creating", ssid_target); g_debug ("no existing connection found for %s, creating", ssid_target);
@ -767,20 +758,15 @@ wireless_try_to_connect (NetDeviceWifi *device_wifi,
panel = net_object_get_panel (NET_OBJECT (device_wifi)); panel = net_object_get_panel (NET_OBJECT (device_wifi));
g_object_set (G_OBJECT (panel), "parameters", parameters, NULL); g_object_set (G_OBJECT (panel), "parameters", parameters, NULL);
g_variant_builder_unref (builder);
} }
out:
return;
} }
static gchar * static gchar *
get_hostname (void) get_hostname (void)
{ {
GDBusConnection *bus; g_autoptr(GDBusConnection) bus = NULL;
GVariant *res; g_autoptr(GVariant) res = NULL;
GVariant *inner; g_autoptr(GVariant) inner = NULL;
gchar *str;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error); bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
@ -801,21 +787,14 @@ get_hostname (void)
-1, -1,
NULL, NULL,
&error); &error);
g_object_unref (bus);
if (res == NULL) if (res == NULL) {
g_warning ("Getting pretty hostname failed: %s", error->message); g_warning ("Getting pretty hostname failed: %s", error->message);
return NULL;
str = NULL;
if (res != NULL) {
g_variant_get (res, "(v)", &inner);
str = g_variant_dup_string (inner, NULL);
g_variant_unref (inner);
g_variant_unref (res);
} }
return str; g_variant_get (res, "(v)", &inner);
return g_variant_dup_string (inner, NULL);
} }
static GBytes * static GBytes *
@ -1026,13 +1005,14 @@ overwrite_ssid_cb (GObject *source_object,
static void static void
start_shared_connection (NetDeviceWifi *device_wifi) start_shared_connection (NetDeviceWifi *device_wifi)
{ {
NMConnection *c; NMConnection *hotspot_connection;
g_autoptr(NMConnection) c = NULL;
NMSettingConnection *sc; NMSettingConnection *sc;
NMSettingWireless *sw; NMSettingWireless *sw;
NMSettingIP4Config *sip; NMSettingIP4Config *sip;
NMSettingWirelessSecurity *sws; NMSettingWirelessSecurity *sws;
NMDevice *device; NMDevice *device;
GBytes *ssid; g_autoptr(GBytes) ssid = NULL;
const gchar *str_mac; const gchar *str_mac;
struct ether_addr *bin_mac; struct ether_addr *bin_mac;
NMClient *client; NMClient *client;
@ -1043,22 +1023,21 @@ start_shared_connection (NetDeviceWifi *device_wifi)
device = net_device_get_nm_device (NET_DEVICE (device_wifi)); device = net_device_get_nm_device (NET_DEVICE (device_wifi));
g_assert (nm_device_get_device_type (device) == NM_DEVICE_TYPE_WIFI); g_assert (nm_device_get_device_type (device) == NM_DEVICE_TYPE_WIFI);
c = net_device_wifi_get_hotspot_connection (device_wifi); hotspot_connection = net_device_wifi_get_hotspot_connection (device_wifi);
ssid = generate_ssid_for_hotspot (device_wifi); ssid = generate_ssid_for_hotspot (device_wifi);
client = net_object_get_client (NET_OBJECT (device_wifi)); client = net_object_get_client (NET_OBJECT (device_wifi));
cancellable = net_object_get_cancellable (NET_OBJECT (device_wifi)); cancellable = net_object_get_cancellable (NET_OBJECT (device_wifi));
if (c != NULL) { if (hotspot_connection != NULL) {
NMSettingWireless *sw; NMSettingWireless *sw;
const char *c_path; const char *c_path;
NMRemoteConnection *connection; NMRemoteConnection *connection;
sw = nm_connection_get_setting_wireless (c); sw = nm_connection_get_setting_wireless (hotspot_connection);
g_object_set (sw, "ssid", ssid, NULL); g_object_set (sw, "ssid", ssid, NULL);
g_bytes_unref (ssid);
c_path = nm_connection_get_path (c); c_path = nm_connection_get_path (hotspot_connection);
connection = nm_client_get_connection_by_path (client, c_path); connection = nm_client_get_connection_by_path (client, c_path);
g_debug ("overwriting ssid to %s", (char *) g_bytes_get_data (ssid, NULL)); g_debug ("overwriting ssid to %s", (char *) g_bytes_get_data (ssid, NULL));
@ -1099,14 +1078,13 @@ start_shared_connection (NetDeviceWifi *device_wifi)
str_mac = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device)); str_mac = nm_device_wifi_get_permanent_hw_address (NM_DEVICE_WIFI (device));
bin_mac = ether_aton (str_mac); bin_mac = ether_aton (str_mac);
if (bin_mac) { if (bin_mac) {
GByteArray *hw_address; g_autoptr(GByteArray) hw_address = NULL;
hw_address = g_byte_array_sized_new (ETH_ALEN); hw_address = g_byte_array_sized_new (ETH_ALEN);
g_byte_array_append (hw_address, bin_mac->ether_addr_octet, ETH_ALEN); g_byte_array_append (hw_address, bin_mac->ether_addr_octet, ETH_ALEN);
g_object_set (sw, g_object_set (sw,
"mac-address", hw_address, "mac-address", hw_address,
NULL); NULL);
g_byte_array_unref (hw_address);
} }
nm_connection_add_setting (c, (NMSetting *)sw); nm_connection_add_setting (c, (NMSetting *)sw);
@ -1115,7 +1093,6 @@ start_shared_connection (NetDeviceWifi *device_wifi)
nm_connection_add_setting (c, (NMSetting *)sip); nm_connection_add_setting (c, (NMSetting *)sip);
g_object_set (sw, "ssid", ssid, NULL); g_object_set (sw, "ssid", ssid, NULL);
g_bytes_unref (ssid);
sws = (NMSettingWirelessSecurity*) nm_setting_wireless_security_new (); sws = (NMSettingWirelessSecurity*) nm_setting_wireless_security_new ();
@ -1146,8 +1123,6 @@ start_shared_connection (NetDeviceWifi *device_wifi)
cancellable, cancellable,
activate_new_cb, activate_new_cb,
device_wifi); device_wifi);
g_object_unref (c);
} }
static void static void
@ -1479,18 +1454,15 @@ really_forgotten (GObject *source_object,
GAsyncResult *res, GAsyncResult *res,
gpointer user_data) gpointer user_data)
{ {
CcWifiConnectionList *list = user_data; g_autoptr(CcWifiConnectionList) list = user_data;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
cc_wifi_connection_list_thaw (list); cc_wifi_connection_list_thaw (list);
g_object_unref (list);
if (!nm_remote_connection_delete_finish (NM_REMOTE_CONNECTION (source_object), res, &error)) { if (!nm_remote_connection_delete_finish (NM_REMOTE_CONNECTION (source_object), res, &error))
g_warning ("failed to delete connection %s: %s", g_warning ("failed to delete connection %s: %s",
nm_object_get_path (NM_OBJECT (source_object)), nm_object_get_path (NM_OBJECT (source_object)),
error->message); error->message);
return;
}
} }
static void static void

View file

@ -287,7 +287,10 @@ static void
net_proxy_init (NetProxy *proxy) net_proxy_init (NetProxy *proxy)
{ {
GtkAdjustment *adjustment; GtkAdjustment *adjustment;
GSettings *settings_tmp; g_autoptr(GSettings) http_settings = NULL;
g_autoptr(GSettings) https_settings = NULL;
g_autoptr(GSettings) ftp_settings = NULL;
g_autoptr(GSettings) socks_settings = NULL;
ProxyMode value; ProxyMode value;
GtkWidget *widget; GtkWidget *widget;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
@ -321,60 +324,56 @@ net_proxy_init (NetProxy *proxy)
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
/* bind the HTTP proxy values */ /* bind the HTTP proxy values */
settings_tmp = g_settings_get_child (proxy->settings, "http"); http_settings = g_settings_get_child (proxy->settings, "http");
widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder, widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder,
"entry_proxy_http")); "entry_proxy_http"));
g_settings_bind (settings_tmp, "host", g_settings_bind (http_settings, "host",
widget, "text", widget, "text",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->builder, adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->builder,
"adjustment_proxy_port_http")); "adjustment_proxy_port_http"));
g_settings_bind (settings_tmp, "port", g_settings_bind (http_settings, "port",
adjustment, "value", adjustment, "value",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
g_object_unref (settings_tmp);
/* bind the HTTPS proxy values */ /* bind the HTTPS proxy values */
settings_tmp = g_settings_get_child (proxy->settings, "https"); https_settings = g_settings_get_child (proxy->settings, "https");
widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder, widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder,
"entry_proxy_https")); "entry_proxy_https"));
g_settings_bind (settings_tmp, "host", g_settings_bind (https_settings, "host",
widget, "text", widget, "text",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->builder, adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->builder,
"adjustment_proxy_port_https")); "adjustment_proxy_port_https"));
g_settings_bind (settings_tmp, "port", g_settings_bind (https_settings, "port",
adjustment, "value", adjustment, "value",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
g_object_unref (settings_tmp);
/* bind the FTP proxy values */ /* bind the FTP proxy values */
settings_tmp = g_settings_get_child (proxy->settings, "ftp"); ftp_settings = g_settings_get_child (proxy->settings, "ftp");
widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder, widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder,
"entry_proxy_ftp")); "entry_proxy_ftp"));
g_settings_bind (settings_tmp, "host", g_settings_bind (ftp_settings, "host",
widget, "text", widget, "text",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->builder, adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->builder,
"adjustment_proxy_port_ftp")); "adjustment_proxy_port_ftp"));
g_settings_bind (settings_tmp, "port", g_settings_bind (ftp_settings, "port",
adjustment, "value", adjustment, "value",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
g_object_unref (settings_tmp);
/* bind the SOCKS proxy values */ /* bind the SOCKS proxy values */
settings_tmp = g_settings_get_child (proxy->settings, "socks"); socks_settings = g_settings_get_child (proxy->settings, "socks");
widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder, widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder,
"entry_proxy_socks")); "entry_proxy_socks"));
g_settings_bind (settings_tmp, "host", g_settings_bind (socks_settings, "host",
widget, "text", widget, "text",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->builder, adjustment = GTK_ADJUSTMENT (gtk_builder_get_object (proxy->builder,
"adjustment_proxy_port_socks")); "adjustment_proxy_port_socks"));
g_settings_bind (settings_tmp, "port", g_settings_bind (socks_settings, "port",
adjustment, "value", adjustment, "value",
G_SETTINGS_BIND_DEFAULT); G_SETTINGS_BIND_DEFAULT);
g_object_unref (settings_tmp);
/* bind the proxy ignore hosts */ /* bind the proxy ignore hosts */
widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder, widget = GTK_WIDGET (gtk_builder_get_object (proxy->builder,

View file

@ -100,7 +100,8 @@ wireless_dialog_response_cb (GtkDialog *foo,
{ {
NMAWifiDialog *dialog = NMA_WIFI_DIALOG (foo); NMAWifiDialog *dialog = NMA_WIFI_DIALOG (foo);
WirelessDialogClosure *closure = user_data; WirelessDialogClosure *closure = user_data;
NMConnection *connection, *fuzzy_match = NULL; g_autoptr(NMConnection) connection = NULL;
NMConnection *fuzzy_match = NULL;
NMDevice *device; NMDevice *device;
NMAccessPoint *ap; NMAccessPoint *ap;
const GPtrArray *all; const GPtrArray *all;
@ -164,9 +165,6 @@ wireless_dialog_response_cb (GtkDialog *foo,
NULL); NULL);
} }
/* Balance nma_wifi_dialog_get_connection() */
g_object_unref (connection);
done: done:
gtk_widget_hide (GTK_WIDGET (dialog)); gtk_widget_hide (GTK_WIDGET (dialog));
gtk_widget_destroy (GTK_WIDGET (dialog)); gtk_widget_destroy (GTK_WIDGET (dialog));

View file

@ -56,7 +56,7 @@ validate (EAPMethod *parent, GError **error)
GtkWidget *widget; GtkWidget *widget;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
const char *file; const char *file;
gboolean provisioning; gboolean provisioning;
gboolean valid = TRUE; gboolean valid = TRUE;
@ -81,7 +81,6 @@ validate (EAPMethod *parent, GError **error)
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap); g_assert (eap);
valid = eap_method_validate (eap, valid ? error : NULL) && valid; valid = eap_method_validate (eap, valid ? error : NULL) && valid;
eap_method_unref (eap);
return valid; return valid;
} }
@ -92,7 +91,7 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
GtkWidget *widget; GtkWidget *widget;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap; g_autoptr(EAPMethod) eap = NULL;
if (method->size_group) if (method->size_group)
g_object_unref (method->size_group); g_object_unref (method->size_group);
@ -122,7 +121,6 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap); g_assert (eap);
eap_method_add_to_size_group (eap, group); eap_method_add_to_size_group (eap, group);
eap_method_unref (eap);
} }
static void static void
@ -132,7 +130,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
GtkWidget *widget; GtkWidget *widget;
const char *text; const char *text;
char *filename; char *filename;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
gboolean enabled; gboolean enabled;
@ -186,7 +184,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
g_assert (eap); g_assert (eap);
eap_method_fill_connection (eap, connection, flags); eap_method_fill_connection (eap, connection, flags);
eap_method_unref (eap);
} }
static void static void
@ -195,7 +192,7 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
EAPMethod *parent = (EAPMethod *) user_data; EAPMethod *parent = (EAPMethod *) user_data;
EAPMethodFAST *method = (EAPMethodFAST *) parent; EAPMethodFAST *method = (EAPMethodFAST *) parent;
GtkWidget *vbox; GtkWidget *vbox;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
GList *elt, *children; GList *elt, *children;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
@ -223,8 +220,6 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
eap_method_add_to_size_group (eap, method->size_group); eap_method_add_to_size_group (eap, method->size_group);
gtk_container_add (GTK_CONTAINER (vbox), eap_widget); gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
eap_method_unref (eap);
wireless_security_changed_cb (combo, method->sec_parent); wireless_security_changed_cb (combo, method->sec_parent);
} }
@ -236,10 +231,10 @@ inner_auth_combo_init (EAPMethodFAST *method,
{ {
EAPMethod *parent = (EAPMethod *) method; EAPMethod *parent = (EAPMethod *) method;
GtkWidget *combo; GtkWidget *combo;
GtkListStore *auth_model; g_autoptr(GtkListStore) auth_model = NULL;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethodSimple *em_gtc; g_autoptr(EAPMethodSimple) em_gtc = NULL;
EAPMethodSimple *em_mschap_v2; g_autoptr(EAPMethodSimple) em_mschap_v2 = NULL;
guint32 active = 0; guint32 active = 0;
const char *phase2_auth = NULL; const char *phase2_auth = NULL;
EAPMethodSimpleFlags simple_flags; EAPMethodSimpleFlags simple_flags;
@ -268,7 +263,6 @@ inner_auth_combo_init (EAPMethodFAST *method,
I_NAME_COLUMN, _("GTC"), I_NAME_COLUMN, _("GTC"),
I_METHOD_COLUMN, em_gtc, I_METHOD_COLUMN, em_gtc,
-1); -1);
eap_method_unref (EAP_METHOD (em_gtc));
/* Check for defaulting to GTC */ /* Check for defaulting to GTC */
if (phase2_auth && !strcasecmp (phase2_auth, "gtc")) if (phase2_auth && !strcasecmp (phase2_auth, "gtc"))
@ -283,7 +277,6 @@ inner_auth_combo_init (EAPMethodFAST *method,
I_NAME_COLUMN, _("MSCHAPv2"), I_NAME_COLUMN, _("MSCHAPv2"),
I_METHOD_COLUMN, em_mschap_v2, I_METHOD_COLUMN, em_mschap_v2,
-1); -1);
eap_method_unref (EAP_METHOD (em_mschap_v2));
/* Check for defaulting to MSCHAPv2 */ /* Check for defaulting to MSCHAPv2 */
if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2")) if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2"))
@ -293,7 +286,6 @@ inner_auth_combo_init (EAPMethodFAST *method,
g_assert (combo); g_assert (combo);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model));
g_object_unref (G_OBJECT (auth_model));
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active);
g_signal_connect (G_OBJECT (combo), "changed", g_signal_connect (G_OBJECT (combo), "changed",

View file

@ -32,5 +32,8 @@ EAPMethodFAST *eap_method_fast_new (WirelessSecurity *ws_parent,
gboolean is_editor, gboolean is_editor,
gboolean secrets_only); gboolean secrets_only);
static void eap_method_fast_unref (EAPMethodFAST *method) { eap_method_unref (EAP_METHOD (method)); }
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodFAST, eap_method_fast_unref)
#endif /* EAP_METHOD_FAST_H */ #endif /* EAP_METHOD_FAST_H */

View file

@ -31,5 +31,8 @@ EAPMethodLEAP *eap_method_leap_new (WirelessSecurity *ws_parent,
NMConnection *connection, NMConnection *connection,
gboolean secrets_only); gboolean secrets_only);
static void eap_method_leap_unref (EAPMethodLEAP *method) { eap_method_unref (EAP_METHOD (method)); }
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodLEAP, eap_method_leap_unref)
#endif /* EAP_METHOD_LEAP_H */ #endif /* EAP_METHOD_LEAP_H */

View file

@ -55,7 +55,7 @@ validate (EAPMethod *parent, GError **error)
GtkWidget *widget; GtkWidget *widget;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
gboolean valid = FALSE; gboolean valid = FALSE;
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
@ -76,7 +76,6 @@ validate (EAPMethod *parent, GError **error)
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap); g_assert (eap);
valid = eap_method_validate (eap, error); valid = eap_method_validate (eap, error);
eap_method_unref (eap);
return valid; return valid;
} }
@ -95,7 +94,7 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
GtkWidget *widget; GtkWidget *widget;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap; g_autoptr(EAPMethod) eap = NULL;
if (method->size_group) if (method->size_group)
g_object_unref (method->size_group); g_object_unref (method->size_group);
@ -129,7 +128,6 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap); g_assert (eap);
eap_method_add_to_size_group (eap, group); eap_method_add_to_size_group (eap, group);
eap_method_unref (eap);
} }
static void static void
@ -140,7 +138,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
GtkWidget *widget; GtkWidget *widget;
const char *text; const char *text;
g_autofree gchar *filename = NULL; g_autofree gchar *filename = NULL;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
int peapver_active = 0; int peapver_active = 0;
@ -188,7 +186,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
g_assert (eap); g_assert (eap);
eap_method_fill_connection (eap, connection, flags); eap_method_fill_connection (eap, connection, flags);
eap_method_unref (eap);
} }
static void static void
inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data) inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
@ -196,7 +193,7 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
EAPMethod *parent = (EAPMethod *) user_data; EAPMethod *parent = (EAPMethod *) user_data;
EAPMethodPEAP *method = (EAPMethodPEAP *) parent; EAPMethodPEAP *method = (EAPMethodPEAP *) parent;
GtkWidget *vbox; GtkWidget *vbox;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
GList *elt, *children; GList *elt, *children;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
@ -223,8 +220,6 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
eap_method_add_to_size_group (eap, method->size_group); eap_method_add_to_size_group (eap, method->size_group);
gtk_container_add (GTK_CONTAINER (vbox), eap_widget); gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
eap_method_unref (eap);
wireless_security_changed_cb (combo, method->sec_parent); wireless_security_changed_cb (combo, method->sec_parent);
} }
@ -236,11 +231,11 @@ inner_auth_combo_init (EAPMethodPEAP *method,
{ {
EAPMethod *parent = (EAPMethod *) method; EAPMethod *parent = (EAPMethod *) method;
GtkWidget *combo; GtkWidget *combo;
GtkListStore *auth_model; g_autoptr(GtkListStore) auth_model = NULL;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethodSimple *em_mschap_v2; g_autoptr(EAPMethodSimple) em_mschap_v2 = NULL;
EAPMethodSimple *em_md5; g_autoptr(EAPMethodSimple) em_md5 = NULL;
EAPMethodSimple *em_gtc; g_autoptr(EAPMethodSimple) em_gtc = NULL;
guint32 active = 0; guint32 active = 0;
const char *phase2_auth = NULL; const char *phase2_auth = NULL;
EAPMethodSimpleFlags simple_flags; EAPMethodSimpleFlags simple_flags;
@ -269,7 +264,6 @@ inner_auth_combo_init (EAPMethodPEAP *method,
I_NAME_COLUMN, _("MSCHAPv2"), I_NAME_COLUMN, _("MSCHAPv2"),
I_METHOD_COLUMN, em_mschap_v2, I_METHOD_COLUMN, em_mschap_v2,
-1); -1);
eap_method_unref (EAP_METHOD (em_mschap_v2));
/* Check for defaulting to MSCHAPv2 */ /* Check for defaulting to MSCHAPv2 */
if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2")) if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2"))
@ -284,7 +278,6 @@ inner_auth_combo_init (EAPMethodPEAP *method,
I_NAME_COLUMN, _("MD5"), I_NAME_COLUMN, _("MD5"),
I_METHOD_COLUMN, em_md5, I_METHOD_COLUMN, em_md5,
-1); -1);
eap_method_unref (EAP_METHOD (em_md5));
/* Check for defaulting to MD5 */ /* Check for defaulting to MD5 */
if (phase2_auth && !strcasecmp (phase2_auth, "md5")) if (phase2_auth && !strcasecmp (phase2_auth, "md5"))
@ -299,7 +292,6 @@ inner_auth_combo_init (EAPMethodPEAP *method,
I_NAME_COLUMN, _("GTC"), I_NAME_COLUMN, _("GTC"),
I_METHOD_COLUMN, em_gtc, I_METHOD_COLUMN, em_gtc,
-1); -1);
eap_method_unref (EAP_METHOD (em_gtc));
/* Check for defaulting to GTC */ /* Check for defaulting to GTC */
if (phase2_auth && !strcasecmp (phase2_auth, "gtc")) if (phase2_auth && !strcasecmp (phase2_auth, "gtc"))
@ -309,7 +301,6 @@ inner_auth_combo_init (EAPMethodPEAP *method,
g_assert (combo); g_assert (combo);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model));
g_object_unref (G_OBJECT (auth_model));
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active);
g_signal_connect (G_OBJECT (combo), "changed", g_signal_connect (G_OBJECT (combo), "changed",

View file

@ -32,5 +32,8 @@ EAPMethodPEAP *eap_method_peap_new (WirelessSecurity *ws_parent,
gboolean is_editor, gboolean is_editor,
gboolean secrets_only); gboolean secrets_only);
static void eap_method_peap_unref (EAPMethodPEAP *method) { eap_method_unref (EAP_METHOD (method)); }
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodPEAP, eap_method_peap_unref)
#endif /* EAP_METHOD_PEAP_H */ #endif /* EAP_METHOD_PEAP_H */

View file

@ -59,5 +59,8 @@ EAPMethodSimple *eap_method_simple_new (WirelessSecurity *ws_parent,
EAPMethodSimpleType type, EAPMethodSimpleType type,
EAPMethodSimpleFlags flags); EAPMethodSimpleFlags flags);
static void eap_method_simple_unref (EAPMethodSimple *method) { eap_method_unref (EAP_METHOD (method)); }
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodSimple, eap_method_simple_unref)
#endif /* EAP_METHOD_SIMPLE_H */ #endif /* EAP_METHOD_SIMPLE_H */

View file

@ -262,7 +262,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
static void static void
private_key_picker_helper (EAPMethod *parent, const char *filename, gboolean changed) private_key_picker_helper (EAPMethod *parent, const char *filename, gboolean changed)
{ {
NMSetting8021x *setting; g_autoptr(NMSetting8021x) setting = NULL;
NMSetting8021xCKFormat cert_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN; NMSetting8021xCKFormat cert_format = NM_SETTING_802_1X_CK_FORMAT_UNKNOWN;
const char *password; const char *password;
GtkWidget *widget; GtkWidget *widget;
@ -273,7 +273,6 @@ private_key_picker_helper (EAPMethod *parent, const char *filename, gboolean cha
setting = (NMSetting8021x *) nm_setting_802_1x_new (); setting = (NMSetting8021x *) nm_setting_802_1x_new ();
nm_setting_802_1x_set_private_key (setting, filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &cert_format, NULL); nm_setting_802_1x_set_private_key (setting, filename, password, NM_SETTING_802_1X_CK_SCHEME_PATH, &cert_format, NULL);
g_object_unref (setting);
/* With PKCS#12, the client cert must be the same as the private key */ /* With PKCS#12, the client cert must be the same as the private key */
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_user_cert_button")); widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_user_cert_button"));

View file

@ -32,5 +32,8 @@ EAPMethodTLS *eap_method_tls_new (WirelessSecurity *ws_parent,
gboolean phase2, gboolean phase2,
gboolean secrets_only); gboolean secrets_only);
static void eap_method_tls_unref (EAPMethodTLS *method) { eap_method_unref (EAP_METHOD (method)); }
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodTLS, eap_method_tls_unref)
#endif /* EAP_METHOD_TLS_H */ #endif /* EAP_METHOD_TLS_H */

View file

@ -55,7 +55,7 @@ validate (EAPMethod *parent, GError **error)
GtkWidget *widget; GtkWidget *widget;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
gboolean valid = FALSE; gboolean valid = FALSE;
g_autoptr(GError) local_error = NULL; g_autoptr(GError) local_error = NULL;
@ -76,7 +76,6 @@ validate (EAPMethod *parent, GError **error)
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap); g_assert (eap);
valid = eap_method_validate (eap, error); valid = eap_method_validate (eap, error);
eap_method_unref (eap);
return valid; return valid;
} }
@ -95,7 +94,7 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
GtkWidget *widget; GtkWidget *widget;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap; g_autoptr(EAPMethod) eap = NULL;
if (method->size_group) if (method->size_group)
g_object_unref (method->size_group); g_object_unref (method->size_group);
@ -129,7 +128,6 @@ add_to_size_group (EAPMethod *parent, GtkSizeGroup *group)
gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, I_METHOD_COLUMN, &eap, -1);
g_assert (eap); g_assert (eap);
eap_method_add_to_size_group (eap, group); eap_method_add_to_size_group (eap, group);
eap_method_unref (eap);
} }
static void static void
@ -140,7 +138,7 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
GtkWidget *widget; GtkWidget *widget;
const char *text; const char *text;
g_autofree gchar *filename = NULL; g_autofree gchar *filename = NULL;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
@ -179,7 +177,6 @@ fill_connection (EAPMethod *parent, NMConnection *connection, NMSettingSecretFla
g_assert (eap); g_assert (eap);
eap_method_fill_connection (eap, connection, flags); eap_method_fill_connection (eap, connection, flags);
eap_method_unref (eap);
} }
static void static void
@ -188,7 +185,7 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
EAPMethod *parent = (EAPMethod *) user_data; EAPMethod *parent = (EAPMethod *) user_data;
EAPMethodTTLS *method = (EAPMethodTTLS *) parent; EAPMethodTTLS *method = (EAPMethodTTLS *) parent;
GtkWidget *vbox; GtkWidget *vbox;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
GList *elt, *children; GList *elt, *children;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
@ -216,8 +213,6 @@ inner_auth_combo_changed_cb (GtkWidget *combo, gpointer user_data)
eap_method_add_to_size_group (eap, method->size_group); eap_method_add_to_size_group (eap, method->size_group);
gtk_container_add (GTK_CONTAINER (vbox), eap_widget); gtk_container_add (GTK_CONTAINER (vbox), eap_widget);
eap_method_unref (eap);
wireless_security_changed_cb (combo, method->sec_parent); wireless_security_changed_cb (combo, method->sec_parent);
} }
@ -229,15 +224,15 @@ inner_auth_combo_init (EAPMethodTTLS *method,
{ {
EAPMethod *parent = (EAPMethod *) method; EAPMethod *parent = (EAPMethod *) method;
GtkWidget *combo; GtkWidget *combo;
GtkListStore *auth_model; g_autoptr(GtkListStore) auth_model = NULL;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethodSimple *em_pap; g_autoptr(EAPMethodSimple) em_pap = NULL;
EAPMethodSimple *em_mschap; g_autoptr(EAPMethodSimple) em_mschap = NULL;
EAPMethodSimple *em_mschap_v2; g_autoptr(EAPMethodSimple) em_mschap_v2 = NULL;
EAPMethodSimple *em_plain_mschap_v2; g_autoptr(EAPMethodSimple) em_plain_mschap_v2 = NULL;
EAPMethodSimple *em_chap; g_autoptr(EAPMethodSimple) em_chap = NULL;
EAPMethodSimple *em_md5; g_autoptr(EAPMethodSimple) em_md5 = NULL;
EAPMethodSimple *em_gtc; g_autoptr(EAPMethodSimple) em_gtc = NULL;
guint32 active = 0; guint32 active = 0;
const char *phase2_auth = NULL; const char *phase2_auth = NULL;
EAPMethodSimpleFlags simple_flags; EAPMethodSimpleFlags simple_flags;
@ -266,7 +261,6 @@ inner_auth_combo_init (EAPMethodTTLS *method,
I_NAME_COLUMN, _("PAP"), I_NAME_COLUMN, _("PAP"),
I_METHOD_COLUMN, em_pap, I_METHOD_COLUMN, em_pap,
-1); -1);
eap_method_unref (EAP_METHOD (em_pap));
/* Check for defaulting to PAP */ /* Check for defaulting to PAP */
if (phase2_auth && !strcasecmp (phase2_auth, "pap")) if (phase2_auth && !strcasecmp (phase2_auth, "pap"))
@ -281,7 +275,6 @@ inner_auth_combo_init (EAPMethodTTLS *method,
I_NAME_COLUMN, _("MSCHAP"), I_NAME_COLUMN, _("MSCHAP"),
I_METHOD_COLUMN, em_mschap, I_METHOD_COLUMN, em_mschap,
-1); -1);
eap_method_unref (EAP_METHOD (em_mschap));
/* Check for defaulting to MSCHAP */ /* Check for defaulting to MSCHAP */
if (phase2_auth && !strcasecmp (phase2_auth, "mschap")) if (phase2_auth && !strcasecmp (phase2_auth, "mschap"))
@ -296,7 +289,6 @@ inner_auth_combo_init (EAPMethodTTLS *method,
I_NAME_COLUMN, _("MSCHAPv2"), I_NAME_COLUMN, _("MSCHAPv2"),
I_METHOD_COLUMN, em_mschap_v2, I_METHOD_COLUMN, em_mschap_v2,
-1); -1);
eap_method_unref (EAP_METHOD (em_mschap_v2));
/* Check for defaulting to MSCHAPv2 */ /* Check for defaulting to MSCHAPv2 */
if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2") && if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2") &&
@ -312,7 +304,6 @@ inner_auth_combo_init (EAPMethodTTLS *method,
I_NAME_COLUMN, _("MSCHAPv2 (no EAP)"), I_NAME_COLUMN, _("MSCHAPv2 (no EAP)"),
I_METHOD_COLUMN, em_plain_mschap_v2, I_METHOD_COLUMN, em_plain_mschap_v2,
-1); -1);
eap_method_unref (EAP_METHOD (em_plain_mschap_v2));
/* Check for defaulting to plain MSCHAPv2 */ /* Check for defaulting to plain MSCHAPv2 */
if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2") && if (phase2_auth && !strcasecmp (phase2_auth, "mschapv2") &&
@ -328,7 +319,6 @@ inner_auth_combo_init (EAPMethodTTLS *method,
I_NAME_COLUMN, _("CHAP"), I_NAME_COLUMN, _("CHAP"),
I_METHOD_COLUMN, em_chap, I_METHOD_COLUMN, em_chap,
-1); -1);
eap_method_unref (EAP_METHOD (em_chap));
/* Check for defaulting to CHAP */ /* Check for defaulting to CHAP */
if (phase2_auth && !strcasecmp (phase2_auth, "chap")) if (phase2_auth && !strcasecmp (phase2_auth, "chap"))
@ -343,7 +333,6 @@ inner_auth_combo_init (EAPMethodTTLS *method,
I_NAME_COLUMN, _("MD5"), I_NAME_COLUMN, _("MD5"),
I_METHOD_COLUMN, em_md5, I_METHOD_COLUMN, em_md5,
-1); -1);
eap_method_unref (EAP_METHOD (em_md5));
/* Check for defaulting to MD5 */ /* Check for defaulting to MD5 */
if (phase2_auth && !strcasecmp (phase2_auth, "md5")) if (phase2_auth && !strcasecmp (phase2_auth, "md5"))
@ -358,7 +347,6 @@ inner_auth_combo_init (EAPMethodTTLS *method,
I_NAME_COLUMN, _("GTC"), I_NAME_COLUMN, _("GTC"),
I_METHOD_COLUMN, em_gtc, I_METHOD_COLUMN, em_gtc,
-1); -1);
eap_method_unref (EAP_METHOD (em_gtc));
/* Check for defaulting to GTC */ /* Check for defaulting to GTC */
if (phase2_auth && !strcasecmp (phase2_auth, "gtc")) if (phase2_auth && !strcasecmp (phase2_auth, "gtc"))
@ -368,7 +356,6 @@ inner_auth_combo_init (EAPMethodTTLS *method,
g_assert (combo); g_assert (combo);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model));
g_object_unref (G_OBJECT (auth_model));
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active);
g_signal_connect (G_OBJECT (combo), "changed", g_signal_connect (G_OBJECT (combo), "changed",

View file

@ -32,5 +32,8 @@ EAPMethodTTLS *eap_method_ttls_new (WirelessSecurity *ws_parent,
gboolean is_editor, gboolean is_editor,
gboolean secrets_only); gboolean secrets_only);
#endif /* EAP_METHOD_TLS_H */ static void eap_method_ttls_unref (EAPMethodTTLS *method) { eap_method_unref (EAP_METHOD (method)); }
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethodTTLS, eap_method_ttls_unref)
#endif /* EAP_METHOD_TTLS_H */

View file

@ -122,13 +122,11 @@ eap_method_phase2_update_secrets_helper (EAPMethod *method,
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo)); model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo));
if (gtk_tree_model_get_iter_first (model, &iter)) { if (gtk_tree_model_get_iter_first (model, &iter)) {
do { do {
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
gtk_tree_model_get (model, &iter, column, &eap, -1); gtk_tree_model_get (model, &iter, column, &eap, -1);
if (eap) { if (eap)
eap_method_update_secrets (eap, connection); eap_method_update_secrets (eap, connection);
eap_method_unref (eap);
}
} while (gtk_tree_model_iter_next (model, &iter)); } while (gtk_tree_model_iter_next (model, &iter));
} }
} }
@ -145,7 +143,7 @@ eap_method_init (gsize obj_size,
const char *default_field, const char *default_field,
gboolean phase2) gboolean phase2)
{ {
EAPMethod *method; g_autoptr(EAPMethod) method = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_return_val_if_fail (obj_size > 0, NULL); g_return_val_if_fail (obj_size > 0, NULL);
@ -168,7 +166,6 @@ eap_method_init (gsize obj_size,
if (!gtk_builder_add_from_resource (method->builder, ui_resource, &error)) { if (!gtk_builder_add_from_resource (method->builder, ui_resource, &error)) {
g_warning ("Couldn't load UI builder resource %s: %s", g_warning ("Couldn't load UI builder resource %s: %s",
ui_resource, error->message); ui_resource, error->message);
eap_method_unref (method);
return NULL; return NULL;
} }
@ -176,14 +173,13 @@ eap_method_init (gsize obj_size,
if (!method->ui_widget) { if (!method->ui_widget) {
g_warning ("Couldn't load UI widget '%s' from UI file %s", g_warning ("Couldn't load UI widget '%s' from UI file %s",
ui_widget_name, ui_resource); ui_widget_name, ui_resource);
eap_method_unref (method);
return NULL; return NULL;
} }
g_object_ref_sink (method->ui_widget); g_object_ref_sink (method->ui_widget);
method->destroy = destroy; method->destroy = destroy;
return method; return g_steal_pointer (&method);
} }
@ -227,7 +223,7 @@ eap_method_validate_filepicker (GtkBuilder *builder,
{ {
GtkWidget *widget; GtkWidget *widget;
g_autofree gchar *filename = NULL; g_autofree gchar *filename = NULL;
NMSetting8021x *setting; g_autoptr(NMSetting8021x) setting = NULL;
gboolean success = TRUE; gboolean success = TRUE;
if (item_type == TYPE_PRIVATE_KEY) { if (item_type == TYPE_PRIVATE_KEY) {
@ -266,8 +262,6 @@ eap_method_validate_filepicker (GtkBuilder *builder,
} else } else
g_warning ("%s: invalid item type %d.", __func__, item_type); g_warning ("%s: invalid item type %d.", __func__, item_type);
g_object_unref (setting);
out: out:
if (!success && error && !*error) if (!success && error && !*error)
g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("unspecified error validating eap-method file")); g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("unspecified error validating eap-method file"));
@ -624,7 +618,7 @@ void
eap_method_ca_cert_ignore_save (NMConnection *connection) eap_method_ca_cert_ignore_save (NMConnection *connection)
{ {
NMSetting8021x *s_8021x; NMSetting8021x *s_8021x;
GSettings *settings; g_autoptr(GSettings) settings = NULL;
gboolean ignore = FALSE, phase2_ignore = FALSE; gboolean ignore = FALSE, phase2_ignore = FALSE;
g_return_if_fail (connection); g_return_if_fail (connection);
@ -641,7 +635,6 @@ eap_method_ca_cert_ignore_save (NMConnection *connection)
g_settings_set_boolean (settings, IGNORE_CA_CERT_TAG, ignore); g_settings_set_boolean (settings, IGNORE_CA_CERT_TAG, ignore);
g_settings_set_boolean (settings, IGNORE_PHASE2_CA_CERT_TAG, phase2_ignore); g_settings_set_boolean (settings, IGNORE_PHASE2_CA_CERT_TAG, phase2_ignore);
g_object_unref (settings);
} }
/** /**
@ -654,7 +647,7 @@ eap_method_ca_cert_ignore_save (NMConnection *connection)
void void
eap_method_ca_cert_ignore_load (NMConnection *connection) eap_method_ca_cert_ignore_load (NMConnection *connection)
{ {
GSettings *settings; g_autoptr(GSettings) settings = NULL;
NMSetting8021x *s_8021x; NMSetting8021x *s_8021x;
gboolean ignore, phase2_ignore; gboolean ignore, phase2_ignore;
@ -677,6 +670,5 @@ eap_method_ca_cert_ignore_load (NMConnection *connection)
g_object_set_data (G_OBJECT (s_8021x), g_object_set_data (G_OBJECT (s_8021x),
IGNORE_PHASE2_CA_CERT_TAG, IGNORE_PHASE2_CA_CERT_TAG,
GUINT_TO_POINTER (phase2_ignore)); GUINT_TO_POINTER (phase2_ignore));
g_object_unref (settings);
} }

View file

@ -130,4 +130,6 @@ gboolean eap_method_ca_cert_ignore_get (EAPMethod *method, NMConnection *connect
void eap_method_ca_cert_ignore_save (NMConnection *connection); void eap_method_ca_cert_ignore_save (NMConnection *connection);
void eap_method_ca_cert_ignore_load (NMConnection *connection); void eap_method_ca_cert_ignore_load (NMConnection *connection);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EAPMethod, eap_method_unref)
#endif /* EAP_METHOD_H */ #endif /* EAP_METHOD_H */

View file

@ -165,7 +165,7 @@ wireless_security_init (gsize obj_size,
const char *ui_widget_name, const char *ui_widget_name,
const char *default_field) const char *default_field)
{ {
WirelessSecurity *sec; g_autoptr(WirelessSecurity) sec = NULL;
g_autoptr(GError) error = NULL; g_autoptr(GError) error = NULL;
g_return_val_if_fail (obj_size > 0, NULL); g_return_val_if_fail (obj_size > 0, NULL);
@ -190,7 +190,6 @@ wireless_security_init (gsize obj_size,
if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) { if (!gtk_builder_add_from_resource (sec->builder, ui_resource, &error)) {
g_warning ("Couldn't load UI builder resource %s: %s", g_warning ("Couldn't load UI builder resource %s: %s",
ui_resource, error->message); ui_resource, error->message);
wireless_security_unref (sec);
return NULL; return NULL;
} }
@ -198,7 +197,6 @@ wireless_security_init (gsize obj_size,
if (!sec->ui_widget) { if (!sec->ui_widget) {
g_warning ("Couldn't load UI widget '%s' from UI file %s", g_warning ("Couldn't load UI widget '%s' from UI file %s",
ui_widget_name, ui_resource); ui_widget_name, ui_resource);
wireless_security_unref (sec);
return NULL; return NULL;
} }
g_object_ref_sink (sec->ui_widget); g_object_ref_sink (sec->ui_widget);
@ -207,7 +205,7 @@ wireless_security_init (gsize obj_size,
sec->adhoc_compatible = TRUE; sec->adhoc_compatible = TRUE;
sec->hotspot_compatible = TRUE; sec->hotspot_compatible = TRUE;
return sec; return g_steal_pointer (&sec);
} }
gboolean gboolean
@ -297,7 +295,7 @@ ws_802_1x_add_to_size_group (WirelessSecurity *sec,
GtkWidget *widget; GtkWidget *widget;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap; g_autoptr(EAPMethod) eap = NULL;
widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, label_name)); widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, label_name));
g_assert (widget); g_assert (widget);
@ -311,7 +309,6 @@ ws_802_1x_add_to_size_group (WirelessSecurity *sec,
gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
g_assert (eap); g_assert (eap);
eap_method_add_to_size_group (eap, size_group); eap_method_add_to_size_group (eap, size_group);
eap_method_unref (eap);
} }
gboolean gboolean
@ -320,7 +317,7 @@ ws_802_1x_validate (WirelessSecurity *sec, const char *combo_name, GError **erro
GtkWidget *widget; GtkWidget *widget;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
gboolean valid = FALSE; gboolean valid = FALSE;
widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name)); widget = GTK_WIDGET (gtk_builder_get_object (sec->builder, combo_name));
@ -331,7 +328,6 @@ ws_802_1x_validate (WirelessSecurity *sec, const char *combo_name, GError **erro
gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
g_assert (eap); g_assert (eap);
valid = eap_method_validate (eap, error); valid = eap_method_validate (eap, error);
eap_method_unref (eap);
return valid; return valid;
} }
@ -342,7 +338,7 @@ ws_802_1x_auth_combo_changed (GtkWidget *combo,
GtkSizeGroup *size_group) GtkSizeGroup *size_group)
{ {
GtkWidget *vbox; GtkWidget *vbox;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
GList *elt, *children; GList *elt, *children;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
@ -377,8 +373,6 @@ ws_802_1x_auth_combo_changed (GtkWidget *combo,
gtk_widget_grab_focus (eap_default_widget); gtk_widget_grab_focus (eap_default_widget);
} }
eap_method_unref (eap);
wireless_security_changed_cb (combo, WIRELESS_SECURITY (sec)); wireless_security_changed_cb (combo, WIRELESS_SECURITY (sec));
} }
@ -392,15 +386,13 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
gboolean secrets_only) gboolean secrets_only)
{ {
GtkWidget *combo, *widget; GtkWidget *combo, *widget;
GtkListStore *auth_model; g_autoptr(GtkListStore) auth_model = NULL;
GtkTreeIter iter; GtkTreeIter iter;
EAPMethodSimple *em_md5; g_autoptr(EAPMethodTLS) em_tls = NULL;
EAPMethodTLS *em_tls; g_autoptr(EAPMethodSimple) em_pwd = NULL;
EAPMethodLEAP *em_leap; g_autoptr(EAPMethodFAST) em_fast = NULL;
EAPMethodSimple *em_pwd; g_autoptr(EAPMethodTTLS) em_ttls = NULL;
EAPMethodFAST *em_fast; g_autoptr(EAPMethodPEAP) em_peap = NULL;
EAPMethodTTLS *em_ttls;
EAPMethodPEAP *em_peap;
const char *default_method = NULL, *ctype = NULL; const char *default_method = NULL, *ctype = NULL;
int active = -1, item = 0; int active = -1, item = 0;
gboolean wired = FALSE; gboolean wired = FALSE;
@ -434,13 +426,14 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY; simple_flags |= EAP_METHOD_SIMPLE_FLAG_SECRETS_ONLY;
if (wired) { if (wired) {
g_autoptr(EAPMethodSimple) em_md5 = NULL;
em_md5 = eap_method_simple_new (sec, connection, EAP_METHOD_SIMPLE_TYPE_MD5, simple_flags); em_md5 = eap_method_simple_new (sec, connection, EAP_METHOD_SIMPLE_TYPE_MD5, simple_flags);
gtk_list_store_append (auth_model, &iter); gtk_list_store_append (auth_model, &iter);
gtk_list_store_set (auth_model, &iter, gtk_list_store_set (auth_model, &iter,
AUTH_NAME_COLUMN, _("MD5"), AUTH_NAME_COLUMN, _("MD5"),
AUTH_METHOD_COLUMN, em_md5, AUTH_METHOD_COLUMN, em_md5,
-1); -1);
eap_method_unref (EAP_METHOD (em_md5));
if (default_method && (active < 0) && !strcmp (default_method, "md5")) if (default_method && (active < 0) && !strcmp (default_method, "md5"))
active = item; active = item;
item++; item++;
@ -452,19 +445,19 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
AUTH_NAME_COLUMN, _("TLS"), AUTH_NAME_COLUMN, _("TLS"),
AUTH_METHOD_COLUMN, em_tls, AUTH_METHOD_COLUMN, em_tls,
-1); -1);
eap_method_unref (EAP_METHOD (em_tls));
if (default_method && (active < 0) && !strcmp (default_method, "tls")) if (default_method && (active < 0) && !strcmp (default_method, "tls"))
active = item; active = item;
item++; item++;
if (!wired) { if (!wired) {
g_autoptr(EAPMethodLEAP) em_leap = NULL;
em_leap = eap_method_leap_new (sec, connection, secrets_only); em_leap = eap_method_leap_new (sec, connection, secrets_only);
gtk_list_store_append (auth_model, &iter); gtk_list_store_append (auth_model, &iter);
gtk_list_store_set (auth_model, &iter, gtk_list_store_set (auth_model, &iter,
AUTH_NAME_COLUMN, _("LEAP"), AUTH_NAME_COLUMN, _("LEAP"),
AUTH_METHOD_COLUMN, em_leap, AUTH_METHOD_COLUMN, em_leap,
-1); -1);
eap_method_unref (EAP_METHOD (em_leap));
if (default_method && (active < 0) && !strcmp (default_method, "leap")) if (default_method && (active < 0) && !strcmp (default_method, "leap"))
active = item; active = item;
item++; item++;
@ -476,7 +469,6 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
AUTH_NAME_COLUMN, _("PWD"), AUTH_NAME_COLUMN, _("PWD"),
AUTH_METHOD_COLUMN, em_pwd, AUTH_METHOD_COLUMN, em_pwd,
-1); -1);
eap_method_unref (EAP_METHOD (em_pwd));
if (default_method && (active < 0) && !strcmp (default_method, "pwd")) if (default_method && (active < 0) && !strcmp (default_method, "pwd"))
active = item; active = item;
item++; item++;
@ -487,7 +479,6 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
AUTH_NAME_COLUMN, _("FAST"), AUTH_NAME_COLUMN, _("FAST"),
AUTH_METHOD_COLUMN, em_fast, AUTH_METHOD_COLUMN, em_fast,
-1); -1);
eap_method_unref (EAP_METHOD (em_fast));
if (default_method && (active < 0) && !strcmp (default_method, "fast")) if (default_method && (active < 0) && !strcmp (default_method, "fast"))
active = item; active = item;
item++; item++;
@ -498,7 +489,6 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
AUTH_NAME_COLUMN, _("Tunneled TLS"), AUTH_NAME_COLUMN, _("Tunneled TLS"),
AUTH_METHOD_COLUMN, em_ttls, AUTH_METHOD_COLUMN, em_ttls,
-1); -1);
eap_method_unref (EAP_METHOD (em_ttls));
if (default_method && (active < 0) && !strcmp (default_method, "ttls")) if (default_method && (active < 0) && !strcmp (default_method, "ttls"))
active = item; active = item;
item++; item++;
@ -509,7 +499,6 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
AUTH_NAME_COLUMN, _("Protected EAP (PEAP)"), AUTH_NAME_COLUMN, _("Protected EAP (PEAP)"),
AUTH_METHOD_COLUMN, em_peap, AUTH_METHOD_COLUMN, em_peap,
-1); -1);
eap_method_unref (EAP_METHOD (em_peap));
if (default_method && (active < 0) && !strcmp (default_method, "peap")) if (default_method && (active < 0) && !strcmp (default_method, "peap"))
active = item; active = item;
item++; item++;
@ -518,7 +507,6 @@ ws_802_1x_auth_combo_init (WirelessSecurity *sec,
g_assert (combo); g_assert (combo);
gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model)); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (auth_model));
g_object_unref (G_OBJECT (auth_model));
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active < 0 ? 0 : (guint32) active); gtk_combo_box_set_active (GTK_COMBO_BOX (combo), active < 0 ? 0 : (guint32) active);
g_signal_connect (G_OBJECT (combo), "changed", auth_combo_changed_cb, sec); g_signal_connect (G_OBJECT (combo), "changed", auth_combo_changed_cb, sec);
@ -541,7 +529,7 @@ ws_802_1x_fill_connection (WirelessSecurity *sec,
NMSettingWirelessSecurity *s_wireless_sec; NMSettingWirelessSecurity *s_wireless_sec;
NMSetting8021x *s_8021x; NMSetting8021x *s_8021x;
NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE; NMSettingSecretFlags secret_flags = NM_SETTING_SECRET_FLAG_NONE;
EAPMethod *eap = NULL; g_autoptr(EAPMethod) eap = NULL;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
@ -568,7 +556,6 @@ ws_802_1x_fill_connection (WirelessSecurity *sec,
nm_connection_add_setting (connection, (NMSetting *) s_8021x); nm_connection_add_setting (connection, (NMSetting *) s_8021x);
eap_method_fill_connection (eap, connection, secret_flags); eap_method_fill_connection (eap, connection, secret_flags);
eap_method_unref (eap);
} }
void void
@ -577,7 +564,6 @@ ws_802_1x_update_secrets (WirelessSecurity *sec,
NMConnection *connection) NMConnection *connection)
{ {
GtkWidget *widget; GtkWidget *widget;
EAPMethod *eap = NULL;
GtkTreeModel *model; GtkTreeModel *model;
GtkTreeIter iter; GtkTreeIter iter;
@ -592,11 +578,11 @@ ws_802_1x_update_secrets (WirelessSecurity *sec,
/* Let each EAP method try to update its secrets */ /* Let each EAP method try to update its secrets */
if (gtk_tree_model_get_iter_first (model, &iter)) { if (gtk_tree_model_get_iter_first (model, &iter)) {
do { do {
g_autoptr(EAPMethod) eap = NULL;
gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1); gtk_tree_model_get (model, &iter, AUTH_METHOD_COLUMN, &eap, -1);
if (eap) { if (eap)
eap_method_update_secrets (eap, connection); eap_method_update_secrets (eap, connection);
eap_method_unref (eap);
}
} while (gtk_tree_model_iter_next (model, &iter)); } while (gtk_tree_model_iter_next (model, &iter));
} }
} }

View file

@ -150,5 +150,7 @@ void ws_802_1x_update_secrets (WirelessSecurity *sec,
const char *combo_name, const char *combo_name,
NMConnection *connection); NMConnection *connection);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WirelessSecurity, wireless_security_unref)
#endif /* WIRELESS_SECURITY_H */ #endif /* WIRELESS_SECURITY_H */