|
2010-11-19
, 16:15
|
Posts: 166 |
Thanked: 154 times |
Joined on Dec 2009
|
#2
|
|
2010-11-20
, 08:25
|
Posts: 48 |
Thanked: 26 times |
Joined on Feb 2010
@ UT@NL
|
#4
|
|
2010-11-20
, 16:02
|
|
Posts: 361 |
Thanked: 219 times |
Joined on Sep 2010
|
#5
|
|
2010-11-20
, 16:51
|
Posts: 48 |
Thanked: 26 times |
Joined on Feb 2010
@ UT@NL
|
#6
|
The Following 2 Users Say Thank You to hsmade For This Useful Post: | ||
|
2010-11-21
, 16:37
|
|
Posts: 361 |
Thanked: 219 times |
Joined on Sep 2010
|
#7
|
sure.. try here: http://hsmade.com/cpumem-applet_0.5-1_armel.deb This is the 0.5-1 version with my added stuff in it. It shows the red and green dot when it see any network traffic on 2/3G or wifi.
|
2010-11-21
, 16:45
|
Posts: 48 |
Thanked: 26 times |
Joined on Feb 2010
@ UT@NL
|
#8
|
|
2010-11-21
, 16:51
|
Posts: 48 |
Thanked: 26 times |
Joined on Feb 2010
@ UT@NL
|
#9
|
--- /orig/cpumem-applet/src/cpumem_status_area_item.c 2010-11-21 17:48:13.000000000 +0100 +++ /new/cpumem-applet/src/cpumem_status_area_item.c 2010-09-28 00:22:20.000000000 +0200 @@ -14,7 +14,7 @@ #include "cpumem_status_area_item.h" -#define CPUMEM_ICON_WIDTH 16 +#define CPUMEM_ICON_WIDTH 22 #define CPUMEM_ICON_HEIGHT 16 #define CPUMEM_BOX_WIDTH 5 #define CPUMEM_BOX_HEIGHT 3 @@ -29,9 +29,12 @@ gint lastU, lastN, lastIO, lastI; guchar last_mem_level; guchar last_cpu_level; + guchar last_net_in; + guchar last_net_out; GdkPixbuf *pixbuf; GdkPixbuf *pixbuf_on; GdkPixbuf *pixbuf_red; + GdkPixbuf *pixbuf_grn; GdkPixbuf *pixbuf_off; osso_context_t *osso; gboolean red; @@ -41,6 +44,51 @@ /* + * Read current network usage and return it + */ +static guchar +check_net_in (CpumemAppletStatusAreaItemPrivate *priv) +{ + char read_buffer[32]; + FILE *fin; + int in; + + fin = (FILE*)popen("/bin/cat /proc/net/dev|/usr/bin/awk '/wlan|wmaster|gprs/{ IN=IN+$2; } END{print IN}'", "r"); + if (fin == NULL) { + g_warning("Can't open network stats\n"); + return TRUE; + } + while (fgets(read_buffer, 32, fin) != NULL) { + sscanf(read_buffer, "%d", &in); + } + pclose(fin); + return in; +} + + +/* + * Read current network usage and return it + */ +static guchar +check_net_out (CpumemAppletStatusAreaItemPrivate *priv) +{ + char read_buffer[32]; + FILE *fin; + int out; + + fin = (FILE*)popen("/bin/cat /proc/net/dev|/usr/bin/awk '/wlan|wmaster|gprs/{ OUT=OUT+$2; } END{print OUT}'", "r"); + if (fin == NULL) { + g_warning("Can't open network stats\n"); + return TRUE; + } + while (fgets(read_buffer, 32, fin) != NULL) { + sscanf(read_buffer, "%d", &out); + } + pclose(fin); + return out; +} + +/* * Read current MEM usage and return indicator between 5 and 1 - how many bars are "full" */ static guchar @@ -150,10 +198,31 @@ /* + * Compose and blit the current status of network dots + */ +static void +blit_net_bars (const guchar in, const guchar out, CpumemAppletStatusAreaItemPrivate *priv) +{ + guint x, y; + + gdk_pixbuf_fill(priv->pixbuf, 0x00000000); + + x = 16; + y = 1; + if (in > 0) + gdk_pixbuf_composite(priv->pixbuf_grn, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_WIDTH, x, y, 1, 1, GDK_INTERP_NEAREST, 255); + y = 10; + if (out > 0) + gdk_pixbuf_composite(priv->pixbuf_red, priv->pixbuf, x, y, + CPUMEM_BOX_WIDTH, CPUMEM_BOX_WIDTH, x, y, 1, 1, GDK_INTERP_NEAREST, 255); +} + +/* * Compose and blit the current status of memory bars */ static void -blit_mem_barsconst guchar level, CpumemAppletStatusAreaItemPrivate *priv) +blit_mem_bars (const guchar level, CpumemAppletStatusAreaItemPrivate *priv) { guint x, y; @@ -230,22 +299,29 @@ { guchar current_cpu_level; guchar current_mem_level; + guchar current_net_in; + guchar current_net_out; CpumemAppletStatusAreaItem *item = (CpumemAppletStatusAreaItem*)data; CpumemAppletStatusAreaItemPrivate *priv = (CpumemAppletStatusAreaItemPrivate*)item->priv; current_cpu_level = check_cpu(priv); current_mem_level = check_mem(priv); + current_net_in = check_net_in(priv); + current_net_out = check_net_out(priv); //g_debug(g_strdup_printf("LOADAPLET - UPDATED CPU %d MEM %d", current_cpu_level, current_mem_level)); //Update and blit only if data changed! - if ((current_mem_level != priv->last_mem_level) || (current_cpu_level != priv->last_cpu_level)) { + if ((current_mem_level != priv->last_mem_level) || (current_cpu_level != priv->last_cpu_level) || (current_net_in != priv->last_net_in) || (current_net_out != priv->last_net_out)) { blit_mem_bars (current_mem_level, priv); blit_cpu_bars (current_cpu_level, priv); + blit_net_bars (current_net_in - priv->last_net_in, current_net_out - priv->last_net_out, priv); if (current_cpu_level == CPUMEM_CPU_MAX) priv->red = FALSE; hd_status_plugin_item_set_status_area_icon (HD_STATUS_PLUGIN_ITEM(data), priv->pixbuf); priv->last_mem_level = current_mem_level; priv->last_cpu_level = current_cpu_level; + priv->last_net_in = current_net_in; + priv->last_net_out = current_net_out; } else if (current_cpu_level == CPUMEM_CPU_MAX) { //Pulsate max CPU load icon also when CPU load stays at max blit_cpu_bars (current_cpu_level, priv); @@ -275,7 +351,7 @@ } } else { //Suspend the updates - screen is off - if (item->priv->timeout_id) != 0) { + if (item->priv->timeout_id != 0) { g_source_remove(item->priv->timeout_id); item->priv->timeout_id = 0; } @@ -339,6 +415,8 @@ item->priv->last_mem_level = -1; item->priv->last_cpu_level = -1; + item->priv->last_net_in = -1; + item->priv->last_net_out = -1; item->priv->timeout_id = -1; item->priv->red = FALSE; item->priv->pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, CPUMEM_ICON_WIDTH, CPUMEM_ICON_HEIGHT); @@ -347,6 +425,8 @@ gdk_pixbuf_fill(item->priv->pixbuf_on, 0xffffffff); item->priv->pixbuf_red = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT); gdk_pixbuf_fill(item->priv->pixbuf_red, 0xff0000ff); + item->priv->pixbuf_grn = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT); + gdk_pixbuf_fill(item->priv->pixbuf_grn, 0x00ff00ff); item->priv->pixbuf_off = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, CPUMEM_BOX_WIDTH, CPUMEM_BOX_HEIGHT); gdk_pixbuf_fill(item->priv->pixbuf_off, 0x777777ff); cpumem_applet_status_area_item_set_area_icon(item);
The Following 2 Users Say Thank You to hsmade For This Useful Post: | ||
is there some software for N900 which displays ongoing traffic
(either WLAN or 2G to 3.5G) as a bar or similar beside the battery meter?
Maybe similar to the field strength bar for GPRS?
Alternatively something like KTrafficAnalyzer?