Index: configure.in =================================================================== RCS file: /cvs/gnome/gnome-applets/configure.in,v retrieving revision 1.307 diff -u -r1.307 configure.in --- configure.in 7 Jun 2004 22:12:01 -0000 1.307 +++ configure.in 27 Jun 2004 21:58:07 -0000 @@ -232,6 +232,15 @@ AM_CONDITIONAL(NEED_LIBAPM, test "x$NEED_LIBAPM" = "xyes") AM_CONDITIONAL(BUILD_BATTSTAT_APPLET, test x$build_battstat_applet = xyes) +dnl ****************************************** +dnl ** wireless check ** +dnl ****************************************** + +HAVE_LIBIW=no +AC_CHECK_LIB(iw,iw_print_version_info,[HAVE_LIBIW=yes],[HAVE_LIBIW=no]) +AC_SUBST(HAVE_LIBIW) +AM_CONDITIONAL(HAVE_LIBIW, test "x$HAVE_LIBIW" = "xyes") + dnl ******************************************* dnl ** mixer applet check ** dnl ******************************************* Index: wireless/Makefile.am =================================================================== RCS file: /cvs/gnome/gnome-applets/wireless/Makefile.am,v retrieving revision 1.7 diff -u -r1.7 Makefile.am --- wireless/Makefile.am 8 Feb 2004 10:16:20 -0000 1.7 +++ wireless/Makefile.am 27 Jun 2004 21:58:08 -0000 @@ -1,11 +1,22 @@ ## Process this file with automake to produce Makefile.in +if HAVE_LIBIW +IWLIB = -liw +IWDIR = +IWINC = -DHAVE_LIBIW +else +IWLIB = +IWDIR = +IWINC = +endif + NULL= SUBDIRS = docs INCLUDES = \ -I$(top_srcdir)/intl \ -I$(top_srcdir)/screen-exec \ + $(IWINC) \ $(GNOME_APPLETS_CFLAGS) \ $(LIBGLADE_CFLAGS) \ -DICONDIR=\""$(datadir)/pixmaps"\" \ @@ -24,6 +35,7 @@ $(top_builddir)/screen-exec/libscreen-exec.la \ $(GNOME_APPLETS_LIBS) \ $(LIBGLADE_LIBS) \ + $(IWLIB) \ $(NULL) gladedir = $(datadir)/wireless-applet/ Index: wireless/wireless-applet.c =================================================================== RCS file: /cvs/gnome/gnome-applets/wireless/wireless-applet.c,v retrieving revision 1.36 diff -u -r1.36 wireless-applet.c --- wireless/wireless-applet.c 10 Jun 2004 13:01:14 -0000 1.36 +++ wireless/wireless-applet.c 27 Jun 2004 21:58:10 -0000 @@ -29,6 +29,9 @@ #include #include #include +#ifdef HAVE_LIBIW +#include +#endif #include #include @@ -63,6 +66,9 @@ PanelApplet base; gchar *device; gboolean show_percent; +#ifdef HAVE_LIBIW + int max_link, avg_link; +#endif GList *devices; @@ -141,7 +147,7 @@ /* Update the percentage */ if (percent > 0) { - tmp = g_strdup_printf ( _("Link Strength: %2.0d%%"), percent); + tmp = g_strdup_printf ( _("%2.0d%%"), percent); } else { tmp = g_strdup_printf (_("N/A")); } @@ -188,6 +194,10 @@ long int noise) { int percent; +#ifdef HAVE_LIBIW + int max_link = applet->max_link; + int avg_link = applet->avg_link; +#endif /* Calculate the percentage based on the link quality */ if (level < 0) { @@ -196,7 +206,16 @@ if (link < 1) { percent = 0; } else { +#ifdef HAVE_LIBIW + if (link > max_link) + percent = 100; + else if (link > avg_link) + percent = 50 + (link - avg_link)/(max_link - avg_link) * 50.0; + else + percent = link/avg_link * 50.0; +#else percent = (int)rint ((log (link) / log (92)) * 100.0); +#endif percent = CLAMP (percent, 0, 100); } } @@ -225,8 +244,30 @@ g_free (pixmapdir); } +#ifdef HAVE_LIBIW +static void +wireless_applet_update_link_range (WirelessApplet *applet, gchar *device) { + struct iw_range range; + int skfd; + + applet->max_link = 92; + applet->avg_link = 46; + + if (!device) return; + if ((skfd = iw_sockets_open()) < 0) return; + + iw_get_range_info (skfd, device, &range); + applet->max_link = range.max_qual.qual; + applet->avg_link = range.avg_qual.qual; + close (skfd); +} +#endif + static void wireless_applet_set_device (WirelessApplet *applet, gchar *device) { +#ifdef HAVE_LIBIW + wireless_applet_update_link_range (applet, device); +#endif g_free (applet->device); applet->device = g_strdup (device); } @@ -371,10 +412,16 @@ { applet->device = panel_applet_gconf_get_string (PANEL_APPLET (applet), "device", NULL); +#ifdef HAVE_LIBIW + wireless_applet_update_link_range (applet, applet->device); +#endif /* Oooh, new applet, let's put in the defaults */ if (applet->device == NULL) { +#ifdef HAVE_LIBIW + wireless_applet_update_link_range (applet, CFG_DEVICE); +#endif applet->device = g_strdup (CFG_DEVICE); applet->show_percent = TRUE; return;