Sun Feb 11 04:28:49 2007 Michael Jennings (mej)

devilhorns' new net module.
----------------------------------------------------------------------


SVN revision: 28305
This commit is contained in:
Michael Jennings 2007-02-11 15:28:53 +00:00
parent b6deb97a9c
commit cec260cdd5
60 changed files with 1237 additions and 1815 deletions

View File

@ -1,2 +1 @@
Originally by Matthew Mullins.
Recoded into seperate modules by Christopher 'devilhorns' Michael <devilhorns@comcast.net>
Christopher 'devilhorns' Michael <devilhorns@devilhorns.us>

View File

@ -1,67 +1,38 @@
MAINTAINERCLEANFILES = Makefile.in e_modules-net.spec
ACLOCAL_AMFLAGS = -I m4
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS = po
SUBDIRS = src
EDJE_CC = @edje_cc@
EDJE_FLAGS = -v \
-id $(top_srcdir) \
-fd $(top_srcdir)
-id $(top_srcdir)/images \
-fd $(top_srcdir)/fonts
# data files for the module
filesdir = $(datadir)
files_DATA = module.desktop \
module.edj \
net.edj
EXTRA_DIST = $(files_DATA) \
module.desktop.in \
module.edc \
net.edc \
fonts/Vera.ttf \
fonts/VeraBd.ttf \
images/module_icon.png \
images/bd.png \
images/device.png \
images/rx.png \
images/tx.png \
images/idle.png
files_DATA = module_icon.png \
module.desktop \
module.edj \
net.edj
EXTRA_DIST=$(files_DATA) \
e_modules-net.spec \
net.edc \
rx_00.png \
rx_01.png \
rx_02.png \
rx_03.png \
rx_04.png \
rx_05.png \
rx_06.png \
rx_07.png \
rx_08.png \
rx_09.png \
rx_10.png \
tx_00.png \
tx_01.png \
tx_02.png \
tx_03.png \
tx_04.png \
tx_05.png \
tx_06.png \
tx_07.png \
tx_08.png \
tx_09.png \
tx_10.png \
VeraMono.ttf
# the module .so file
INCLUDES = -I. \
-I$(top_srcdir) \
-I$(includedir) \
@e_cflags@
pkgdir = $(datadir)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.c \
e_mod_main.h \
e_mod_config.c
module_la_LIBADD = @e_libs@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h $(top_builddir)/net.edj
%.edj: %.edc
%.edj: %.edc
$(EDJE_CC) $(EDJE_FLAGS) $< $@
module.edj: module.edc
$(EDJE_CC) $(EDJE_FLAGS) module.edc module.edj
clean-local:
rm -rf net.edj *~
rm -rf module.edj net.edj *~
uninstall:
rm -rf $(datadir)
rm -rf $(datadir)

Binary file not shown.

View File

@ -5,22 +5,11 @@ rm -f aclocal.m4 ltmain.sh
touch README
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS -I m4 || exit 1
echo "Running autoheader..." ; autoheader || exit 1
echo "Running autoconf..." ; autoconf || exit 1
echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1
echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1
echo "Generating gettext net.pot template"; \
xgettext \
--output net.pot \
--output-dir=po \
--language=C \
--add-location \
--keyword=D_ \
--sort-by-file \
--copyright-holder="TODO" \
--foreign-user \
`find . -name "*.[ch]" -print` || exit 1
if [ -z "$NOCONFIGURE" ]; then
./configure "$@"

View File

@ -1,156 +1,76 @@
dnl Process this file with autoconf to produce a configure script.
# get rid of that stupid cache mechanism
rm -f config.cache
AC_INIT(configure.in)
AC_PREREQ(2.59)
AC_INIT([net2], [0.0.1], [devilhorns@devilhorns.us])
AC_CONFIG_HEADERS(config.h)
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([1.9 foreign])
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE(net, 0.0.1)
AM_CONFIG_HEADER(config.h)
AC_ISC_POSIX
AC_PROG_CC
AM_PROG_CC_STDC
AC_HEADER_STDC
AC_C_CONST
AM_ENABLE_SHARED
AM_PROG_LIBTOOL
ALL_LINGUAS="eo fi it sv ja"
AC_SUBST(ALL_LINGUAS)
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION(0.14)
AC_HEADER_STDC
MODULE_ARCH="$host_os-$host_cpu"
AC_SUBST(MODULE_ARCH)
AC_DEFINE_UNQUOTED(MODULE_ARCH, "$MODULE_ARCH", "Module architecture")
if test "x${bindir}" = 'x${exec_prefix}/bin'; then
if test "x${exec_prefix}" = "xNONE"; then
if test "x${prefix}" = "xNONE"; then
bindir="${ac_default_prefix}/bin";
else
bindir="${prefix}/bin";
fi
else
if test "x${prefix}" = "xNONE"; then
bindir="${ac_default_prefix}/bin";
else
bindir="${prefix}/bin";
fi
fi
# Check Library Directory
if test "x${libdir}" = "x${exec_prefix}/lib"; then
if test "x${exec_prefix}" = "xNONE"; then
if test "x${prefix}" = "xNONE"; then
libdir="${ac_default_prefix}/lib";
else
libdir="${prefix}/lib";
fi
else
if test "x${prefix}" = "xNONE"; then
libdir="${ac_default_prefix}/lib";
else
libdir="${prefix}/lib";
fi
fi
fi
if test "x${libdir}" = 'x${exec_prefix}/lib'; then
if test "x${exec_prefix}" = "xNONE"; then
if test "x${prefix}" = "xNONE"; then
libdir="${ac_default_prefix}/lib";
else
libdir="${prefix}/lib";
fi
else
if test "x${prefix}" = "xNONE"; then
libdir="${ac_default_prefix}/lib";
else
libdir="${prefix}/lib";
fi
fi
fi
dnl Set PACKAGE_BIN_DIR in config.h.
if test "x${bindir}" = 'xNONE'; then
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${ac_default_prefix}/bin", "Package installed binaries destination")
else
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${prefix}/bin", "Package installed binaries destination")
fi
#
# Set Library Directory in config.h
#
if test "x${libdir}" = "xNONE"; then
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${ac_default_prefix}/lib", "Package libraries destination")
else
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${prefix}/lib", "Package libraries destination")
fi
else
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}", "Package installed binaries destination")
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${libdir}", "Package libraries destination")
fi
dnl Set PACKAGE_LIB_DIR in config.h.
if test "x${libdir}" = 'xNONE'; then
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${ac_default_prefix}/lib", "Package installed libraries destination")
else
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${prefix}/lib", "Package installed libraries destination")
fi
else
AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${libdir}", "Package installed libraries destination")
fi
dnl Set PACKAGE_DATA_DIR in config.h.
#
# Set Data Directory in config.h
#
if test "x${prefix}" = "xNONE"; then
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${HOME}/.e/e/modules/${PACKAGE}", "Package installed data destination")
datadir="${HOME}/.e/e/modules/${PACKAGE}"
datadir="${HOME}/.e/e/modules/${PACKAGE}"
else
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${libdir}/enlightenment/modules/${PACKAGE}", "Package installed data destination")
datadir="${libdir}/enlightenment/modules/${PACKAGE}"
datadir="${libdir}/enlightenment/modules/${PACKAGE}"
fi
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${datadir}", "Package data destination")
AC_PREFIX_DEFAULT(${HOME}/.e/e)
if test "x$prefix" = "xNONE"; then
datarootdir=${ac_default_prefix}
else
datarootdir=${prefix}/share
fi
localedir=${datarootdir}/locale
AC_SUBST(LOCALEDIR, "${localedir}")
AC_DEFINE_UNQUOTED(LOCALEDIR, "${localedir}", [Module Locale Directory])
#
# Check EFL Libs
#
AC_PATH_GENERIC([edje], [0.5.0], [], [AC_MSG_ERROR(Edje is not installed)],)
AC_PATH_PROG(EDJE_CC, "edje_cc", "", $PATH)
#AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl)
#AC_SUBST(dlopen_libs)
AC_ARG_WITH(edje-config,
[ --with-edje-config=EDJE_CONFIG use edje-config specified ],
[
EDJE_CONFIG=$withval;
echo "using "$EDJE_CONFIG" for edje-config";
/
],[
PROG="edje-config";
AC_PATH_PROG(EDJE_CONFIG, $PROG, "", $PATH)
])
edje_cflags=`$EDJE_CONFIG --cflags`
edje_libs=`$EDJE_CONFIG --libs`
AC_SUBST(edje_cflags)
AC_SUBST(edje_libs)
edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc"
AC_ARG_WITH(edje-cc,
[ --with-edje-cc=PATH specify a specific path to edje_cc],
[
v=$withval;
edje_cc=$v
echo " Enlightenment edje_cc explicitly set to "$edje_cc;
],[
edje_cc="`$EDJE_CONFIG --prefix`/bin/edje_cc"
])
AC_SUBST(edje_cc)
AC_ARG_WITH(enlightenment-config,
[ --with-enlightenment-config=E_CONFIG use enlightenment-config specified ],
[
E_CONFIG=$withval;
echo "using "$E_CONFIG" for enlightenment-config";
],[
PROG="enlightenment-config";
AC_PATH_PROG(E_CONFIG, $PROG, "", $PATH)
])
e_cflags=`$E_CONFIG --cflags`
e_libs=`$E_CONFIG --libs`
e_modules=`$E_CONFIG --module-dir`
AC_SUBST(e_cflags)
AC_SUBST(e_libs)
AC_SUBST(e_modules)
#
# Check Enlightenment
#
AC_PATH_GENERIC([enlightenment], [0.16.999.037], [], [AC_MSG_ERROR(Enlightenment is not installed)],)
AC_OUTPUT([
Makefile
e_modules-net.spec
src/Makefile
module.desktop
po/Makefile
],[
])
],[])

View File

@ -1,220 +0,0 @@
#include <e.h>
#include <Ecore.h>
#include "e_mod_main.h"
struct _E_Config_Dialog_Data
{
char *device;
double poll_time;
int always_text;
double max;
Ecore_List *devs;
int dev_num;
};
/* Protos */
static void *_create_data (E_Config_Dialog * cfd);
static void _free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata);
static Evas_Object *_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas,
E_Config_Dialog_Data * cfdata);
static int _basic_apply_data (E_Config_Dialog * cfd,
E_Config_Dialog_Data * cfdata);
static void _fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata);
static void _net_config_get_devices (Ecore_List * devs);
/* Config Calls */
void
_config_net_module (Config_Item * ci)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
E_Container *con;
char buf[4096];
v = E_NEW (E_Config_Dialog_View, 1);
v->create_cfdata = _create_data;
v->free_cfdata = _free_data;
v->basic.apply_cfdata = _basic_apply_data;
v->basic.create_widgets = _basic_create_widgets;
snprintf (buf, sizeof (buf), "%s/module.edj",
e_module_dir_get (net_config->module));
con = e_container_current_get (e_manager_current_get ());
cfd = e_config_dialog_new (con, D_ ("Net Configuration"), "Net", "_e_modules_net_config_dialog", buf, 0, v, ci);
net_config->config_dialog = cfd;
}
static void
_fill_data (Config_Item * ci, E_Config_Dialog_Data * cfdata)
{
char *tmp;
int i;
cfdata->poll_time = ci->poll_time;
cfdata->always_text = ci->always_text;
cfdata->max = ci->max;
if (ci->device != NULL)
cfdata->device = strdup (ci->device);
else
cfdata->device = NULL;
if (!cfdata->device)
return;
cfdata->devs = ecore_list_new ();
_net_config_get_devices (cfdata->devs);
if (!cfdata->devs)
return;
i = 0;
ecore_list_goto_first (cfdata->devs);
while ((tmp = ecore_list_next (cfdata->devs)) != NULL)
{
if (!strcmp (cfdata->device, tmp))
{
cfdata->dev_num = i;
break;
}
i++;
}
}
static void *
_create_data (E_Config_Dialog * cfd)
{
E_Config_Dialog_Data *cfdata;
Config_Item *ci;
ci = cfd->data;
cfdata = E_NEW (E_Config_Dialog_Data, 1);
_fill_data (ci, cfdata);
return cfdata;
}
static void
_free_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
{
if (!net_config)
return;
net_config->config_dialog = NULL;
E_FREE (cfdata->device);
if (cfdata->devs)
ecore_list_destroy (cfdata->devs);
free (cfdata);
cfdata = NULL;
}
static Evas_Object *
_basic_create_widgets (E_Config_Dialog * cfd, Evas * evas,
E_Config_Dialog_Data * cfdata)
{
Evas_Object *o, *of, *ob, *ot;
E_Radio_Group *rg;
char *tmp;
int i;
o = e_widget_list_add (evas, 0, 0);
of = e_widget_framelist_add (evas, D_ ("General Settings"), 0);
rg = e_widget_radio_group_new (&(cfdata->always_text));
ob = e_widget_radio_add (evas, D_ ("Always Show Text"), 1, rg);
e_widget_framelist_object_append (of, ob);
ob = e_widget_radio_add (evas, D_ ("Show Text On Mouse Over"), 0, rg);
e_widget_framelist_object_append (of, ob);
e_widget_list_object_append (o, of, 1, 1, 0.5);
of = e_widget_framelist_add (evas, D_ ("Device Settings"), 0);
ot = e_widget_table_add (evas, 0);
if (cfdata->devs)
{
rg = e_widget_radio_group_new (&(cfdata->dev_num));
i = 0;
ecore_list_goto_first (cfdata->devs);
while ((tmp = ecore_list_next (cfdata->devs)) != NULL)
{
ob = e_widget_radio_add (evas, tmp, i, rg);
e_widget_table_object_append (ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
i++;
}
}
i++;
ob = e_widget_label_add (evas, D_ ("Check Interval:"));
e_widget_table_object_append (ot, ob, 0, i, 1, 1, 0, 0, 1, 0);
i++;
ob =
e_widget_slider_add (evas, 1, 0, _("%1.0f seconds"), 1, 60, 1, 0,
&(cfdata->poll_time), NULL, 150);
e_widget_table_object_append (ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
i++;
ob = e_widget_label_add (evas, D_ ("Max MTU:"));
e_widget_table_object_append (ot, ob, 0, i, 1, 1, 0, 0, 1, 0);
i++;
ob =
e_widget_slider_add (evas, 1, 0, _("%1.0f"), 100, 1500, 100, 0,
&(cfdata->max), NULL, 150);
e_widget_table_object_append (ot, ob, 0, i, 1, 1, 1, 0, 1, 0);
e_widget_framelist_object_append (of, ot);
e_widget_list_object_append (o, of, 1, 1, 0.5);
return o;
}
static int
_basic_apply_data (E_Config_Dialog * cfd, E_Config_Dialog_Data * cfdata)
{
char *tmp;
Config_Item *ci;
ci = cfd->data;
tmp = ecore_list_goto_index (cfdata->devs, cfdata->dev_num);
if (tmp != NULL)
{
evas_stringshare_del (ci->device);
ci->device = evas_stringshare_add (tmp);
}
ci->poll_time = cfdata->poll_time;
ci->always_text = cfdata->always_text;
ci->max = cfdata->max;
e_config_save_queue ();
_net_config_updated (ci->id);
return 1;
}
static void
_net_config_get_devices (Ecore_List * devs)
{
FILE *stat;
char dev[64];
char buf[256];
unsigned long dummy;
stat = fopen ("/proc/net/dev", "r");
if (!stat)
return;
while (fgets (buf, 256, stat))
{
int i = 0;
for (; buf[i] != 0; i++)
{
if (buf[i] == ':')
buf[i] = ' ';
}
if (sscanf (buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%lu %lu %lu %lu\n", dev, &dummy, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 16)
continue;
ecore_list_append (devs, strdup (dev));
}
fclose (stat);
}

View File

@ -1,585 +0,0 @@
#include <e.h>
#include "e_mod_main.h"
typedef struct _Instance Instance;
typedef struct _Net Net;
struct _Instance
{
E_Gadcon_Client *gcc;
Evas_Object *net_obj;
Net *net;
Ecore_Timer *check_timer;
unsigned long old_in;
unsigned long old_out;
};
struct _Net
{
Instance *inst;
Evas_Object *net_obj;
};
/* Func Protos for Gadcon */
static E_Gadcon_Client *_gc_init (E_Gadcon * gc, const char *name,
const char *id, const char *style);
static void _gc_shutdown (E_Gadcon_Client * gcc);
static void _gc_orient (E_Gadcon_Client * gcc);
static char *_gc_label (void);
static Evas_Object *_gc_icon (Evas * evas);
/* Func Protos for Module */
static void _net_cb_mouse_down (void *data, Evas * e, Evas_Object * obj,
void *event_info);
static void _net_cb_mouse_in (void *data, Evas * e, Evas_Object * obj,
void *event_info);
static void _net_cb_mouse_out (void *data, Evas * e, Evas_Object * obj,
void *event_info);
static void _net_menu_cb_configure (void *data, E_Menu * m, E_Menu_Item * mi);
static void _net_menu_cb_post (void *data, E_Menu * m);
static Config_Item *_net_config_item_get (const char *id);
static Net *_net_new (Evas * evas);
static void _net_free (Net * net);
static void _net_update_rx (void *data, int value);
static void _net_update_tx (void *data, int value);
static int _net_cb_check (void *data);
static E_Config_DD *conf_edd = NULL;
static E_Config_DD *conf_item_edd = NULL;
Config *net_config = NULL;
/* Define the gadcon class and functions provided by this module */
static const E_Gadcon_Client_Class _gc_class = {
GADCON_CLIENT_CLASS_VERSION,
"net", {_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon},
E_GADCON_CLIENT_STYLE_PLAIN
};
static E_Gadcon_Client *
_gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style)
{
E_Gadcon_Client *gcc;
Evas_Object *o;
Instance *inst;
Config_Item *ci;
Net *net;
inst = E_NEW (Instance, 1);
ci = _net_config_item_get (id);
if (!ci->id)
ci->id = evas_stringshare_add (id);
net = _net_new (gc->evas);
net->inst = inst;
inst->net = net;
o = net->net_obj;
gcc = e_gadcon_client_new (gc, name, id, style, o);
gcc->data = inst;
inst->gcc = gcc;
inst->net_obj = o;
evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_DOWN,
_net_cb_mouse_down, inst);
evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_MOVE,
_net_cb_mouse_in, inst);
evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_IN, _net_cb_mouse_in,
inst);
evas_object_event_callback_add (o, EVAS_CALLBACK_MOUSE_OUT,
_net_cb_mouse_out, inst);
if (ci->always_text)
edje_object_signal_emit (inst->net_obj, "label_active", "");
_net_cb_check (inst);
inst->check_timer = ecore_timer_add (ci->poll_time, _net_cb_check, inst);
net_config->instances = evas_list_append (net_config->instances, inst);
return gcc;
}
static void
_gc_orient (E_Gadcon_Client * gcc)
{
e_gadcon_client_aspect_set (gcc, 16, 16);
e_gadcon_client_min_size_set (gcc, 16, 16);
}
static char *
_gc_label (void)
{
return D_ ("Net");
}
static Evas_Object *
_gc_icon (Evas * evas)
{
Evas_Object *o;
char buf[4096];
o = edje_object_add (evas);
snprintf (buf, sizeof (buf), "%s/module.edj",
e_module_dir_get (net_config->module));
edje_object_file_set (o, buf, "icon");
return o;
}
static void
_gc_shutdown (E_Gadcon_Client * gcc)
{
Instance *inst;
Net *net;
inst = gcc->data;
net = inst->net;
if (inst->check_timer)
ecore_timer_del (inst->check_timer);
net_config->instances = evas_list_remove (net_config->instances, inst);
evas_object_event_callback_del (net->net_obj, EVAS_CALLBACK_MOUSE_DOWN,
_net_cb_mouse_down);
evas_object_event_callback_del (net->net_obj, EVAS_CALLBACK_MOUSE_MOVE,
_net_cb_mouse_in);
evas_object_event_callback_del (net->net_obj, EVAS_CALLBACK_MOUSE_IN,
_net_cb_mouse_in);
evas_object_event_callback_del (net->net_obj, EVAS_CALLBACK_MOUSE_OUT,
_net_cb_mouse_out);
_net_free (net);
free (inst);
inst = NULL;
}
static void
_net_cb_mouse_down (void *data, Evas * e, Evas_Object * obj, void *event_info)
{
Instance *inst;
Evas_Event_Mouse_Down *ev;
inst = data;
ev = event_info;
if ((ev->button == 3) && (!net_config->menu))
{
E_Menu *mn;
E_Menu_Item *mi;
int x, y, w, h;
mn = e_menu_new ();
e_menu_post_deactivate_callback_set (mn, _net_menu_cb_post, inst);
net_config->menu = mn;
mi = e_menu_item_new (mn);
e_menu_item_label_set (mi, D_ ("Configuration"));
e_util_menu_item_edje_icon_set (mi, "enlightenment/configuration");
e_menu_item_callback_set (mi, _net_menu_cb_configure, inst);
mi = e_menu_item_new (mn);
e_menu_item_separator_set (mi, 1);
e_gadcon_client_util_menu_items_append (inst->gcc, mn, 0);
e_gadcon_canvas_zone_geometry_get (inst->gcc->gadcon, &x, &y, &w, &h);
e_menu_activate_mouse (mn,
e_util_zone_current_get (e_manager_current_get
()), x + ev->output.x,
y + ev->output.y, 1, 1,
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
evas_event_feed_mouse_up (inst->gcc->gadcon->evas, ev->button,
EVAS_BUTTON_NONE, ev->timestamp, NULL);
}
}
static void
_net_menu_cb_post (void *data, E_Menu * m)
{
if (!net_config->menu)
return;
e_object_del (E_OBJECT (net_config->menu));
net_config->menu = NULL;
}
static void
_net_menu_cb_configure (void *data, E_Menu * m, E_Menu_Item * mi)
{
Instance *inst;
Config_Item *ci;
inst = data;
ci = _net_config_item_get (inst->gcc->id);
_config_net_module (ci);
}
void
_net_config_updated (const char *id)
{
Evas_List *l;
Config_Item *ci;
if (!net_config)
return;
ci = _net_config_item_get (id);
for (l = net_config->instances; l; l = l->next)
{
Instance *inst;
inst = l->data;
if (!inst->gcc->id)
continue;
if (!strcmp (inst->gcc->id, ci->id))
{
if (inst->check_timer)
ecore_timer_del (inst->check_timer);
inst->check_timer =
ecore_timer_add ((double) ci->poll_time, _net_cb_check, inst);
if (ci->always_text)
edje_object_signal_emit (inst->net_obj, "label_active", "");
else
edje_object_signal_emit (inst->net_obj, "label_passive", "");
break;
}
}
}
static Config_Item *
_net_config_item_get (const char *id)
{
Evas_List *l;
Config_Item *ci;
for (l = net_config->items; l; l = l->next)
{
ci = l->data;
if (!ci->id)
continue;
if (!strcmp (ci->id, id))
return ci;
}
ci = E_NEW (Config_Item, 1);
ci->id = evas_stringshare_add (id);
ci->device = evas_stringshare_add ("eth0");
ci->poll_time = 1.0;
ci->max = 1500.0;
ci->always_text = 0;
net_config->items = evas_list_append (net_config->items, ci);
return ci;
}
/* Module routines */
EAPI E_Module_Api e_modapi = {
E_MODULE_API_VERSION,
"Net"
};
EAPI void *
e_modapi_init (E_Module * m)
{
bindtextdomain (PACKAGE, LOCALEDIR);
bind_textdomain_codeset (PACKAGE, "UTF-8");
conf_item_edd = E_CONFIG_DD_NEW ("Net_Config_Item", Config_Item);
#undef T
#undef D
#define T Config_Item
#define D conf_item_edd
E_CONFIG_VAL (D, T, id, STR);
E_CONFIG_VAL (D, T, device, STR);
E_CONFIG_VAL (D, T, max, DOUBLE);
E_CONFIG_VAL (D, T, poll_time, DOUBLE);
E_CONFIG_VAL (D, T, always_text, INT);
conf_edd = E_CONFIG_DD_NEW ("Net_Config", Config);
#undef T
#undef D
#define T Config
#define D conf_edd
E_CONFIG_LIST (D, T, items, conf_item_edd);
net_config = e_config_domain_load ("module.net", conf_edd);
if (!net_config)
{
Config_Item *ci;
net_config = E_NEW (Config, 1);
ci = E_NEW (Config_Item, 1);
ci->id = evas_stringshare_add ("0");
ci->device = evas_stringshare_add ("eth0");
ci->poll_time = 1.0;
ci->max = 1500.0;
ci->always_text = 0;
net_config->items = evas_list_append (net_config->items, ci);
}
net_config->module = m;
e_gadcon_provider_register (&_gc_class);
return m;
}
EAPI int
e_modapi_shutdown (E_Module * m)
{
net_config->module = NULL;
e_gadcon_provider_unregister (&_gc_class);
if (net_config->config_dialog)
e_object_del (E_OBJECT (net_config->config_dialog));
if (net_config->menu)
{
e_menu_post_deactivate_callback_set (net_config->menu, NULL, NULL);
e_object_del (E_OBJECT (net_config->menu));
net_config->menu = NULL;
}
while (net_config->items)
{
Config_Item *ci;
ci = net_config->items->data;
net_config->items =
evas_list_remove_list (net_config->items, net_config->items);
if (ci->id)
evas_stringshare_del (ci->id);
if (ci->device)
evas_stringshare_del (ci->device);
free (ci);
ci = NULL;
}
free (net_config);
net_config = NULL;
E_CONFIG_DD_FREE (conf_item_edd);
E_CONFIG_DD_FREE (conf_edd);
return 1;
}
EAPI int
e_modapi_save (E_Module * m)
{
Evas_List *l;
for (l = net_config->instances; l; l = l->next)
{
Instance *inst;
Config_Item *ci;
inst = l->data;
ci = _net_config_item_get (inst->gcc->id);
if (ci->id)
evas_stringshare_del (ci->id);
ci->id = evas_stringshare_add (inst->gcc->id);
}
e_config_domain_save ("module.net", conf_edd, net_config);
return 1;
}
EAPI int
e_modapi_about (E_Module * m)
{
e_module_dialog_show (m, D_ ("Enlightenment Network Monitor Module"),
D_
("This module is used to monitor a network device."));
return 1;
}
static Net *
_net_new (Evas * evas)
{
Net *net;
char buf[4096];
net = E_NEW (Net, 1);
net->net_obj = edje_object_add (evas);
snprintf (buf, sizeof (buf), "%s/net.edj",
e_module_dir_get (net_config->module));
if (!e_theme_edje_object_set
(net->net_obj, "base/theme/modules/net", "modules/net/main"))
edje_object_file_set (net->net_obj, buf, "modules/net/main");
evas_object_show (net->net_obj);
return net;
}
static void
_net_free (Net * n)
{
evas_object_del (n->net_obj);
free (n);
n = NULL;
}
static void
_net_update_rx (void *data, int value)
{
Edje_Message_Int_Set *val;
Instance *inst;
inst = data;
val = malloc (sizeof (Edje_Message_Int_Set) + (1 * sizeof (int)));
val->count = 1;
val->val[0] = value;
edje_object_message_send (inst->net_obj, EDJE_MESSAGE_INT_SET, 1, val);
free (val);
val = NULL;
}
static void
_net_update_tx (void *data, int value)
{
Edje_Message_Int_Set *val;
Instance *inst;
inst = data;
val = malloc (sizeof (Edje_Message_Int_Set) + (1 * sizeof (int)));
val->count = 1;
val->val[0] = value;
edje_object_message_send (inst->net_obj, EDJE_MESSAGE_INT_SET, 2, val);
free (val);
val = NULL;
}
static void
_net_cb_mouse_in (void *data, Evas * e, Evas_Object * obj, void *event_info)
{
Instance *inst;
Config_Item *ci;
inst = data;
ci = _net_config_item_get(inst->gcc->id);
if (!ci->always_text)
edje_object_signal_emit (inst->net_obj, "label_active", "");
}
static void
_net_cb_mouse_out (void *data, Evas * e, Evas_Object * obj, void *event_info)
{
Instance *inst;
Config_Item *ci;
inst = data;
ci = _net_config_item_get (inst->gcc->id);
if (!ci->always_text)
edje_object_signal_emit (inst->net_obj, "label_passive", "");
}
static int
_net_cb_check (void *data)
{
Instance *inst;
Config_Item *ci;
FILE *stat;
char dev[64];
char buf[256];
unsigned long in = 0;
unsigned long out = 0;
unsigned long dummy = 0;
int found;
long bytes_in, bytes_out;
char in_str[100];
char out_str[100];
double i, o;
inst = data;
ci = _net_config_item_get (inst->gcc->id);
stat = fopen ("/proc/net/dev", "r");
if (!stat)
return 1;
found = 0;
while (fgets (buf, 256, stat))
{
int i = 0;
for (; buf[i] != 0; i++)
if (buf[i] == ':')
buf[i] = ' ';
if (sscanf (buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%lu %lu %lu %lu\n", dev, &in, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &out, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17)
continue;
if (!ci->device)
continue;
if (!strcmp (dev, ci->device))
{
found = 1;
break;
}
}
fclose (stat);
if (!found)
return 1;
bytes_in = in - inst->old_in;
bytes_out = out - inst->old_out;
bytes_in = bytes_in / ci->poll_time;
bytes_out = bytes_out / ci->poll_time;
if (bytes_in < 0)
bytes_in = 0;
if (bytes_out < 0)
bytes_out = 0;
inst->old_in = in;
inst->old_out = out;
edje_object_part_text_set (inst->net_obj, "net_label", ci->device);
if (bytes_in <= 0)
edje_object_part_text_set (inst->net_obj, "rx_label", "Rx: 0 B");
else
{
if (bytes_in > 1048576)
snprintf (in_str, sizeof (in_str), "Rx: %ld Mb",
(bytes_in / 1048576));
else if (bytes_in > 1024 && bytes_in < 1048576)
snprintf (in_str, sizeof (in_str), "Rx: %ld Kb", (bytes_in / 1024));
else
snprintf (in_str, sizeof (in_str), "Rx: %ld B", bytes_in);
edje_object_part_text_set (inst->net_obj, "rx_label", in_str);
}
if (bytes_out <= 0)
edje_object_part_text_set (inst->net_obj, "tx_label", "Tx: 0 B");
else
{
if (bytes_out > 1048576)
snprintf (out_str, sizeof (out_str), "Tx: %ld Mb",
(bytes_out / 1048576));
else if (bytes_out > 1024 && bytes_out < 1048576)
snprintf (out_str, sizeof (out_str), "Tx: %ld Kb",
(bytes_out / 1024));
else
snprintf (out_str, sizeof (out_str), "Tx: %ld B", bytes_out);
edje_object_part_text_set (inst->net_obj, "tx_label", out_str);
}
i = 0.0;
if (bytes_in != 0.0)
i = ((double) bytes_in / (double) ci->max);
o = 0.0;
if (bytes_out != 0.0)
o = ((double) bytes_out / (double) ci->max);
if (i < 0.0)
i = 0.0;
if (o < 0.0)
o = 0.0;
if ((i > 0.0) && (i < 1.0))
i = 1.0;
if ((o > 0.0) && (o < 1.0))
o = 1.0;
_net_update_rx (inst, i);
_net_update_tx (inst, o);
return 1;
}

View File

@ -1,38 +0,0 @@
#define D_(str) dgettext(PACKAGE, str)
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
typedef struct _Config Config;
typedef struct _Config_Item Config_Item;
struct _Config
{
E_Module *module;
E_Config_Dialog *config_dialog;
E_Menu *menu;
Evas_List *instances;
Evas_List *items;
};
struct _Config_Item
{
const char *id;
const char *device;
double poll_time;
double max;
int always_text;
};
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init(E_Module *m);
EAPI int e_modapi_shutdown(E_Module *m);
EAPI int e_modapi_save(E_Module *m);
EAPI int e_modapi_about(E_Module *m);
void _net_config_updated(const char *id);
void _config_net_module(Config_Item *ci);
extern Config *net_config;
#endif

BIN
fonts/Vera.ttf Normal file

Binary file not shown.

BIN
fonts/VeraBd.ttf Normal file

Binary file not shown.

BIN
images/bd.png Normal file

Binary file not shown.

BIN
images/icon.xcf Normal file

Binary file not shown.

BIN
images/idle.png Normal file

Binary file not shown.

BIN
images/module_icon.png Normal file

Binary file not shown.

BIN
images/module_icon.xcf Normal file

Binary file not shown.

BIN
images/rx.png Normal file

Binary file not shown.

BIN
images/tx.png Normal file

Binary file not shown.

138
m4/ac_path_generic.m4 Normal file
View File

@ -0,0 +1,138 @@
dnl @synopsis AC_PATH_GENERIC(LIBRARY [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
dnl
dnl Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and LIBRARY_LIBS
dnl
dnl The script must support `--cflags' and `--libs' args.
dnl If MINIMUM-VERSION is specified, the script must also support the
dnl `--version' arg.
dnl If the `--with-library-[exec-]prefix' arguments to ./configure are given,
dnl it must also support `--prefix' and `--exec-prefix'.
dnl (In other words, it must be like gtk-config.)
dnl
dnl For example:
dnl
dnl AC_PATH_GENERIC(Foo, 1.0.0)
dnl
dnl would run `foo-config --version' and check that it is at least 1.0.0
dnl
dnl If so, the following would then be defined:
dnl
dnl FOO_CFLAGS to `foo-config --cflags`
dnl FOO_LIBS to `foo-config --libs`
dnl
dnl At present there is no support for additional "MODULES" (see AM_PATH_GTK)
dnl (shamelessly stolen from gtk.m4 and then hacked around a fair amount)
dnl
dnl @author Angus Lees <gusl@cse.unsw.edu.au>
AC_DEFUN([AC_PATH_GENERIC],
[dnl
dnl we're going to need uppercase, lowercase and user-friendly versions of the
dnl string `LIBRARY'
pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
dnl
dnl Get the cflags and libraries from the LIBRARY-config script
dnl
AC_ARG_WITH(DOWN-prefix,
[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)],
DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
AC_ARG_WITH(DOWN-exec-prefix,
[ --with-]DOWN[-exec-prefix=PFX Exec prefix where $1 is installed (optional)],
DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
if test x$DOWN[]_config_exec_prefix != x ; then
DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
if test x${UP[]_CONFIG+set} != xset ; then
UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
fi
fi
if test x$DOWN[]_config_prefix != x ; then
DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
if test x${UP[]_CONFIG+set} != xset ; then
UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
fi
fi
AC_PATH_PROG(UP[]_CONFIG, DOWN-config, no)
ifelse([$2], ,
AC_MSG_CHECKING(for $1),
AC_MSG_CHECKING(for $1 - version >= $2)
)
no_[]DOWN=""
if test "$UP[]_CONFIG" = "no" ; then
no_[]DOWN=yes
else
UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
ifelse([$2], , ,[
DOWN[]_config_major_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\1/'`
DOWN[]_config_minor_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\2/'`
DOWN[]_config_micro_version=`$UP[]_CONFIG $DOWN[]_config_args \
--version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\3/'`
DOWN[]_wanted_major_version="regexp($2, [\<\([0-9]*\)], [\1])"
DOWN[]_wanted_minor_version="regexp($2, [\<\([0-9]*\)\.\([0-9]*\)], [\2])"
DOWN[]_wanted_micro_version="regexp($2, [\<\([0-9]*\).\([0-9]*\).\([0-9]*\)], [\3])"
# Compare wanted version to what config script returned.
# If I knew what library was being run, i'd probably also compile
# a test program at this point (which also extracted and tested
# the version in some library-specific way)
if test "$DOWN[]_config_major_version" -lt \
"$DOWN[]_wanted_major_version" \
-o \( "$DOWN[]_config_major_version" -eq \
"$DOWN[]_wanted_major_version" \
-a "$DOWN[]_config_minor_version" -lt \
"$DOWN[]_wanted_minor_version" \) \
-o \( "$DOWN[]_config_major_version" -eq \
"$DOWN[]_wanted_major_version" \
-a "$DOWN[]_config_minor_version" -eq \
"$DOWN[]_wanted_minor_version" \
-a "$DOWN[]_config_micro_version" -lt \
"$DOWN[]_wanted_micro_version" \) ; then
# older version found
no_[]DOWN=yes
echo -n "*** An old version of $1 "
echo -n "($DOWN[]_config_major_version"
echo -n ".$DOWN[]_config_minor_version"
echo ".$DOWN[]_config_micro_version) was found."
echo -n "*** You need a version of $1 newer than "
echo -n "$DOWN[]_wanted_major_version"
echo -n ".$DOWN[]_wanted_minor_version"
echo ".$DOWN[]_wanted_micro_version."
echo "***"
echo "*** If you have already installed a sufficiently new version, this error"
echo "*** probably means that the wrong copy of the DOWN-config shell script is"
echo "*** being found. The easiest way to fix this is to remove the old version"
echo "*** of $1, but you can also set the UP[]_CONFIG environment to point to the"
echo "*** correct copy of DOWN-config. (In this case, you will have to"
echo "*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf"
echo "*** so that the correct libraries are found at run-time)"
fi
])
fi
if test "x$no_[]DOWN" = x ; then
AC_MSG_RESULT(yes)
ifelse([$3], , :, [$3])
else
AC_MSG_RESULT(no)
if test "$UP[]_CONFIG" = "no" ; then
echo "*** The DOWN-config script installed by $1 could not be found"
echo "*** If $1 was installed in PREFIX, make sure PREFIX/bin is in"
echo "*** your path, or set the UP[]_CONFIG environment variable to the"
echo "*** full path to DOWN-config."
fi
UP[]_CFLAGS=""
UP[]_LIBS=""
ifelse([$4], , :, [$4])
fi
AC_SUBST(UP[]_CFLAGS)
AC_SUBST(UP[]_LIBS)
popdef([UP])
popdef([DOWN])
])

28
module.edc Normal file
View File

@ -0,0 +1,28 @@
images
{
image: "module_icon.png" COMP;
}
collections
{
group
{
name: "icon";
max: 128 128;
parts
{
part
{
name: "base";
mouse_events: 0;
description
{
state: "default" 0.0;
aspect: 1.0 1.0;
aspect_preference: BOTH;
image.normal: "module_icon.png";
}
}
}
}
}

685
net.edc
View File

@ -1,499 +1,290 @@
images
images
{
image: "module_icon.png" COMP;
image: "rx_00.png" COMP;
image: "rx_01.png" COMP;
image: "rx_02.png" COMP;
image: "rx_03.png" COMP;
image: "rx_04.png" COMP;
image: "rx_05.png" COMP;
image: "rx_06.png" COMP;
image: "rx_07.png" COMP;
image: "rx_08.png" COMP;
image: "rx_09.png" COMP;
image: "rx_10.png" COMP;
image: "tx_00.png" COMP;
image: "tx_01.png" COMP;
image: "tx_02.png" COMP;
image: "tx_03.png" COMP;
image: "tx_04.png" COMP;
image: "tx_05.png" COMP;
image: "tx_06.png" COMP;
image: "tx_07.png" COMP;
image: "tx_08.png" COMP;
image: "tx_09.png" COMP;
image: "tx_10.png" COMP;
image: "device.png" COMP;
image: "rx.png" COMP;
image: "tx.png" COMP;
image: "idle.png" COMP;
image: "bd.png" COMP;
}
fonts
fonts
{
font: "VeraMono.ttf" "VeraMono";
font: "Vera.ttf" "Vera";
font: "VeraBd.ttf" "VeraBold";
}
collections
collections
{
group
group
{
name: "modules/net/main";
min: 4 4;
max: 128 128;
script
parts
{
public message(Msg_Type:type, id, ...)
part
{
if ((type == MSG_INT_SET) && (id == 1))
{
new f = getarg(2);
new Float:value;
value = f;
value = (value / 10);
set_state(PART:"rx_meter", "default", value);
}
if ((type == MSG_INT_SET) && (id == 2))
{
new f = getarg(2);
new Float:value;
value = f;
value = (value / 10);
set_state(PART:"tx_meter", "default", value);
}
}
}
parts
{
part
{
name: "fade_clip";
type: RECT;
description
{
state: "default" 0.0;
color: 255 255 255 255;
rel1
{
relative: 0.0 0.0;
offset: 0 0;
}
rel2
{
relative: 1.0 1.0;
offset: -1 -1;
}
}
}
part
{
name: "net";
name: "rx";
type: IMAGE;
clip_to: "fade_clip";
description
description
{
state: "default" 0.0;
aspect: 1.0 1.0;
aspect_preference: BOTH;
rel1
{
relative: 0.0 0.0;
offset: 0 0;
}
rel2
{
relative: 1.0 1.0;
offset: -1 -1;
}
image
{
normal: "module_icon.png";
}
color: 255 255 255 192;
visible: 0;
rel1.to: "base";
rel2.to: "base";
image.normal: "rx.png";
color: 255 255 255 0;
}
description
{
state: "active" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part
{
name: "net_label";
type: TEXT;
effect: SOFT_SHADOW;
description
{
state: "default" 0.0;
color: 255 255 255 0;
color3: 0 0 0 0;
visible: 0;
rel1
{
relative: 0.0 0.0;
offset: 0 0;
to: "net";
}
rel2
{
relative: 1.0 1.0;
offset: -1 -1;
to: "net";
}
text
{
text: "";
font: "VeraMono";
size: 9;
min: 1 1;
align: 0.5 0.5;
text_class: "module_normal";
}
}
description
{
state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
color3: 0 0 0 42;
color_class: "module_label";
}
}
part
{
name: "rx_meter";
name: "base";
type: IMAGE;
clip_to: "fade_clip";
description
description
{
state: "default" 0.0;
rel1
{
relative: 0.0 0.0;
offset: 0 0;
}
rel2
{
relative: 1.0 0.25;
offset: -1 -1;
}
image
{
normal: "rx_00.png";
}
color: 255 255 255 192;
}
description
{
state: "default" 0.1;
inherit: "default" 0.0;
image
{
normal: "rx_01.png";
}
}
description
{
state: "default" 0.2;
inherit: "default" 0.0;
image
{
normal: "rx_02.png";
}
}
description
{
state: "default" 0.3;
inherit: "default" 0.0;
image
{
normal: "rx_03.png";
}
}
description
{
state: "default" 0.4;
inherit: "default" 0.0;
image
{
normal: "rx_04.png";
}
}
description
{
state: "default" 0.5;
inherit: "default" 0.0;
image
{
normal: "rx_05.png";
}
}
description
{
state: "default" 0.6;
inherit: "default" 0.0;
image
{
normal: "rx_06.png";
}
}
description
{
state: "default" 0.7;
inherit: "default" 0.0;
image
{
normal: "rx_07.png";
}
}
description
{
state: "default" 0.8;
inherit: "default" 0.0;
image
{
normal: "rx_08.png";
}
}
description
{
state: "default" 0.9;
inherit: "default" 0.0;
image
{
normal: "rx_09.png";
}
}
description
{
state: "default" 1.0;
inherit: "default" 0.0;
image
{
normal: "rx_10.png";
}
aspect: 1.0 1.0;
aspect_preference: BOTH;
image.normal: "idle.png";
}
}
part
{
name: "rx_label";
type: TEXT;
effect: SOFT_SHADOW;
description
{
state: "default" 0.0;
color: 255 255 255 0;
color3: 0 0 0 0;
visible: 0;
rel1
{
relative: 0.5 0.0;
offset: 0 0;
to: "rx_meter";
}
rel2
{
relative: 0.5 1.0;
offset: -1 -1;
to: "rx_meter";
}
text
{
text: "Rx:";
font: "VeraMono";
size: 9;
min: 1 1;
align: 0.5 1.0;
text_class: "module_small";
}
}
description
{
state: "visible" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
color3: 0 0 0 42;
color_class: "module_label";
}
}
part
{
name: "tx_meter";
name: "tx";
type: IMAGE;
clip_to: "fade_clip";
description
{
state: "default" 0.0;
rel1
{
relative: 0.0 0.75;
offset: 0 0;
}
rel2
{
relative: 1.0 1.0;
offset: -1 -1;
}
image
{
normal: "tx_00.png";
}
color: 255 255 255 192;
}
description
{
state: "default" 0.1;
inherit: "default" 0.0;
image
{
normal: "tx_01.png";
}
}
description
{
state: "default" 0.2;
inherit: "default" 0.0;
image
{
normal: "tx_02.png";
}
}
description
{
state: "default" 0.3;
inherit: "default" 0.0;
image
{
normal: "tx_03.png";
}
}
description
{
state: "default" 0.4;
inherit: "default" 0.0;
image
{
normal: "tx_04.png";
}
}
description
{
state: "default" 0.5;
inherit: "default" 0.0;
image
{
normal: "tx_05.png";
}
}
description
{
state: "default" 0.6;
inherit: "default" 0.0;
image
{
normal: "tx_06.png";
}
}
description
{
state: "default" 0.7;
inherit: "default" 0.0;
image
{
normal: "tx_07.png";
}
}
description
{
state: "default" 0.8;
inherit: "default" 0.0;
image
{
normal: "tx_08.png";
}
}
description
{
state: "default" 0.9;
inherit: "default" 0.0;
image
{
normal: "tx_09.png";
}
}
description
{
state: "default" 1.0;
inherit: "default" 0.0;
image
{
normal: "tx_10.png";
}
}
}
part
{
name: "tx_label";
type: TEXT;
effect: SOFT_SHADOW;
description
{
state: "default" 0.0;
color: 255 255 255 0;
color3: 0 0 0 0;
aspect: 1.0 1.0;
aspect_preference: BOTH;
visible: 0;
rel1
{
relative: 0.5 0.0;
offset: 0 0;
to: "tx_meter";
}
rel2
{
relative: 0.5 1.0;
offset: -1 -1;
to: "tx_meter";
}
text
{
text: "Tx:";
font: "VeraMono";
size: 9;
min: 1 1;
align: 0.5 1.0;
text_class: "module_small";
}
rel1.to: "base";
rel2.to: "base";
image.normal: "tx.png";
color: 255 255 255 0;
}
description
{
state: "visible" 0.0;
state: "active" 0.0;
inherit: "default" 0.0;
visible: 1;
color: 255 255 255 255;
color3: 0 0 0 42;
color_class: "module_label";
}
}
}
}
programs
{
program
{
name: "go_active";
signal: "label_active";
source: "";
action: STATE_SET "visible" 0.0;
transition: SINUSOIDAL 0.5;
target: "rx_label";
target: "tx_label";
target: "net_label";
name: "recv";
signal: "e,state,receive,active";
source: "e";
action: STATE_SET "active" 0.0;
target: "rx";
transition: SINUSOIDAL 0.25;
}
program
{
name: "go_passive";
signal: "label_passive";
source: "";
name: "send";
signal: "e,state,send,active";
source: "e";
action: STATE_SET "active" 0.0;
target: "tx";
transition: SINUSOIDAL 0.25;
}
program
{
name: "recv_idle";
signal: "e,state,receive,idle";
source: "e";
action: STATE_SET "default" 0.0;
transition: SINUSOIDAL 1.0;
target: "rx_label";
target: "tx_label";
target: "net_label";
target: "rx";
transition: DECELERATE 0.75;
}
program
{
name: "send_idle";
signal: "e,state,send,idle";
source: "e";
action: STATE_SET "default" 0.0;
target: "tx";
transition: DECELERATE 0.75;
}
}
}
group
{
name: "modules/net/popup";
parts
{
part
{
name: "base";
mouse_events: 0;
type: RECT;
description
{
state: "default" 0.0;
rel1.offset: 1 1;
rel2.offset: -2 -2;
color: 221 221 221 255;
min: 125 50;
}
}
part
{
name: "bd";
mouse_events: 0;
description
{
state: "default" 0.0;
rel1.offset: 0 0;
rel2.offset: -1 -1;
image
{
normal: "bd.png";
border: 1 1 1 1;
middle: 0;
}
fill.smooth: 0;
}
}
part
{
name: "e.text.title";
type: TEXT;
effect: SOFT_SHADOW;
mouse_events: 0;
description
{
state: "default" 0.0;
fixed: 0 1;
align: 0.5 0.0;
rel1.offset: 0 4;
rel2.relative: 1.0 0.0;
rel2.offset: -1 4;
color: 255 255 255 255;
color3: 0 0 0 42;
color_class: "menu_title";
text
{
text: "";
font: "VeraBold";
size: 10;
min: 1 1;
align: 0.5 0.0;
text_class: "menu_title";
elipsis: 0.0;
}
}
}
part
{
name: "icon";
mouse_events: 0;
description
{
state: "default" 0.0;
min: 32 32;
max: 32 32;
align: 0.0 0.5;
fixed: 1 1;
rel1
{
relative: 0.0 1.0;
offset: 6 10;
to_y: "e.text.title";
}
rel2
{
relative: 0.0 1.0;
offset: 6 10;
to_y: "e.text.title";
}
image.normal: "device.png";
}
}
part
{
name: "e.text.recv";
type: TEXT;
effect: SHADOW;
mouse_events: 0;
description
{
state: "default" 0.0;
fixed: 1 1;
rel1
{
relative: 1.0 0.0;
offset: 8 6;
to: "icon";
}
rel2
{
relative: 1.0 0.0;
offset: -8 6;
to_y: "icon";
}
color: 74 180 74 255;
color3: 0 0 0 42;
color_class: "menu_item";
text
{
text: "Rx:";
font: "VeraBold";
size: 10;
min: 1 1;
align: 0.0 0.5;
text_class: "menu_item";
elipsis: 0.0;
}
}
}
part
{
name: "e.text.send";
type: TEXT;
effect: SHADOW;
mouse_events: 0;
description
{
state: "default" 0.0;
fixed: 1 1;
rel1
{
relative: 1.0 1.0;
offset: 8 -6;
to: "icon";
}
rel2
{
relative: 1.0 1.0;
offset: -8 -6;
to_y: "icon";
}
color: 164 46 46 255;
color3: 0 0 0 42;
color_class: "menu_item";
text
{
text: "Tx:";
font: "VeraBold";
size: 10;
min: 1 1;
align: 0.0 0.5;
text_class: "menu_item";
elipsis: 0.0;
}
}
}
}
}

View File

@ -1,28 +0,0 @@
MAINTAINERCLEANFILES = Makefile.in $(PACKAGE).pot
MSGFMT = msgfmt
localedir = @LOCALEDIR@
locale_DATA = $(addsuffix .mo,$(ALL_LINGUAS))
EXTRA_DIST = $(PACKAGE).pot $(addsuffix .po,$(ALL_LINGUAS))
%.mo : %.po
$(MSGFMT) -f -o $@ $<
install-localeDATA:
uninstall-localeDATA:
install-data-local:
for L in $(ALL_LINGUAS); do \
$(mkinstalldirs) $(DESTDIR)$(localedir)/$$L/LC_MESSAGES; \
$(INSTALL_DATA) \
$$L.mo $(DESTDIR)$(localedir)/$$L/LC_MESSAGES/$(PACKAGE).mo; \
done
uninstall:
for L in $(ALL_LINGUAS); do \
rm -f $(DESTDIR)$(localedir)/$$L/LC_MESSAGES/$(PACKAGE).mo; \
done
clean-local:
rm -f *.mo

View File

@ -1,63 +0,0 @@
# translation of eo.po to
# This file is put in the public domain.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Language-Team: Esperanto <translation-team-eo@lists.sourceforge.net>\n"
"Report-Msgid-Bugs-To: olivierweb@ifrance.com\n"
"Project-Id-Version: eo\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-08-29 10:20+0200\n"
"PO-Revision-Date: 2006-08-30 23:27+0200\n"
"Last-Translator: \n"
"Language-Team: <fr@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: KBabel 1.11.2\n"
#: e_mod_config.c:44
msgid "Net Configuration"
msgstr "Konfiguraĵo de Reto"
#: e_mod_config.c:122
msgid "General Settings"
msgstr "Ĝeneralaj Agordoj"
#: e_mod_config.c:124
msgid "Always Show Text"
msgstr "Cxiam Vidigi Tekston"
#: e_mod_config.c:126
msgid "Show Text On Mouse Over"
msgstr "Vidigi Tekston dum movado de muso"
#: e_mod_config.c:130
msgid "Device Settings"
msgstr "Aparataj Agordoj"
#: e_mod_config.c:142
msgid "Check Interval:"
msgstr "Kontroli Intervalon :"
#: e_mod_config.c:150
msgid "Max MTU:"
msgstr ""
#: e_mod_main.c:114
msgid "Net"
msgstr "Reto"
#: e_mod_main.c:176
msgid "Configuration"
msgstr "Konfiguraĵo"
#: e_mod_main.c:379
msgid "Enlightenment Network Monitor Module"
msgstr "\"Enlightenment-a Reta Kasxauxskulto\" Modulo"
#: e_mod_main.c:381
msgid "This module is used to monitor a network device."
msgstr "Tiu modulo uzigxas por kasxauxskulti retan aparaton"

View File

@ -1,47 +0,0 @@
# Enlightenment 0.17 net Finnish translation
# This file is put in the public domain.
# First author: Jyri Hämäläinen <wildfinn@gmail.com>, 2005.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: enlightenment-devel@lists.sourceforge.net\n"
"POT-Creation-Date: 2006-04-04\n"
"PO-Revision-Date: 2006-04-04\n"
"Last-Translator: Jyri Hämäläinen <wildfinn@gmail.com>\n"
"Language-Team: Jyri Hämäläinen <wildfinn@gmail.com>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: e_mod_config.c:39
msgid "Net Configuration"
msgstr "Verkkovalvojan asetukset"
#: e_mod_config.c:114
msgid "General Settings"
msgstr "Yleiset asetukset"
#: e_mod_config.c:115
msgid "Show Text"
msgstr "Näytä teksti"
#: e_mod_config.c:117
msgid "Show Graph"
msgstr "Näytä kuvaaja"
#: e_mod_config.c:121
msgid "Device Settings"
msgstr "Laiteasetukset"
#: e_mod_config.c:133
msgid "Check Interval:"
msgstr "Terkistusväli:"
#: e_mod_main.c:96
msgid "Enlightenment Network Monitor Module"
msgstr "Enlightenment verkkovalvojamoduuli"
#: e_mod_main.c:97
msgid "This module is used to monitor a network device."
msgstr "Tämä moduuli tarkkailee verkkolaitetta."

View File

@ -1,59 +0,0 @@
# Italian translation for E17 net module.
# This file is put in the public domain.
# Massimo Maiurana <maiurana@inwind.it>, 2005.
#
msgid ""
msgstr ""
"Project-Id-Version: Net\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-05-27 13:52+0200\n"
"PO-Revision-Date: 2006-05-27 13:58+0200\n"
"Last-Translator: Massimo Maiurana <maiurana@inwind.it>\n"
"Language-Team: none\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"
#: e_mod_config.c:39
msgid "Net Configuration"
msgstr "Configurazione modulo Net"
#: e_mod_config.c:115
msgid "General Settings"
msgstr "Impostazioni generali"
#: e_mod_config.c:117
msgid "Always Show Text"
msgstr "Mostra testo sempre"
#: e_mod_config.c:119
msgid "Show Text On Mouse Over"
msgstr "Mostra testo al passaggio del mouse"
#: e_mod_config.c:123
msgid "Device Settings"
msgstr "Impostazione del dispositivo"
#: e_mod_config.c:135
msgid "Check Interval:"
msgstr "Frequenza di aggiornamento:"
#: e_mod_config.c:141
msgid "Max MTU:"
msgstr "MTU massima:"
#: e_mod_main.c:105
msgid "Net"
msgstr "Net"
#: e_mod_main.c:152
msgid "Configuration"
msgstr "Configurazione"
#: e_mod_main.c:361
msgid "Enlightenment Network Monitor Module"
msgstr "Modulo Net di Enlightenment"
#: e_mod_main.c:361
msgid "This module is used to monitor a network device."
msgstr "Questo modulo viene usato per monitorare un dispositivo di rete."

View File

@ -1,64 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# This file is put in the public domain.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
# Yasufumi Haga <yasufumi.haga@nifty.com>, 2006
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Net\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-05-28 19:42+0900\n"
"PO-Revision-Date: 2006-05-28 22:42+0900\n"
"Last-Translator: Yasufumi Haga <yasufumi.haga@nifty.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: e_mod_config.c:39
msgid "Net Configuration"
msgstr "net の設定"
#: e_mod_config.c:115
msgid "General Settings"
msgstr "一般の設定"
#: e_mod_config.c:117
msgid "Always Show Text"
msgstr "常に表示する"
#: e_mod_config.c:119
msgid "Show Text On Mouse Over"
msgstr "マウスが乗れば表示する"
#: e_mod_config.c:123
msgid "Device Settings"
msgstr "デバイスの設定"
#: e_mod_config.c:135
msgid "Check Interval:"
msgstr "監視間隔"
#: e_mod_config.c:141
msgid "Max MTU:"
msgstr "最大 MTU:"
#: e_mod_main.c:105
msgid "Net"
msgstr ""
#: e_mod_main.c:152
msgid "Configuration"
msgstr "設定"
#: e_mod_main.c:361
msgid "Enlightenment Network Monitor Module"
msgstr "Enlightenment ネットワーク監視モジュール"
#: e_mod_main.c:361
msgid "This module is used to monitor a network device."
msgstr "これはネットワークデバイスを監視するためのモジュールです."
#~ msgid "Show Graph"
#~ msgstr "グラフを表示する"

View File

@ -1,64 +0,0 @@
# Swedish translation of Net module for E17.
# This file is put in the public domain.
# Anders Trobäck <enlightenment@troback.com>, 2006.
# , fuzzy
#
#
msgid ""
msgstr ""
"Project-Id-Version: Net module for E17 N/A\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2006-07-05 17:22+0200\n"
"PO-Revision-Date: 2006-07-05 23:33+0200\n"
"Last-Translator: Anders Trobäck <enlightenment@troback.com>\n"
"Language-Team: Swedish\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit"
#: e_mod_config.c:41
msgid "Net Configuration"
msgstr "Net konfiguration"
#: e_mod_config.c:117
msgid "General Settings"
msgstr "Allmänna inställningar"
#: e_mod_config.c:119
msgid "Always Show Text"
msgstr "Visa alltid text"
#: e_mod_config.c:121
msgid "Show Text On Mouse Over"
msgstr "Visa text när musen är över"
#: e_mod_config.c:125
msgid "Device Settings"
msgstr "Enhetsinställningar"
#: e_mod_config.c:137
msgid "Check Interval:"
msgstr "Kontrollintervall:"
#: e_mod_config.c:143
msgid "Max MTU:"
msgstr "Max MTU:"
#: e_mod_main.c:105
msgid "Net"
msgstr "Net"
#: e_mod_main.c:160
msgid "Configuration"
msgstr "Konfiguration"
#: e_mod_main.c:349
msgid "Enlightenment Network Monitor Module"
msgstr "Enlightenment nätverksövervakningsmodul"
#: e_mod_main.c:349
msgid "This module is used to monitor a network device."
msgstr "Denna modul används för att övervaka ett nätverkskort."
#~ msgid "Show Graph"
#~ msgstr "Visa graf"

BIN
rx_00.png

Binary file not shown.

BIN
rx_01.png

Binary file not shown.

BIN
rx_02.png

Binary file not shown.

BIN
rx_03.png

Binary file not shown.

BIN
rx_04.png

Binary file not shown.

BIN
rx_05.png

Binary file not shown.

BIN
rx_06.png

Binary file not shown.

BIN
rx_07.png

Binary file not shown.

BIN
rx_08.png

Binary file not shown.

BIN
rx_09.png

Binary file not shown.

BIN
rx_10.png

Binary file not shown.

27
src/Makefile.am Normal file
View File

@ -0,0 +1,27 @@
ACLOCAL_AMFLAGS = -I m4
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I. \
-I$(top_srcdir) \
-I$(includedir) \
@ENLIGHTENMENT_CFLAGS@
pkgdir = $(datadir)/$(MODULE_ARCH)
pkg_LTLIBRARIES = module.la
module_la_SOURCES = e_mod_main.h \
e_mod_gadcon.h \
e_mod_net.h \
e_mod_config.h \
e_mod_configure.h \
e_mod_main.c \
e_mod_gadcon.c \
e_mod_net.c \
e_mod_config.c \
e_mod_configure.c
module_la_LIBADD = @ENLIGHTENMENT_LIBS@
module_la_LDFLAGS = -module -avoid-version
module_la_DEPENDENCIES = $(top_builddir)/config.h
clean-local:
rm -rf *~

56
src/e_mod_config.c Normal file
View File

@ -0,0 +1,56 @@
#include <e.h>
#include "e_mod_main.h"
#include "e_mod_config.h"
EAPI Config_Item *
_config_item_get(const char *id)
{
Evas_List *l;
Config_Item *ci;
for (l = cfg->items; l; l = l->next)
{
ci = l->data;
if (!ci->id) continue;
if (!strcmp(ci->id, id)) return ci;
}
ci = E_NEW(Config_Item, 1);
ci->id = evas_stringshare_add(id);
ci->device = evas_stringshare_add("eth0");
ci->poll_time = 1.0;
cfg->items = evas_list_append(cfg->items, ci);
return ci;
}
EAPI Ecore_List *
_config_devices_get(void)
{
Ecore_List *devs = NULL;
FILE *f;
char buf[256];
char dev[64];
unsigned long dummy;
f = fopen("/proc/net/dev", "r");
if (!f) return NULL;
devs = ecore_list_new();
ecore_list_set_free_cb(devs, free);
while (fgets(buf, 256, f))
{
int i = 0;
for (; buf[i] != 0; i++)
if (buf[i] == ':') buf[i] = ' ';
if (sscanf (buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%lu %lu %lu %lu\n", dev, &dummy, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17)
continue;
ecore_list_append(devs, strdup(dev));
}
fclose(f);
if (devs) ecore_list_goto_first(devs);
return devs;
}

28
src/e_mod_config.h Normal file
View File

@ -0,0 +1,28 @@
#ifndef E_MOD_CONFIG_H
#define E_MOD_CONFIG_H
typedef struct _Config Config;
typedef struct _Config_Item Config_Item;
struct _Config
{
E_Module *mod;
E_Config_Dialog *cfd;
E_Menu *menu;
Evas_List *instances;
Evas_List *items;
};
struct _Config_Item
{
const char *id;
const char *device;
double poll_time;
};
EAPI Config_Item *_config_item_get(const char *id);
EAPI Ecore_List *_config_devices_get(void);
extern Config *cfg;
#endif

139
src/e_mod_configure.c Normal file
View File

@ -0,0 +1,139 @@
#include <e.h>
#include "e_mod_main.h"
#include "e_mod_configure.h"
#include "e_mod_config.h"
struct _E_Config_Dialog_Data
{
char *device;
double poll_time;
Ecore_List *devs;
int num;
};
static void *_create_data(E_Config_Dialog *cfd);
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
static void _fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata);
static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
static int _apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
EAPI void
_configure_net_module(void *data)
{
E_Config_Dialog *cfd;
E_Config_Dialog_View *v;
E_Container *con;
Config_Item *ci;
char buf[PATH_MAX];
if (e_config_dialog_find("Net", "_netmod_config_dialog")) return;
ci = data;
v = E_NEW(E_Config_Dialog_View, 1);
v->create_cfdata = _create_data;
v->free_cfdata = _free_data;
v->basic.apply_cfdata = _apply_data;
v->basic.create_widgets = _basic_create;
snprintf(buf, sizeof(buf), "%s/net.edj", e_module_dir_get(cfg->mod));
con = e_container_current_get(e_manager_current_get());
cfd = e_config_dialog_new(con, _("Net Module Configuration"), "Net",
"_netmod_config_dialog", buf, 0, v, ci);
cfg->cfd = cfd;
}
static void *
_create_data(E_Config_Dialog *cfd)
{
E_Config_Dialog_Data *cfdata;
Config_Item *ci;
ci = cfd->data;
cfdata = E_NEW(E_Config_Dialog_Data, 1);
_fill_data(ci, cfdata);
return cfdata;
}
static void
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
if (cfdata->devs) ecore_list_destroy(cfdata->devs);
E_FREE(cfdata->device);
E_FREE(cfdata);
if (!cfg) return;
cfg->cfd = NULL;
}
static void
_fill_data(Config_Item *ci, E_Config_Dialog_Data *cfdata)
{
char *tmp;
int i = 0;
cfdata->poll_time = ci->poll_time;
if (ci->device) cfdata->device = strdup(ci->device);
cfdata->devs = _config_devices_get();
if (!cfdata->devs) return;
while ((tmp = ecore_list_next(cfdata->devs)) != NULL)
{
if (!strcmp(cfdata->device, tmp))
{
cfdata->num = i;
break;
}
i++;
}
}
static Evas_Object *
_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
{
Evas_Object *o, *ob, *of;
E_Radio_Group *rg;
char *tmp;
int i = 0;
o = e_widget_list_add(evas, 0, 0);
of = e_widget_framelist_add(evas, _("General Settings"), 0);
ob = e_widget_label_add(evas, _("Check Interval"));
e_widget_framelist_object_append(of, ob);
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f seconds"), 1, 60, 1, 0,
&(cfdata->poll_time), NULL, 150);
e_widget_framelist_object_append(of, ob);
e_widget_list_object_append(o, of, 1, 1, 0.5);
if (!cfdata->devs) return o;
of = e_widget_framelist_add(evas, _("Device Settings"), 0);
rg = e_widget_radio_group_new(&(cfdata->num));
ecore_list_goto_first(cfdata->devs);
while ((tmp = ecore_list_next(cfdata->devs)) != NULL)
{
ob = e_widget_radio_add(evas, tmp, i, rg);
e_widget_framelist_object_append(of, ob);
i++;
}
e_widget_list_object_append(o, of, 1, 1, 0.5);
return o;
}
static int
_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
{
char *tmp;
Config_Item *ci;
ci = cfd->data;
tmp = ecore_list_goto_index(cfdata->devs, cfdata->num);
if (tmp != NULL)
{
evas_stringshare_del(ci->device);
ci->device = evas_stringshare_add(tmp);
}
ci->poll_time = cfdata->poll_time;
e_config_save_queue();
return 1;
}

6
src/e_mod_configure.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef E_MOD_CONFIGURE_H
#define E_MOD_CONFIGURE_H
EAPI void _configure_net_module(void *data);
#endif

106
src/e_mod_gadcon.c Normal file
View File

@ -0,0 +1,106 @@
#include <e.h>
#include "e_mod_main.h"
#include "e_mod_gadcon.h"
#include "e_mod_net.h"
#include "e_mod_config.h"
static const E_Gadcon_Client_Class _gc_class =
{
GADCON_CLIENT_CLASS_VERSION, "net",
{_gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon},
E_GADCON_CLIENT_STYLE_PLAIN
};
static E_Gadcon_Client *
_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
{
Instance *inst;
E_Gadcon_Client *gcc;
Config_Item *ci;
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/net.edj", e_module_dir_get(cfg->mod));
ci = _config_item_get(id);
if (!ci->id) evas_stringshare_add(id);
inst = E_NEW(Instance, 1);
inst->o_net = edje_object_add(gc->evas);
if (!e_theme_edje_object_set(inst->o_net, "base/theme/modules/net",
"modules/net/main"))
edje_object_file_set(inst->o_net, buf, "modules/net/main");
evas_object_show(inst->o_net);
gcc = e_gadcon_client_new(gc, name, id, style, inst->o_net);
gcc->data = inst;
inst->gcc = gcc;
inst->timer = ecore_timer_add(ci->poll_time, _cb_poll, inst);
evas_object_event_callback_add(inst->o_net, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down, inst);
evas_object_event_callback_add(inst->o_net, EVAS_CALLBACK_MOUSE_IN,
_cb_mouse_in, inst);
evas_object_event_callback_add(inst->o_net, EVAS_CALLBACK_MOUSE_OUT,
_cb_mouse_out, inst);
cfg->instances = evas_list_append(cfg->instances, inst);
return gcc;
}
static void
_gc_shutdown(E_Gadcon_Client *gcc)
{
Instance *inst;
inst = gcc->data;
cfg->instances = evas_list_remove(cfg->instances, inst);
if (inst->timer) ecore_timer_del(inst->timer);
if (inst->o_net)
{
evas_object_event_callback_del(inst->o_net, EVAS_CALLBACK_MOUSE_DOWN,
_cb_mouse_down);
evas_object_event_callback_del(inst->o_net, EVAS_CALLBACK_MOUSE_IN,
_cb_mouse_in);
evas_object_event_callback_del(inst->o_net, EVAS_CALLBACK_MOUSE_OUT,
_cb_mouse_out);
evas_object_del(inst->o_net);
}
E_FREE(inst);
}
static void
_gc_orient(E_Gadcon_Client *gcc)
{
e_gadcon_client_aspect_set(gcc, 16, 16);
e_gadcon_client_min_size_set(gcc, 16, 16);
}
static char *
_gc_label(void)
{
return _("Net");
}
static Evas_Object *
_gc_icon(Evas *evas)
{
Evas_Object *o;
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/module.edj", e_module_dir_get(cfg->mod));
o = edje_object_add(evas);
edje_object_file_set(o, buf, "icon");
return o;
}
EAPI void
_gc_register(void)
{
e_gadcon_provider_register(&_gc_class);
}
EAPI void
_gc_unregister(void)
{
e_gadcon_provider_unregister(&_gc_class);
}

13
src/e_mod_gadcon.h Normal file
View File

@ -0,0 +1,13 @@
#ifndef E_MOD_GADCON_H
#define E_MOD_GADCON_H
static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
static void _gc_shutdown(E_Gadcon_Client *gcc);
static void _gc_orient(E_Gadcon_Client *gcc);
static char *_gc_label(void);
static Evas_Object *_gc_icon(Evas *evas);
EAPI void _gc_register(void);
EAPI void _gc_unregister(void);
#endif

96
src/e_mod_main.c Normal file
View File

@ -0,0 +1,96 @@
#include <e.h>
#include "e_mod_main.h"
#include "e_mod_gadcon.h"
#include "e_mod_config.h"
static E_Config_DD *conf_edd = NULL;
static E_Config_DD *item_edd = NULL;
Config *cfg = NULL;
EAPI E_Module_Api e_modapi =
{
E_MODULE_API_VERSION, "Net"
};
EAPI void *
e_modapi_init(E_Module *m)
{
item_edd = E_CONFIG_DD_NEW("Config_Item", Config_Item);
E_CONFIG_VAL(item_edd, Config_Item, id, STR);
E_CONFIG_VAL(item_edd, Config_Item, device, STR);
E_CONFIG_VAL(item_edd, Config_Item, poll_time, DOUBLE);
conf_edd = E_CONFIG_DD_NEW("Config", Config);
E_CONFIG_LIST(conf_edd, Config, items, item_edd);
cfg = e_config_domain_load("module.net", conf_edd);
if (!cfg)
{
Config_Item *ci;
cfg = E_NEW(Config, 1);
ci = _config_item_get("0");
}
cfg->mod = m;
_gc_register();
return m;
}
EAPI int
e_modapi_shutdown(E_Module *m)
{
cfg->mod = NULL;
_gc_unregister();
if (cfg->cfd) e_object_del(E_OBJECT(cfg->cfd));
if (cfg->menu)
{
e_menu_post_deactivate_callback_set(cfg->menu, NULL, NULL);
e_object_del(E_OBJECT(cfg->menu));
cfg->menu = NULL;
}
while (cfg->items)
{
Config_Item *ci;
ci = cfg->items->data;
if (ci->id) evas_stringshare_del(ci->id);
if (ci->device) evas_stringshare_del(ci->device);
cfg->items = evas_list_remove_list(cfg->items, cfg->items);
E_FREE(ci);
}
E_FREE(cfg);
E_CONFIG_DD_FREE(item_edd);
E_CONFIG_DD_FREE(conf_edd);
return 1;
}
EAPI int
e_modapi_save(E_Module *m)
{
Evas_List *l;
for (l = cfg->instances; l; l = l->next)
{
Instance *inst;
Config_Item *ci;
inst = l->data;
ci = _config_item_get(inst->gcc->id);
if (ci->id) evas_stringshare_del(ci->id);
ci->id = evas_stringshare_add(inst->gcc->id);
}
e_config_domain_save("module.net", conf_edd, cfg);
return 1;
}
EAPI int
e_modapi_about(E_Module *m)
{
e_module_dialog_show(m, _("Network Monitor Module"),
_("Module to monitor network traffic"));
return 1;
}

29
src/e_mod_main.h Normal file
View File

@ -0,0 +1,29 @@
#ifndef E_MOD_MAIN_H
#define E_MOD_MAIN_H
typedef struct _Instance Instance;
typedef struct _Popup Popup;
struct _Instance
{
E_Gadcon_Client *gcc;
Evas_Object *o_net;
Ecore_Timer *timer;
Popup *popup;
unsigned long in, out;
};
struct _Popup
{
E_Popup *win;
Evas_Object *o_bg;
};
EAPI extern E_Module_Api e_modapi;
EAPI void *e_modapi_init(E_Module *m);
EAPI int e_modapi_shutdown(E_Module *m);
EAPI int e_modapi_save(E_Module *m);
EAPI int e_modapi_about(E_Module *m);
#endif

245
src/e_mod_net.c Normal file
View File

@ -0,0 +1,245 @@
#include <e.h>
#include "e_mod_main.h"
#include "e_mod_net.h"
#include "e_mod_config.h"
#include "e_mod_configure.h"
static void _cb_post(void *data, E_Menu *m);
static void _cb_configure(void *data, E_Menu *m, E_Menu_Item *mi);
EAPI int
_cb_poll(void *data)
{
Instance *inst;
Config_Item *ci;
FILE *f;
char buf[256], dev[64], tmp[100];
int found = 0;
long bin, bout;
unsigned long in, out, dummy = 0;
inst = data;
ci = _config_item_get(inst->gcc->id);
f = fopen("/proc/net/dev", "r");
if (!f) return 1;
while (fgets(buf, 256, f))
{
int i = 0;
for (; buf[i] != 0; i++)
if (buf[i] == ':') buf[i] = ' ';
if (sscanf (buf, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu "
"%lu %lu %lu %lu\n", dev, &in, &dummy, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &out, &dummy,
&dummy, &dummy, &dummy, &dummy, &dummy, &dummy) < 17)
continue;
if (!strcmp(dev, ci->device)) found = 1;
if (found) break;
}
fclose(f);
if (!found) return 1;
bin = in - inst->in;
bout = out - inst->out;
bin = bin / ci->poll_time;
bout = bout / ci->poll_time;
inst->in = in;
inst->out = out;
if (bin <= 0)
edje_object_signal_emit(inst->o_net, "e,state,receive,idle", "e");
else
edje_object_signal_emit(inst->o_net, "e,state,receive,active", "e");
if (bout <= 0)
edje_object_signal_emit(inst->o_net, "e,state,send,idle", "e");
else
edje_object_signal_emit(inst->o_net, "e,state,send,active", "e");
if (!inst->popup) return 1;
if (bin > 1048576)
snprintf(tmp, sizeof(tmp), "Rx: %ld Mb", (bin / 1048576));
else if ((bin > 1024) && (bin < 1048576))
snprintf(tmp, sizeof(tmp), "Rx: %ld Kb", (bin / 1024));
else
snprintf(tmp, sizeof(tmp), "Rx: %ld B", bin);
edje_object_part_text_set(inst->popup->o_bg, "e.text.recv", tmp);
if (bout > 1048576)
snprintf(tmp, sizeof(tmp), "Tx: %ld Mb", (bout / 1048576));
else if ((bout > 1024) && (bout < 1048576))
snprintf(tmp, sizeof(tmp), "Tx: %ld Kb", (bout / 1024));
else
snprintf(tmp, sizeof(tmp), "Tx: %ld B", bout);
edje_object_part_text_set(inst->popup->o_bg, "e.text.send", tmp);
return 1;
}
EAPI void
_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event)
{
Instance *inst;
Evas_Event_Mouse_Down *ev;
inst = data;
ev = event;
if ((ev->button == 3) && (!cfg->menu))
{
E_Menu *mn;
E_Menu_Item *mi;
int x, y;
mn = e_menu_new();
e_menu_post_deactivate_callback_set(mn, _cb_post, inst);
cfg->menu = mn;
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _("Configuration"));
e_util_menu_item_edje_icon_set(mi, "enlightenment/configuration");
e_menu_item_callback_set(mi, _cb_configure, inst);
mi = e_menu_item_new(mn);
e_menu_item_separator_set(mi, 1);
e_gadcon_client_util_menu_items_append(inst->gcc, mn, 0);
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y,
NULL, NULL);
e_menu_activate_mouse(mn,
e_util_zone_current_get(e_manager_current_get()),
x + ev->output.x, y + ev->output.y, 1, 1,
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
e_util_evas_fake_mouse_up_later(inst->gcc->gadcon->evas, ev->button);
}
}
EAPI void
_cb_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event)
{
Instance *inst;
Config_Item *ci;
E_Container *con;
Evas_Object *bg, *box, *icon, *label;
Evas_Coord x, y, w, h;
Evas_Coord ox, oy, ow, oh;
int top, wx, wy, ww, wh;
char buf[PATH_MAX];
inst = data;
if (inst->popup) return;
inst->popup = E_NEW(Popup, 1);
ci = _config_item_get(inst->gcc->id);
snprintf(buf, sizeof(buf), "%s/net.edj", e_module_dir_get(cfg->mod));
evas_object_geometry_get(inst->o_net, &ox, &oy, &ow, &oh);
con = e_container_current_get(e_manager_current_get());
inst->popup->win = e_popup_new(e_zone_current_get(con), 0, 0, 0, 0);
bg = edje_object_add(inst->popup->win->evas);
inst->popup->o_bg = bg;
if (!e_theme_edje_object_set(bg, "base/theme/modules",
"modules/net/popup"))
edje_object_file_set(bg, buf, "modules/net/popup");
snprintf(buf, sizeof(buf), _("Device - %s"), ci->device);
edje_object_part_text_set(bg, "e.text.title", buf);
evas_object_show(bg);
snprintf(buf, sizeof(buf), "Rx: 0 B");
edje_object_part_text_set(bg, "e.text.recv", buf);
snprintf(buf, sizeof(buf), "Tx: 0 B");
edje_object_part_text_set(bg, "e.text.send", buf);
edje_object_size_min_calc(bg, &ww, &wh);
evas_object_move(bg, 0, 0);
evas_object_resize(bg, ww, wh);
e_gadcon_canvas_zone_geometry_get(inst->gcc->gadcon, &x, &y, &w, &h);
wx = x + ox;
wy = y + oy;
if ((wy - con->y) < (con->h / 2))
top = 0;
else
top = 1;
switch (inst->gcc->gadcon->orient)
{
case E_GADCON_ORIENT_CORNER_LT:
wx += ox + ow;
if (top) wy += (oh - 5);
break;
case E_GADCON_ORIENT_LEFT:
case E_GADCON_ORIENT_CORNER_LB:
wx += ox + ow;
wy = oy;
break;
case E_GADCON_ORIENT_CORNER_RT:
wx -= (ww - ((x + w) - (ox + ow)) + 5);
if (top) wy += oh;
break;
case E_GADCON_ORIENT_RIGHT:
wx -= (ww - ((x + w) - (ox + ow)) + 5);
if (top) wy -= (oh - 5);
break;
case E_GADCON_ORIENT_CORNER_RB:
wx -= (ww - ((x + w) - (ox + ow)) + 5);
wy = oy;
break;
case E_GADCON_ORIENT_TOP:
case E_GADCON_ORIENT_CORNER_TL:
case E_GADCON_ORIENT_CORNER_TR:
wx += ((ow - ww) / 2);
if (wx < x) wx = x;
if ((wx + ww) > (x + w)) wx = ((x + w) - ww);
if (!top) wy += oh;
break;
case E_GADCON_ORIENT_BOTTOM:
case E_GADCON_ORIENT_CORNER_BL:
case E_GADCON_ORIENT_CORNER_BR:
wx += ((ow - ww) / 2);
if (wx < x) wx = x;
if ((wx + ww) > (x + w)) wx = ((x + w) - ww);
wy = (oy - wh);
break;
default:
break;
}
e_popup_move_resize(inst->popup->win, wx, wy, ww, wh);
e_popup_show(inst->popup->win);
}
EAPI void
_cb_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event)
{
Instance *inst;
inst = data;
if (!inst->popup) return;
evas_object_del(inst->popup->o_bg);
e_object_del(E_OBJECT(inst->popup->win));
E_FREE(inst->popup);
}
static void
_cb_post(void *data, E_Menu *m)
{
if (!cfg->menu) return;
e_menu_post_deactivate_callback_set(cfg->menu, NULL, NULL);
e_object_del(E_OBJECT(cfg->menu));
cfg->menu = NULL;
}
static void
_cb_configure(void *data, E_Menu *m, E_Menu_Item *mi)
{
Instance *inst;
Config_Item *ci;
inst = data;
ci = _config_item_get(inst->gcc->id);
_configure_net_module(ci);
}

9
src/e_mod_net.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef E_MOD_NET_H
#define E_MOD_NET_H
EAPI int _cb_poll(void *data);
EAPI void _cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event);
EAPI void _cb_mouse_in(void *data, Evas *evas, Evas_Object *obj, void *event);
EAPI void _cb_mouse_out(void *data, Evas *evas, Evas_Object *obj, void *event);
#endif

BIN
tx_00.png

Binary file not shown.

BIN
tx_01.png

Binary file not shown.

BIN
tx_02.png

Binary file not shown.

BIN
tx_03.png

Binary file not shown.

BIN
tx_04.png

Binary file not shown.

BIN
tx_05.png

Binary file not shown.

BIN
tx_06.png

Binary file not shown.

BIN
tx_07.png

Binary file not shown.

BIN
tx_08.png

Binary file not shown.

BIN
tx_09.png

Binary file not shown.

BIN
tx_10.png

Binary file not shown.