Commit 62dee81e authored by Rodrigo Moya's avatar Rodrigo Moya

Initial revision

parents
German Poo-Caaman~o <gpoo@ubiobio.cl>
This diff is collapsed.
SUBDIRS = src
gping: A GNOME interface for ping
gping only pretends give to GNOME a graphical interfaces for
the classic network program: ping.
Test Cases
(If you find another test case, please let me know).
User interaction:
* Toggle buttons and sensitive:
1. For:
a) Enter a right hostname and press return; and
b) Enter a right hostname push Ping button
The UI must:
- The host entry must toggle to insensitive
- The button Ping must change to Stop
And try:
1.1 Wait until the process stop automatically
- The host entry must toggle to sensitive
- The button Stop must change to Ping
1.2 Push the Stop button to stop the process
- The host entry must toggle to sensitive
- The button Stop must change to Ping
2. Try the items in 1, with a bad hostname
(inexistent, by example: aeiou)
3. Try 1 and 2, with differnt counts (minimal,
maximal, medium)
Process Interacion:
For 1, 2 and 3, compare the results (format) shown
on the GUI with the console program equivalent.
Known Issues:
On same error cases (2) the GUI doesn't show
any text, because de GIOChannel doesn' return any
value, but GIOCondition is G_IO_IN.
(see ping.c - io_text_buffer_dialog)
Bug fixes:
[X] Add any new entry at the end of GtkTreeView, not in the cursor
position. This bug is valid on ping, traceroute and scan.
General:
[ ] Add gconf support to store:
- Last host requested
- Last settings used (count ping, netstat query, etc)
[ ] Implement information of network devices
[ ] Add support for IPv6
[ ] To implement "link state" and "collission"
[X] Implement traceroute (with tcp and/or icmp)
[X] Implement netstat
[X] Add DNS query
[ ] Add Whois query
[ ] Add support to IPv6 (ping6, traceroute6, network interface)
[ ] Add Copy-to-clipboard on Information (info.c)
[ ] Show error messages, feeback to the user.
(for instance: Host not found)
[ ] Glib-ize util-mii
i18n:
[X] Add internacionalization support (mostly add files in POTFILES.in)
UI:
[ ] A graphical traceroute
[X] A better ping output: GtkTreeView instead GtkTextView and
a label to show the perfomance every time.
[ ] Accept arguments by command line.
Portability:
[-] Multiplataform support (may be with a ping/traceroute helper to
process de same output)
[X] Detection of network devices
[ ] Add *BSD support in ping command/output
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
PKG_NAME="gnome-netinfo"
(test -f $srcdir/configure.in \
&& test -d $srcdir/src \
&& test -d $srcdir/src/ping.c) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level $PKG_NAME directory"
exit 1
}
gnome_autogen=`which gnome-autogen.sh`
test -z "$gnome_autogen"
USE_GNOME2_MACROS=1 . $gnome_autogen
AC_PREREQ(2.52)
AC_INIT(src/ping.c)
dnl Useful to call aclocal after 'make'
AC_SUBST(ACLOCAL_AMFLAGS, "$ACLOCAL_FLAGS")
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(gnome-netinfo, 0.1.0)
AM_MAINTAINER_MODE
AC_PROG_INTLTOOL([0.11])
GNOME_PLATFORM_GNOME_2(yes, force)
AC_ISC_POSIX
AC_PROG_CC
AC_STDC_HEADERS
AC_CHECK_HEADERS(sys/sockio.h sys/socket.h)
dnl AC_ARG_PROGRAM
AM_PROG_LIBTOOL
GNOME_COMPILE_WARNINGS(yes)
CFLAGS="$CFLAGS $WARN_CFLAGS"
PKG_CHECK_MODULES(GNETWORK, libgnomeui-2.0 libgnome-2.0 gtk+-2.0 glib-2.0 libglade-2.0 gconf-2.0)
AC_SUBST(GNETWORK_CFLAGS)
AC_SUBST(GNETWORK_LIBS)
dnl Find ifconfig
dnl
AC_ARG_WITH(ifconfig, [ --with-ifconfig=PATH Where ifconfig is.])
if test "x$with_ifconfig" = "x" ; then
AC_PATH_PROG(IFCONFIG_PROGRAM,
ifconfig,,
$PATH:/sbin:/usr/etc:/usr/sbin)
if test "x$IFCONFIG_PROGRAM" != "x" ; then
AC_DEFINE_UNQUOTED(IFCONFIG_PROGRAM, "$IFCONFIG_PROGRAM", [The ifconfig program])
fi
else
AC_DEFINE_UNQUOTED(IFCONFIG_PROGRAM, "$with_ifconfig", [The ifconfig program])
fi
AM_CONDITIONAL(HAVE_IFCONFIG, test "x$IFCONFIG_PROGRAM" != "x")
dnl
dnl Translations
dnl
GETTEXT_PACKAGE=gnome-netinfo
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE",[The gettext package])
ALL_LINGUAS="az ca cs da de el es fr ga gl he hu it ja ko ms nl no pl pt pt_BR ru sr sr@Latn sv tr uk vi wa zh_CN zh_TW"
AM_GLIB_GNU_GETTEXT
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${ac_default_prefix}/share/pixmaps", [Pixmap directory])
else
AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${prefix}/share/pixmaps", [Pixmap directory])
fi
dnl
dnl Debugging flags
dnl
set_debug=no
AC_ARG_ENABLE(debug,
[ --enable-debug Lots of noisy debug messages],
set_debug="$enableval")
AC_MSG_CHECKING(if debug messages are enabled)
if test "$set_debug" != "no"; then
AC_MSG_RESULT(yes)
CFLAGS="-DGRD_DEBUG $CFLAGS"
else
AC_MSG_RESULT(no)
fi
AC_OUTPUT([
Makefile
po/Makefile.in
src/Makefile])
This diff is collapsed.
# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
src/callbacks.c
src/callbacks.h
src/gnome-netinfo.glade
src/info.c
src/info.h
src/lookup.c
src/main.c
src/netinfo.c
src/netinfo.h
src/netstat.c
src/netstat.h
src/ping.c
src/ping.h
src/scan.c
src/traceroute.c
src/traceroute.h
src/utils.c
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Makefile
Makefile.in
gnome-netinfo
gnome-netinfo.desktop
dialogdir = $(datadir)/$(PACKAGE)/dialogs
dialog_DATA = gnome-netinfo.glade
INCLUDES = \
-DGNOME_NETINFO_LOCALEDIR=\""$(datadir)/locale"\" \
-DDATADIR=\""$(dialogdir)/"\" \
@GNETWORK_CFLAGS@
LDADD = \
$(GNETWORK_LIBS)
bin_PROGRAMS = gnome-netinfo
gnome_netinfo_SOURCES = \
callbacks.c callbacks.h \
netinfo.c netinfo.h \
ping.c ping.h \
traceroute.c traceroute.h \
netstat.c netstat.h \
info.c info.h \
scan.c scan.h \
lookup.c lookup.h \
finger.c finger.h \
whois.c whois.h \
utils.c utils.h \
util-mii.c util-mii.h mii.h \
util-mii-wireless.h \
main.c
gnome_netinfo_LDADD = @GNETWORK_LIBS@
pixmapdir = $(datadir)/pixmaps
pixmap_DATA = gnome-netinfo.png
EXTRA_DIST = \
$(pixmap_DATA) \
gnome-netinfo.desktop.in \
$(dialog_DATA) \
gnome-netinfo.gladep
Applicationsdir = $(datadir)/applications
Applications_in_files = gnome-netinfo.desktop.in
Applications_DATA = $(Applications_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
install-data-local:
@$(NORMAL_INSTALL)
/* -*- mode:C; indent-tabs-mode:t; tab-width:8; c-basic-offset:8; -*- */
/* gnome-netinfo - A GUI Interface for network utilities
* Copyright (C) 2002 by German Poo-Caaman~o
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gnome.h>
#include <sys/wait.h>
#include <unistd.h>
#include <sys/types.h>
#include <signal.h>
#include "callbacks.h"
#include "traceroute.h"
#include "info.h"
#include "ping.h"
#include "netstat.h"
#include "scan.h"
#include "lookup.h"
#include "finger.h"
#include "whois.h"
/* Ping callbacks */
void
on_ping_activate (GtkWidget * widget, gpointer data)
{
Netinfo *pinger = data;
g_return_if_fail (pinger != NULL);
if (pinger->running) {
ping_stop (pinger);
} else {
ping_do (pinger);
}
}
/* Traceroute callbacks */
void
on_traceroute_activate (GtkWidget * widget, gpointer data)
{
Netinfo *tracer = data;
g_return_if_fail (tracer != NULL);
if (tracer->running) {
traceroute_stop (tracer);
} else {
traceroute_do (tracer);
}
}
void
on_netstat_activate (GtkWidget * widget, gpointer data)
{
Netinfo *netstat = data;
g_return_if_fail (netstat != NULL);
if (netstat->running) {
netstat_stop (netstat);
} else {
netstat_do (netstat);
}
}
/* Info callbacks */
#ifdef IFCONFIG_PROGRAM
void
on_info_nic_changed (GtkEntry * entry, gpointer info)
{
const gchar *nic;
g_return_if_fail (info != NULL);
nic = gtk_entry_get_text (entry);
if (strlen (nic) > 0) {
info_do (nic, (Netinfo *) & info);
}
}
#endif
/* Scan callbacks */
void
on_scan_activate (GtkWidget * widget, gpointer data)
{
Netinfo *scan = data;
g_return_if_fail (scan != NULL);
if (scan->running) {
scan_stop (scan);
} else {
scan_do (scan);
}
}
/* Lookup callbacks */
void
on_lookup_activate (GtkWidget * widget, gpointer data)
{
Netinfo *lookup = data;
g_return_if_fail (lookup != NULL);
if (lookup->running) {
lookup_stop (lookup);
} else {
lookup_do (lookup);
}
}
/* Finger callbacks */
void
on_finger_activate (GtkWidget * widget, gpointer data)
{
Netinfo *finger = data;
g_return_if_fail (finger != NULL);
if (finger->running) {
finger_stop (finger);
} else {
finger_do (finger);
}
}
/* Whois callbacks */
void
on_whois_activate (GtkWidget * widget, gpointer data)
{
Netinfo *whois = data;
g_return_if_fail (whois != NULL);
if (whois->running) {
whois_stop (whois);
} else {
whois_do (whois);
}
}
void
gn_quit_app (GtkWidget * widget, gpointer data)
{
gint status, pid;
pid = getpid () + 1;
while (waitpid (-1, &status, WNOHANG) == 0) {
if (waitpid (pid, &status, WNOHANG) == 0)
kill (pid, SIGKILL);
pid ++;
}
gtk_main_quit ();
}
void
on_about_activate (GtkWidget * parent, gpointer data)
{
static GtkWidget *about_box = NULL;
GdkPixbuf *pixbuf = NULL;
const gchar *authors[] = {
"Germán Poo Caamaño <gpoo@ubiobio.cl>",
"William Jon McCann <mccann@jhu.edu>", NULL
};
const gchar *documentors[] = { NULL };
const gchar copyright[1024];
g_sprintf (copyright, "Copyright \xc2\xa9 2003 %s", "Germán Poo Caamaño");
if (about_box != NULL) {
gtk_window_present (GTK_WINDOW (about_box));
return;
}
{
gchar *filename = NULL;
filename = g_build_filename (GNOME_ICONDIR, "gnome-netinfo.png", NULL);
if (filename != NULL) {
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
g_free (filename);
}
}
about_box = gnome_about_new ("GNOME Network Information",
VERSION,
copyright,
_
("Graphical user interface for common network utilities"),
authors, documentors,
_("This is an untranslated version of GNOME Network Information"),
pixbuf);
if (pixbuf != NULL)
g_object_unref (pixbuf);
gtk_window_set_transient_for (GTK_WINDOW (about_box),
GTK_WINDOW (parent));
g_signal_connect (G_OBJECT (about_box), "destroy",
G_CALLBACK (gtk_widget_destroyed), &about_box);
gtk_widget_show (about_box);
}
void
on_copy_activate (GtkWidget * notebook, gpointer data)
{
gint page;
Netinfo *netinfo;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
page = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
switch (page) {
case INFO:
netinfo = g_object_get_data (G_OBJECT (notebook), "info");
break;
case PING:
netinfo =
g_object_get_data (G_OBJECT (notebook), "pinger");
break;
case TRACEROUTE:
netinfo =
g_object_get_data (G_OBJECT (notebook), "tracer");
break;
case NETSTAT:
netinfo =
g_object_get_data (G_OBJECT (notebook), "netstat");
break;
case PORTSCAN:
netinfo = g_object_get_data (G_OBJECT (notebook), "scan");
break;
case LOOKUP:
netinfo = g_object_get_data (G_OBJECT (notebook), "lookup");
break;
case FINGER:
netinfo = g_object_get_data (G_OBJECT (notebook), "finger");
break;
case WHOIS:
netinfo = g_object_get_data (G_OBJECT (notebook), "whois");
break;
default:
g_print ("default notebook page?\n");
return;
}
if (netinfo->copy_output != NULL) {
(netinfo->copy_output) ((gpointer) netinfo, NULL);
}
}
void
on_clear_history_activate (GtkWidget * notebook, gpointer data)
{
Netinfo *netinfo;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
/* Pages all share a history id for host entry except whois */
netinfo = g_object_get_data (G_OBJECT (notebook), "finger");
gnome_entry_clear_history (GNOME_ENTRY (netinfo->host));
gnome_entry_clear_history (GNOME_ENTRY (netinfo->user));
netinfo = g_object_get_data (G_OBJECT (notebook), "whois");
gnome_entry_clear_history (GNOME_ENTRY (netinfo->host));
}
#include <gnome.h>
typedef void* (* NetinfoActivateFn) (GtkWidget *widget, gpointer data);
void on_ping_activate (GtkWidget * editable, gpointer data);
void on_traceroute_activate (GtkWidget * editable, gpointer data);
void on_netstat_activate (GtkWidget * widget, gpointer data);
void on_info_nic_changed (GtkEntry *entry, gpointer output);
void on_scan_activate (GtkWidget * widget, gpointer data);
void on_lookup_activate (GtkWidget * editable, gpointer data);
void on_finger_activate (GtkWidget * editable, gpointer data);
void on_whois_activate (GtkWidget * editable, gpointer data);
/* General stuff */
void gn_quit_app (GtkWidget * widget, gpointer data);
void on_about_activate (GtkWidget * parent, gpointer data);
void on_copy_activate (GtkWidget * notebook, gpointer data);
void on_clear_history_activate (GtkWidget * notebook, gpointer data);
/* -*- mode:C; indent-tabs-mode:t; tab-width:8; c-basic-offset:8; -*- */
/* gnome-netinfo - A GUI Interface for network utilities
* Copyright (C) 2003 by William Jon McCann
* Copyright (C) 2003 by German Poo-Caaman~o
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <gnome.h>
#include "finger.h"
#include "utils.h"
void
finger_stop (Netinfo * netinfo)
{
g_return_if_fail (netinfo != NULL);
netinfo_stop_process_command (netinfo);
}
void
finger_do (Netinfo * netinfo)
{
GtkTextBuffer *buffer = NULL;
GtkTextIter start, end;
const gchar *host = NULL;
const gchar *user = NULL;
gchar *command = NULL;
gchar *program = NULL;
GtkWidget *parent;
gchar **command_line;
gchar **command_options;
gint i, j, num_terms;
gchar *command_arg = NULL;
gboolean user_is_set, host_is_set;
g_return_if_fail (netinfo != NULL);
host = netinfo_get_host (netinfo);
user = netinfo_get_user (netinfo);
buffer =
gtk_text_view_get_buffer (GTK_TEXT_VIEW (netinfo->output));
gtk_text_buffer_get_start_iter (buffer, &start);
gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_delete (buffer, &start, &end);
parent = gtk_widget_get_toplevel (netinfo->output);
program = util_find_program_dialog ("finger", parent);
if (program != NULL) {
/* possible arguments are:
* none, user, user@host, @host
*/
user_is_set = (strcmp (user, "") != 0);
host_is_set = (strcmp (host, "") != 0);
if (user_is_set && ! host_is_set) {
command_arg = g_strdup (user);
} else if (user_is_set && host_is_set) {
command_arg = g_strdup_printf ("%s@%s", user, host);
} else if (! user_is_set && host_is_set) {
command_arg = g_strdup_printf ("@%s", host);
}
num_terms = 3;
if (command_arg != NULL)
num_terms++;
command_options = g_strsplit (FINGER_OPTIONS, " ", -1);
if (command_options != NULL) {
for (j = 0; command_options[j] != NULL; j++)
num_terms++;
}
command_line = g_new (gchar *, num_terms + 1);
i = 0;
command_line[i++] = g_strdup (program);
command_line[i++] = g_strdup ("finger");
if (command_options != NULL) {
for (j = 0; command_options[j] != NULL; j++)
command_line[i++] = g_strdup (command_options[j]);
}