1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 12:27:52 +00:00

remove infopipe support

git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@718 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
Philip Kovacs 2006-11-04 00:25:22 +00:00
parent 0411537dce
commit 03ebbf2cf4
6 changed files with 2 additions and 453 deletions

View File

@ -4,10 +4,6 @@ if BUILD_AUDACIOUS
audacious = audacious.c audacious.h
endif
if BUILD_INFOPIPE
infopipe = infopipe.c infopipe.h
endif
if BUILD_BMPX
bmpx = bmpx.c
endif
@ -67,7 +63,6 @@ conky_SOURCES = \
$(freebsd) \
fs.c \
$(hddtemp) \
$(infopipe) \
$(linux) \
mail.c \
mixer.c \

View File

@ -237,11 +237,6 @@ void update_stuff()
update_audacious();
#endif
#ifdef INFOPIPE
if (NEED(INFO_INFOPIPE))
update_infopipe();
#endif
#ifdef BMPX
if (NEED(INFO_BMPX))
update_bmpx();

View File

@ -73,9 +73,6 @@ static void print_version()
#ifdef AUDACIOUS
" * audacious\n"
#endif /* AUDACIOUS */
#ifdef INFOPIPE
" * infopipe\n"
#endif /* INFOPIPE */
#ifdef BMPX
" * bmpx\n"
#endif /* BMPX */
@ -1084,21 +1081,6 @@ enum text_object_type {
OBJ_audacious_playlist_position,
OBJ_audacious_bar,
#endif
#ifdef INFOPIPE
OBJ_infopipe_status,
OBJ_infopipe_title,
OBJ_infopipe_length,
OBJ_infopipe_length_seconds,
OBJ_infopipe_position,
OBJ_infopipe_position_seconds,
OBJ_infopipe_bitrate,
OBJ_infopipe_frequency,
OBJ_infopipe_channels,
OBJ_infopipe_filename,
OBJ_infopipe_playlist_length,
OBJ_infopipe_playlist_position,
OBJ_infopipe_bar,
#endif
#ifdef BMPX
OBJ_bmpx_title,
OBJ_bmpx_artist,
@ -2975,24 +2957,6 @@ static struct text_object *construct_text_object(const char *s, const char *arg,
(void) scan_bar(arg, &obj->a, &obj->b);
END
#endif
#ifdef INFOPIPE
OBJ(infopipe_status, INFO_INFOPIPE) END
OBJ(infopipe_title, INFO_INFOPIPE) END
OBJ(infopipe_length, INFO_INFOPIPE) END
OBJ(infopipe_length_seconds, INFO_INFOPIPE) END
OBJ(infopipe_position, INFO_INFOPIPE) END
OBJ(infopipe_position_seconds, INFO_INFOPIPE) END
OBJ(infopipe_bitrate, INFO_INFOPIPE) END
OBJ(infopipe_frequency, INFO_INFOPIPE) END
OBJ(infopipe_channels, INFO_INFOPIPE) END
OBJ(infopipe_filename, INFO_INFOPIPE) END
OBJ(infopipe_playlist_length, INFO_INFOPIPE) END
OBJ(infopipe_playlist_position, INFO_INFOPIPE) END
OBJ(infopipe_bar, INFO_INFOPIPE)
(void) scan_bar(arg, &obj->a, &obj->b);
END
#endif
#ifdef BMPX
OBJ(bmpx_title, INFO_BMPX)
memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
@ -4624,50 +4588,6 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
new_bar(p,obj->a,obj->b,(int)(progress*255.0f));
}
#endif
#ifdef INFOPIPE
OBJ(infopipe_status) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_STATUS]);
}
OBJ(infopipe_title) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_TITLE]);
}
OBJ(infopipe_length) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_LENGTH]);
}
OBJ(infopipe_length_seconds) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_LENGTH_SECONDS]);
}
OBJ(infopipe_position) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_POSITION]);
}
OBJ(infopipe_position_seconds) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_POSITION_SECONDS]);
}
OBJ(infopipe_bitrate) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_BITRATE]);
}
OBJ(infopipe_frequency) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_FREQUENCY]);
}
OBJ(infopipe_channels) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_CHANNELS]);
}
OBJ(infopipe_filename) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_FILENAME]);
}
OBJ(infopipe_playlist_length) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PLAYLIST_LENGTH]);
}
OBJ(infopipe_playlist_position) {
snprintf(p, p_max_size, "%s", cur->infopipe.items[INFOPIPE_PLAYLIST_POSITION]);
}
OBJ(infopipe_bar) {
double progress;
progress= atof(cur->infopipe.items[INFOPIPE_POSITION_SECONDS]) /
atof(cur->infopipe.items[INFOPIPE_LENGTH_SECONDS]);
new_bar(p,obj->a,obj->b,(int)(progress*255.0f));
}
#endif
#ifdef BMPX
OBJ(bmpx_title) {
snprintf(p, p_max_size, "%s", cur->bmpx.title);
@ -6160,10 +6080,6 @@ void reload_config(void)
if ( (info.audacious.thread) && (destroy_audacious_thread()!=0) )
ERR("error destroying audacious thread");
#endif
#ifdef INFOPIPE
if ( (info.infopipe.thread) && (destroy_infopipe_thread()!=0) )
ERR("error destroying audacious thread");
#endif
#ifdef TCP_PORT_MONITOR
destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
#endif
@ -6183,10 +6099,6 @@ void reload_config(void)
#ifdef AUDACIOUS
if ( (!info.audacious.thread) && (create_audacious_thread() !=0) )
CRIT_ERR("unable to create audacious thread!");
#endif
#ifdef INFOPIPE
if ( (!info.infopipe.thread) && (create_infopipe_thread() !=0) )
CRIT_ERR("unable to create infopipe thread!");
#endif
extract_variable_text(text);
free(text);
@ -6256,10 +6168,6 @@ void clean_up(void)
if ( info.audacious.thread && (destroy_audacious_thread()!=0) )
ERR("error destroying audacious thread");
#endif
#ifdef INFOPIPE
if ( info.infopipe.thread && (destroy_infopipe_thread()!=0) )
ERR("error destroying infopipe thread");
#endif
}
static int string_to_bool(const char *s)
@ -7237,10 +7145,6 @@ int main(int argc, char **argv)
if ( info.audacious.thread && (destroy_audacious_thread()!=0) )
ERR("error destroying audacious thread");
#endif
#ifdef INFOPIPE
if ( info.infopipe.thread && (destroy_infopipe_thread()!=0) )
ERR("error destroying infopipe thread");
#endif
#if defined(__FreeBSD__)
kvm_close(kd);

View File

@ -46,10 +46,6 @@
#include "audacious.h"
#endif
#ifdef INFOPIPE
#include "infopipe.h"
#endif
#ifdef XMMS2
#include <xmmsclient/xmmsclient.h>
#endif
@ -190,17 +186,6 @@ struct audacious_s {
};
#endif
#ifdef INFOPIPE
struct infopipe_s {
infopipe_t items; /* e.g. items[INFOPIPE_STATUS] */
int runnable; /* used to signal worker thread to stop */
pthread_t thread; /* worker thread */
pthread_attr_t thread_attr; /* thread attributes */
pthread_mutex_t item_mutex; /* mutex for item array */
pthread_mutex_t runnable_mutex; /* mutex for runnable flag */
};
#endif
#ifdef BMPX
void update_bmpx();
struct bmpx_s {
@ -253,14 +238,11 @@ enum {
#ifdef AUDACIOUS
INFO_AUDACIOUS = 23,
#endif
#ifdef INFOPIPE
INFO_INFOPIPE = 24,
#endif
#ifdef BMPX
INFO_BMPX = 25,
INFO_BMPX = 24,
#endif
#ifdef XMMS2
INFO_XMMS2 = 26,
INFO_XMMS2 = 25,
#endif
};
@ -317,9 +299,6 @@ struct information {
#ifdef AUDACIOUS
struct audacious_s audacious;
#endif
#ifdef INFOPIPE
struct infopipe_s infopipe;
#endif
#ifdef BMPX
struct bmpx_s bmpx;
#endif

View File

@ -1,268 +0,0 @@
/* -------------------------------------------------------------------------
* infopipe.c: conky support for infopipe plugin
*
* Copyright (C) 2005 Philip Kovacs kovacsp3@comcast.net
*
* $Id$
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* --------------------------------------------------------------------------- */
#include <pthread.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/select.h>
#include <sys/time.h>
#include <sys/types.h>
#include <fcntl.h>
#include "config.h"
#include "conky.h"
#include "infopipe.h"
#define INFOPIPE_NAMED_PIPE "/tmp/xmms-info"
/* 14 keys comprise the output of the infopipe plugin. */
enum _infopipe_keys {
INFOPIPE_KEY_PROTOCOL=0,
INFOPIPE_KEY_VERSION,
INFOPIPE_KEY_STATUS,
INFOPIPE_KEY_PLAYLIST_TUNES,
INFOPIPE_KEY_PLAYLIST_CURRTUNE,
INFOPIPE_KEY_USEC_POSITION,
INFOPIPE_KEY_POSITION,
INFOPIPE_KEY_USEC_TIME,
INFOPIPE_KEY_TIME,
INFOPIPE_KEY_BITRATE,
INFOPIPE_KEY_FREQUENCY,
INFOPIPE_KEY_CHANNELS,
INFOPIPE_KEY_TITLE,
INFOPIPE_KEY_FILE
};
/* access to this item array is synchronized */
static infopipe_t infopipe_items;
/* ----------------------------------------
* Conky update function for infopipe data.
* ---------------------------------------- */
void update_infopipe(void)
{
/*
The worker thread is updating the infopipe_items array asynchronously to the main
conky thread. We merely copy the infopipe_items array into the main thread's info
structure when the main thread's update cycle fires.
*/
pthread_mutex_lock(&info.infopipe.item_mutex);
memcpy(&info.infopipe.items,infopipe_items,sizeof(infopipe_items));
pthread_mutex_unlock(&info.infopipe.item_mutex);
}
/* ------------------------------------------------------------
* Create a worker thread for infopipe media player status.
*
* Returns 0 on success, -1 on error.
* ------------------------------------------------------------*/
int create_infopipe_thread(void)
{
/* Is a worker is thread already running? */
if (info.infopipe.thread)
return(-1);
/* Joinable thread for infopipe activity */
pthread_attr_init(&info.infopipe.thread_attr);
pthread_attr_setdetachstate(&info.infopipe.thread_attr, PTHREAD_CREATE_JOINABLE);
/* Init mutexes */
pthread_mutex_init(&info.infopipe.item_mutex, NULL);
pthread_mutex_init(&info.infopipe.runnable_mutex, NULL);
/* Init runnable condition for worker thread */
pthread_mutex_lock(&info.infopipe.runnable_mutex);
info.infopipe.runnable=1;
pthread_mutex_unlock(&info.infopipe.runnable_mutex);
if (pthread_create(&info.infopipe.thread, &info.infopipe.thread_attr, infopipe_thread_func, NULL))
return(-1);
return 0;
}
/* ------------------------------------------------
* Destroy infopipe status thread.
*
* Returns 0 on success, -1 on error.
* ------------------------------------------------ */
int destroy_infopipe_thread(void)
{
/* Is a worker is thread running? If not, no error. */
if (!info.infopipe.thread)
return(0);
/* Signal infopipe worker thread to terminate */
pthread_mutex_lock(&info.infopipe.runnable_mutex);
info.infopipe.runnable=0;
pthread_mutex_unlock(&info.infopipe.runnable_mutex);
/* Destroy thread attribute and wait for thread */
pthread_attr_destroy(&info.infopipe.thread_attr);
if (pthread_join(info.infopipe.thread, NULL))
return(-1);
/* Destroy mutexes */
pthread_mutex_destroy(&info.infopipe.item_mutex);
pthread_mutex_destroy(&info.infopipe.runnable_mutex);
info.infopipe.thread=(pthread_t)0;
return 0;
}
/* --------------------------------------------------
* Worker thread function for InfoPipe data sampling.
* -------------------------------------------------- */
void *infopipe_thread_func(void *pvoid)
{
int i,rc,fd,runnable;
fd_set readset;
struct timeval tm;
static char buf[2048],line[128];
static infopipe_t items;
char *pbuf,c;
pvoid=(void*)pvoid; /* avoid warning */
/* Grab the runnable signal. Should be non-zero here or we do nothing. */
pthread_mutex_lock(&info.infopipe.runnable_mutex);
runnable=info.infopipe.runnable;
pthread_mutex_unlock(&info.infopipe.runnable_mutex );
/* Loop until the main thread sets the runnable signal to 0. */
while(runnable) {
for (;;) { /* convenience loop so we can break below */
memset(buf,0,sizeof(buf));
if ((fd=open(INFOPIPE_NAMED_PIPE, O_RDONLY | O_NONBLOCK)) < 0) {
/* InfoPipe is not running */
memset(items,0,sizeof(items));
strcpy(items[INFOPIPE_STATUS],"Not running");
break;
}
FD_ZERO(&readset);
FD_SET(fd,&readset);
/* On Linux, select() reduces the timer by the amount of time not slept,
* so we must reset the timer with each loop. */
tm.tv_sec=1;
tm.tv_usec=0;
rc=select(fd+1,&readset,NULL,NULL,&tm);
if (rc == -1) {
/* -- debug --
perror("infopipe select()");
*/
}
else if (rc && FD_ISSET(fd,&readset)) { /* ready to read */
if (read(fd,buf,sizeof(buf)) > 0) { /* buf has data */
pbuf=buf;
for (i=0;i<14;i++) {
/* 14 lines of key: value pairs presented in a known order */
memset(line,0,sizeof(line));
if ( sscanf(pbuf,"%*[^:]: %[^\n]",line) == EOF )
break;
while((c = *pbuf++) && (c != '\n'));
switch(i) {
case INFOPIPE_KEY_PROTOCOL:
break;
case INFOPIPE_KEY_VERSION:
break;
case INFOPIPE_KEY_STATUS:
strncpy(items[INFOPIPE_STATUS],line,sizeof(items[INFOPIPE_STATUS])-1);
break;
case INFOPIPE_KEY_PLAYLIST_TUNES:
strncpy(items[INFOPIPE_PLAYLIST_LENGTH],line,sizeof(items[INFOPIPE_PLAYLIST_LENGTH])-1);
break;
case INFOPIPE_KEY_PLAYLIST_CURRTUNE:
strncpy(items[INFOPIPE_PLAYLIST_POSITION],line,sizeof(items[INFOPIPE_PLAYLIST_POSITION])-1);
break;
case INFOPIPE_KEY_USEC_POSITION:
snprintf(items[INFOPIPE_POSITION_SECONDS],sizeof(items[INFOPIPE_POSITION_SECONDS])-1,
"%d", atoi(line) / 1000);
break;
case INFOPIPE_KEY_POSITION:
strncpy(items[INFOPIPE_POSITION],line,sizeof(items[INFOPIPE_POSITION])-1);
break;
case INFOPIPE_KEY_USEC_TIME:
snprintf(items[INFOPIPE_LENGTH_SECONDS],sizeof(items[INFOPIPE_LENGTH_SECONDS])-1,
"%d", atoi(line) / 1000);
break;
case INFOPIPE_KEY_TIME:
strncpy(items[INFOPIPE_LENGTH],line,sizeof(items[INFOPIPE_LENGTH])-1);
break;
case INFOPIPE_KEY_BITRATE:
strncpy(items[INFOPIPE_BITRATE],line,sizeof(items[INFOPIPE_BITRATE])-1);
break;
case INFOPIPE_KEY_FREQUENCY:
strncpy(items[INFOPIPE_FREQUENCY],line,sizeof(items[INFOPIPE_FREQUENCY])-1);
break;
case INFOPIPE_KEY_CHANNELS:
strncpy(items[INFOPIPE_CHANNELS],line,sizeof(items[INFOPIPE_CHANNELS])-1);
break;
case INFOPIPE_KEY_TITLE:
strncpy(items[INFOPIPE_TITLE],line,sizeof(items[INFOPIPE_TITLE])-1);
break;
case INFOPIPE_KEY_FILE:
strncpy(items[INFOPIPE_FILENAME],line,sizeof(items[INFOPIPE_FILENAME])-1);
break;
default:
break;
}
}
/* -- debug --
for(i=0;i<14;i++)
printf("%s\n",items[i]);
*/
}
}
else {
/* -- debug --
printf("no infopipe data\n");
*/
}
close(fd);
break;
}
/* Deliver the refreshed items array to g_items. */
pthread_mutex_lock(&info.infopipe.item_mutex);
memcpy(&infopipe_items,items,sizeof(items));
pthread_mutex_unlock(&info.infopipe.item_mutex);
/* Grab the runnable signal for next loop. */
pthread_mutex_lock(&info.infopipe.runnable_mutex);
runnable=info.infopipe.runnable;
pthread_mutex_unlock(&info.infopipe.runnable_mutex);
sleep(1);
}
pthread_exit(NULL);
}

View File

@ -1,56 +0,0 @@
/* -------------------------------------------------------------------------
* infopipe.h: conky support for infopipe plugin
*
* Copyright (C) 2005 Philip Kovacs kovacsp3@comcast.net
*
* $Id$
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* --------------------------------------------------------------------------- */
#ifndef INFOPIPE_H
#define INFOPIPE_H
enum _infopipe_items {
INFOPIPE_STATUS=0,
INFOPIPE_TITLE,
INFOPIPE_LENGTH,
INFOPIPE_LENGTH_SECONDS,
INFOPIPE_POSITION,
INFOPIPE_POSITION_SECONDS,
INFOPIPE_BITRATE,
INFOPIPE_FREQUENCY,
INFOPIPE_CHANNELS,
INFOPIPE_FILENAME,
INFOPIPE_PLAYLIST_LENGTH,
INFOPIPE_PLAYLIST_POSITION,
};
/* 12 slots for the infopipe values */
typedef char infopipe_t[12][128];
/* create a worker thread for infopipe media player status */
int create_infopipe_thread(void);
/* destroy infopipe media player worker thread */
int destroy_infopipe_thread(void);
/* Service routine for the conky main thread */
void update_infopipe(void);
/* Thread functions */
void *infopipe_thread_func(void *);
#endif