diff options
Diffstat (limited to 'clients/tui')
34 files changed, 165 insertions, 113 deletions
diff --git a/clients/tui/meson.build b/clients/tui/meson.build new file mode 100644 index 00000000..40eb4b4a --- /dev/null +++ b/clients/tui/meson.build @@ -0,0 +1,72 @@ +name = 'nmtui' + +deps = [ + newt_dep, + nm_core_dep +] + +cflags = clients_cflags + [ + '-DG_LOG_DOMAIN="@0@"'.format(name), + '-DNMLOCALEDIR="@0@"'.format(nm_localedir) +] + +subdir('newt') + +sources = files( + 'nm-editor-bindings.c', + 'nm-editor-utils.c', + 'nmt-address-list.c', + 'nmt-connect-connection-list.c', + 'nmt-device-entry.c', + 'nmt-edit-connection-list.c', + 'nmt-editor.c', + 'nmt-editor-grid.c', + 'nmt-editor-page.c', + 'nmt-editor-page-device.c', + 'nmt-editor-section.c', + 'nmt-ip-entry.c', + 'nmt-mac-entry.c', + 'nmt-mtu-entry.c', + 'nmt-page-bond.c', + 'nmt-page-bridge.c', + 'nmt-page-bridge-port.c', + 'nmt-page-dsl.c', + 'nmt-page-ethernet.c', + 'nmt-page-infiniband.c', + 'nmt-page-ip4.c', + 'nmt-page-ip6.c', + 'nmt-page-ip-tunnel.c', + 'nmt-page-ppp.c', + 'nmt-page-team.c', + 'nmt-page-team-port.c', + 'nmt-page-vlan.c', + 'nmt-page-wifi.c', + 'nmt-password-dialog.c', + 'nmt-password-fields.c', + 'nmt-route-editor.c', + 'nmt-route-entry.c', + 'nmt-route-table.c', + 'nmt-slave-list.c', + 'nmtui.c', + 'nmtui-connect.c', + 'nmtui-edit.c', + 'nmtui-hostname.c', + 'nmt-utils.c', + 'nmt-widget-list.c' +) + +deps += [ + libnm_dep, + libnmc_base_dep, + libnmt_newt_dep +] + +executable( + name, + sources, + dependencies: deps, + c_args: cflags, + link_args: ldflags_linker_script_binary, + link_depends: linker_script_binary, + install: true +) diff --git a/clients/tui/newt/meson.build b/clients/tui/newt/meson.build new file mode 100644 index 00000000..aeec39da --- /dev/null +++ b/clients/tui/newt/meson.build @@ -0,0 +1,35 @@ +sources = files( + 'nmt-newt-button-box.c', + 'nmt-newt-button.c', + 'nmt-newt-checkbox.c', + 'nmt-newt-component.c', + 'nmt-newt-container.c', + 'nmt-newt-entry.c', + 'nmt-newt-entry-numeric.c', + 'nmt-newt-form.c', + 'nmt-newt-grid.c', + 'nmt-newt-hacks.c', + 'nmt-newt-label.c', + 'nmt-newt-listbox.c', + 'nmt-newt-popup.c', + 'nmt-newt-section.c', + 'nmt-newt-separator.c', + 'nmt-newt-stack.c', + 'nmt-newt-textbox.c', + 'nmt-newt-toggle-button.c', + 'nmt-newt-utils.c', + 'nmt-newt-widget.c' +) + +libnmt_newt = static_library( + 'nmt-newt', + sources: sources + [libnm_enum[1]], + include_directories: libnm_inc, + dependencies: deps, + c_args: cflags +) + +libnmt_newt_dep = declare_dependency( + include_directories: include_directories('.'), + link_with: libnmt_newt +) diff --git a/clients/tui/newt/nmt-newt-button-box.h b/clients/tui/newt/nmt-newt-button-box.h index dec2c347..2dce1689 100644 --- a/clients/tui/newt/nmt-newt-button-box.h +++ b/clients/tui/newt/nmt-newt-button-box.h @@ -57,5 +57,4 @@ void nmt_newt_button_box_add_widget_start (NmtNewtButtonBox *bbox, void nmt_newt_button_box_add_widget_end (NmtNewtButtonBox *bbox, NmtNewtWidget *widget); - #endif /* NMT_NEWT_BUTTON_BOX_H */ diff --git a/clients/tui/newt/nmt-newt-section.c b/clients/tui/newt/nmt-newt-section.c index 38152c96..34073454 100644 --- a/clients/tui/newt/nmt-newt-section.c +++ b/clients/tui/newt/nmt-newt-section.c @@ -304,7 +304,7 @@ adjust_border_for_allocation (NmtNewtSectionPrivate *priv, label = nmt_newt_label_new (line_glyph); g_ptr_array_add (priv->border_line_labels, label); nmt_newt_grid_add (NMT_NEWT_GRID (priv->border_grid), label, 0, i + 1); - } else + } else nmt_newt_widget_set_visible (priv->border_line_labels->pdata[i], TRUE); } nmt_newt_widget_set_visible (priv->border_end_label, TRUE); diff --git a/clients/tui/newt/nmt-newt-utils.c b/clients/tui/newt/nmt-newt-utils.c index f37a851e..e8866500 100644 --- a/clients/tui/newt/nmt-newt-utils.c +++ b/clients/tui/newt/nmt-newt-utils.c @@ -65,9 +65,9 @@ nmt_newt_dialog_g_log_handler (const char *log_domain, } full_message = g_strdup_printf ("%s%s%s%s%s", - log_domain ? log_domain : "", + log_domain ?: "", log_domain && level_name ? " " : "", - level_name ? level_name : "", + level_name ?: "", log_domain || level_name ? ": " : "", message); @@ -87,7 +87,7 @@ nmt_newt_dialog_g_log_handler (const char *log_domain, newtGridSetField (grid, 0, 1, NEWT_GRID_COMPONENT, ok, 0, 1, 0, 0, NEWT_ANCHOR_RIGHT, 0); - newtGridWrappedWindow (grid, (char *) (level_name ? level_name : "")); + newtGridWrappedWindow (grid, (char *) (level_name ?: "")); newtGridFree (grid, TRUE); form = newtForm (NULL, NULL, 0); @@ -359,21 +359,11 @@ nmt_newt_edit_string (const char *data) goto done; } -#if GLIB_CHECK_VERSION (2, 34, 0) - G_GNUC_BEGIN_IGNORE_DEPRECATIONS if (!g_spawn_check_exit_status (status, &error)) { nmt_newt_message_dialog (_("Editor failed: %s"), error->message); g_error_free (error); goto done; } - G_GNUC_END_IGNORE_DEPRECATIONS -#else - if (WIFEXITED (status)) { - if (WEXITSTATUS (status) != 0) - nmt_newt_message_dialog (_("Editor failed with status %d"), WEXITSTATUS (status)); - } else if (WIFSIGNALED (status)) - nmt_newt_message_dialog (_("Editor failed with signal %d"), WTERMSIG (status)); -#endif if (!g_file_get_contents (filename, &new_data, NULL, &error)) { nmt_newt_message_dialog (_("Could not re-read file: %s"), error->message); @@ -386,5 +376,5 @@ nmt_newt_edit_string (const char *data) g_free (filename); return new_data; -} +} diff --git a/clients/tui/newt/nmt-newt-widget.c b/clients/tui/newt/nmt-newt-widget.c index 5602c062..94f3011e 100644 --- a/clients/tui/newt/nmt-newt-widget.c +++ b/clients/tui/newt/nmt-newt-widget.c @@ -311,7 +311,7 @@ nmt_newt_widget_real_activated (NmtNewtWidget *widget) if (priv->exit_on_activate) nmt_newt_form_quit (nmt_newt_widget_get_form (widget)); -} +} /** * nmt_newt_widget_activated: @@ -363,7 +363,7 @@ nmt_newt_widget_set_exit_on_activate (NmtNewtWidget *widget, priv->exit_on_activate = exit_on_activate; g_object_notify (G_OBJECT (widget), "exit-on-activate"); } -} +} /** * nmt_newt_widget_get_visible: diff --git a/clients/tui/nm-editor-bindings.h b/clients/tui/nm-editor-bindings.h index facbf1c6..72bd91e3 100644 --- a/clients/tui/nm-editor-bindings.h +++ b/clients/tui/nm-editor-bindings.h @@ -19,8 +19,6 @@ #ifndef NM_EDITOR_BINDINGS_H #define NM_EDITOR_BINDINGS_H -#include "NetworkManager.h" - void nm_editor_bindings_init (void); void nm_editor_bind_ip_addresses_with_prefix_to_strv (int family, diff --git a/clients/tui/nm-editor-utils.c b/clients/tui/nm-editor-utils.c index b71e9fbe..8fecefa8 100644 --- a/clients/tui/nm-editor-utils.c +++ b/clients/tui/nm-editor-utils.c @@ -27,8 +27,6 @@ #include "nm-default.h" -#include "NetworkManager.h" - #include "nm-editor-utils.h" #if 0 #include "nm-vpn-helpers.h" diff --git a/clients/tui/nm-editor-utils.h b/clients/tui/nm-editor-utils.h index 6f66edfe..e15cc5e8 100644 --- a/clients/tui/nm-editor-utils.h +++ b/clients/tui/nm-editor-utils.h @@ -19,8 +19,6 @@ #ifndef NM_EDITOR_UTILS_H #define NM_EDITOR_UTILS_H -#include "NetworkManager.h" - typedef struct { const char *name; GType setting_type; diff --git a/clients/tui/nmt-connect-connection-list.c b/clients/tui/nmt-connect-connection-list.c index 6e69a04b..ae633ec0 100644 --- a/clients/tui/nmt-connect-connection-list.c +++ b/clients/tui/nmt-connect-connection-list.c @@ -13,7 +13,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * - * Copyright 2013 Red Hat, Inc. + * Copyright 2013 - 2017 Red Hat, Inc. */ /** @@ -28,12 +28,9 @@ #include <stdlib.h> -#include "NetworkManager.h" - -#include "nm-utils/nm-hash-utils.h" - #include "nmtui.h" #include "nmt-connect-connection-list.h" +#include "nm-client-utils.h" G_DEFINE_TYPE (NmtConnectConnectionList, nmt_connect_connection_list, NMT_TYPE_NEWT_LISTBOX) @@ -310,7 +307,7 @@ add_connections_for_aps (NmtConnectDevice *nmtdev, } if (!nmtconn->name) - nmtconn->name = nmtconn->ssid ? nmtconn->ssid : "<unknown>"; + nmtconn->name = nmtconn->ssid ?: "<unknown>"; nmtdev->conns = g_slist_prepend (nmtdev->conns, nmtconn); } @@ -379,7 +376,7 @@ append_nmt_devices_for_virtual_devices (GSList *nmt_devices, g_free (name); else { nmtdev = g_slice_new0 (NmtConnectDevice); - nmtdev->name = name ? name : g_strdup ("Unknown"); + nmtdev->name = name ?: g_strdup("Unknown"); nmtdev->sort_order = sort_order; g_hash_table_insert (devices_by_name, nmtdev->name, nmtdev); @@ -527,7 +524,7 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list) if (nmtconn->ap) { guint8 strength = nm_access_point_get_strength (nmtconn->ap); - strength_col = nm_utils_wifi_strength_bars (strength); + strength_col = nmc_wifi_strength_bars (strength); } else strength_col = NULL; @@ -536,7 +533,7 @@ nmt_connect_connection_list_rebuild (NmtConnectConnectionList *list) nmtconn->name, (int)(max_width - nmt_newt_text_width (nmtconn->name)), "", strength_col ? " " : "", - strength_col ? strength_col : ""); + strength_col ?: ""); nmt_newt_listbox_append (listbox, row, nmtconn); g_free (row); diff --git a/clients/tui/nmt-device-entry.c b/clients/tui/nmt-device-entry.c index be1ad492..a4d63e4f 100644 --- a/clients/tui/nmt-device-entry.c +++ b/clients/tui/nmt-device-entry.c @@ -40,8 +40,6 @@ #include <sys/socket.h> #include <linux/if_arp.h> -#include "NetworkManager.h" - #include "nmtui.h" #include "nmt-device-entry.h" diff --git a/clients/tui/nmt-device-entry.h b/clients/tui/nmt-device-entry.h index 9278244f..9c288822 100644 --- a/clients/tui/nmt-device-entry.h +++ b/clients/tui/nmt-device-entry.h @@ -21,8 +21,6 @@ #include "nmt-editor-grid.h" -#include "NetworkManager.h" - #define NMT_TYPE_DEVICE_ENTRY (nmt_device_entry_get_type ()) #define NMT_DEVICE_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMT_TYPE_DEVICE_ENTRY, NmtDeviceEntry)) #define NMT_DEVICE_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMT_TYPE_DEVICE_ENTRY, NmtDeviceEntryClass)) diff --git a/clients/tui/nmt-edit-connection-list.c b/clients/tui/nmt-edit-connection-list.c index e90140b3..356c0b4b 100644 --- a/clients/tui/nmt-edit-connection-list.c +++ b/clients/tui/nmt-edit-connection-list.c @@ -319,7 +319,6 @@ listbox_activated (NmtNewtWidget *listbox, gpointer list) edit_clicked (NMT_NEWT_BUTTON (priv->edit), list); } - static void connection_saved (GObject *conn, GAsyncResult *result, @@ -502,7 +501,7 @@ nmt_edit_connection_list_class_init (NmtEditConnectionListClass *list_class) G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - + /** * NmtEditConnectionListFilter: * @list: the #NmtEditConnectionList diff --git a/clients/tui/nmt-edit-connection-list.h b/clients/tui/nmt-edit-connection-list.h index 9726e287..cb02ea4b 100644 --- a/clients/tui/nmt-edit-connection-list.h +++ b/clients/tui/nmt-edit-connection-list.h @@ -21,8 +21,6 @@ #include "nmt-newt.h" -#include "NetworkManager.h" - #define NMT_TYPE_EDIT_CONNECTION_LIST (nmt_edit_connection_list_get_type ()) #define NMT_EDIT_CONNECTION_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NMT_TYPE_EDIT_CONNECTION_LIST, NmtEditConnectionList)) #define NMT_EDIT_CONNECTION_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NMT_TYPE_EDIT_CONNECTION_LIST, NmtEditConnectionListClass)) diff --git a/clients/tui/nmt-editor-grid.c b/clients/tui/nmt-editor-grid.c index a57e780b..bc8a7843 100644 --- a/clients/tui/nmt-editor-grid.c +++ b/clients/tui/nmt-editor-grid.c @@ -70,7 +70,7 @@ typedef struct { * Creates a new #NmtEditorGrid * * Returns: a new #NmtEditorGrid - */ + */ NmtNewtWidget * nmt_editor_grid_new (void) { @@ -369,7 +369,6 @@ nmt_editor_grid_size_request (NmtNewtWidget *widget, *width += 2; } - static void nmt_editor_grid_size_allocate (NmtNewtWidget *widget, int x, diff --git a/clients/tui/nmt-editor-page.h b/clients/tui/nmt-editor-page.h index 93a66155..687f84a7 100644 --- a/clients/tui/nmt-editor-page.h +++ b/clients/tui/nmt-editor-page.h @@ -19,8 +19,6 @@ #ifndef NMT_EDITOR_PAGE_H #define NMT_EDITOR_PAGE_H -#include "NetworkManager.h" - #include "nmt-editor-grid.h" #include "nmt-editor-section.h" diff --git a/clients/tui/nmt-editor.c b/clients/tui/nmt-editor.c index 515e3471..b18f23d5 100644 --- a/clients/tui/nmt-editor.c +++ b/clients/tui/nmt-editor.c @@ -153,7 +153,6 @@ page_saved (gpointer data, gpointer user_data) nmt_editor_page_saved (page); } - static void save_connection_and_exit (NmtNewtButton *button, gpointer user_data) diff --git a/clients/tui/nmt-editor.h b/clients/tui/nmt-editor.h index 5620c5e8..ea51723e 100644 --- a/clients/tui/nmt-editor.h +++ b/clients/tui/nmt-editor.h @@ -19,8 +19,6 @@ #ifndef NMT_EDITOR_H #define NMT_EDITOR_H -#include "NetworkManager.h" - #include "nmt-newt.h" #define NMT_TYPE_EDITOR (nmt_editor_get_type ()) diff --git a/clients/tui/nmt-mac-entry.c b/clients/tui/nmt-mac-entry.c index b954d2e0..23c2ab1c 100644 --- a/clients/tui/nmt-mac-entry.c +++ b/clients/tui/nmt-mac-entry.c @@ -32,10 +32,8 @@ #include <string.h> -#include "NetworkManager.h" #include "nm-common-macros.h" - G_DEFINE_TYPE (NmtMacEntry, nmt_mac_entry, NMT_TYPE_NEWT_ENTRY) #define NMT_MAC_ENTRY_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NMT_TYPE_MAC_ENTRY, NmtMacEntryPrivate)) diff --git a/clients/tui/nmt-page-bond.c b/clients/tui/nmt-page-bond.c index e39a4c96..1629c8b0 100644 --- a/clients/tui/nmt-page-bond.c +++ b/clients/tui/nmt-page-bond.c @@ -203,21 +203,21 @@ slaves_changed (GObject *object, nmt_newt_component_set_sensitive (NMT_NEWT_COMPONENT (priv->mode), TRUE); } -#define WIDGET_CHANGED_FUNC(widget, func, option) \ -static void \ -widget ## _widget_changed (GObject *object, \ - GParamSpec *pspec, \ - gpointer user_data) \ -{ \ - NmtPageBond *bond = NMT_PAGE_BOND (user_data); \ - NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond); \ - \ - if (priv->updating) \ - return; \ - \ - priv->updating = TRUE; \ - nm_setting_bond_add_option (priv->s_bond, option, func (priv->widget)); \ - priv->updating = FALSE; \ +#define WIDGET_CHANGED_FUNC(widget, func, option) \ +static void \ +widget ## _widget_changed (GObject *object, \ + GParamSpec *pspec, \ + gpointer user_data) \ +{ \ + NmtPageBond *bond = NMT_PAGE_BOND (user_data); \ + NmtPageBondPrivate *priv = NMT_PAGE_BOND_GET_PRIVATE (bond); \ + \ + if (priv->updating) \ + return; \ + \ + priv->updating = TRUE; \ + nm_setting_bond_add_option (priv->s_bond, option, func (priv->widget)); \ + priv->updating = FALSE; \ } WIDGET_CHANGED_FUNC (primary, nmt_newt_entry_get_text, NM_SETTING_BOND_OPTION_PRIMARY) diff --git a/clients/tui/nmt-page-team-port.c b/clients/tui/nmt-page-team-port.c index af2221ad..0d40373d 100644 --- a/clients/tui/nmt-page-team-port.c +++ b/clients/tui/nmt-page-team-port.c @@ -68,7 +68,7 @@ edit_clicked (NmtNewtButton *button, NM_SETTING_TEAM_PORT_CONFIG, new_config, NULL); g_free (new_config); -} +} static void nmt_page_team_port_constructed (GObject *object) diff --git a/clients/tui/nmt-page-team.c b/clients/tui/nmt-page-team.c index 2523bd85..cfe12703 100644 --- a/clients/tui/nmt-page-team.c +++ b/clients/tui/nmt-page-team.c @@ -121,7 +121,7 @@ edit_clicked (NmtNewtButton *button, NM_SETTING_TEAM_CONFIG, new_config, NULL); g_free (new_config); -} +} static void nmt_page_team_constructed (GObject *object) diff --git a/clients/tui/nmt-page-wifi.c b/clients/tui/nmt-page-wifi.c index 35625fe4..00439c19 100644 --- a/clients/tui/nmt-page-wifi.c +++ b/clients/tui/nmt-page-wifi.c @@ -384,7 +384,6 @@ nmt_page_wifi_finalize (GObject *object) G_OBJECT_CLASS (nmt_page_wifi_parent_class)->finalize (object); } - static void nmt_page_wifi_class_init (NmtPageWifiClass *wifi_class) { diff --git a/clients/tui/nmt-password-dialog.c b/clients/tui/nmt-password-dialog.c index fb9567e6..16920fcf 100644 --- a/clients/tui/nmt-password-dialog.c +++ b/clients/tui/nmt-password-dialog.c @@ -144,12 +144,12 @@ nmt_password_dialog_constructed (GObject *object) NMSecretAgentSimpleSecret *secret = priv->secrets->pdata[i]; NmtNewtEntryFlags flags; - widget = nmt_newt_label_new (secret->name); + widget = nmt_newt_label_new (secret->pretty_name); nmt_newt_grid_add (secret_grid, widget, 0, i); nmt_newt_widget_set_padding (widget, 4, 0, 1, 0); flags = NMT_NEWT_ENTRY_NONEMPTY; - if (secret->password) + if (secret->is_secret) flags |= NMT_NEWT_ENTRY_PASSWORD; widget = nmt_newt_entry_new (30, flags); if (secret->value) diff --git a/clients/tui/nmt-route-editor.h b/clients/tui/nmt-route-editor.h index 8e63830e..d83523bc 100644 --- a/clients/tui/nmt-route-editor.h +++ b/clients/tui/nmt-route-editor.h @@ -19,8 +19,6 @@ #ifndef NMT_ROUTE_EDITOR_H #define NMT_ROUTE_EDITOR_H -#include "NetworkManager.h" - #include "nmt-newt.h" #define NMT_TYPE_ROUTE_EDITOR (nmt_route_editor_get_type ()) diff --git a/clients/tui/nmt-route-entry.c b/clients/tui/nmt-route-entry.c index 1b37389f..109759cc 100644 --- a/clients/tui/nmt-route-entry.c +++ b/clients/tui/nmt-route-entry.c @@ -32,8 +32,6 @@ #include <netinet/in.h> #include <stdlib.h> -#include "NetworkManager.h" - #include "nmt-route-entry.h" #include "nmt-ip-entry.h" @@ -154,7 +152,7 @@ static newtComponent nmt_route_entry_get_focus_component (NmtNewtWidget *widget) { NmtRouteEntryPrivate *priv = NMT_ROUTE_ENTRY_GET_PRIVATE (widget); - + return nmt_newt_widget_get_focus_component (priv->dest); } diff --git a/clients/tui/nmt-route-table.c b/clients/tui/nmt-route-table.c index a63f5205..c2e55542 100644 --- a/clients/tui/nmt-route-table.c +++ b/clients/tui/nmt-route-table.c @@ -30,8 +30,6 @@ #include <netinet/in.h> #include <stdlib.h> -#include "NetworkManager.h" - #include "nmt-route-table.h" #include "nmt-route-entry.h" #include "nmt-widget-list.h" @@ -163,12 +161,10 @@ remove_route (NmtWidgetList *list, gpointer table) { NmtRouteTablePrivate *priv = NMT_ROUTE_TABLE_GET_PRIVATE (table); - NMIPRoute *route; if (num >= priv->routes->len) return; - route = priv->routes->pdata[num]; g_ptr_array_remove_index (priv->routes, num); nmt_widget_list_set_length (list, priv->routes->len); diff --git a/clients/tui/nmt-slave-list.c b/clients/tui/nmt-slave-list.c index a8c31e05..893b7caf 100644 --- a/clients/tui/nmt-slave-list.c +++ b/clients/tui/nmt-slave-list.c @@ -26,8 +26,6 @@ #include "nm-default.h" -#include "NetworkManager.h" - #include "nmt-slave-list.h" G_DEFINE_TYPE (NmtSlaveList, nmt_slave_list, NMT_TYPE_EDIT_CONNECTION_LIST) diff --git a/clients/tui/nmt-utils.c b/clients/tui/nmt-utils.c index a8c1c5f0..7cd71be2 100644 --- a/clients/tui/nmt-utils.c +++ b/clients/tui/nmt-utils.c @@ -47,7 +47,7 @@ * * When the async callback is invoked, it should call * nmt_sync_op_complete_boolean() or nmt_sync_op_complete_pointer() to - * return a result or an error to the caller. + * return a result or an error to the caller. * * There is no free/clear function; any memory that needs to be freed * will have been returned to the caller from diff --git a/clients/tui/nmtui-connect.c b/clients/tui/nmtui-connect.c index 086e4bd3..2a954fb8 100644 --- a/clients/tui/nmtui-connect.c +++ b/clients/tui/nmtui-connect.c @@ -100,41 +100,38 @@ secrets_requested (NMSecretAgentSimple *agent, { NmtNewtForm *form; NMConnection *connection = NM_CONNECTION (user_data); - char *cookie = NULL; - char *gateway = NULL; - char *gwcert = NULL; int i; /* Get secrets for OpenConnect VPN */ - if (connection && nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME)) { + if ( connection + && nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME)) { NMSettingVpn *s_vpn = nm_connection_get_setting_vpn (connection); - const char *vpn_type = nm_setting_vpn_get_service_type (s_vpn); - if (!g_strcmp0 (vpn_type, NM_DBUS_INTERFACE ".openconnect")) { + if (nm_streq0 (nm_setting_vpn_get_service_type (s_vpn), NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT)) { + gs_free char *cookie = NULL; + gs_free char *gateway = NULL; + gs_free char *gwcert = NULL; + openconnect_authenticate (connection, &cookie, &gateway, &gwcert); for (i = 0; i < secrets->len; i++) { NMSecretAgentSimpleSecret *secret = secrets->pdata[i]; - if (!g_strcmp0 (secret->vpn_type, NM_DBUS_INTERFACE ".openconnect")) { - if (!g_strcmp0 (secret->vpn_property, "cookie")) { - g_free (secret->value); - secret->value = cookie; - cookie = NULL; - } else if (!g_strcmp0 (secret->vpn_property, "gateway")) { - g_free (secret->value); - secret->value = gateway; - gateway = NULL; - } else if (!g_strcmp0 (secret->vpn_property, "gwcert")) { - g_free (secret->value); - secret->value = gwcert; - gwcert = NULL; - } + if (secret->secret_type != NM_SECRET_AGENT_SECRET_TYPE_VPN_SECRET) + continue; + if (!nm_streq0 (secret->vpn_type, NM_SECRET_AGENT_VPN_TYPE_OPENCONNECT)) + continue; + if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "cookie")) { + g_free (secret->value); + secret->value = g_steal_pointer (&cookie); + } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "gateway")) { + g_free (secret->value); + secret->value = g_steal_pointer (&gateway); + } else if (nm_streq0 (secret->entry_id, NM_SECRET_AGENT_ENTRY_ID_PREFX_VPN_SECRET "gwcert")) { + g_free (secret->value); + secret->value = g_steal_pointer (&gwcert); } } - g_free (cookie); - g_free (gateway); - g_free (gwcert); } } diff --git a/clients/tui/nmtui-edit.c b/clients/tui/nmtui-edit.c index a92e45a3..657724e3 100644 --- a/clients/tui/nmtui-edit.c +++ b/clients/tui/nmtui-edit.c @@ -27,8 +27,6 @@ #include <stdlib.h> -#include "NetworkManager.h" - #include "nmtui.h" #include "nmtui-edit.h" #include "nmt-edit-connection-list.h" diff --git a/clients/tui/nmtui-hostname.c b/clients/tui/nmtui-hostname.c index f8005502..2c4fb28e 100644 --- a/clients/tui/nmtui-hostname.c +++ b/clients/tui/nmtui-hostname.c @@ -112,7 +112,7 @@ nmtui_hostname (gboolean is_top, int argc, char **argv) nmt_sync_op_init (&op); nm_client_save_hostname_async (nm_client, hostname, NULL, hostname_set, &op); if (nmt_sync_op_wait_boolean (&op, &error)) { - /* Translators: this indicates the result. ie, "I have set the hostname to ..." */ + /* TRANSLATORS: this indicates the result. ie, "I have set the hostname to ..." */ nmt_newt_message_dialog (_("Set hostname to '%s'"), hostname); } else { nmt_newt_message_dialog (_("Unable to set hostname: %s"), error->message); diff --git a/clients/tui/nmtui.c b/clients/tui/nmtui.c index 70cad5d6..97c528e7 100644 --- a/clients/tui/nmtui.c +++ b/clients/tui/nmtui.c @@ -30,8 +30,6 @@ #include <stdlib.h> #include <string.h> -#include "NetworkManager.h" - #include "nmt-newt.h" #include "nm-editor-bindings.h" @@ -228,7 +226,7 @@ main (int argc, char **argv) int i; setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); + bindtextdomain (GETTEXT_PACKAGE, NMLOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); diff --git a/clients/tui/nmtui.h b/clients/tui/nmtui.h index efb59622..5ef8e82a 100644 --- a/clients/tui/nmtui.h +++ b/clients/tui/nmtui.h @@ -19,8 +19,6 @@ #ifndef NMTUI_H #define NMTUI_H -#include "NetworkManager.h" - extern NMClient *nm_client; void nmtui_quit (void); |