static gboolean handle_arguments (NMConnectionList *list, const char *type, gboolean create, gboolean show, const char *edit_uuid, gboolean quit_after) { gboolean show_list = TRUE; GType ctype; /* Grab type to create or show */ ctype = nm_connection_lookup_setting_type (type ? type : NM_SETTING_WIRED_SETTING_NAME); if (ctype == 0) { g_warning ("Unknown connection type '%s'", type); return TRUE; } if (show) { /* Just show the given connection type page */ nm_connection_list_set_type (list, ctype); } else if (create) { if (!type) { g_warning ("'create' requested but no connection type given."); return TRUE; } nm_connection_list_create (list, ctype); show_list = FALSE; } else if (edit_uuid) { /* Show the edit dialog for the given UUID */ nm_connection_list_edit (list, edit_uuid); show_list = FALSE; } /* If only editing a single connection, exit when done with that connection */ if (show_list == FALSE && quit_after == TRUE) g_signal_connect_swapped (list, "editing-done", G_CALLBACK (g_main_loop_quit), loop); return show_list; }
static gboolean handle_arguments (NMConnectionList *list, const char *type, gboolean create, gboolean show, const char *edit_uuid, gboolean quit_after) { gboolean show_list = TRUE; GType ctype; char *type_tmp = NULL; const char *p, *detail = NULL; if (type) { p = strchr (type, ':'); if (p) { type = type_tmp = g_strndup (type, p - type); detail = p + 1; } } else type = NM_SETTING_WIRED_SETTING_NAME; /* Grab type to create or show */ ctype = nm_connection_lookup_setting_type (type); if (ctype == 0) { g_warning ("Unknown connection type '%s'", type); g_free (type_tmp); return TRUE; } if (show) { /* Just show the given connection type page */ nm_connection_list_set_type (list, ctype); } else if (create) { if (!type) { g_warning ("'create' requested but no connection type given."); g_free (type_tmp); return TRUE; } /* If type is "vpn" and the user cancels the "vpn type" dialog, we need * to quit. But we haven't even started yet. So postpone this to an idle. */ g_idle_add (idle_create_connection, list); g_object_set_data (G_OBJECT (list), "nm-connection-editor-ctype", GUINT_TO_POINTER (ctype)); g_object_set_data_full (G_OBJECT (list), "nm-connection-editor-detail", g_strdup (detail), g_free); show_list = FALSE; } else if (edit_uuid) { /* Show the edit dialog for the given UUID */ nm_connection_list_edit (list, edit_uuid); show_list = FALSE; } /* If only editing a single connection, exit when done with that connection */ if (show_list == FALSE && quit_after == TRUE) g_signal_connect_swapped (list, "editing-done", G_CALLBACK (g_main_loop_quit), loop); g_free (type_tmp); return show_list; }
static gboolean handle_arguments (NMConnectionList *list, const char *type, gboolean create, gboolean show, const char *edit_uuid, const char *import, gboolean quit_after) { gboolean show_list = TRUE; GType ctype = 0; gs_free char *type_tmp = NULL; const char *p, *detail = NULL; CreateConnectionInfo *info; if (type) { p = strchr (type, ':'); if (p) { type = type_tmp = g_strndup (type, p - type); detail = p + 1; } ctype = nm_setting_lookup_type (type); if (ctype == 0 && !p) { gs_free char *service_type = NULL; /* allow using the VPN name directly, without "vpn:" prefix. */ service_type = nm_vpn_plugin_info_list_find_service_type (vpn_get_plugin_infos (), type); if (service_type) { ctype = NM_TYPE_SETTING_VPN; detail = type; } } if (ctype == 0) { g_warning ("Unknown connection type '%s'", type); return TRUE; } } if (show) { /* Just show the given connection type page */ nm_connection_list_set_type (list, ctype); } else if (create || import) { /* If type is "vpn" and the user cancels the "vpn type" dialog, we need * to quit. But we haven't even started yet. So postpone this to an idle. */ info = g_slice_new0 (CreateConnectionInfo); info->list = g_object_ref (list); info->create = create; info->detail = g_strdup (detail); if (create) info->ctype = ctype; else { info->ctype = NM_TYPE_SETTING_VPN; info->connection = vpn_connection_from_file (import); } g_idle_add (idle_create_connection, info); show_list = FALSE; } else if (edit_uuid) { /* Show the edit dialog for the given UUID */ nm_connection_list_edit (list, edit_uuid); show_list = FALSE; } /* If only editing a single connection, exit when done with that connection */ if (show_list == FALSE && quit_after == TRUE) g_signal_connect_swapped (list, "editing-done", G_CALLBACK (g_main_loop_quit), loop); return show_list; }