1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-11-05 21:07:52 +00:00

RSS was not really disabled when it was supposed to be. Experimental wireless support.

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@896 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Toni Spets 2007-08-07 12:51:08 +00:00
parent 43f30219e9
commit a3e81ae59f
6 changed files with 163 additions and 1 deletions

View File

@ -196,6 +196,20 @@ if test x$want_rss = xyes; then
AC_DEFINE(RSS, 1, [Define if you want rss support])
fi
dnl
dnl Wireless extensions
dnl
AC_ARG_ENABLE([wlan],
AC_HELP_STRING([--enable-wlan], [enable if you want wireless support @<:@default=no@:>@]),
[want_wlan="$enableval"], [want_wlan=no])
#
AM_CONDITIONAL(BUILD_RSS, test x$want_wlan = xyes)
if test x$want_wlan = xyes; then
LIBS="$LIBS -liw"
AC_DEFINE(HAVE_IWLIB, 1, [Define if you want wireless support])
fi
dnl
dnl IMLIB2
dnl
@ -543,4 +557,5 @@ $PACKAGE $VERSION configured successfully:
hddtemp: $want_hddtemp
portmon: $want_portmon
RSS: $want_rss
wireless: $want_wlan
EOF

View File

@ -1001,6 +1001,13 @@ enum text_object_type {
OBJ_pb_battery,
OBJ_voltage_mv,
OBJ_voltage_v,
OBJ_wireless_essid,
OBJ_wireless_mode,
OBJ_wireless_bitrate,
OBJ_wireless_link_qual,
OBJ_wireless_link_qual_max,
OBJ_wireless_link_bar,
OBJ_wireless_ap,
#endif /* __linux__ */
OBJ_if_empty,
OBJ_if_existing,
@ -2165,6 +2172,46 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
obj->data.cpu_index=atoi(&arg[0]);
}
obj->a = 1;
#ifdef HAVE_IWLIB
END OBJ(wireless_essid, INFO_NET)
if(arg)
obj->data.net = get_net_stat(arg);
else
CRIT_ERR("wireless_essid: needs an argument");
END OBJ(wireless_mode, INFO_NET)
if(arg)
obj->data.net = get_net_stat(arg);
else
CRIT_ERR("wireless_mode: needs an argument");
END OBJ(wireless_ap, INFO_NET)
if(arg)
obj->data.net = get_net_stat(arg);
else
CRIT_ERR("wireless_ap: needs an argument");
END OBJ(wireless_bitrate, INFO_NET)
if(arg)
obj->data.net = get_net_stat(arg);
else
CRIT_ERR("wireless_bitrate: needs an argument");
END OBJ(wireless_link_qual, INFO_NET)
if(arg)
obj->data.net = get_net_stat(arg);
else
CRIT_ERR("wireless_link_qual: needs an argument");
END OBJ(wireless_link_qual_max, INFO_NET)
if(arg)
obj->data.net = get_net_stat(arg);
else
CRIT_ERR("wireless_link_qual_max: needs an argument");
END OBJ(wireless_link_bar, INFO_NET)
if(arg) {
arg = scan_bar(arg, &obj->a, &obj->b);
obj->data.net = get_net_stat(arg);
} else
CRIT_ERR("wireless_link_bar: needs an argument");
#endif /* HAVE_IWLIB */
#endif /* __linux__ */
END OBJ(freq_dyn, 0);
END OBJ(freq_dyn_g, 0);
@ -3482,6 +3529,30 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
obj->a = get_voltage(p, p_max_size, "%'.3f", 1000, obj->data.cpu_index);
}
}
#ifdef HAVE_IWLIB
OBJ(wireless_essid) {
snprintf(p, p_max_size, "%s", obj->data.net->essid);
}
OBJ(wireless_mode) {
snprintf(p, p_max_size, "%s", obj->data.net->mode);
}
OBJ(wireless_bitrate) {
snprintf(p, p_max_size, "%s", obj->data.net->bitrate);
}
OBJ(wireless_ap) {
snprintf(p, p_max_size, "%s", obj->data.net->ap);
}
OBJ(wireless_link_qual) {
snprintf(p, p_max_size, "%d", obj->data.net->link_qual);
}
OBJ(wireless_link_qual_max) {
snprintf(p, p_max_size, "%d", obj->data.net->link_qual_max);
}
OBJ(wireless_link_bar) {
new_bar(p, obj->a, obj->b, ((double)obj->data.net->link_qual/obj->data.net->link_qual_max)*255.0);
}
#endif /* HAVE_IWLIB */
#endif /* __linux__ */
OBJ(freq_dyn) {

View File

@ -101,6 +101,13 @@ struct net_stat {
struct sockaddr addr;
int linkstatus;
double net_rec[15], net_trans[15];
// wireless extensions
char essid[32];
char bitrate[16];
char mode[16];
char ap[18];
int link_qual;
int link_qual_max;
};
unsigned int diskio_value;

View File

@ -32,6 +32,10 @@
#include <net/if.h>
#include <math.h>
#ifdef HAVE_IWLIB
#include <iwlib.h>
#endif
#define SHORTSTAT_TEMPL "%*s %llu %llu %llu"
#define LONGSTAT_TEMPL "%*s %llu %llu %llu "
@ -154,6 +158,13 @@ inline void update_net_stats()
char buf[256];
double delta;
#ifdef HAVE_IWLIB
// wireless info variables
int skfd, has_bitrate = 0, link_qual = 0, link_qual_max = 0;
struct wireless_info *winfo;
struct iwreq wrq;
#endif
/* get delta */
delta = current_update_time - last_update_time;
if (delta <= 0.0001)
@ -264,6 +275,57 @@ inline void update_net_stats()
}
}
#ifdef HAVE_IWLIB
/* update wireless info */
winfo = malloc(sizeof(struct wireless_info));
memset(winfo, 0, sizeof(struct wireless_info));
skfd = iw_sockets_open();
if(iw_get_basic_config(skfd, s, &(winfo->b)) > -1) {
// set present winfo variables
if(iw_get_stats(skfd, s, &(winfo->stats), &winfo->range, winfo->has_range) >= 0)
winfo->has_stats = 1;
if(iw_get_range_info(skfd, s, &(winfo->range)) >= 0)
winfo->has_range = 1;
if(iw_get_ext(skfd, s, SIOCGIWAP, &wrq) >= 0) {
winfo->has_ap_addr = 1;
memcpy(&(winfo->ap_addr), &(wrq.u.ap_addr), sizeof (sockaddr));
}
// get bitrate
if(iw_get_ext(skfd, s, SIOCGIWRATE, &wrq) >= 0) {
memcpy(&(winfo->bitrate), &(wrq.u.bitrate), sizeof(iwparam));
iw_print_bitrate(ns->bitrate, 16, winfo->bitrate.value);
has_bitrate = 1;
}
// get link quality
if(winfo->has_range && winfo->has_stats && ((winfo->stats.qual.level != 0) || (winfo->stats.qual.updated & IW_QUAL_DBM))) {
if(!(winfo->stats.qual.updated & IW_QUAL_QUAL_INVALID)) {
ns->link_qual = winfo->stats.qual.qual;
ns->link_qual_max = winfo->range.max_qual.qual;
}
}
// get ap mac
if(winfo->has_ap_addr) {
iw_sawap_ntop(&winfo->ap_addr, ns->ap);
}
// get essid
if(winfo->b.has_essid) {
if(winfo->b.essid_on)
snprintf(ns->essid, 32, "%s", winfo->b.essid);
else
snprintf(ns->essid, 32, "off/any");
}
snprintf(ns->mode, 16, "%s", iw_operation_mode[winfo->b.mode]);
}
iw_sockets_close(skfd);
free(winfo);
#endif
}
fclose(net_dev_fp);
@ -314,7 +376,6 @@ inline void update_wifi_stats()
sscanf(p, "%*d %d. %d. %d", &l, &m, &n);
ns->linkstatus = (int) (log(MIN(MAX(l,1),92)) / log(92) * 100);
}
/*** end wireless patch ***/

View File

@ -15,6 +15,8 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifdef RSS
#include <libxml/parser.h>
#include <libxml/tree.h>
#include <string.h>
@ -213,3 +215,5 @@ PRSS* prss_parse_doc(xmlDocPtr doc)
free(result);
return NULL;
}
#endif

View File

@ -6,6 +6,8 @@
* new rss.c written by hifi (Toni Spets)
*/
#ifdef RSS
#include <stdio.h>
#include <string.h>
#include <time.h>
@ -154,3 +156,5 @@ get_rss_info(char *uri, int delay)
return curdata;
}
#endif