From 0663160417062186768af2b73f03b44476f3a792 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Arreola=20Rodr=C3=ADguez?= Date: Wed, 21 Dec 2022 23:11:16 -0600 Subject: [PATCH] Renombro cuadro de dialogo. --- client-gtk/Makefile.am | 2 +- ...{ni-ip-add-dialog.c => ni-add-ip-dialog.c} | 76 +++++++++---------- client-gtk/ni-add-ip-dialog.h | 72 ++++++++++++++++++ client-gtk/ni-ip-add-dialog.h | 72 ------------------ client-gtk/ni-window-interface.c | 12 +-- src/ip-address.c | 8 +- 6 files changed, 121 insertions(+), 121 deletions(-) rename client-gtk/{ni-ip-add-dialog.c => ni-add-ip-dialog.c} (80%) create mode 100644 client-gtk/ni-add-ip-dialog.h delete mode 100644 client-gtk/ni-ip-add-dialog.h diff --git a/client-gtk/Makefile.am b/client-gtk/Makefile.am index b8a7f37..302a69d 100644 --- a/client-gtk/Makefile.am +++ b/client-gtk/Makefile.am @@ -10,7 +10,7 @@ inador_gtk_client_SOURCES = main.c \ ni-interface.c ni-interface.h \ ni-window-interface.c ni-window-interface.h \ ni-ip.c ni-ip.h \ - ni-ip-add-dialog.c ni-ip-add-dialog.h \ + ni-add-ip-dialog.c ni-add-ip-dialog.h \ ni-interface-filter.c ni-interface-filter.h \ ni-interface-chooser-dialog.c ni-interface-chooser-dialog.h \ ni-route.c ni-route.h \ diff --git a/client-gtk/ni-ip-add-dialog.c b/client-gtk/ni-add-ip-dialog.c similarity index 80% rename from client-gtk/ni-ip-add-dialog.c rename to client-gtk/ni-add-ip-dialog.c index ebe6fe2..2d08faf 100644 --- a/client-gtk/ni-ip-add-dialog.c +++ b/client-gtk/ni-add-ip-dialog.c @@ -28,10 +28,10 @@ #include #include -#include "ni-ip-add-dialog.h" +#include "ni-add-ip-dialog.h" #include "ni-ip.h" -struct _NIIPAddDialogPrivate { +struct _NIAddIPDialogPrivate { int family; GtkWidget *entry; @@ -49,7 +49,7 @@ enum { N_PROPERTIES }; -G_DEFINE_TYPE_WITH_PRIVATE (NIIPAddDialog, ni_ip_add_dialog, GTK_TYPE_DIALOG) +G_DEFINE_TYPE_WITH_PRIVATE (NIAddIPDialog, ni_add_ip_dialog, GTK_TYPE_DIALOG) static GParamSpec *obj_properties[N_PROPERTIES] = { NULL, }; @@ -76,7 +76,7 @@ static void split_ip_mask (const char *texto, gchar *ip, int ip_size, gchar *mas } } -gboolean ip_valid_ipv4 (const char *ip) { +static gboolean ip_valid_ipv4 (const char *ip) { struct in_addr addr; if (inet_pton (AF_INET, ip, &addr) == 0) { @@ -86,7 +86,7 @@ gboolean ip_valid_ipv4 (const char *ip) { return TRUE; } -gboolean ip_valid_ipv6 (const char *ip) { +static gboolean ip_valid_ipv6 (const char *ip) { struct in6_addr addr; if (inet_pton (AF_INET6, ip, &addr) == 0) { @@ -96,7 +96,7 @@ gboolean ip_valid_ipv6 (const char *ip) { return TRUE; } -static void ni_ip_add_dialog_update_response (NIIPAddDialog *dialog) { +static void ni_add_ip_dialog_update_response (NIAddIPDialog *dialog) { if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->check_p2p)) && dialog->priv->valid_p2p_ip == FALSE) { gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, FALSE); return; @@ -110,17 +110,17 @@ static void ni_ip_add_dialog_update_response (NIIPAddDialog *dialog) { gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, TRUE); } -static void ni_ip_add_dialog_validate_main_ip (GtkEditable *editable, gpointer data) { - NIIPAddDialog *dialog = NI_IP_ADD_DIALOG (data); +static void ni_add_ip_dialog_validate_main_ip (GtkEditable *editable, gpointer data) { + NIAddIPDialog *dialog = NI_ADD_IP_DIALOG (data); struct_addr addr; int prefix; - dialog->priv->valid_main_ip = ni_ip_add_dialog_get_address (dialog, &addr, &prefix); - ni_ip_add_dialog_update_response (dialog); + dialog->priv->valid_main_ip = ni_add_ip_dialog_get_address (dialog, &addr, &prefix); + ni_add_ip_dialog_update_response (dialog); } -static void ni_ip_add_dialog_validate_p2p_ip (GtkEditable *editable, gpointer data) { - NIIPAddDialog *dialog = NI_IP_ADD_DIALOG (data); +static void ni_add_ip_dialog_validate_p2p_ip (GtkEditable *editable, gpointer data) { + NIAddIPDialog *dialog = NI_ADD_IP_DIALOG (data); const gchar *texto; int prefix; @@ -130,7 +130,7 @@ static void ni_ip_add_dialog_validate_p2p_ip (GtkEditable *editable, gpointer da if (dialog->priv->family == AF_INET || dialog->priv->family == AF_UNSPEC) { dialog->priv->valid_p2p_ip = ip_valid_ipv4 (texto); if (dialog->priv->valid_p2p_ip) { - ni_ip_add_dialog_update_response (dialog); + ni_add_ip_dialog_update_response (dialog); return; } } @@ -139,23 +139,23 @@ static void ni_ip_add_dialog_validate_p2p_ip (GtkEditable *editable, gpointer da dialog->priv->valid_p2p_ip = ip_valid_ipv6 (texto); } - ni_ip_add_dialog_update_response (dialog); + ni_add_ip_dialog_update_response (dialog); } -void ni_ip_add_dialog_toggle_p2p_cb (GtkWidget *widget, gpointer data) { - NIIPAddDialog *dialog = NI_IP_ADD_DIALOG (data); +void ni_add_ip_dialog_toggle_p2p_cb (GtkWidget *widget, gpointer data) { + NIAddIPDialog *dialog = NI_ADD_IP_DIALOG (data); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) { gtk_widget_set_sensitive (dialog->priv->entry_p2p, TRUE); } else { gtk_widget_set_sensitive (dialog->priv->entry_p2p, FALSE); } - ni_ip_add_dialog_update_response (dialog); + ni_add_ip_dialog_update_response (dialog); } -static void ni_ip_add_dialog_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { - NIIPAddDialog *dialog = NI_IP_ADD_DIALOG (object); - g_return_if_fail (NI_IS_IP_ADD_DIALOG (object)); +static void ni_add_ip_dialog_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) { + NIAddIPDialog *dialog = NI_ADD_IP_DIALOG (object); + g_return_if_fail (NI_IS_ADD_IP_DIALOG (object)); switch (prop_id) { case PROP_IP_FAMILY: @@ -173,9 +173,9 @@ static void ni_ip_add_dialog_set_property (GObject *object, guint prop_id, const } } -static void ni_ip_add_dialog_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { - NIIPAddDialog *dialog = NI_IP_ADD_DIALOG (object); - g_return_if_fail (NI_IS_IP_ADD_DIALOG (object)); +static void ni_add_ip_dialog_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { + NIAddIPDialog *dialog = NI_ADD_IP_DIALOG (object); + g_return_if_fail (NI_IS_ADD_IP_DIALOG (object)); switch (prop_id) { case PROP_IP_FAMILY: @@ -186,14 +186,14 @@ static void ni_ip_add_dialog_get_property (GObject *object, guint prop_id, GValu } } -static void ni_ip_add_dialog_class_init (NIIPAddDialogClass *klass) { +static void ni_add_ip_dialog_class_init (NIAddIPDialogClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); GtkWindowClass *window_class = GTK_WINDOW_CLASS (klass); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); GtkDialogClass *dialog_class = GTK_DIALOG_CLASS (klass); - object_class->set_property = ni_ip_add_dialog_set_property; - object_class->get_property = ni_ip_add_dialog_get_property; + object_class->set_property = ni_add_ip_dialog_set_property; + object_class->get_property = ni_add_ip_dialog_get_property; obj_properties[PROP_IP_FAMILY] = g_param_spec_uint ( "family", @@ -205,8 +205,8 @@ static void ni_ip_add_dialog_class_init (NIIPAddDialogClass *klass) { g_object_class_install_properties (object_class, N_PROPERTIES, obj_properties); } -static void ni_ip_add_dialog_init (NIIPAddDialog *dialog) { - NIIPAddDialogPrivate *priv = ni_ip_add_dialog_get_instance_private (dialog); +static void ni_add_ip_dialog_init (NIAddIPDialog *dialog) { + NIAddIPDialogPrivate *priv = ni_add_ip_dialog_get_instance_private (dialog); GtkWidget *image; GtkWidget *vbox, *expander; GtkWidget *container, *label, *hbox; @@ -240,7 +240,7 @@ static void ni_ip_add_dialog_init (NIIPAddDialog *dialog) { priv->entry = gtk_entry_new (); gtk_entry_set_placeholder_text (GTK_ENTRY (priv->entry), "192.0.2.1/24 or 2001:db8::1/64"); - g_signal_connect (priv->entry, "changed", G_CALLBACK (ni_ip_add_dialog_validate_main_ip), dialog); + g_signal_connect (priv->entry, "changed", G_CALLBACK (ni_add_ip_dialog_validate_main_ip), dialog); gtk_box_pack_start (GTK_BOX (hbox), priv->entry, TRUE, TRUE, 0); expander = gtk_expander_new_with_mnemonic ("_Opciones avanzadas"); @@ -254,11 +254,11 @@ static void ni_ip_add_dialog_init (NIIPAddDialog *dialog) { gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3); priv->check_p2p = gtk_check_button_new_with_label ("Point-to-point address:"); - g_signal_connect (priv->check_p2p, "toggled", G_CALLBACK (ni_ip_add_dialog_toggle_p2p_cb), dialog); + g_signal_connect (priv->check_p2p, "toggled", G_CALLBACK (ni_add_ip_dialog_toggle_p2p_cb), dialog); gtk_box_pack_start (GTK_BOX (hbox), priv->check_p2p, FALSE, FALSE, 0); priv->entry_p2p = gtk_entry_new (); - g_signal_connect (priv->entry_p2p, "changed", G_CALLBACK (ni_ip_add_dialog_validate_p2p_ip), dialog); + g_signal_connect (priv->entry_p2p, "changed", G_CALLBACK (ni_add_ip_dialog_validate_p2p_ip), dialog); gtk_box_pack_start (GTK_BOX (hbox), priv->entry_p2p, TRUE, TRUE, 0); gtk_widget_set_sensitive (priv->entry_p2p, FALSE); @@ -271,7 +271,7 @@ static void ni_ip_add_dialog_init (NIIPAddDialog *dialog) { gtk_widget_show_all (container); } -gboolean ni_ip_add_dialog_get_address (NIIPAddDialog *dialog, struct_addr *addr, int *prefix) { +gboolean ni_add_ip_dialog_get_address (NIAddIPDialog *dialog, struct_addr *addr, int *prefix) { const gchar *texto; gchar *rest, ip[128], mask[32]; int lprefix; @@ -324,11 +324,11 @@ gboolean ni_ip_add_dialog_get_address (NIIPAddDialog *dialog, struct_addr *addr, return FALSE; } -gboolean ni_ip_add_dialog_has_p2p_address (NIIPAddDialog *dialog) { +gboolean ni_add_ip_dialog_has_p2p_address (NIAddIPDialog *dialog) { return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->check_p2p)); } -gboolean ni_ip_add_dialog_get_p2p_address (NIIPAddDialog *dialog, struct_addr *addr) { +gboolean ni_add_ip_dialog_get_p2p_address (NIAddIPDialog *dialog, struct_addr *addr) { gboolean valid; const gchar *texto; @@ -361,14 +361,14 @@ gboolean ni_ip_add_dialog_get_p2p_address (NIIPAddDialog *dialog, struct_addr *a return FALSE; } -gboolean ni_ip_add_dialog_get_noprefix (NIIPAddDialog *dialog) { +gboolean ni_add_ip_dialog_get_noprefix (NIAddIPDialog *dialog) { return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->priv->check_noprefix)); } -GtkWidget* ni_ip_add_dialog_new (int family) { - NIIPAddDialog *dialog; +GtkWidget* ni_add_ip_dialog_new (int family) { + NIAddIPDialog *dialog; - dialog = g_object_new (NI_TYPE_IP_ADD_DIALOG, "family", family, NULL); + dialog = g_object_new (NI_TYPE_ADD_IP_DIALOG, "family", family, NULL); return GTK_WIDGET (dialog); } diff --git a/client-gtk/ni-add-ip-dialog.h b/client-gtk/ni-add-ip-dialog.h new file mode 100644 index 0000000..033f25b --- /dev/null +++ b/client-gtk/ni-add-ip-dialog.h @@ -0,0 +1,72 @@ +/* + * ni-add-ip-dialog.h + * This file is part of Network Inador + * + * Copyright (C) 2021 - Gatuno + * + * Network Inador is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Network Inador is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Network Inador; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301 USA + */ + +#ifndef __NI_ADD_IP_DIALOG_H__ +#define __NI_ADD_IP_DIALOG_H__ + +#include + +#include "ni-ip.h" + +G_BEGIN_DECLS + +typedef struct _NIAddIPDialogClass NIAddIPDialogClass; +typedef struct _NIAddIPDialog NIAddIPDialog; +typedef struct _NIAddIPDialogPrivate NIAddIPDialogPrivate; + +/* + * Type declaration. + */ +#define NI_TYPE_ADD_IP_DIALOG (ni_add_ip_dialog_get_type ()) +#define NI_ADD_IP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NI_TYPE_ADD_IP_DIALOG, NIAddIPDialog)) +#define NI_ADD_IP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NI_TYPE_ADD_IP_DIALOG, NIAddIPDialogClass)) +#define NI_IS_ADD_IP_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NI_TYPE_ADD_IP_DIALOG)) +#define NI_IS_ADD_IP_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NI_TYPE_ADD_IP_DIALOG)) +#define NI_ADD_IP_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NI_TYPE_ADD_IP_DIALOG, NIAddIPDialogClass)) + +GType ni_add_ip_dialog_get_type (void); + +struct _NIAddIPDialogClass { + GtkDialogClass parent_class; + +}; + +struct _NIAddIPDialog { + GtkDialog parent_instance; + + NIAddIPDialogPrivate *priv; +}; + +/* + * Method definitions. + */ +GtkWidget* ni_add_ip_dialog_new (int family); + +gboolean ni_add_ip_dialog_get_address (NIAddIPDialog *dialog, struct_addr *addr, int *prefix); +gboolean ni_add_ip_dialog_has_p2p_address (NIAddIPDialog *dialog); +gboolean ni_add_ip_dialog_get_p2p_address (NIAddIPDialog *dialog, struct_addr *addr); +gboolean ni_add_ip_dialog_get_noprefix (NIAddIPDialog *dialog); + +G_END_DECLS + +#endif /* __NI_ADD_IP_DIALOG_H__ */ + diff --git a/client-gtk/ni-ip-add-dialog.h b/client-gtk/ni-ip-add-dialog.h deleted file mode 100644 index 1e2808e..0000000 --- a/client-gtk/ni-ip-add-dialog.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * ni-add-ip-dialog.h - * This file is part of Network Inador - * - * Copyright (C) 2021 - Gatuno - * - * Network Inador is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Network Inador is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Network Inador; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, - * Boston, MA 02110-1301 USA - */ - -#ifndef __NI_IP_ADD_DIALOG_H__ -#define __NI_IP_ADD_DIALOG_H__ - -#include - -#include "ni-ip.h" - -G_BEGIN_DECLS - -typedef struct _NIIPAddDialogClass NIIPAddDialogClass; -typedef struct _NIIPAddDialog NIIPAddDialog; -typedef struct _NIIPAddDialogPrivate NIIPAddDialogPrivate; - -/* - * Type declaration. - */ -#define NI_TYPE_IP_ADD_DIALOG (ni_ip_add_dialog_get_type ()) -#define NI_IP_ADD_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NI_TYPE_IP_ADD_DIALOG, NIIPAddDialog)) -#define NI_IP_ADD_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NI_TYPE_IP_ADD_DIALOG, NIIPAddDialogClass)) -#define NI_IS_IP_ADD_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NI_TYPE_IP_ADD_DIALOG)) -#define NI_IS_IP_ADD_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NI_TYPE_IP_ADD_DIALOG)) -#define NI_IP_ADD_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NI_TYPE_IP_ADD_DIALOG, NIIPAddDialogClass)) - -GType ni_ip_add_dialog_get_type (void); - -struct _NIIPAddDialogClass { - GtkDialogClass parent_class; - -}; - -struct _NIIPAddDialog { - GtkDialog parent_instance; - - NIIPAddDialogPrivate *priv; -}; - -/* - * Method definitions. - */ -GtkWidget* ni_ip_add_dialog_new (int family); - -gboolean ni_ip_add_dialog_get_address (NIIPAddDialog *dialog, struct_addr *addr, int *prefix); -gboolean ni_ip_add_dialog_has_p2p_address (NIIPAddDialog *dialog); -gboolean ni_ip_add_dialog_get_p2p_address (NIIPAddDialog *dialog, struct_addr *addr); -gboolean ni_ip_add_dialog_get_noprefix (NIIPAddDialog *dialog); - -G_END_DECLS - -#endif /* __NI_IP_ADD_DIALOG_H__ */ - diff --git a/client-gtk/ni-window-interface.c b/client-gtk/ni-window-interface.c index b9195b3..2701bda 100644 --- a/client-gtk/ni-window-interface.c +++ b/client-gtk/ni-window-interface.c @@ -37,7 +37,7 @@ #include "ni-client.h" #include "ni-interface.h" #include "ni-ip.h" -#include "ni-ip-add-dialog.h" +#include "ni-add-ip-dialog.h" #include "../src/link-types.h" #include "ni-interface-chooser-dialog.h" #include "ni-interface-filter.h" @@ -164,7 +164,7 @@ static void ni_window_interface_addr_button_add_cb (GtkWidget *widget, int famil gboolean has_p2p; uint32_t flags = 0; - dialog = ni_ip_add_dialog_new (family); + dialog = ni_add_ip_dialog_new (family); gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window_iface)); @@ -176,15 +176,15 @@ static void ni_window_interface_addr_button_add_cb (GtkWidget *widget, int famil /* Mandar la ip al network-inador */ ni_client = ni_interface_get_client (window_iface->priv->ni_interface); - ni_ip_add_dialog_get_address (NI_IP_ADD_DIALOG (dialog), &addr, &prefix); - has_p2p = ni_ip_add_dialog_has_p2p_address (NI_IP_ADD_DIALOG (dialog)); + ni_add_ip_dialog_get_address (NI_ADD_IP_DIALOG (dialog), &addr, &prefix); + has_p2p = ni_add_ip_dialog_has_p2p_address (NI_ADD_IP_DIALOG (dialog)); if (has_p2p) { memcpy (&p2p_addr, &addr, sizeof (p2p_addr)); - ni_ip_add_dialog_get_p2p_address (NI_IP_ADD_DIALOG (dialog), &addr); + ni_add_ip_dialog_get_p2p_address (NI_ADD_IP_DIALOG (dialog), &addr); } flags |= IFA_F_PERMANENT; - if (ni_ip_add_dialog_get_noprefix (NI_IP_ADD_DIALOG (dialog))) { + if (ni_add_ip_dialog_get_noprefix (NI_ADD_IP_DIALOG (dialog))) { flags |= IFA_F_NOPREFIXROUTE; } //void ni_client_ask_ip_new (NIClient *ni_client, NIInterface *ni_interface, int family, int prefix, struct_addr *addr, uint32_t flags, unsigned char scope, int has_local, struct_addr *local_addr, int has_brd, struct_addr *brd_addr) { diff --git a/src/ip-address.c b/src/ip-address.c index 620144b..95aa111 100644 --- a/src/ip-address.c +++ b/src/ip-address.c @@ -396,9 +396,9 @@ int ip_address_add_ip (NetworkInadorHandle *handle, int index, IPAddr *ip_addr) nl_socket_modify_cb (handle->nl_sock_route, NL_CB_ACK, NL_CB_CUSTOM, _ip_address_wait_ack_or_error, &error); nl_socket_modify_err_cb (handle->nl_sock_route, NL_CB_CUSTOM, _ip_address_wait_error, &error); - nl_recvmsgs_default (handle->nl_sock_route); + ret = nl_recvmsgs_default (handle->nl_sock_route); - if (ret <= 0 || error < 0) { + if (ret < 0 || error < 0) { return -1; } @@ -479,9 +479,9 @@ int ip_address_del_ip (NetworkInadorHandle *handle, int index, IPAddr *ip_addr) nl_socket_modify_cb (handle->nl_sock_route, NL_CB_ACK, NL_CB_CUSTOM, _ip_address_wait_ack_or_error, &error); nl_socket_modify_err_cb (handle->nl_sock_route, NL_CB_CUSTOM, _ip_address_wait_error, &error); - nl_recvmsgs_default (handle->nl_sock_route); + ret = nl_recvmsgs_default (handle->nl_sock_route); - if (ret <= 0 || error < 0) { + if (ret < 0 || error < 0) { return -1; }