1 /* -*- mode:C; indent-tabs-mode:t; tab-width:8; c-basic-offset:8; -*- */
2 /* gnome-netinfo - A GUI Interface for network utilities
3  * Copyright (C) 2002, 2003 by German Poo-Caaman~o
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #include <glib.h>
21 #include <gtk/gtk.h>
22 
23 #include "gn-combo-history.h"
24 
25 #ifndef __NETINFO__
26 #define __NETINFO__
27 
28 #define NETINFO_FOREACH_FUNC(a)  (NetinfoForeachFunc) a
29 #define NETINFO_COPY_FUNC(a)  (NetinfoCopyFunc) a
30 
31 typedef void (*NetinfoForeachFunc) (gpointer * netinfo, gchar * line, gint len,
32 				    gpointer user_data);
33 typedef void (*NetinfoCopyFunc) (gpointer * netinfo, gpointer user_data);
34 
35 typedef struct _Netinfo Netinfo;
36 
37 struct _Netinfo {
38 	GtkWidget *main_window;
39 	GtkWidget *progress_bar;
40 	GtkWidget *status_bar;
41 	gchar     *stbar_text;
42 	GtkWidget *page_label;
43 	GtkWidget *user;
44 	GtkWidget *host;
45 	GtkWidget *count;
46 	GtkWidget *output;
47 	GtkWidget *limited;
48 	GtkWidget *button;
49 	GtkWidget *type;
50 	GtkWidget *sensitive;
51 	GtkWidget *routing;
52 	GtkWidget *protocol;
53 	GtkWidget *multicast;
54 	GtkWidget *graph;
55 	gboolean running;
56 	gboolean toggle;
57 	gboolean use_tracepath;
58 	gint child_pid;
59 	gint pipe_out;
60 	gint pipe_err;
61 	gchar **command_line;
62 	gchar *label_run;
63 	gchar *label_stop;
64 	GString *command_output;
65 	NetinfoForeachFunc process_line;
66 	NetinfoCopyFunc copy_output;
67 	GCallback button_callback;
68 	GnComboHistory *history;
69 	/* extra definitions for ping */
70 	GtkWidget *min;
71 	GtkWidget *max;
72 	GtkWidget *avg;
73 	GtkWidget *packets_transmitted;
74 	GtkWidget *packets_received;
75 	GtkWidget *packets_success;
76 	gboolean has_beep;
77 	/* extra definitions for info */
78 	GtkWidget *combo;
79 	GtkWidget *ipv6_frame;
80 	/* GkWidget *ipv4_frame; */
81 	GtkWidget *list_ip_addr;
82 	GtkWidget *nic;
83 	GtkWidget *hw_address;
84 	GtkWidget *ip_address;
85 	GtkWidget *broadcast;
86 	GtkWidget *netmask;
87 	GtkWidget *dst_address;
88 	GtkWidget *configure_button;
89 	/*GtkWidget *multicast;*/
90 	GtkWidget *link_speed;
91 	GtkWidget *state;
92 	GtkWidget *mtu;
93 	GtkWidget *tx_bytes;
94 	GtkWidget *tx;
95 	GtkWidget *tx_errors;
96 	GtkWidget *rx_bytes;
97 	GtkWidget *rx;
98 	GtkWidget *rx_errors;
99 	GtkWidget *collisions;
100 	/* extra definitions for finger */
101 	GnComboHistory *history_user;
102 };
103 
104 enum {
105 	INACTIVE = FALSE,
106 	ACTIVE = TRUE
107 };
108 
109 /* Notebook pages */
110 enum {
111 	INFO = 0,
112 	PING,
113 	NETSTAT,
114 	TRACEROUTE,
115 	PORTSCAN,
116 	LOOKUP,
117 	FINGER,
118 	WHOIS,
119 	NUM_PAGES
120 };
121 
122 enum {
123 	IPV4,
124 	IPV6
125 };
126 
127 #endif  /* __NETINFO__ */
128 
129 /* Generic functions */
130 void netinfo_process_command (Netinfo * netinfo);
131 void netinfo_stop_process_command (Netinfo * netinfo);
132 void netinfo_text_buffer_insert (Netinfo * netinfo);
133 
134 gint netinfo_get_count (Netinfo * netinfo);
135 const gchar * netinfo_get_host (Netinfo * netinfo);
136 const gchar * netinfo_get_user (Netinfo * netinfo);
137 void netinfo_set_host (Netinfo * netinfo, const gchar *host);
138 gboolean netinfo_is_ipv6_enable (void);
139 void netinfo_set_user (Netinfo * netinfo, const gchar *user);
140 gint netinfo_get_ip_version (Netinfo * netinfo);
141 void netinfo_error_message (Netinfo     * netinfo,
142 			    const gchar * primary,
143 			    const gchar * secondary);
144 gboolean netinfo_validate_host (Netinfo * netinfo);
145 gboolean netinfo_validate_domain (Netinfo * netinfo);
146 void netinfo_toggle_button (Netinfo * netinfo);
147 void netinfo_toggle_state (Netinfo * netinfo, gboolean state,
148 			   gpointer user_data);
149 gboolean netinfo_io_text_buffer_dialog (GIOChannel * channel,
150 					GIOCondition condition, gpointer data);
151 
152 void netinfo_progress_indicator_stop (Netinfo * netinfo);
153 
154 void netinfo_progress_indicator_start (Netinfo * netinfo);
155