diff --git a/ChangeLog b/ChangeLog index 18131fc..a88a9d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ -2003-08-31 Bernhard Wale +2003-09-06 Bernhard Walle + * added error message if the network device could not be found or if + /proc/net/dev could not be opened + * changed "ms" to "s" because that was wrong + * Released 0.2.0pre6 + +2003-08-31 Bernhard Walle * Fixed problem with unnecessary calls of init_netload(). * Call init_osspecific() on the right place. This caused the plugin not to work on (at least) NetBSD. diff --git a/configure b/configure index 153063b..6189441 100755 --- a/configure +++ b/configure @@ -1748,7 +1748,7 @@ fi # Define the identity of the package. PACKAGE=xfce4-netload-plugin - VERSION=0.2.0pre5 + VERSION=0.2.0pre6 cat >>confdefs.h <<_ACEOF diff --git a/configure.ac b/configure.ac index f6b61e8..cbcb70f 100644 --- a/configure.ac +++ b/configure.ac @@ -9,7 +9,7 @@ AC_INIT([panel-plugin/netload.c]) AM_CONFIG_HEADER([config.h]) -AM_INIT_AUTOMAKE([xfce4-netload-plugin], [0.2.0pre5]) +AM_INIT_AUTOMAKE([xfce4-netload-plugin], [0.2.0pre6]) AM_MAINTAINER_MODE diff --git a/panel-plugin/net.c b/panel-plugin/net.c index a1ff879..36a1a85 100644 --- a/panel-plugin/net.c +++ b/panel-plugin/net.c @@ -1,7 +1,7 @@ /* XFce 4 - Netload Plugin * Copyright (c) 2003 Bernhard Walle * - * Id: $Id: net.c,v 1.4 2003/08/31 12:54:36 bwalle Exp $ + * Id: $Id: net.c,v 1.5 2003/09/06 12:37:20 bwalle Exp $ * * 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 @@ -65,11 +65,15 @@ #endif - - -void init_netload(netdata* data, const char* device) +int init_netload(netdata* data, const char* device) { memset( data, 0, sizeof(netdata) ); + + if (device == NULL || strlen(device) == 0) + { + return TRUE; + } + strncpy( data->ifdata.if_name, device, 9 ); data->ifdata.if_name[9] = '\0'; @@ -78,7 +82,7 @@ void init_netload(netdata* data, const char* device) if (checkinterface(data) != TRUE) { data->correct_interface = FALSE; - return; + return FALSE; } /* init in a sane state */ @@ -91,6 +95,8 @@ void init_netload(netdata* data, const char* device) #ifdef DEBUG fprintf( stderr, "The netload plugin was initialized for '%s'.\n", device ); #endif /* DEBUG */ + + return TRUE; } diff --git a/panel-plugin/net.h b/panel-plugin/net.h index 5da5356..d6c1588 100644 --- a/panel-plugin/net.h +++ b/panel-plugin/net.h @@ -1,7 +1,7 @@ /* XFce 4 - Netload Plugin * Copyright (c) 2003 Bernhard Walle * - * Id: $Id: net.h,v 1.5 2003/08/31 12:54:36 bwalle Exp $ + * Id: $Id: net.h,v 1.6 2003/09/06 12:37:20 bwalle Exp $ * * 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 @@ -31,6 +31,19 @@ #include "os.h" #include "slurm.h" +#define MSGSIZE 1024 + +#ifndef gettext_noop +#define gettext_noop(String) String +#endif + +/** errorcodes */ +typedef enum { + UNKNOWN_ERROR, /* 0 */ + PROC_DEVICE_NOT_FOUND, /* 1 */ + INTERFACE_NOT_FOUND /* 2 */ +} errorcode_t; + /* * We need this because we cannot use static variables. Using of static variables allows @@ -43,6 +56,7 @@ typedef struct { char old_interface[9]; double backup_in; + errorcode_t errorcode; double backup_out; double cur_in; double cur_out; @@ -80,13 +94,14 @@ typedef struct } netdata; - /** * Initializes the netload plugin. Used to set up inital values. This function must * be called after each change of the network interface. * @param device The network device, e.g. ippp0 for ISDN on Linux. + * @return true if no error occurs, false otherwise. If there's + * an error, the error message may be set */ -void init_netload(netdata* data, const char* device); +int init_netload(netdata* data, const char* device); /** * Gets the current netload. You must call init_netload() once before you use this function! diff --git a/panel-plugin/netload.c b/panel-plugin/netload.c index 983a21a..c95fbae 100644 --- a/panel-plugin/netload.c +++ b/panel-plugin/netload.c @@ -1,7 +1,7 @@ /* XFce 4 - Netload Plugin * Copyright (c) 2003 Bernhard Walle * - * Id: $Id: netload.c,v 1.7 2003/08/31 12:54:36 bwalle Exp $ + * Id: $Id: netload.c,v 1.8 2003/09/06 12:37:20 bwalle Exp $ * * 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 @@ -43,7 +43,6 @@ extern xmlDocPtr xmlconfig; /* Defaults */ #define DEFAULT_TEXT "Net" -#define DEFAULT_DEVICE "eth0" #define INIT_MAX 4096 #define MINIMAL_MAX 1024 @@ -62,6 +61,14 @@ static gchar* DEFAULT_COLOR[] = { "#FF4F00", "#FFE500" }; #define TOT 2 #define SUM 2 +#define APP_NAME N_("Xfce4-Netload-Plugin") + +static char *errormessages[] = { + N_("Unknown error."), + N_("Linux proc device '/proc/net/dev' not found."), + N_("Interface was not found.") +}; + typedef struct { gboolean use_label; @@ -256,7 +263,7 @@ static t_global_monitor * monitor_new(void) global->monitor = g_new(t_monitor, 1); global->monitor->options.label_text = g_strdup(DEFAULT_TEXT); - global->monitor->options.network_device = g_strdup(DEFAULT_DEVICE); + global->monitor->options.network_device = g_strdup(""); global->monitor->options.old_network_device = g_strdup(""); global->monitor->options.use_label = TRUE; global->monitor->options.auto_max = TRUE; @@ -509,7 +516,16 @@ static void setup_monitor(t_global_monitor *global) if (!strcmp(global->monitor->options.network_device, global->monitor->options.old_network_device) == 0) { - init_netload( &(global->monitor->data), global->monitor->options.network_device); + if (!init_netload( &(global->monitor->data), global->monitor->options.network_device)) + { + xfce_err (_("%s: Error in initalizing:\n%s"), + _(APP_NAME), + _(errormessages[ + global->monitor->data.errorcode == 0 + ? INTERFACE_NOT_FOUND + : global->monitor->data.errorcode ])); + } + if (global->monitor->options.old_network_device) { g_free(global->monitor->options.old_network_device); @@ -629,19 +645,11 @@ static void monitor_write_config(Control *ctrl, xmlNodePtr parent) xmlSetProp(root, "Text", global->monitor->options.label_text); } - else - { - xmlSetProp(root, "Text", DEFAULT_TEXT); - } if (global->monitor->options.network_device) { xmlSetProp(root, "Network_Device", global->monitor->options.network_device); } - else - { - xmlSetProp(root, "Network_Device", DEFAULT_DEVICE); - } g_snprintf(value, 20, "%lu", global->monitor->options.max[IN]); xmlSetProp(root, "Max_In", value); @@ -981,7 +989,7 @@ static void monitor_create_options(Control *control, GtkContainer *container, Gt gtk_box_pack_start(GTK_BOX(update_hbox), GTK_WIDGET(global->monitor->update_spinner), FALSE, FALSE, 0); - update_unit_label = gtk_label_new(_("ms")); + update_unit_label = gtk_label_new(_("s")); gtk_box_pack_start(GTK_BOX(update_hbox), GTK_WIDGET(update_unit_label), FALSE, FALSE, 0); diff --git a/panel-plugin/wormulon/linux.c b/panel-plugin/wormulon/linux.c index 6811693..8ff2140 100644 --- a/panel-plugin/wormulon/linux.c +++ b/panel-plugin/wormulon/linux.c @@ -1,6 +1,6 @@ -/* $Id: linux.c,v 1.3 2003/08/31 12:54:36 bwalle Exp $ */ - +/* $Id: linux.c,v 1.4 2003/09/06 12:37:20 bwalle Exp $ */ +#include "linux.h" /***************************************************************************** * @@ -49,6 +49,13 @@ int checkinterface(netdata* data) break; } } + + /* check if the /proc/net/dev exists */ + if (access(PATH_NET_DEV, R_OK) != 0) + { + data->errorcode = PROC_DEVICE_NOT_FOUND; + return FALSE; + } return interfacefound; } diff --git a/po/ChangeLog b/po/ChangeLog index b20e4de..c39decf 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -1,3 +1,7 @@ +2003-09-06 Bernhard Walle + * Updated translation strings according to the new release. + * Updated German translation. + 2003-08-27 Carles Muoz Gorriz * Updated Catalan translation diff --git a/po/ca.po b/po/ca.po index 6396474..a3e04bd 100644 --- a/po/ca.po +++ b/po/ca.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: XFce 4\n" -"POT-Creation-Date: 2003-08-31 14:41+0200\n" +"POT-Creation-Date: 2003-09-06 14:31+0200\n" "PO-Revision-Date: 2003-08-26 23:58+0100\n" "Last-Translator: Carles Mu-oz Gorriz \n" "Language-Team: ca \n" @@ -14,7 +14,23 @@ msgstr "" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -#: panel-plugin/netload.c:216 +#: panel-plugin/netload.c:64 +msgid "Xfce4-Netload-Plugin" +msgstr "" + +#: panel-plugin/netload.c:67 +msgid "Unknown error." +msgstr "" + +#: panel-plugin/netload.c:68 +msgid "Linux proc device '/proc/net/dev' not found." +msgstr "" + +#: panel-plugin/netload.c:69 +msgid "Interface was not found." +msgstr "" + +#: panel-plugin/netload.c:223 #, c-format msgid "" "Average of last %d measures:\n" @@ -27,50 +43,58 @@ msgstr "" "Sortint: %s kBytes/s\n" "Total: %s kBytes/s" -#: panel-plugin/netload.c:834 +#: panel-plugin/netload.c:521 +#, c-format +msgid "" +"%s: Error in initalizing:\n" +"%s" +msgstr "" + +#: panel-plugin/netload.c:842 msgid "Select color" msgstr "Seleccioneu el color" -#: panel-plugin/netload.c:887 +#: panel-plugin/netload.c:895 msgid "Bar color (incoming):" msgstr "Color de la barra (entrant):" -#: panel-plugin/netload.c:888 +#: panel-plugin/netload.c:896 msgid "Bar color (outgoing):" msgstr "Color de la barra (sortint):" -#: panel-plugin/netload.c:891 +#: panel-plugin/netload.c:899 msgid "Maximum (incoming):" msgstr "Màxim (entrant):" -#: panel-plugin/netload.c:892 +#: panel-plugin/netload.c:900 msgid "Maximum (outgoing):" msgstr "Màxim (sortint):" -#: panel-plugin/netload.c:916 +#: panel-plugin/netload.c:924 msgid "Text to display:" msgstr "Text a mostrar:" -#: panel-plugin/netload.c:947 +#: panel-plugin/netload.c:955 msgid "Network device:" msgstr "Dispositiu de xarxa:" -#: panel-plugin/netload.c:973 +#: panel-plugin/netload.c:981 msgid "Update interval:" msgstr "Interval d'actualització:" -#: panel-plugin/netload.c:984 -msgid "ms" +#: panel-plugin/netload.c:992 +#, fuzzy +msgid "s" msgstr "ms" -#: panel-plugin/netload.c:997 +#: panel-plugin/netload.c:1005 msgid "Automatic maximum" msgstr "Màxim automatitzat" -#: panel-plugin/netload.c:1029 +#: panel-plugin/netload.c:1037 msgid "kByte/s" msgstr "kBytes/s" -#: panel-plugin/netload.c:1117 +#: panel-plugin/netload.c:1125 msgid "Netload" msgstr "Càrrega de red" diff --git a/po/de.po b/po/de.po index 153c4f5..113fc7a 100644 --- a/po/de.po +++ b/po/de.po @@ -3,15 +3,31 @@ msgid "" msgstr "" "Project-Id-Version: de\n" -"POT-Creation-Date: 2003-08-31 14:41+0200\n" -"PO-Revision-Date: 2003-08-10 19:35+0200\n" +"POT-Creation-Date: 2003-09-06 14:31+0200\n" +"PO-Revision-Date: 2003-09-06 14:25+0200\n" "Last-Translator: Bernhard Walle \n" "Language-Team: Deutsch \n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.0.2\n" -#: panel-plugin/netload.c:216 +#: panel-plugin/netload.c:64 +msgid "Xfce4-Netload-Plugin" +msgstr "Xfce4-Netzlast-Plugin" + +#: panel-plugin/netload.c:67 +msgid "Unknown error." +msgstr "Unbekannter Fehler." + +#: panel-plugin/netload.c:68 +msgid "Linux proc device '/proc/net/dev' not found." +msgstr "Linux Prozessdatei '/proc/net/dev' nicht gefunden." + +#: panel-plugin/netload.c:69 +msgid "Interface was not found." +msgstr "Schnittstelle nicht gefunden." + +#: panel-plugin/netload.c:223 #, c-format msgid "" "Average of last %d measures:\n" @@ -24,50 +40,59 @@ msgstr "" "Ausgehend: %s kByte/s\n" "Gesamt: %s kByte/s" -#: panel-plugin/netload.c:834 +#: panel-plugin/netload.c:521 +#, c-format +msgid "" +"%s: Error in initalizing:\n" +"%s" +msgstr "" +"%s: Fehler beim Initialisieren:\n" +"%s" + +#: panel-plugin/netload.c:842 msgid "Select color" msgstr "Farbe auswählen" -#: panel-plugin/netload.c:887 +#: panel-plugin/netload.c:895 msgid "Bar color (incoming):" msgstr "Balkenfarbe (eingehend):" -#: panel-plugin/netload.c:888 +#: panel-plugin/netload.c:896 msgid "Bar color (outgoing):" msgstr "Balkenfarbe (ausgehend):" -#: panel-plugin/netload.c:891 +#: panel-plugin/netload.c:899 msgid "Maximum (incoming):" msgstr "Maximum (eingehend):" -#: panel-plugin/netload.c:892 +#: panel-plugin/netload.c:900 msgid "Maximum (outgoing):" msgstr "Maximum (ausgehend):" -#: panel-plugin/netload.c:916 +#: panel-plugin/netload.c:924 msgid "Text to display:" msgstr "Angezeigter Text:" -#: panel-plugin/netload.c:947 +#: panel-plugin/netload.c:955 msgid "Network device:" msgstr "Netzwerkschnittstelle:" -#: panel-plugin/netload.c:973 +#: panel-plugin/netload.c:981 msgid "Update interval:" msgstr "Aktualisierungsintervall:" -#: panel-plugin/netload.c:984 -msgid "ms" -msgstr "ms" +#: panel-plugin/netload.c:992 +msgid "s" +msgstr "s" -#: panel-plugin/netload.c:997 +#: panel-plugin/netload.c:1005 msgid "Automatic maximum" msgstr "Automatisches Maximum" -#: panel-plugin/netload.c:1029 +#: panel-plugin/netload.c:1037 msgid "kByte/s" msgstr "kByte/s" -#: panel-plugin/netload.c:1117 +#: panel-plugin/netload.c:1125 msgid "Netload" msgstr "Netzlast" diff --git a/po/lt.po b/po/lt.po index e10b6c4..e7ce915 100644 --- a/po/lt.po +++ b/po/lt.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: xfce4-netload 1.0\n" -"POT-Creation-Date: 2003-08-31 14:41+0200\n" +"POT-Creation-Date: 2003-09-06 14:31+0200\n" "PO-Revision-Date: 2003-08-15 11:08+0300\n" "Last-Translator: Mantas \n" "Language-Team: \n" @@ -14,7 +14,23 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: panel-plugin/netload.c:216 +#: panel-plugin/netload.c:64 +msgid "Xfce4-Netload-Plugin" +msgstr "" + +#: panel-plugin/netload.c:67 +msgid "Unknown error." +msgstr "" + +#: panel-plugin/netload.c:68 +msgid "Linux proc device '/proc/net/dev' not found." +msgstr "" + +#: panel-plugin/netload.c:69 +msgid "Interface was not found." +msgstr "" + +#: panel-plugin/netload.c:223 #, fuzzy, c-format msgid "" "Average of last %d measures:\n" @@ -26,52 +42,59 @@ msgstr "" "Siunčiami: %lld bitų/s\n" "Viso: %lld bitų/s" -#: panel-plugin/netload.c:834 +#: panel-plugin/netload.c:521 +#, c-format +msgid "" +"%s: Error in initalizing:\n" +"%s" +msgstr "" + +#: panel-plugin/netload.c:842 msgid "Select color" msgstr "Pasirinkite spalvą" -#: panel-plugin/netload.c:887 +#: panel-plugin/netload.c:895 msgid "Bar color (incoming):" msgstr "Juostos spalva (gaunami duomenys)" -#: panel-plugin/netload.c:888 +#: panel-plugin/netload.c:896 msgid "Bar color (outgoing):" msgstr "Juostos spalva (siunčiami duomenys)" -#: panel-plugin/netload.c:891 +#: panel-plugin/netload.c:899 #, fuzzy msgid "Maximum (incoming):" msgstr "Juostos spalva (gaunami duomenys)" -#: panel-plugin/netload.c:892 +#: panel-plugin/netload.c:900 #, fuzzy msgid "Maximum (outgoing):" msgstr "Juostos spalva (siunčiami duomenys)" -#: panel-plugin/netload.c:916 +#: panel-plugin/netload.c:924 msgid "Text to display:" msgstr "Rodomas tekstas:" -#: panel-plugin/netload.c:947 +#: panel-plugin/netload.c:955 msgid "Network device:" msgstr "Tinklo įrenginys" -#: panel-plugin/netload.c:973 +#: panel-plugin/netload.c:981 msgid "Update interval:" msgstr "" -#: panel-plugin/netload.c:984 -msgid "ms" +#: panel-plugin/netload.c:992 +msgid "s" msgstr "" -#: panel-plugin/netload.c:997 +#: panel-plugin/netload.c:1005 msgid "Automatic maximum" msgstr "" -#: panel-plugin/netload.c:1029 +#: panel-plugin/netload.c:1037 msgid "kByte/s" msgstr "" -#: panel-plugin/netload.c:1117 +#: panel-plugin/netload.c:1125 msgid "Netload" msgstr "Tinklo apkrovimas" diff --git a/po/xfce4-netload.pot b/po/xfce4-netload.pot index 5954b07..0a1471a 100644 --- a/po/xfce4-netload.pot +++ b/po/xfce4-netload.pot @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2003-08-31 14:41+0200\n" +"POT-Creation-Date: 2003-09-06 14:31+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -15,7 +15,23 @@ msgstr "" "Content-Type: text/plain; charset=CHARSET\n" "Content-Transfer-Encoding: 8bit\n" -#: panel-plugin/netload.c:216 +#: panel-plugin/netload.c:64 +msgid "Xfce4-Netload-Plugin" +msgstr "" + +#: panel-plugin/netload.c:67 +msgid "Unknown error." +msgstr "" + +#: panel-plugin/netload.c:68 +msgid "Linux proc device '/proc/net/dev' not found." +msgstr "" + +#: panel-plugin/netload.c:69 +msgid "Interface was not found." +msgstr "" + +#: panel-plugin/netload.c:223 #, c-format msgid "" "Average of last %d measures:\n" @@ -24,50 +40,57 @@ msgid "" "Total: %s kByte/s" msgstr "" -#: panel-plugin/netload.c:834 +#: panel-plugin/netload.c:521 +#, c-format +msgid "" +"%s: Error in initalizing:\n" +"%s" +msgstr "" + +#: panel-plugin/netload.c:842 msgid "Select color" msgstr "" -#: panel-plugin/netload.c:887 +#: panel-plugin/netload.c:895 msgid "Bar color (incoming):" msgstr "" -#: panel-plugin/netload.c:888 +#: panel-plugin/netload.c:896 msgid "Bar color (outgoing):" msgstr "" -#: panel-plugin/netload.c:891 +#: panel-plugin/netload.c:899 msgid "Maximum (incoming):" msgstr "" -#: panel-plugin/netload.c:892 +#: panel-plugin/netload.c:900 msgid "Maximum (outgoing):" msgstr "" -#: panel-plugin/netload.c:916 +#: panel-plugin/netload.c:924 msgid "Text to display:" msgstr "" -#: panel-plugin/netload.c:947 +#: panel-plugin/netload.c:955 msgid "Network device:" msgstr "" -#: panel-plugin/netload.c:973 +#: panel-plugin/netload.c:981 msgid "Update interval:" msgstr "" -#: panel-plugin/netload.c:984 -msgid "ms" +#: panel-plugin/netload.c:992 +msgid "s" msgstr "" -#: panel-plugin/netload.c:997 +#: panel-plugin/netload.c:1005 msgid "Automatic maximum" msgstr "" -#: panel-plugin/netload.c:1029 +#: panel-plugin/netload.c:1037 msgid "kByte/s" msgstr "" -#: panel-plugin/netload.c:1117 +#: panel-plugin/netload.c:1125 msgid "Netload" msgstr ""