Added Net Module.
-Seperating monitor module into seperate modules. -Net Module still needs some work... -TODO: Add graphing. SVN revision: 20587
This commit is contained in:
commit
a95b8a5871
|
@ -0,0 +1,23 @@
|
||||||
|
.deps
|
||||||
|
.libs
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
aclocal.m4
|
||||||
|
autom4te.cache
|
||||||
|
config.guess
|
||||||
|
config.h
|
||||||
|
config.h.in
|
||||||
|
config.log
|
||||||
|
config.status
|
||||||
|
config.sub
|
||||||
|
configure
|
||||||
|
depcomp
|
||||||
|
install-sh
|
||||||
|
libtool
|
||||||
|
missing
|
||||||
|
ltmain.sh
|
||||||
|
stamp-h1
|
||||||
|
*.lo
|
||||||
|
*.la
|
||||||
|
*.spec
|
||||||
|
*.tar.gz
|
|
@ -0,0 +1,2 @@
|
||||||
|
Originally by Matthew Mullins.
|
||||||
|
Recoded into seperate modules by Christopher 'devilhorns' Michael <devilhorns@comcast.net>
|
|
@ -0,0 +1,28 @@
|
||||||
|
Copyright (C) 2000 Christopher Michael and various contributors (see AUTHORS)
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to
|
||||||
|
deal in the Software without restriction, including without limitation the
|
||||||
|
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||||
|
sell copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies of the Software and its Copyright notices. In addition publicly
|
||||||
|
documented acknowledgment must be given that this software has been used if no
|
||||||
|
source code of this software is made available publicly. This includes
|
||||||
|
acknowledgments in either Copyright notices, Manuals, Publicity and Marketing
|
||||||
|
documents or any documentation provided with any product containing this
|
||||||
|
software. This License does not apply to any software that links to the
|
||||||
|
libraries provided by this software (statically or dynamically), but only to
|
||||||
|
the software provided.
|
||||||
|
|
||||||
|
Please see the COPYING.PLAIN for a plain-english explanation of this notice
|
||||||
|
and it's intent.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||||
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||||
|
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,33 @@
|
||||||
|
Plain English Copyright Notice
|
||||||
|
|
||||||
|
This file is not intended to be the actual License. The reason this file
|
||||||
|
exists is that we here are programmers and engineers. We aren't lawyers. We
|
||||||
|
provide licenses that we THINK say the right things, but we have our own
|
||||||
|
intentions at heart. This is a plain-english explanation of what those
|
||||||
|
intentions are, and if you follow them you will be within the "spirit" of
|
||||||
|
the license.
|
||||||
|
|
||||||
|
The intent is for us to enjoy writing software that is useful to us (the
|
||||||
|
AUTHORS) and allow others to use it freely and also benefit from the work we
|
||||||
|
put into making it. We don't want to restrict others using it. They should
|
||||||
|
not *HAVE* to make the source code of the applications they write that
|
||||||
|
simply link to these libraries (be that statically or dynamically), or for
|
||||||
|
them to be limited as to what license they choose to use (be it open, closed
|
||||||
|
or anything else). But we would like to know you are using these libraries.
|
||||||
|
We simply would like to know that it has been useful to someone. This is why
|
||||||
|
we ask for acknowledgement of some sort.
|
||||||
|
|
||||||
|
You can do what you want with the source of this software - it doesn't
|
||||||
|
matter. We still have it here for ourselves and it is open and free to use
|
||||||
|
and download and play with. It can't be taken away. We don't really mind what
|
||||||
|
you do with the source to your software. We would simply like to know that
|
||||||
|
you are using it - especially if it makes it to a commerical product. If you
|
||||||
|
simply e-mail all the AUTHORS (see COPYING and AUTHORS files) telling us, and
|
||||||
|
then make sure you include a paragraph or page in the manual for the product
|
||||||
|
with the copyright notice and state that you used this software, we will be
|
||||||
|
very happy. If you want to contribute back modifications and fixes you may have
|
||||||
|
made we will welcome those too with open arms (generally). If you want help
|
||||||
|
with changes needed, ports needed or features to be added, arrangements can
|
||||||
|
be easily made with some dialogue.
|
||||||
|
|
||||||
|
Christopher Michael <devilhorns@comcast.net>
|
|
@ -0,0 +1,11 @@
|
||||||
|
COMPILING and INSTALLING:
|
||||||
|
|
||||||
|
If you got a official release tar archive do:
|
||||||
|
./autogen.sh
|
||||||
|
|
||||||
|
Then to compile:
|
||||||
|
make
|
||||||
|
|
||||||
|
To install:
|
||||||
|
make install
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
MAINTAINERCLEANFILES = Makefile.in
|
||||||
|
|
||||||
|
EDJE_CC = @edje_cc@
|
||||||
|
EDJE_FLAGS = -v
|
||||||
|
|
||||||
|
# data files for the module
|
||||||
|
filesdir = $(datadir)
|
||||||
|
|
||||||
|
files_DATA = \
|
||||||
|
module_icon.png \
|
||||||
|
net.edj \
|
||||||
|
net.edc \
|
||||||
|
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 \
|
||||||
|
e_mod_config.h
|
||||||
|
|
||||||
|
module_la_LIBADD = @e_libs@ -lm
|
||||||
|
module_la_LDFLAGS = -module -avoid-version
|
||||||
|
module_la_DEPENDENCIES = $(top_builddir)/config.h
|
||||||
|
|
||||||
|
net.edj: Makefile net.edc
|
||||||
|
$(EDJE_CC) $(EDJE_FLAGS) \
|
||||||
|
net.edc \
|
||||||
|
net.edj
|
||||||
|
|
||||||
|
clean-local:
|
||||||
|
rm -rf *.edj *~
|
||||||
|
|
Binary file not shown.
|
@ -0,0 +1,16 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
rm -rf autom4te.cache
|
||||||
|
rm -f aclocal.m4 ltmain.sh
|
||||||
|
|
||||||
|
touch README
|
||||||
|
|
||||||
|
echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || 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
|
||||||
|
|
||||||
|
if [ -z "$NOCONFIGURE" ]; then
|
||||||
|
./configure "$@"
|
||||||
|
fi
|
|
@ -0,0 +1,200 @@
|
||||||
|
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_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
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
else
|
||||||
|
AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}", "Package installed binaries 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.
|
||||||
|
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}"
|
||||||
|
else
|
||||||
|
AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/lib/enlightenment/modules/${PACKAGE}", "Package installed data destination")
|
||||||
|
datadir="${prefix}/lib/enlightenment/modules/${PACKAGE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_PREFIX_DEFAULT(${HOME}/.e/e)
|
||||||
|
if test "x$prefix" = "xNONE"; then
|
||||||
|
datarootdir=${ac_default_prefix}
|
||||||
|
else
|
||||||
|
datarootdir=${prefix}/share
|
||||||
|
fi
|
||||||
|
|
||||||
|
#AC_CHECK_LIB(dl, dlopen, dlopen_libs=-ldl)
|
||||||
|
#AC_SUBST(dlopen_libs)
|
||||||
|
|
||||||
|
AC_ARG_WITH(ecore-config,
|
||||||
|
[ --with-ecore-config=ECORE_CONFIG use ecore-config specified ],
|
||||||
|
[
|
||||||
|
ECORE_CONFIG=$withval;
|
||||||
|
echo "using "$ECORE_CONFIG" for ecore-config";
|
||||||
|
],[
|
||||||
|
PROG="ecore-config";
|
||||||
|
AC_PATH_PROG(ECORE_CONFIG, $PROG, "", $PATH)
|
||||||
|
])
|
||||||
|
ecore_cflags=`$ECORE_CONFIG --cflags`
|
||||||
|
ecore_libs=`$ECORE_CONFIG --libs`
|
||||||
|
AC_SUBST(ecore_cflags)
|
||||||
|
AC_SUBST(ecore_libs)
|
||||||
|
|
||||||
|
AC_ARG_WITH(evas-config,
|
||||||
|
[ --with-evas-config=EVAS_CONFIG use evas-config specified ],
|
||||||
|
[
|
||||||
|
EVAS_CONFIG=$withval;
|
||||||
|
echo "using "$EVAS_CONFIG" for evas-config";
|
||||||
|
],[
|
||||||
|
PROG="evas-config";
|
||||||
|
AC_PATH_PROG(EVAS_CONFIG, $PROG, "", $PATH)
|
||||||
|
])
|
||||||
|
evas_cflags=`$EVAS_CONFIG --cflags`
|
||||||
|
evas_libs=`$EVAS_CONFIG --libs`
|
||||||
|
AC_SUBST(evas_cflags)
|
||||||
|
AC_SUBST(evas_libs)
|
||||||
|
|
||||||
|
AC_ARG_WITH(esmart-config,
|
||||||
|
[ --with-esmart-config=ESMART_CONFIG use esmart-config specified ],
|
||||||
|
[
|
||||||
|
ESMART_CONFIG=$withval;
|
||||||
|
echo "using "$ESMART_CONFIG" for esmart-config";
|
||||||
|
],[
|
||||||
|
PROG="esmart-config";
|
||||||
|
AC_PATH_PROG(ESMART_CONFIG, $PROG, "", $PATH)
|
||||||
|
])
|
||||||
|
esmart_cflags=`$ESMART_CONFIG --cflags`
|
||||||
|
esmart_libs=`$ESMART_CONFIG --libs`
|
||||||
|
AC_SUBST(esmart_cflags)
|
||||||
|
AC_SUBST(esmart_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(eet-config,
|
||||||
|
[ --with-eet-config=EET_CONFIG use eet-config specified ],
|
||||||
|
[
|
||||||
|
EET_CONFIG=$withval;
|
||||||
|
echo "using "$EET_CONFIG" for eet-config";
|
||||||
|
],[
|
||||||
|
PROG="eet-config";
|
||||||
|
AC_PATH_PROG(EET_CONFIG, $PROG, "", $PATH)
|
||||||
|
])
|
||||||
|
eet_cflags=`$EET_CONFIG --cflags`
|
||||||
|
eet_libs=`$EET_CONFIG --libs`
|
||||||
|
AC_SUBST(eet_cflags)
|
||||||
|
AC_SUBST(eet_libs)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
AC_OUTPUT([
|
||||||
|
Makefile
|
||||||
|
],[
|
||||||
|
])
|
||||||
|
|
|
@ -0,0 +1,184 @@
|
||||||
|
#include <e.h>
|
||||||
|
#include "e_mod_main.h"
|
||||||
|
#include "e_mod_config.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
struct _E_Config_Dialog_Data
|
||||||
|
{
|
||||||
|
char *device;
|
||||||
|
int check_interval;
|
||||||
|
|
||||||
|
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 (Net *n, E_Config_Dialog_Data *cfdata);
|
||||||
|
static void _net_config_get_devices (Ecore_List *devs);
|
||||||
|
|
||||||
|
/* Config Calls */
|
||||||
|
void
|
||||||
|
_configure_net_module(E_Container *con, Net *n)
|
||||||
|
{
|
||||||
|
E_Config_Dialog *cfd;
|
||||||
|
E_Config_Dialog_View *v;
|
||||||
|
|
||||||
|
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;
|
||||||
|
v->override_auto_apply = 1;
|
||||||
|
|
||||||
|
cfd = e_config_dialog_new(con, _("Net Configuration"), NULL, 0, v, n);
|
||||||
|
n->cfd = cfd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_fill_data(Net *n, E_Config_Dialog_Data *cfdata)
|
||||||
|
{
|
||||||
|
char *tmp;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
cfdata->check_interval = n->conf->check_interval;
|
||||||
|
|
||||||
|
if (n->conf->device != NULL)
|
||||||
|
cfdata->device = strdup(n->conf->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;
|
||||||
|
Net *n;
|
||||||
|
|
||||||
|
n = cfd->data;
|
||||||
|
cfdata = E_NEW(E_Config_Dialog_Data, 1);
|
||||||
|
_fill_data(n, cfdata);
|
||||||
|
return cfdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||||
|
{
|
||||||
|
Net *n;
|
||||||
|
|
||||||
|
n = cfd->data;
|
||||||
|
n->cfd = NULL;
|
||||||
|
free(cfdata);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
Net *n;
|
||||||
|
char *tmp;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
n = cfd->data;
|
||||||
|
|
||||||
|
o = e_widget_list_add(evas, 0, 0);
|
||||||
|
of = e_widget_framelist_add(evas, _("Device Settings"), 0);
|
||||||
|
ot = e_widget_table_add(evas, 0);
|
||||||
|
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, _("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, NULL, &(cfdata->check_interval), 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;
|
||||||
|
Net *n;
|
||||||
|
|
||||||
|
n = cfd->data;
|
||||||
|
//e_border_button_bindings_ungrab_all();
|
||||||
|
tmp = ecore_list_goto_index(cfdata->devs, cfdata->dev_num);
|
||||||
|
if (tmp != NULL)
|
||||||
|
n->conf->device = (char *)evas_stringshare_add(strdup(tmp));
|
||||||
|
n->conf->check_interval = cfdata->check_interval;
|
||||||
|
e_config_save_queue ();
|
||||||
|
//e_border_button_bindings_grab_all ();
|
||||||
|
|
||||||
|
if (n->face->monitor)
|
||||||
|
ecore_timer_interval_set(n->face->monitor, (double)cfdata->check_interval);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
#ifdef E_TYPEDEFS
|
||||||
|
#else
|
||||||
|
#ifndef E_MOD_CONFIG_H
|
||||||
|
#define E_MOD_CONFIG_H
|
||||||
|
|
||||||
|
#include "e_mod_main.h"
|
||||||
|
|
||||||
|
void _configure_net_module(E_Container *con, Net *n);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
#endif
|
|
@ -0,0 +1,506 @@
|
||||||
|
#include <e.h>
|
||||||
|
#include "e_mod_main.h"
|
||||||
|
#include "e_mod_config.h"
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
static Net *_net_init(E_Module *m);
|
||||||
|
static void _net_shutdown(Net *n);
|
||||||
|
static void _net_config_menu_new(Net *n);
|
||||||
|
|
||||||
|
static int _net_face_init(Net_Face *nf);
|
||||||
|
static void _net_face_menu_new(Net_Face *nf);
|
||||||
|
static void _net_face_enable(Net_Face *nf);
|
||||||
|
static void _net_face_disable(Net_Face *nf);
|
||||||
|
static void _net_face_free(Net_Face *nf);
|
||||||
|
static void _net_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change);
|
||||||
|
static void _net_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info);
|
||||||
|
static void _net_face_cb_menu_edit(void *data, E_Menu *mn, E_Menu_Item *mi);
|
||||||
|
static void _net_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi);
|
||||||
|
|
||||||
|
static int _net_face_update_values(void *data);
|
||||||
|
static void _net_face_graph_values(Net_Face *nf, int in, int out);
|
||||||
|
|
||||||
|
static int net_count;
|
||||||
|
|
||||||
|
EAPI E_Module_Api e_modapi =
|
||||||
|
{
|
||||||
|
E_MODULE_API_VERSION,
|
||||||
|
"Net"
|
||||||
|
};
|
||||||
|
|
||||||
|
EAPI void *
|
||||||
|
e_modapi_init(E_Module *m)
|
||||||
|
{
|
||||||
|
Net *n;
|
||||||
|
|
||||||
|
n = _net_init(m);
|
||||||
|
if (!n)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
m->config_menu = n->config_menu;
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
e_modapi_shutdown(E_Module *m)
|
||||||
|
{
|
||||||
|
Net *n;
|
||||||
|
|
||||||
|
n = m->data;
|
||||||
|
if (!n)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (m->config_menu)
|
||||||
|
{
|
||||||
|
e_menu_deactivate(m->config_menu);
|
||||||
|
e_object_del(E_OBJECT(m->config_menu));
|
||||||
|
m->config_menu = NULL;
|
||||||
|
}
|
||||||
|
if (n->cfd)
|
||||||
|
{
|
||||||
|
e_object_del(E_OBJECT(n->cfd));
|
||||||
|
n->cfd = NULL;
|
||||||
|
}
|
||||||
|
_net_shutdown(n);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
e_modapi_save(E_Module *m)
|
||||||
|
{
|
||||||
|
Net *n;
|
||||||
|
|
||||||
|
n = m->data;
|
||||||
|
if (!n)
|
||||||
|
return 0;
|
||||||
|
e_config_domain_save("module.net", n->conf_edd, n->conf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
e_modapi_info(E_Module *m)
|
||||||
|
{
|
||||||
|
m->icon_file = strdup(PACKAGE_DATA_DIR"/module_icon.png");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
e_modapi_about(E_Module *m)
|
||||||
|
{
|
||||||
|
e_module_dialog_show(_("Enlightenment Network Monitor Module"),
|
||||||
|
_("This module is used to monitor a network device."));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
EAPI int
|
||||||
|
e_modapi_config(E_Module *m)
|
||||||
|
{
|
||||||
|
Net *n;
|
||||||
|
E_Container *con;
|
||||||
|
|
||||||
|
n = m->data;
|
||||||
|
if (!n)
|
||||||
|
return 0;
|
||||||
|
if (!n->face)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
con = e_container_current_get(e_manager_current_get());
|
||||||
|
if (n->face->con == con)
|
||||||
|
_configure_net_module(con, n);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Net *
|
||||||
|
_net_init(E_Module *m)
|
||||||
|
{
|
||||||
|
Net *n;
|
||||||
|
E_Menu_Item *mi;
|
||||||
|
Evas_List *mans, *l, *l2;
|
||||||
|
|
||||||
|
n = E_NEW(Net, 1);
|
||||||
|
if (!n)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
n->conf_edd = E_CONFIG_DD_NEW("Net_Config", Config);
|
||||||
|
#undef T
|
||||||
|
#undef D
|
||||||
|
#define T Config
|
||||||
|
#define D n->conf_edd
|
||||||
|
E_CONFIG_VAL(D, T, device, STR);
|
||||||
|
E_CONFIG_VAL(D, T, check_interval, INT);
|
||||||
|
|
||||||
|
n->conf = e_config_domain_load("module.net", n->conf_edd);
|
||||||
|
if (!n->conf)
|
||||||
|
{
|
||||||
|
n->conf = E_NEW(Config, 1);
|
||||||
|
n->conf->device = (char *)evas_stringshare_add("eth0");
|
||||||
|
n->conf->check_interval = 30;
|
||||||
|
}
|
||||||
|
E_CONFIG_LIMIT(n->conf->check_interval, 0, 60);
|
||||||
|
|
||||||
|
_net_config_menu_new(n);
|
||||||
|
|
||||||
|
mans = e_manager_list();
|
||||||
|
for (l = mans; l; l = l->next)
|
||||||
|
{
|
||||||
|
E_Manager *man;
|
||||||
|
|
||||||
|
man = l->data;
|
||||||
|
for (l2 = man->containers; l2; l2 = l2->next)
|
||||||
|
{
|
||||||
|
E_Container *con;
|
||||||
|
Net_Face *nf;
|
||||||
|
|
||||||
|
con = l2->data;
|
||||||
|
nf = E_NEW(Net_Face, 1);
|
||||||
|
if (nf)
|
||||||
|
{
|
||||||
|
nf->conf_face_edd = E_CONFIG_DD_NEW("Net_Face_Config", Config_Face);
|
||||||
|
#undef T
|
||||||
|
#undef D
|
||||||
|
#define T Config_Face
|
||||||
|
#define D nf->conf_face_edd
|
||||||
|
E_CONFIG_VAL(D, T, enabled, UCHAR);
|
||||||
|
|
||||||
|
n->face = nf;
|
||||||
|
nf->net = n;
|
||||||
|
nf->con = con;
|
||||||
|
nf->evas = con->bg_evas;
|
||||||
|
|
||||||
|
nf->conf = E_NEW(Config_Face, 1);
|
||||||
|
nf->conf->enabled = 1;
|
||||||
|
|
||||||
|
if (!_net_face_init(nf))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
_net_face_menu_new(nf);
|
||||||
|
|
||||||
|
mi = e_menu_item_new(n->config_menu);
|
||||||
|
e_menu_item_label_set(mi, _("Configuration"));
|
||||||
|
e_menu_item_callback_set(mi, _net_face_cb_menu_configure, nf);
|
||||||
|
|
||||||
|
mi = e_menu_item_new(n->config_menu);
|
||||||
|
e_menu_item_label_set(mi, con->name);
|
||||||
|
e_menu_item_submenu_set(mi, nf->menu);
|
||||||
|
|
||||||
|
if (!nf->conf->enabled)
|
||||||
|
_net_face_disable(nf);
|
||||||
|
else
|
||||||
|
_net_face_enable(nf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_shutdown(Net *n)
|
||||||
|
{
|
||||||
|
_net_face_free(n->face);
|
||||||
|
|
||||||
|
if (n->conf->device)
|
||||||
|
evas_stringshare_del(n->conf->device);
|
||||||
|
|
||||||
|
E_FREE(n->conf);
|
||||||
|
E_CONFIG_DD_FREE(n->conf_edd);
|
||||||
|
E_FREE(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_config_menu_new(Net *n)
|
||||||
|
{
|
||||||
|
E_Menu *mn;
|
||||||
|
|
||||||
|
mn = e_menu_new();
|
||||||
|
n->config_menu = mn;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_net_face_init(Net_Face *nf)
|
||||||
|
{
|
||||||
|
Evas_Object *o;
|
||||||
|
char buf[4096];
|
||||||
|
|
||||||
|
evas_event_freeze(nf->evas);
|
||||||
|
|
||||||
|
o = edje_object_add(nf->evas);
|
||||||
|
nf->net_obj = o;
|
||||||
|
|
||||||
|
if (!e_theme_edje_object_set(o, "base/theme/modules/net",
|
||||||
|
"modules/net/main"))
|
||||||
|
{
|
||||||
|
snprintf(buf, sizeof(buf), PACKAGE_DATA_DIR"/net.edj");
|
||||||
|
edje_object_file_set(o, buf, "modules/net/main");
|
||||||
|
}
|
||||||
|
|
||||||
|
evas_object_show(o);
|
||||||
|
|
||||||
|
/*
|
||||||
|
o = evas_object_rectangle_add(nf->evas);
|
||||||
|
nf->chart_obj = o;
|
||||||
|
evas_object_layer_set(o, 2);
|
||||||
|
evas_object_repeat_events_set(o, 0);
|
||||||
|
evas_object_color_set(o, 0, 0, 0, 255);
|
||||||
|
evas_object_show(o);
|
||||||
|
*/
|
||||||
|
|
||||||
|
o = evas_object_rectangle_add(nf->evas);
|
||||||
|
nf->event_obj = o;
|
||||||
|
evas_object_layer_set(o, 2);
|
||||||
|
evas_object_repeat_events_set(o, 1);
|
||||||
|
evas_object_color_set(o, 0, 0, 0, 0);
|
||||||
|
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
|
||||||
|
_net_face_cb_mouse_down, nf);
|
||||||
|
evas_object_show(o);
|
||||||
|
|
||||||
|
nf->gmc = e_gadman_client_new(nf->con->gadman);
|
||||||
|
e_gadman_client_domain_set(nf->gmc, "module.net", net_count++);
|
||||||
|
e_gadman_client_policy_set(nf->gmc,
|
||||||
|
E_GADMAN_POLICY_ANYWHERE |
|
||||||
|
E_GADMAN_POLICY_HMOVE |
|
||||||
|
E_GADMAN_POLICY_HSIZE |
|
||||||
|
E_GADMAN_POLICY_VMOVE |
|
||||||
|
E_GADMAN_POLICY_VSIZE);
|
||||||
|
e_gadman_client_min_size_set(nf->gmc, 4, 4);
|
||||||
|
e_gadman_client_max_size_set(nf->gmc, 128, 128);
|
||||||
|
e_gadman_client_auto_size_set(nf->gmc, 40, 40);
|
||||||
|
e_gadman_client_align_set(nf->gmc, 1.0, 1.0);
|
||||||
|
e_gadman_client_aspect_set(nf->gmc, 1.0, 1.0);
|
||||||
|
e_gadman_client_resize(nf->gmc, 40, 40);
|
||||||
|
e_gadman_client_change_func_set(nf->gmc, _net_face_cb_gmc_change, nf);
|
||||||
|
e_gadman_client_load(nf->gmc);
|
||||||
|
evas_event_thaw(nf->evas);
|
||||||
|
|
||||||
|
nf->monitor = ecore_timer_add((double)nf->net->conf->check_interval, _net_face_update_values, nf);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_menu_new(Net_Face *nf)
|
||||||
|
{
|
||||||
|
E_Menu *mn;
|
||||||
|
E_Menu_Item *mi;
|
||||||
|
|
||||||
|
mn = e_menu_new();
|
||||||
|
nf->menu = mn;
|
||||||
|
|
||||||
|
mi = e_menu_item_new(mn);
|
||||||
|
e_menu_item_label_set(mi, _("Configuration"));
|
||||||
|
e_menu_item_callback_set(mi, _net_face_cb_menu_configure, nf);
|
||||||
|
|
||||||
|
mi = e_menu_item_new(mn);
|
||||||
|
e_menu_item_label_set(mi, _("Edit Mode"));
|
||||||
|
e_menu_item_callback_set(mi, _net_face_cb_menu_edit, nf);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_enable(Net_Face *nf)
|
||||||
|
{
|
||||||
|
nf->conf->enabled = 1;
|
||||||
|
e_config_save_queue();
|
||||||
|
evas_object_show(nf->net_obj);
|
||||||
|
/* evas_object_show(nf->chart_obj); */
|
||||||
|
evas_object_show(nf->event_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_disable(Net_Face *nf)
|
||||||
|
{
|
||||||
|
nf->conf->enabled = 0;
|
||||||
|
e_config_save_queue();
|
||||||
|
evas_object_hide(nf->event_obj);
|
||||||
|
/* evas_object_hide(nf->chart_obj); */
|
||||||
|
evas_object_hide(nf->net_obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_free(Net_Face *nf)
|
||||||
|
{
|
||||||
|
if (nf->monitor)
|
||||||
|
ecore_timer_del(nf->monitor);
|
||||||
|
if (nf->menu)
|
||||||
|
e_object_del(E_OBJECT(nf->menu));
|
||||||
|
if (nf->event_obj)
|
||||||
|
evas_object_del(nf->event_obj);
|
||||||
|
if (nf->net_obj)
|
||||||
|
evas_object_del(nf->net_obj);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (nf->chart_obj)
|
||||||
|
evas_object_del(nf->chart_obj);
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (nf->gmc)
|
||||||
|
{
|
||||||
|
e_gadman_client_save(nf->gmc);
|
||||||
|
e_object_del(E_OBJECT(nf->gmc));
|
||||||
|
}
|
||||||
|
|
||||||
|
E_FREE(nf->conf);
|
||||||
|
E_FREE(nf);
|
||||||
|
net_count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
|
||||||
|
{
|
||||||
|
Net_Face *nf;
|
||||||
|
Evas_Coord x, y, w, h;
|
||||||
|
|
||||||
|
nf = data;
|
||||||
|
switch (change)
|
||||||
|
{
|
||||||
|
case E_GADMAN_CHANGE_MOVE_RESIZE:
|
||||||
|
e_gadman_client_geometry_get(nf->gmc, &x, &y, &w, &h);
|
||||||
|
evas_object_move(nf->net_obj, x, y);
|
||||||
|
/* evas_object_move(nf->chart_obj, x, y); */
|
||||||
|
evas_object_move(nf->event_obj, x, y);
|
||||||
|
evas_object_resize(nf->net_obj, w, h);
|
||||||
|
/* evas_object_resize(nf->chart_obj, w, h); */
|
||||||
|
evas_object_resize(nf->event_obj, w, h);
|
||||||
|
break;
|
||||||
|
case E_GADMAN_CHANGE_RAISE:
|
||||||
|
evas_object_raise(nf->net_obj);
|
||||||
|
/* evas_object_raise(nf->chart_obj); */
|
||||||
|
evas_object_raise(nf->event_obj);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info)
|
||||||
|
{
|
||||||
|
Net_Face *nf;
|
||||||
|
Evas_Event_Mouse_Down *ev;
|
||||||
|
|
||||||
|
ev = event_info;
|
||||||
|
nf = data;
|
||||||
|
if (ev->button == 3)
|
||||||
|
{
|
||||||
|
e_menu_activate_mouse(nf->menu, e_zone_current_get(nf->con),
|
||||||
|
ev->output.x, ev->output.y, 1, 1,
|
||||||
|
E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
|
||||||
|
e_util_container_fake_mouse_up_all_later(nf->con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_cb_menu_edit(void *data, E_Menu *mn, E_Menu_Item *mi)
|
||||||
|
{
|
||||||
|
Net_Face *nf;
|
||||||
|
|
||||||
|
nf = data;
|
||||||
|
e_gadman_mode_set(nf->gmc->gadman, E_GADMAN_MODE_EDIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_cb_menu_configure(void *data, E_Menu *mn, E_Menu_Item *mi)
|
||||||
|
{
|
||||||
|
Net_Face *nf;
|
||||||
|
|
||||||
|
nf = data;
|
||||||
|
_configure_net_module(nf->con, nf->net);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_net_face_update_values(void *data)
|
||||||
|
{
|
||||||
|
Net_Face *nf;
|
||||||
|
FILE *stat;
|
||||||
|
char dev[64];
|
||||||
|
char buf[256];
|
||||||
|
unsigned long in, out, dummy;
|
||||||
|
static unsigned long old_in, old_out;
|
||||||
|
int found;
|
||||||
|
|
||||||
|
nf = data;
|
||||||
|
|
||||||
|
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 (!strcmp(dev, strdup(nf->net->conf->device)))
|
||||||
|
{
|
||||||
|
found = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(stat);
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (in != old_in)
|
||||||
|
old_in = in;
|
||||||
|
else
|
||||||
|
in = 0;
|
||||||
|
|
||||||
|
if (out != old_out)
|
||||||
|
old_out = out;
|
||||||
|
else
|
||||||
|
out = 0;
|
||||||
|
|
||||||
|
/* Graph values */
|
||||||
|
/* _net_face_graph_values(nf, in, out); */
|
||||||
|
|
||||||
|
/* Update the modules text */
|
||||||
|
Edje_Message_Int_Set *msg;
|
||||||
|
|
||||||
|
msg = malloc(sizeof(Edje_Message_Int_Set) + 1 * sizeof(int));
|
||||||
|
msg->count = 2;
|
||||||
|
msg->val[0] = in;
|
||||||
|
msg->val[1] = out;
|
||||||
|
edje_object_message_send(nf->net_obj, EDJE_MESSAGE_INT_SET, 1, msg);
|
||||||
|
free(msg);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_net_face_graph_values(Net_Face *nf, int in, int out)
|
||||||
|
{
|
||||||
|
Evas_Object *o;
|
||||||
|
int x, y, w, h;
|
||||||
|
double factor = 0.0;
|
||||||
|
int in_val, out_val;
|
||||||
|
|
||||||
|
if (!nf)
|
||||||
|
return;
|
||||||
|
|
||||||
|
evas_object_geometry_get(nf->net_obj, &x, &y, &w, &h);
|
||||||
|
|
||||||
|
/* Graph Values */
|
||||||
|
factor = ((double)h / (double)100);
|
||||||
|
in_val = (int)((double)in * factor);
|
||||||
|
out_val = (int)((double)out * factor);
|
||||||
|
|
||||||
|
if (in_val > 100)
|
||||||
|
in_val = 100;
|
||||||
|
if (out_val > 100)
|
||||||
|
out_val = 100;
|
||||||
|
|
||||||
|
o = evas_object_line_add(nf->evas);
|
||||||
|
evas_object_clip_set(o, nf->chart_obj);
|
||||||
|
evas_object_layer_set(o, 2);
|
||||||
|
evas_object_line_xy_set(o, x + w, y, x + w, y + in_val);
|
||||||
|
evas_object_color_set(o, 255, 0, 0, 128);
|
||||||
|
evas_object_pass_events_set(o, 1);
|
||||||
|
evas_object_show(o);
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
#ifndef E_MOD_MAIN_H
|
||||||
|
#define E_MOD_MAIN_H
|
||||||
|
|
||||||
|
typedef struct _Config Config;
|
||||||
|
typedef struct _Config_Face Config_Face;
|
||||||
|
typedef struct _Net Net;
|
||||||
|
typedef struct _Net_Face Net_Face;
|
||||||
|
|
||||||
|
struct _Config
|
||||||
|
{
|
||||||
|
char *device;
|
||||||
|
int check_interval;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Config_Face
|
||||||
|
{
|
||||||
|
unsigned char enabled;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Net
|
||||||
|
{
|
||||||
|
E_Menu *config_menu;
|
||||||
|
Net_Face *face;
|
||||||
|
Config *conf;
|
||||||
|
|
||||||
|
E_Config_DD *conf_edd;
|
||||||
|
E_Config_Dialog *cfd;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _Net_Face
|
||||||
|
{
|
||||||
|
Evas *evas;
|
||||||
|
E_Container *con;
|
||||||
|
E_Menu *menu;
|
||||||
|
Net *net;
|
||||||
|
|
||||||
|
Config_Face *conf;
|
||||||
|
E_Config_DD *conf_face_edd;
|
||||||
|
|
||||||
|
Evas_Object *net_obj;
|
||||||
|
Evas_Object *event_obj;
|
||||||
|
Evas_Object *chart_obj;
|
||||||
|
|
||||||
|
Ecore_Timer *monitor;
|
||||||
|
|
||||||
|
E_Gadman_Client *gmc;
|
||||||
|
};
|
||||||
|
|
||||||
|
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_info (E_Module *m);
|
||||||
|
EAPI int e_modapi_about (E_Module *m);
|
||||||
|
EAPI int e_modapi_config (E_Module *m);
|
||||||
|
|
||||||
|
#endif
|
Binary file not shown.
|
@ -0,0 +1,144 @@
|
||||||
|
images
|
||||||
|
{
|
||||||
|
image, "module_icon.png" COMP;
|
||||||
|
image, "bg.png" COMP;
|
||||||
|
image, "over.png" COMP;
|
||||||
|
image, "over_res.png" COMP;
|
||||||
|
}
|
||||||
|
|
||||||
|
fonts
|
||||||
|
{
|
||||||
|
font, "VeraMono.ttf" "VeraMono";
|
||||||
|
}
|
||||||
|
|
||||||
|
collections
|
||||||
|
{
|
||||||
|
group
|
||||||
|
{
|
||||||
|
name, "modules/net/main";
|
||||||
|
script {
|
||||||
|
public message(Msg_Type:type, id, ...) {
|
||||||
|
if (type == MSG_INT_SET) {
|
||||||
|
new tmp;
|
||||||
|
new in_str[64];
|
||||||
|
new out_str[64];
|
||||||
|
|
||||||
|
tmp = getarg(2);
|
||||||
|
if (tmp > 1048576) {
|
||||||
|
tmp = tmp / 1048576;
|
||||||
|
snprintf(in_str, sizeof(in_str), "%i MB", tmp);
|
||||||
|
}
|
||||||
|
else if (tmp > 1024 && tmp < 1048576) {
|
||||||
|
tmp = tmp / 1024;
|
||||||
|
snprintf(in_str, sizeof(in_str), "%i KB", tmp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
snprintf(in_str, sizeof(in_str), "%i B", tmp);
|
||||||
|
}
|
||||||
|
set_text(PART:"in-text", in_str);
|
||||||
|
|
||||||
|
tmp = getarg(3);
|
||||||
|
if (tmp > 1048576) {
|
||||||
|
tmp = tmp / 1048576;
|
||||||
|
snprintf(out_str, sizeof(out_str), "%i MB", tmp);
|
||||||
|
}
|
||||||
|
else if (tmp > 1024 && tmp < 1048576) {
|
||||||
|
tmp = tmp / 1024;
|
||||||
|
snprintf(out_str, sizeof(out_str), "%i KB", tmp);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
snprintf(out_str, sizeof(out_str), "%i B", tmp);
|
||||||
|
}
|
||||||
|
set_text(PART:"out-text", out_str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
parts{
|
||||||
|
part {
|
||||||
|
name, "background";
|
||||||
|
mouse_events, 1;
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
rel1 { to, "overlay"; }
|
||||||
|
rel2 { to, "overlay"; }
|
||||||
|
image { normal, "bg.png"; border, 6 6 6 6; }
|
||||||
|
fill { smooth, 0; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
part {
|
||||||
|
name, "overlay";
|
||||||
|
mouse_events, 0;
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
image { normal, "over.png";
|
||||||
|
border, 13 13 13 13;
|
||||||
|
middle, 0;
|
||||||
|
}
|
||||||
|
fill {
|
||||||
|
smooth, 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
part {
|
||||||
|
name, "net";
|
||||||
|
mouse_events, 0;
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
color, 255 255 255 128;
|
||||||
|
aspect: 1.0 1.0;
|
||||||
|
rel1{ offset, 4 4; }
|
||||||
|
rel2{ offset, -5 -5; }
|
||||||
|
image { normal, "module_icon.png"; }
|
||||||
|
fill { smooth, 0; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
part
|
||||||
|
{
|
||||||
|
name, "out-text";
|
||||||
|
type, TEXT;
|
||||||
|
effect, SOFT_SHADOW;
|
||||||
|
mouse_events, 0;
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
align, 1.0 0.0;
|
||||||
|
rel1 { relative, 1.0 0.0; to_x, "overlay"; offset, -2 1; }
|
||||||
|
rel2 { relative, 1.0 0.0; }
|
||||||
|
color, 0 0 0 255;
|
||||||
|
color3, 255 255 255 100;
|
||||||
|
text {
|
||||||
|
text, "out"; font, "VeraMono";
|
||||||
|
size, 10; min, 1 1;
|
||||||
|
align, 1.0 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
part
|
||||||
|
{
|
||||||
|
name, "in-text";
|
||||||
|
type, TEXT;
|
||||||
|
effect, SOFT_SHADOW;
|
||||||
|
mouse_events, 0;
|
||||||
|
description {
|
||||||
|
state, "default" 0.0;
|
||||||
|
align, 1.0 0.0;
|
||||||
|
rel1 { relative, 1.0 1.0; to_x, "overlay"; offset, -2 -10; }
|
||||||
|
rel2 { relative, 1.0 1.0; }
|
||||||
|
color, 0 0 0 255;
|
||||||
|
color3, 255 255 255 100;
|
||||||
|
text {
|
||||||
|
text, "in"; font, "VeraMono";
|
||||||
|
size, 10; min, 1 1;
|
||||||
|
align, 1.0 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}//close group net
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue