aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorreinelt <>2006-04-15 05:22:52 +0000
committerreinelt <>2006-04-15 05:22:52 +0000
commit8c0942f25ab0d4f70861bd0f75fc44c0bf041a58 (patch)
tree1393a83355222e6ae3606f212c6f5101e703d34b
parent052f72657914a6d1da50eccb23545c674754cbaf (diff)
downloadlcd4linux-8c0942f25ab0d4f70861bd0f75fc44c0bf041a58.tar.gz
[lcd4linux @ 2006-04-15 05:22:52 by reinelt]
mpd plugin from Stefan Kuhne
-rw-r--r--Makefile.am1
-rw-r--r--Makefile.in21
-rw-r--r--config.h.in6
-rwxr-xr-xconfigure243
-rw-r--r--plugin.c14
-rw-r--r--plugin_mpd.c239
-rw-r--r--plugins.m419
-rw-r--r--widget_image.c12
8 files changed, 539 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am
index 53488fd..1759787 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -102,6 +102,7 @@ plugin_imon.c \
plugin_isdn.c \
plugin_loadavg.c \
plugin_meminfo.c \
+plugin_mpd.c \
plugin_mysql.c \
plugin_netdev.c \
plugin_pop3.c \
diff --git a/Makefile.in b/Makefile.in
index e4c2eff..840b2d7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -104,7 +104,7 @@ lcd4linux_DEPENDENCIES = @DRIVERS@ @PLUGINS@
lcd4linux_SOURCES = lcd4linux.c cfg.c cfg.h debug.c debug.h drv.c drv.h evaluator.c evaluator.h hash.c hash.h layout.c layout.h pid.c pid.h timer.c timer.h thread.c thread.h udelay.c udelay.h qprintf.c qprintf.h rgb.c rgb.h widget.c widget.h widget_text.c widget_text.h widget_bar.c widget_bar.h widget_icon.c widget_icon.h widget_image.c widget_image.h widget_keypad.c widget_keypad.h widget_timer.c widget_timer.h widget_gpo.c widget_gpo.h plugin.c plugin.h plugin_cfg.c plugin_math.c plugin_string.c plugin_test.c plugin_time.c
-EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_gpio.c drv_generic_gpio.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_i2c.c drv_generic_i2c.h drv_generic_keypad.c drv_generic_keypad.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_G15.c drv_HD44780.c drv_Image.c drv_LCD2USB.c drv_LCDLinux.c drv_LCDTerm.c drv_LPH7508.c drv_LUIse.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_Noritake.c drv_NULL.c drv_RouterBoard.c drv_Sample.c drv_serdisplib.c drv_SimpleLCD.c drv_T6963.c drv_Trefon.c drv_USBLCD.c drv_WincorNixdorf.c drv_X11.c font_6x8.h lcd4linux_i2c.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_file.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_python.c plugin_sample.c plugin_seti.c plugin_statfs.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c
+EXTRA_lcd4linux_SOURCES = drv_generic_text.c drv_generic_text.h drv_generic_graphic.c drv_generic_graphic.h drv_generic_gpio.c drv_generic_gpio.h drv_generic_serial.c drv_generic_serial.h drv_generic_parport.c drv_generic_parport.h drv_generic_i2c.c drv_generic_i2c.h drv_generic_keypad.c drv_generic_keypad.h drv_BeckmannEgle.c drv_BWCT.c drv_Crystalfontz.c drv_Curses.c drv_Cwlinux.c drv_G15.c drv_HD44780.c drv_Image.c drv_LCD2USB.c drv_LCDLinux.c drv_LCDTerm.c drv_LPH7508.c drv_LUIse.c drv_M50530.c drv_MatrixOrbital.c drv_MilfordInstruments.c drv_Noritake.c drv_NULL.c drv_RouterBoard.c drv_Sample.c drv_serdisplib.c drv_SimpleLCD.c drv_T6963.c drv_Trefon.c drv_USBLCD.c drv_WincorNixdorf.c drv_X11.c font_6x8.h lcd4linux_i2c.h plugin_apm.c plugin_cpuinfo.c plugin_diskstats.c plugin_dvb.c plugin_exec.c plugin_file.c plugin_i2c_sensors.c plugin_imon.c plugin_isdn.c plugin_loadavg.c plugin_meminfo.c plugin_mpd.c plugin_mysql.c plugin_netdev.c plugin_pop3.c plugin_ppp.c plugin_proc_stat.c plugin_python.c plugin_sample.c plugin_seti.c plugin_statfs.c plugin_uname.c plugin_uptime.c plugin_wireless.c plugin_xmms.c
EXTRA_DIST = lcd4linux.conf.sample lcd4kde.conf lcd4linux.kdelnk lcd4linux.xpm lcd4linux.lsm curses.m4 AUTHORS CREDITS FAQ NEWS TODO README README.Drivers README.Plugins README.KDE plugin_sample.c
@@ -161,15 +161,16 @@ DEP_FILES = .deps/cfg.P .deps/debug.P .deps/drv.P .deps/drv_BWCT.P \
.deps/plugin_dvb.P .deps/plugin_exec.P .deps/plugin_file.P \
.deps/plugin_i2c_sensors.P .deps/plugin_imon.P .deps/plugin_isdn.P \
.deps/plugin_loadavg.P .deps/plugin_math.P .deps/plugin_meminfo.P \
-.deps/plugin_mysql.P .deps/plugin_netdev.P .deps/plugin_pop3.P \
-.deps/plugin_ppp.P .deps/plugin_proc_stat.P .deps/plugin_python.P \
-.deps/plugin_sample.P .deps/plugin_seti.P .deps/plugin_statfs.P \
-.deps/plugin_string.P .deps/plugin_test.P .deps/plugin_time.P \
-.deps/plugin_uname.P .deps/plugin_uptime.P .deps/plugin_wireless.P \
-.deps/plugin_xmms.P .deps/qprintf.P .deps/rgb.P .deps/thread.P \
-.deps/timer.P .deps/udelay.P .deps/widget.P .deps/widget_bar.P \
-.deps/widget_gpo.P .deps/widget_icon.P .deps/widget_image.P \
-.deps/widget_keypad.P .deps/widget_text.P .deps/widget_timer.P
+.deps/plugin_mpd.P .deps/plugin_mysql.P .deps/plugin_netdev.P \
+.deps/plugin_pop3.P .deps/plugin_ppp.P .deps/plugin_proc_stat.P \
+.deps/plugin_python.P .deps/plugin_sample.P .deps/plugin_seti.P \
+.deps/plugin_statfs.P .deps/plugin_string.P .deps/plugin_test.P \
+.deps/plugin_time.P .deps/plugin_uname.P .deps/plugin_uptime.P \
+.deps/plugin_wireless.P .deps/plugin_xmms.P .deps/qprintf.P .deps/rgb.P \
+.deps/thread.P .deps/timer.P .deps/udelay.P .deps/widget.P \
+.deps/widget_bar.P .deps/widget_gpo.P .deps/widget_icon.P \
+.deps/widget_image.P .deps/widget_keypad.P .deps/widget_text.P \
+.deps/widget_timer.P
SOURCES = $(lcd4linux_SOURCES) $(EXTRA_lcd4linux_SOURCES)
OBJECTS = $(lcd4linux_OBJECTS)
diff --git a/config.h.in b/config.h.in
index c2c36c3..3b9aa7f 100644
--- a/config.h.in
+++ b/config.h.in
@@ -49,6 +49,9 @@
/* Define to 1 if you have the `m' library (-lm). */
#undef HAVE_LIBM
+/* Define to 1 if you have the <libmpd/libmpd.h> header file. */
+#undef HAVE_LIBMPD_LIBMPD_H
+
/* Define to 1 if you have the <linux/dvb/frontend.h> header file. */
#undef HAVE_LINUX_DVB_FRONTEND_H
@@ -284,6 +287,9 @@
/* meminfo plugin */
#undef PLUGIN_MEMINFO
+/* mpd plugin */
+#undef PLUGIN_MPD
+
/* mysql plugin */
#undef PLUGIN_MYSQL
diff --git a/configure b/configure
index d4cf0e1..d55747c 100755
--- a/configure
+++ b/configure
@@ -6811,6 +6811,7 @@ echo "$as_me: error: run ./configure --with-plugins=..." >&2;}
PLUGIN_ISDN="yes"
PLUGIN_LOADAVG="yes"
PLUGIN_MEMINFO="yes"
+ PLUGIN_MPD="yes"
PLUGIN_MYSQL="yes"
PLUGIN_NETDEV="yes"
PLUGIN_POP3="yes"
@@ -6858,6 +6859,9 @@ echo "$as_me: error: run ./configure --with-plugins=..." >&2;}
meminfo)
PLUGIN_MEMINFO=$val
;;
+ mpd)
+ PLUGIN_MPD=$val
+ ;;
mysql)
PLUGIN_MYSQL=$val
;;
@@ -7306,6 +7310,245 @@ cat >>confdefs.h <<\_ACEOF
_ACEOF
fi
+if test "$PLUGIN_MPD" = "yes"; then
+
+for ac_header in libmpd/libmpd.h
+do
+as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+else
+ # Is the header compilable?
+echo "$as_me:$LINENO: checking $ac_header usability" >&5
+echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+$ac_includes_default
+#include <$ac_header>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+ (eval $ac_compile) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest.$ac_objext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_header_compiler=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_header_compiler=no
+fi
+rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6
+
+# Is the header present?
+echo "$as_me:$LINENO: checking $ac_header presence" >&5
+echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+#include <$ac_header>
+_ACEOF
+if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } >/dev/null; then
+ if test -s conftest.err; then
+ ac_cpp_err=$ac_c_preproc_warn_flag
+ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+ else
+ ac_cpp_err=
+ fi
+else
+ ac_cpp_err=yes
+fi
+if test -z "$ac_cpp_err"; then
+ ac_header_preproc=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+ yes:no: )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+ ac_header_preproc=yes
+ ;;
+ no:yes:* )
+ { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+ { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+ (
+ cat <<\_ASBOX
+## ---------------------------------------------------- ##
+## Report this to lcd4linux-users@lists.sourceforge.net ##
+## ---------------------------------------------------- ##
+_ASBOX
+ ) |
+ sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+echo "$as_me:$LINENO: checking for $ac_header" >&5
+echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+if eval "test \"\${$as_ac_Header+set}\" = set"; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ eval "$as_ac_Header=\$ac_header_preproc"
+fi
+echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+ cat >>confdefs.h <<_ACEOF
+#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ has_libmpd_header="true"
+else
+ has_libmpd_header="false"
+fi
+
+done
+
+ if test "$has_libmpd_header" = "true"; then
+ echo "$as_me:$LINENO: checking for libmpd_init in -llibmpd" >&5
+echo $ECHO_N "checking for libmpd_init in -llibmpd... $ECHO_C" >&6
+if test "${ac_cv_lib_libmpd_libmpd_init+set}" = set; then
+ echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-llibmpd $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h. */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h. */
+
+/* Override any gcc2 internal prototype to avoid an error. */
+#ifdef __cplusplus
+extern "C"
+#endif
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char libmpd_init ();
+int
+main ()
+{
+libmpd_init ();
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+ (eval $ac_link) 2>conftest.er1
+ ac_status=$?
+ grep -v '^ *+' conftest.er1 >conftest.err
+ rm -f conftest.er1
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+ { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; } &&
+ { ac_try='test -s conftest$ac_exeext'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); }; }; then
+ ac_cv_lib_libmpd_libmpd_init=yes
+else
+ echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ac_cv_lib_libmpd_libmpd_init=no
+fi
+rm -f conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+echo "$as_me:$LINENO: result: $ac_cv_lib_libmpd_libmpd_init" >&5
+echo "${ECHO_T}$ac_cv_lib_libmpd_libmpd_init" >&6
+if test $ac_cv_lib_libmpd_libmpd_init = yes; then
+ has_libmpd_lib="true"
+else
+ has_libmpd_lib="false"
+fi
+
+ if test "$has_libmpd_lib" = "true"; then
+ PLUGINS="$PLUGINS plugin_mpd.o"
+ PLUGINLIBS="$PLUGINLIBS -lmpd"
+
+cat >>confdefs.h <<\_ACEOF
+#define PLUGIN_MPD 1
+_ACEOF
+
+ else
+ { echo "$as_me:$LINENO: WARNING: libmpd lib not found: mpd plugin disabled" >&5
+echo "$as_me: WARNING: libmpd lib not found: mpd plugin disabled" >&2;}
+ fi
+ else
+ { echo "$as_me:$LINENO: WARNING: libmpd/libmpd.h header not found: mpd plugin disabled" >&5
+echo "$as_me: WARNING: libmpd/libmpd.h header not found: mpd plugin disabled" >&2;}
+ fi
+fi
if test "$PLUGIN_MYSQL" = "yes"; then
for ac_header in mysql/mysql.h
diff --git a/plugin.c b/plugin.c
index b68ede1..72d2847 100644
--- a/plugin.c
+++ b/plugin.c
@@ -1,4 +1,4 @@
-/* $Id: plugin.c,v 1.40 2006/02/19 15:42:19 reinelt Exp $
+/* $Id: plugin.c,v 1.41 2006/04/15 05:22:52 reinelt Exp $
*
* plugin handler for the Evaluator
*
@@ -23,6 +23,9 @@
*
*
* $Log: plugin.c,v $
+ * Revision 1.41 2006/04/15 05:22:52 reinelt
+ * mpd plugin from Stefan Kuhne
+ *
* Revision 1.40 2006/02/19 15:42:19 reinelt
* file plugin from Chris Maj
*
@@ -242,6 +245,8 @@ int plugin_init_loadavg(void);
void plugin_exit_loadavg(void);
int plugin_init_meminfo(void);
void plugin_exit_meminfo(void);
+int plugin_init_mpd(void);
+void plugin_exit_mpd(void);
int plugin_init_mysql(void);
void plugin_exit_mysql(void);
int plugin_init_netdev(void);
@@ -311,6 +316,10 @@ int plugin_init(void)
#ifdef PLUGIN_MEMINFO
plugin_init_meminfo();
#endif
+#ifdef PLUGIN_MPD
+ plugin_init_mpd();
+#endif
+
#ifdef PLUGIN_MYSQL
plugin_init_mysql();
#endif
@@ -390,6 +399,9 @@ void plugin_exit(void)
#ifdef PLUGIN_MEMINFO
plugin_exit_meminfo();
#endif
+#ifdef PLUGIN_MPD
+ plugin_exit_mpd();
+#endif
#ifdef PLUGIN_MYSQL
plugin_exit_mysql();
#endif
diff --git a/plugin_mpd.c b/plugin_mpd.c
new file mode 100644
index 0000000..1316687
--- /dev/null
+++ b/plugin_mpd.c
@@ -0,0 +1,239 @@
+/* $Id: plugin_mpd.c,v 1.1 2006/04/15 05:22:52 reinelt Exp $
+ *
+ * mpd informations
+ *
+ * Copyright (C) 2006 Stefan Kuhne <sk-privat@gmx.net>
+ * Copyright (C) 2006 The LCD4Linux Team <lcd4linux-devel@users.sourceforge.net>
+ *
+ * This file is part of LCD4Linux.
+ *
+ * LCD4Linux is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * LCD4Linux 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *
+ * $Log: plugin_mpd.c,v $
+ * Revision 1.1 2006/04/15 05:22:52 reinelt
+ * mpd plugin from Stefan Kuhne
+ *
+ */
+
+/*
+ * exported functions:
+ *
+ * int plugin_init_sample (void)
+ * adds various functions
+ *
+ */
+
+
+#include "config.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
+#include "debug.h"
+#include "plugin.h"
+
+#include <libmpd/libmpd.h>
+
+#ifdef WITH_DMALLOC
+#include <dmalloc.h>
+#endif
+
+/* Struct Pointer */
+
+struct Pointer {
+ mpd_Connection *conn;
+ mpd_Status *status;
+ mpd_InfoEntity *entity;
+};
+
+
+
+static struct Pointer connect()
+{
+ char *host = "localhost";
+ char *port = "6600";
+ int iport;
+ char *test;
+ struct Pointer mpd;
+
+ if ((test = getenv("MPD_HOST"))) {
+ host = test;
+ }
+
+ if ((test = getenv("MPD_PORT"))) {
+ port = test;
+ }
+
+ iport = strtol(port, &test, 10);
+
+ if (iport < 0 || *test != '\0') {
+ fprintf(stderr, "MPD_PORT \"%s\" is not a positive integer\n", port);
+ exit(EXIT_FAILURE);
+ }
+
+ mpd.conn = mpd_newConnection(host, iport, 10);
+
+ mpd_sendCommandListOkBegin(mpd.conn);
+ mpd_sendStatusCommand(mpd.conn);
+ mpd_sendCurrentSongCommand(mpd.conn);
+ mpd_sendCommandListEnd(mpd.conn);
+
+ if ((mpd.status = mpd_getStatus(mpd.conn)) == NULL) {
+ fprintf(stderr, "%s\n", mpd.conn->errorStr);
+ mpd_closeConnection(mpd.conn);
+ }
+
+ if (mpd.status->error) {
+ printf("error: %s\n", mpd.status->error);
+ }
+
+ if (mpd.conn->error) {
+ fprintf(stderr, "%s\n", mpd.conn->errorStr);
+ mpd_closeConnection(mpd.conn);
+ }
+
+ return mpd;
+}
+
+
+static void disconnect(struct Pointer mpd)
+{
+ if (mpd.conn->error) {
+ fprintf(stderr, "%s\n", mpd.conn->errorStr);
+ mpd_closeConnection(mpd.conn);
+ }
+
+ mpd_finishCommand(mpd.conn);
+ if (mpd.conn->error) {
+ fprintf(stderr, "%s\n", mpd.conn->errorStr);
+ mpd_closeConnection(mpd.conn);
+ }
+
+ mpd_freeStatus(mpd.status);
+ mpd_closeConnection(mpd.conn);
+}
+
+
+/* function 'artist' */
+/* takes one argument, a number */
+/* multiplies the number by 3.0 */
+/* same as 'mul2', but shorter */
+
+static void artist(RESULT * result, RESULT * query)
+{
+ char *value = " ";
+ struct Pointer mpd = connect();
+
+ mpd_nextListOkCommand(mpd.conn);
+
+ while ((mpd.entity = mpd_getNextInfoEntity(mpd.conn))) {
+ mpd_Song *song = mpd.entity->info.song;
+
+ if (mpd.entity->type != MPD_INFO_ENTITY_TYPE_SONG) {
+ mpd_freeInfoEntity(mpd.entity);
+ continue;
+ }
+
+ if (song->artist) {
+ value = strdup(song->artist);
+ }
+ mpd_freeInfoEntity(mpd.entity);
+ }
+
+ disconnect(mpd);
+
+ /* store result */
+ SetResult(&result, R_STRING, value);
+
+ free(value);
+}
+
+
+static void title(RESULT * result, RESULT * query)
+{
+ char *value = " ";
+ struct Pointer mpd = connect();
+
+ mpd_nextListOkCommand(mpd.conn);
+
+ while ((mpd.entity = mpd_getNextInfoEntity(mpd.conn))) {
+ mpd_Song *song = mpd.entity->info.song;
+
+ if (mpd.entity->type != MPD_INFO_ENTITY_TYPE_SONG) {
+ mpd_freeInfoEntity(mpd.entity);
+ continue;
+ }
+
+ if (song->title) {
+ value = strdup(song->title);
+ }
+ mpd_freeInfoEntity(mpd.entity);
+ }
+
+ disconnect(mpd);
+
+ /* store result */
+ SetResult(&result, R_STRING, value);
+
+ free(value);
+}
+
+
+static void album(RESULT * result, RESULT * query)
+{
+ char *value = " ";
+ struct Pointer mpd = connect();
+
+ mpd_nextListOkCommand(mpd.conn);
+
+ while ((mpd.entity = mpd_getNextInfoEntity(mpd.conn))) {
+ mpd_Song *song = mpd.entity->info.song;
+
+ if (mpd.entity->type != MPD_INFO_ENTITY_TYPE_SONG) {
+ mpd_freeInfoEntity(mpd.entity);
+ continue;
+ }
+
+ if (song->album) {
+ value = strdup(song->album);
+ }
+ mpd_freeInfoEntity(mpd.entity);
+ }
+
+ disconnect(mpd);
+
+ /* store result */
+ SetResult(&result, R_STRING, value);
+
+ free(value);
+}
+
+
+int plugin_init_mpd(void)
+{
+ AddFunction("mpd::artist", 0, artist);
+ AddFunction("mpd::title", 0, title);
+ AddFunction("mpd::album", 0, album);
+
+ return 0;
+}
+
+
+void plugin_exit_mpd(void)
+{
+ /* empty */
+}
diff --git a/plugins.m4 b/plugins.m4
index 65f641b..808eb36 100644
--- a/plugins.m4
+++ b/plugins.m4
@@ -60,6 +60,7 @@ for plugin in $plugins; do
PLUGIN_ISDN="yes"
PLUGIN_LOADAVG="yes"
PLUGIN_MEMINFO="yes"
+ PLUGIN_MPD="yes"
PLUGIN_MYSQL="yes"
PLUGIN_NETDEV="yes"
PLUGIN_POP3="yes"
@@ -107,6 +108,9 @@ for plugin in $plugins; do
meminfo)
PLUGIN_MEMINFO=$val
;;
+ mpd)
+ PLUGIN_MPD=$val
+ ;;
mysql)
PLUGIN_MYSQL=$val
;;
@@ -206,6 +210,21 @@ if test "$PLUGIN_MEMINFO" = "yes"; then
PLUGINS="$PLUGINS plugin_meminfo.o"
AC_DEFINE(PLUGIN_MEMINFO,1,[meminfo plugin])
fi
+if test "$PLUGIN_MPD" = "yes"; then
+ AC_CHECK_HEADERS(libmpd/libmpd.h, [has_libmpd_header="true"], [has_libmpd_header="false"])
+ if test "$has_libmpd_header" = "true"; then
+ AC_CHECK_LIB(libmpd, libmpd_init, [has_libmpd_lib="true"], [has_libmpd_lib="false"])
+ if test "$has_libmpd_lib" = "true"; then
+ PLUGINS="$PLUGINS plugin_mpd.o"
+ PLUGINLIBS="$PLUGINLIBS -lmpd"
+ AC_DEFINE(PLUGIN_MPD,1,[mpd plugin])
+ else
+ AC_MSG_WARN(libmpd lib not found: mpd plugin disabled)
+ fi
+ else
+ AC_MSG_WARN(libmpd/libmpd.h header not found: mpd plugin disabled)
+ fi
+fi
if test "$PLUGIN_MYSQL" = "yes"; then
AC_CHECK_HEADERS(mysql/mysql.h, [has_mysql_header="true"], [has_mysql_header="false"])
if test "$has_mysql_header" = "true"; then
diff --git a/widget_image.c b/widget_image.c
index 9ce0ebd..63e20ad 100644
--- a/widget_image.c
+++ b/widget_image.c
@@ -1,4 +1,4 @@
-/* $Id: widget_image.c,v 1.6 2006/04/09 14:17:50 reinelt Exp $
+/* $Id: widget_image.c,v 1.7 2006/04/15 05:22:52 reinelt Exp $
*
* image widget handling
*
@@ -21,6 +21,9 @@
*
*
* $Log: widget_image.c,v $
+ * Revision 1.7 2006/04/15 05:22:52 reinelt
+ * mpd plugin from Stefan Kuhne
+ *
* Revision 1.6 2006/04/09 14:17:50 reinelt
* autoconf/library fixes, image and graphic display inversion
*
@@ -157,9 +160,9 @@ static void widget_image_render(const char *Name, WIDGET_IMAGE * Image)
/* our alpha is 0 (transparent) to 255 (opaque) */
Image->bitmap[i].A = (a == 127) ? 0 : 255 - 2 * a;
if (Image->inverted) {
- Image->bitmap[i].R = 255 - Image->bitmap[i].R;
- Image->bitmap[i].G = 255 - Image->bitmap[i].G;
- Image->bitmap[i].B = 255 - Image->bitmap[i].B;
+ Image->bitmap[i].R = 255 - Image->bitmap[i].R;
+ Image->bitmap[i].G = 255 - Image->bitmap[i].G;
+ Image->bitmap[i].B = 255 - Image->bitmap[i].B;
}
}
}
@@ -212,7 +215,6 @@ static void widget_image_update(void *Self)
Image->inverted = Image->inverted > 0;
DelResult(&result);
}
-
#ifdef WITH_GD
/* render image into bitmap */
widget_image_render(W->name, Image);