diff --git a/htmlUI/index.php b/htmlUI/index.php deleted file mode 100644 index 5e1959825..000000000 --- a/htmlUI/index.php +++ /dev/null @@ -1,10 +0,0 @@ - \ No newline at end of file diff --git a/htmlUI/templates/header.tpl b/htmlUI/templates/header.tpl index e7ec30a32..9b94c6da7 100644 --- a/htmlUI/templates/header.tpl +++ b/htmlUI/templates/header.tpl @@ -6,22 +6,22 @@ Campcaster - - - + + + - - + + - - + + {include file="script/basics.js.tpl"} {include file="script/contextmenu.js.tpl"} {include file="script/collector.js.tpl"} {include file="script/alttext.js.tpl"} - + diff --git a/ui_browser.php b/htmlUI/ui_browser.php similarity index 100% rename from ui_browser.php rename to htmlUI/ui_browser.php diff --git a/ui_handler.php b/htmlUI/ui_handler.php similarity index 100% rename from ui_handler.php rename to htmlUI/ui_handler.php diff --git a/src/modules/core/bin/autogen.sh b/src/modules/core/bin/autogen.sh deleted file mode 100755 index 42607afb6..000000000 --- a/src/modules/core/bin/autogen.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.sourcefabric.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Run this to set up the build system: configure, makefiles, etc. -# (based on the version in enlightenment's cvs) -#------------------------------------------------------------------------------- - -package="Core" - -# assume we're in $basedir/bin -reldir=`dirname $0`/.. -basedir=`cd $reldir; pwd;` -test -z "$basedir" && basedir=. -usrdir=`cd $basedir/../../../usr; pwd;` - -bindir=$basedir/bin -etcdir=$basedir/etc -tmpdir=$basedir/tmp - -cd "$tmpdir" -DIE=0 - -(autoheader --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have autoconf installed to compile $package." - echo "Download the appropriate package for your distribution," - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" - DIE=1 -} - -(autoconf --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have autoconf installed to compile $package." - echo "Download the appropriate package for your distribution," - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" - DIE=1 -} - -if test "$DIE" -eq 1; then - exit 1 -fi - -if test -z "$*"; then - echo "I am going to run ./configure with no arguments - if you wish " - echo "to pass any to it, please specify them on the $0 command line." -fi - -echo "Generating configuration files for $package, please wait...." - -configure_ac=${etcdir}/configure.ac -configure=${tmpdir}/configure -aclocal_m4=${tmpdir}/aclocal.m4 - -# copy over configure.ac and acinlclude.m4 from etc to tmp, -# as aclocal >= 1.8 is sooo unbelivably stupid that it will simply try to -# look for configure.ac in the current directory, and include acinclude.m4 -# in aclocal.m4 it without a directory path in front -ACLOCAL_FLAGS="-I ${tmpdir} --acdir=${tmpdir} --output=${aclocal_m4}" -echo " aclocal $ACLOCAL_FLAGS" -cp -f ${configure_ac} ${tmpdir} -cp -f ${etcdir}/acinclude.m4 ${tmpdir} -aclocal $ACLOCAL_FLAGS - -echo " autoheader ${configure_ac}" -autoheader ${configure_ac} - -echo " autoconf -I ${tmpdir} -o ${configure} ${configure_ac}" -autoconf -I ${tmpdir} -o ${configure} ${configure_ac} - diff --git a/src/modules/core/bin/gen_coverage_data.sh b/src/modules/core/bin/gen_coverage_data.sh deleted file mode 100755 index d9b78e642..000000000 --- a/src/modules/core/bin/gen_coverage_data.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.sourcefabric.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- -#------------------------------------------------------------------------------- -# This script generates code coverage data for the module -#------------------------------------------------------------------------------- -module="Campcaster Core" - -reldir=`dirname $0`/.. -basedir=`cd $reldir; pwd;` -bindir=$basedir/bin -docdir=$basedir/doc -tmpdir=$basedir/tmp - -usrdir=`cd $basedir/../../../usr; pwd;` - -coverage_report_dir=$docdir/coverage - -raw_coverage_file=$tmpdir/raw_coverage.info -coverage_file=$tmpdir/coverage.info - -lcov=$usrdir/bin/lcov -genhtml=$usrdir/bin/genhtml - - -cd $basedir - -#------------------------------------------------------------------------------- -# Re-configure with covarege collection enabled, compile and run the tests -#------------------------------------------------------------------------------- -$bindir/autogen.sh --enable-coverage -make clean -make check - -#------------------------------------------------------------------------------- -# Generate some symlinks so that the sources are visible from tmpdir -#------------------------------------------------------------------------------- -ln -s $basedir/include $tmpdir/include -ln -s $basedir/src $tmpdir/src - - -#------------------------------------------------------------------------------- -# Use lcov to generate an HTML report on the coverage data -#------------------------------------------------------------------------------- -$lcov -d $tmpdir -c > $raw_coverage_file -$lcov -e $raw_coverage_file "$tmpdir/*" > $coverage_file -rm -rf $coverage_report_dir -mkdir -p $coverage_report_dir -$genhtml -t "$module" -o $coverage_report_dir $coverage_file - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -rm -f $tmpdir/include -rm -f $tmpdir/src diff --git a/src/modules/core/configure b/src/modules/core/configure deleted file mode 100755 index 0c58cc366..000000000 --- a/src/modules/core/configure +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.campware.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Run this script to configure the environment. -# -# This script in effect calls the real automake / autoconf configure script -#------------------------------------------------------------------------------- - -# assume we're in $basedir -reldir=`dirname $0` -basedir=`cd $reldir; pwd;` -test -z "$basedir" && basedir=. - -bindir=$basedir/bin -tmpdir=$basedir/tmp - - -autogen=$bindir/autogen.sh -configure=$tmpdir/configure - -if [ ! -x $configure ]; then - (cd $basedir && $autogen "$@") -fi - -(cd $tmpdir && $configure "$@") - diff --git a/src/modules/core/doc/.keepme b/src/modules/core/doc/.keepme deleted file mode 100644 index e0808fa16..000000000 --- a/src/modules/core/doc/.keepme +++ /dev/null @@ -1 +0,0 @@ -keep me diff --git a/src/modules/core/doc/doxygen/.keepme b/src/modules/core/doc/doxygen/.keepme deleted file mode 100644 index e0808fa16..000000000 --- a/src/modules/core/doc/doxygen/.keepme +++ /dev/null @@ -1 +0,0 @@ -keep me diff --git a/src/modules/core/etc/Makefile.in b/src/modules/core/etc/Makefile.in deleted file mode 100644 index d564b7282..000000000 --- a/src/modules/core/etc/Makefile.in +++ /dev/null @@ -1,245 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.sourcefabric.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# @configure_input@ -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# General command definitions -#------------------------------------------------------------------------------- -MKDIR = mkdir -p -RM = rm -f -RMDIR = rm -rf -DOXYGEN = doxygen -CP = cp -f - - -#------------------------------------------------------------------------------- -# Basic directory and file definitions -#------------------------------------------------------------------------------- -PACKAGE_NAME = @PACKAGE_NAME@ - -BASE_DIR = @builddir@ -DOC_DIR = ${BASE_DIR}/doc -DOXYGEN_DIR = ${DOC_DIR}/doxygen -COVERAGE_DIR = ${DOC_DIR}/coverage -ETC_DIR = ${BASE_DIR}/etc -INCLUDE_DIR = ${BASE_DIR}/include -LIB_DIR = ${BASE_DIR}/lib -SRC_DIR = ${BASE_DIR}/src -TMP_DIR = ${BASE_DIR}/tmp -VAR_DIR = ${BASE_DIR}/var - -prefix = @prefix@ - -USR_DIR = ${prefix} -USR_INCLUDE_DIR = ${USR_DIR}/include -USR_BIN_DIR = ${USR_DIR}/bin -USR_LIB_DIR = ${USR_DIR}/lib - -GENRB = @GENRB@ -TMP_LOCALIZATION_DIR = ${TMP_DIR}/${PACKAGE_NAME} -GENRBOPTS = --destdir ${TMP_LOCALIZATION_DIR} \ - --encoding utf-8 \ - --strict - -VPATH = ${SRC_DIR} - -BOOST_CFLAGS=@BOOST_CPPFLAGS@ -BOOST_LIBS=@BOOST_LDFLAGS@ -BOOST_DATE_TIME_LIB=@BOOST_DATE_TIME_LIB@ - -LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@ -LIBXMLPP_LIBS=@LIBXMLPP_LIBS@ - -CURL_CFLAGS=@CURL_CFLAGS@ -CURL_LIBS=@CURL_LIBS@ - -ICU_CFLAGS=@ICU_CFLAGS@ -ICU_CXXFLAGS=@ICU_CXXFLAGS@ -ICU_LIBS=@ICU_LIBS@ - -TAGLIB_CFLAGS=@TAGLIB_CFLAGS@ -TAGLIB_LIBS=@TAGLIB_LIBS@ - -TEST_RESULTS = ${DOC_DIR}/testResults.xml -# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR -TEST_XSLT = ../etc/testResultToHtml.xsl - -CORE_LIB = livesupport_core -CORE_LIB_FILE = ${LIB_DIR}/lib${CORE_LIB}.a -TEST_RUNNER = ${TMP_DIR}/testRunner - -DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config - -export LD_LIBRARY_PATH:=${USR_LIB_DIR}:${LD_LIBRARY_PATH} - - -#------------------------------------------------------------------------------- -# Configuration parameters -#------------------------------------------------------------------------------- -CPPFLAGS = @CPPFLAGS@ -CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \ - -pedantic -Wall -Wno-long-long \ - ${BOOST_CFLAGS} \ - ${TAGLIB_CFLAGS} \ - ${LIBXMLPP_CFLAGS} \ - -I${USR_INCLUDE_DIR} \ - -I${INCLUDE_DIR} -I${TMP_DIR} -LDFLAGS = @LDFLAGS@ -pthread \ - ${BOOST_LIBS} \ - ${CURL_LIBS} \ - ${ICU_LIBS} \ - ${TAGLIB_LIBS} \ - ${LIBXMLPP_LIBS} \ - -L${USR_LIB_DIR} \ - -L${LIB_DIR} - - -#------------------------------------------------------------------------------- -# Dependencies -#------------------------------------------------------------------------------- -CORE_LIB_OBJS = ${TMP_DIR}/UniqueId.o \ - ${TMP_DIR}/Uuid.o \ - ${TMP_DIR}/Playable.o \ - ${TMP_DIR}/AudioClip.o \ - ${TMP_DIR}/FadeInfo.o \ - ${TMP_DIR}/ScheduleEntry.o \ - ${TMP_DIR}/PlaylistElement.o \ - ${TMP_DIR}/Playlist.o \ - ${TMP_DIR}/TimeConversion.o \ - ${TMP_DIR}/Thread.o \ - ${TMP_DIR}/LocalizedObject.o \ - ${TMP_DIR}/LocalizedConfigurable.o \ - ${TMP_DIR}/Md5.o \ - ${TMP_DIR}/XmlRpcTools.o \ - ${TMP_DIR}/XmlRpcException.o \ - ${TMP_DIR}/BaseTestMethod.o \ - ${TMP_DIR}/SearchCriteria.o \ - ${TMP_DIR}/MetadataType.o \ - ${TMP_DIR}/MetadataTypeContainer.o \ - ${TMP_DIR}/OptionsContainer.o \ - ${TMP_DIR}/FileTools.o \ - ${TMP_DIR}/AsyncState.o \ - ${TMP_DIR}/MetadataConstraint.o \ - ${TMP_DIR}/NumericConstraint.o \ - ${TMP_DIR}/NumericRangeConstraint.o \ - ${TMP_DIR}/EnumerationConstraint.o \ - ${TMP_DIR}/RdsItem.o \ - ${TMP_DIR}/RdsContainer.o \ - ${TMP_DIR}/NumericTools.o - -TEST_RUNNER_OBJS = ${TMP_DIR}/TestRunner.o \ - ${TMP_DIR}/FileToolsTest.o \ - ${TMP_DIR}/UuidTest.o \ - ${TMP_DIR}/UniqueIdTest.o \ - ${TMP_DIR}/AudioClipTest.o \ - ${TMP_DIR}/ScheduleEntryTest.o \ - ${TMP_DIR}/FadeInfoTest.o \ - ${TMP_DIR}/PlaylistElementTest.o \ - ${TMP_DIR}/PlaylistTest.o \ - ${TMP_DIR}/TimeConversionTest.o \ - ${TMP_DIR}/TestRunnable.o \ - ${TMP_DIR}/ThreadTest.o \ - ${TMP_DIR}/LocalizedObjectTest.o \ - ${TMP_DIR}/LocalizedConfigurableTest.o \ - ${TMP_DIR}/Md5Test.o \ - ${TMP_DIR}/XmlRpcToolsTest.o \ - ${TMP_DIR}/SearchCriteriaTest.o \ - ${TMP_DIR}/MetadataTypeContainerTest.o \ - ${TMP_DIR}/AsyncStateTest.o \ - ${TMP_DIR}/RdsContainerTest.o \ - ${TMP_DIR}/NumericToolsTest.o - -TEST_RUNNER_RES = ${TMP_LOCALIZATION_DIR}/root.res \ - ${TMP_LOCALIZATION_DIR}/en.res \ - ${TMP_LOCALIZATION_DIR}/hu.res \ - ${TMP_LOCALIZATION_DIR}/jp.res - -TEST_RUNNER_LIBS = -l${CORE_LIB} ${ICU_LIBS} ${BOOST_DATE_TIME_LIB} \ - -lcppunit -ldl -lxmlrpc++ -ltar - - -#------------------------------------------------------------------------------- -# Targets -#------------------------------------------------------------------------------- -.PHONY: all dir_setup doc clean docclean depclean distclean check install - -all: dir_setup ${CORE_LIB_FILE} - -dir_setup: ${TMP_DIR} ${TMP_LOCALIZATION_DIR} ${DOXYGEN_DIR} - -doc: - ${DOXYGEN} ${DOXYGEN_CONFIG} - -clean: - ${RM} ${CORE_LIB_OBJS} ${CORE_LIB_FILE} - ${RM} ${TEST_RUNNER_OBJS} ${TEST_RUNNER_RES} ${TEST_RUNNER} - ${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da ${TMP_DIR}/*.info - ${RMDIR} ${TMP_LOCALIZATION_DIR} - -docclean: - ${RMDIR} ${DOXYGEN_DIR}/html - ${RMDIR} ${COVERAGE_DIR}/* - ${RM} ${TEST_RESULTS} - -depclean: clean - -distclean: clean docclean - ${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te* ${TMP_DIR}/ac*.m4 - -check: ${TEST_RUNNER} ${TEST_RUNNER_RES} - ${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT} - -install: all - ${MKDIR} ${USR_INCLUDE_DIR}/LiveSupport/Core - ${CP} ${INCLUDE_DIR}/LiveSupport/Core/*.h \ - ${USR_INCLUDE_DIR}/LiveSupport/Core - ${CP} ${CORE_LIB_FILE} ${USR_LIB_DIR} - - -#------------------------------------------------------------------------------- -# Specific targets -#------------------------------------------------------------------------------- -${CORE_LIB_FILE}: ${CORE_LIB_OBJS} - ${AR} crus $@ $^ - -${TMP_DIR}: - ${MKDIR} ${TMP_DIR} - -${TMP_LOCALIZATION_DIR}: - ${MKDIR} ${TMP_LOCALIZATION_DIR} - -${DOXYGEN_DIR}: - ${MKDIR} ${DOXYGEN_DIR} - -${TEST_RUNNER}: ${TEST_RUNNER_OBJS} ${CORE_LIB_FILE} - ${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS} - - -#------------------------------------------------------------------------------- -# Pattern rules -#------------------------------------------------------------------------------- -${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx - ${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $< - -${TMP_LOCALIZATION_DIR}/%.res : ${VAR_DIR}/%.txt - ${GENRB} ${GENRBOPTS} $^ - diff --git a/src/modules/core/etc/acinclude.m4 b/src/modules/core/etc/acinclude.m4 deleted file mode 100644 index 937632e1f..000000000 --- a/src/modules/core/etc/acinclude.m4 +++ /dev/null @@ -1,576 +0,0 @@ -dnl----------------------------------------------------------------------------- -dnl Copyright (c) 2010 Sourcefabric O.P.S. -dnl -dnl This file is part of the Campcaster project. -dnl http://campcaster.sourcefabric.org/ -dnl -dnl Campcaster is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2 of the License, or -dnl (at your option) any later version. -dnl -dnl Campcaster is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with Campcaster; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -dnl -dnl----------------------------------------------------------------------------- - -dnl----------------------------------------------------------------------------- -dnl Macro to check for available modules using pkg-conf -dnl -dnl usage: -dnl PKG_CHECK_MODULES(GSTUFF,[gtk+-2.0 >= 1.3], action-if, action-not) -dnl -dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page -dnl also defines GSTUFF_PKG_ERRORS on error -dnl -dnl This function was taken from the glade-- project -dnl----------------------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_MODULES], [ - succeeded=no - - if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) - fi - - if test "$PKG_CONFIG" = "no" ; then - echo "*** The pkg-config script could not be found. Make sure it is" - echo "*** in your path, or set the PKG_CONFIG environment variable" - echo "*** to the full path to pkg-config." - echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config." - else - PKG_CONFIG_MIN_VERSION=0.9.0 - if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then - AC_MSG_CHECKING(for $2) - - if $PKG_CONFIG --exists "$2" ; then - AC_MSG_RESULT(yes) - succeeded=yes - - AC_MSG_CHECKING($1_CFLAGS) - $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` - AC_MSG_RESULT($$1_CFLAGS) - - AC_MSG_CHECKING($1_LIBS) - $1_LIBS=`$PKG_CONFIG --libs "$2"` - AC_MSG_RESULT($$1_LIBS) - else - $1_CFLAGS="" - $1_LIBS="" - ## If we have a custom action on failure, don't print errors, but - ## do set a variable so people can do so. - $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` - ifelse([$4], ,echo $$1_PKG_ERRORS,) - fi - - AC_SUBST($1_CFLAGS) - AC_SUBST($1_LIBS) - else - echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." - echo "*** See http://www.freedesktop.org/software/pkgconfig" - fi - fi - - if test $succeeded = yes; then - ifelse([$3], , :, [$3]) - else - ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4]) - fi -]) - - - -dnl----------------------------------------------------------------------------- -dnl Macro to check for taglib of sufficient version by looking at taglib-config -dnl -dnl usage: -dnl AC_CHECK_TAGLIB(version, action-if, action-not) -dnl -dnl defines TAGLIB_LIBS, TAGLIB_CFLAGS, see taglib-config man page -dnl----------------------------------------------------------------------------- -AC_DEFUN([AC_CHECK_TAGLIB], [ - succeeded=no - - if test -z "$TAGLIB_CONFIG"; then - AC_PATH_PROG(TAGLIB_CONFIG, taglib-config, no) - fi - - if test "$TAGLIB_CONFIG" = "no" ; then - echo "*** The taglib-config script could not be found. Make sure it is" - echo "*** in your path, and that taglib is properly installed." - echo "*** Or see http://developer.kde.org/~wheeler/taglib.html" - else - TAGLIB_VERSION=`$TAGLIB_CONFIG --version` - AC_MSG_CHECKING(for taglib >= $1) - VERSION_CHECK=`expr $TAGLIB_VERSION \>\= $1` - if test "$VERSION_CHECK" = "1" ; then - AC_MSG_RESULT(yes) - succeeded=yes - - AC_MSG_CHECKING(TAGLIB_CFLAGS) - TAGLIB_CFLAGS=`$TAGLIB_CONFIG --cflags` - AC_MSG_RESULT($TAGLIB_CFLAGS) - - AC_MSG_CHECKING(TAGLIB_LIBS) - TAGLIB_LIBS=`$TAGLIB_CONFIG --libs` - AC_MSG_RESULT($TAGLIB_LIBS) - else - TAGLIB_CFLAGS="" - TAGLIB_LIBS="" - ## If we have a custom action on failure, don't print errors, but - ## do set a variable so people can do so. - ifelse([$3], ,echo "can't find taglib >= $1",) - fi - - AC_SUBST(TAGLIB_CFLAGS) - AC_SUBST(TAGLIB_LIBS) - fi - - if test $succeeded = yes; then - ifelse([$2], , :, [$2]) - else - ifelse([$3], , AC_MSG_ERROR([Library requirements (taglib) not met.]), [$3]) - fi -]) - - - -dnl----------------------------------------------------------------------------- -dnl Macro to check for ICU of sufficient version by looking at icu-config -dnl -dnl usage: -dnl AC_CHECK_ICU(version, action-if, action-not) -dnl -dnl defines ICU_LIBS, ICU_CFLAGS, ICU_CXXFLAGS, see icu-config man page -dnl----------------------------------------------------------------------------- -AC_DEFUN([AC_CHECK_ICU], [ - succeeded=no - - if test -z "$ICU_CONFIG"; then - AC_PATH_PROG(ICU_CONFIG, icu-config, no) - fi - - if test "$ICU_CONFIG" = "no" ; then - echo "*** The icu-config script could not be found. Make sure it is" - echo "*** in your path, and that taglib is properly installed." - echo "*** Or see http://ibm.com/software/globalization/icu/" - else - ICU_VERSION=`$ICU_CONFIG --version` - AC_MSG_CHECKING(for ICU >= $1) - VERSION_CHECK=`expr $ICU_VERSION \>\= $1` - if test "$VERSION_CHECK" = "1" ; then - AC_MSG_RESULT(yes) - succeeded=yes - - AC_MSG_CHECKING(ICU_CFLAGS) - ICU_CFLAGS=`$ICU_CONFIG --cflags` - AC_MSG_RESULT($ICU_CFLAGS) - - AC_MSG_CHECKING(ICU_CXXFLAGS) - ICU_CXXFLAGS=`$ICU_CONFIG --cxxflags` - AC_MSG_RESULT($ICU_CXXFLAGS) - - AC_MSG_CHECKING(ICU_LIBS) - ICU_LIBS=`$ICU_CONFIG --ldflags` - AC_MSG_RESULT($ICU_LIBS) - else - ICU_CFLAGS="" - ICU_CXXFLAGS="" - ICU_LIBS="" - ## If we have a custom action on failure, don't print errors, but - ## do set a variable so people can do so. - ifelse([$3], ,echo "can't find ICU >= $1",) - fi - - AC_SUBST(ICU_CFLAGS) - AC_SUBST(ICU_CXXFLAGS) - AC_SUBST(ICU_LIBS) - fi - - if test $succeeded = yes; then - ifelse([$2], , :, [$2]) - else - ifelse([$3], , AC_MSG_ERROR([Library requirements (ICU) not met.]), [$3]) - fi -]) - - - -dnl----------------------------------------------------------------------------- -dnl Macro to check for C++ namespaces -dnl for more information on this macro, see -dnl http://autoconf-archive.cryp.to/ac_cxx_namespaces.html -dnl -dnl usage: -dnl If the compiler can prevent names clashes using namespaces, -dnl define HAVE_NAMESPACES. -dnl----------------------------------------------------------------------------- -AC_DEFUN([AC_CXX_NAMESPACES], -[AC_CACHE_CHECK(whether the compiler implements namespaces, -ac_cv_cxx_namespaces, -[AC_LANG_SAVE - AC_LANG_CPLUSPLUS - AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], - [using namespace Outer::Inner; return i;], - ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) - AC_LANG_RESTORE -]) -if test "$ac_cv_cxx_namespaces" = yes; then - AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces]) -fi -]) - - -dnl----------------------------------------------------------------------------- -dnl Test for the Boost C++ libraries of a particular version (or newer). -dnl for more information on boost, see http://www.boost.org/ -dnl for more information on this macro, see -dnl http://autoconf-archive.cryp.to/ax_boost_base.html -dnl -dnl usage: -dnl If no path to the installed boost library is given the macro searches -dnl under ${prefix}, /usr, /usr/local, and /opt, and evaluates the $BOOST_ROOT -dnl environment variable. Further documentation is available at -dnl http://randspringer.de/boost/index.html -dnl -dnl This macro calls: AC_SUBST(BOOST_CPPFLAGS) and AC_SUBST(BOOST_LDFLAGS) -dnl and sets: HAVE_BOOST -dnl -dnl Modified for Campcaster: -dnl * --with-boost default changed to Yes; -dnl * if the library is not found, it does not die, just prints "no", leaves -dnl HAVE_BOOST undefined, and sets the BOOST_CPPFLAGS and BOOST_LDFLAGS -dnl variables to ""; -dnl * ${prefix} is prepended to the search path. -dnl -dnl Author: Thomas Porschberg -dnl -dnl License: -dnl Copyright © 2006 Thomas Porschberg -dnl Copying and distribution of this file, with or without modification, -dnl are permitted in any medium without royalty provided the copyright notice -dnl and this notice are preserved. -dnl----------------------------------------------------------------------------- -AC_DEFUN([AX_BOOST_BASE], -[ -AC_ARG_WITH([boost], - AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is Yes) - it is possible to specify the root directory for boost (optional)]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ac_boost_path="" - else - want_boost="yes" - ac_boost_path="$withval" - fi - ], - [want_boost="yes"]) - -if test "x$want_boost" = "xyes"; then - boost_lib_version_req=ifelse([$1], ,1.20.0,$1) - boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` - boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` - boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$boost_lib_version_req_sub_minor" = "x" ; then - boost_lib_version_req_sub_minor="0" - fi - WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` - AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) - succeeded=no - - dnl first we check the system location for boost libraries - dnl this location ist chosen if boost libraries are installed with the --layout=system option - dnl or if you install boost with RPM - if test "$ac_boost_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_path/lib" - BOOST_CPPFLAGS="-I$ac_boost_path/include" - else - for ac_boost_path_tmp in ${prefix} /usr /usr/local /opt ; do - if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then - BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib" - BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" - break; - fi - done - fi - - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - - - - dnl if we found no boost with system layout we search for boost libraries - dnl built and installed without the --layout=system option or for a staged(not installed) version - if test "x$succeeded" != "xyes"; then - _version=0 - if test "$ac_boost_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_path/lib" - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - fi - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" - done - fi - else - for ac_boost_path in /usr /usr/local /opt ; do - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - best_path=$ac_boost_path - fi - done - fi - done - - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" - BOOST_LDFLAGS="-L$best_path/lib" - - if test "x$BOOST_ROOT" != "x"; then - if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then - version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` - stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` - stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` - V_CHECK=`expr $stage_version_shorten \>\= $_version` - if test "$V_CHECK" = "1" ; then - AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) - BOOST_CPPFLAGS="-I$BOOST_ROOT" - BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib" - fi - fi - fi - fi - - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - fi - - if test "$succeeded" != "yes" ; then - BOOST_CPPFLAGS="" - BOOST_LDFLAGS="" - AC_MSG_RESULT(no) - else - AC_SUBST(BOOST_CPPFLAGS) - AC_SUBST(BOOST_LDFLAGS) - AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" -fi - -]) - - -dnl----------------------------------------------------------------------------- -dnl Test for Date_Time library from the Boost C++ libraries. -dnl for more information on boost, see http://www.boost.org/ -dnl for more information on this macro, see -dnl http://autoconf-archive.cryp.to/ax_boost_date_time.html -dnl -dnl usage: -dnl The macro requires a preceding call to AX_BOOST_BASE. -dnl Further documentation is available at -dnl . -dnl -dnl This macro calls: AC_SUBST(BOOST_DATE_TIME_LIB) -dnl and sets: HAVE_BOOST_DATE_TIME -dnl -dnl Modified for Campcaster: -dnl * --with-boost-date-time default changed to Yes. -dnl * added some more recognized suffixes to the library's name, incl. "-st". -dnl -dnl Authors: -dnl Thomas Porschberg -dnl Michael Tindal -dnl -dnl License: -dnl Copyright © 2006 Thomas Porschberg -dnl Copying and distribution of this file, with or without modification, -dnl are permitted in any medium without royalty provided the copyright notice -dnl and this notice are preserved. -dnl----------------------------------------------------------------------------- -AC_DEFUN([AX_BOOST_DATE_TIME], -[ - AC_ARG_WITH([boost-date-time], - AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@], - [use the Date_Time library from boost - it is possible to specify a certain library for the linker - e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ax_boost_user_date_time_lib="" - else - want_boost="yes" - ax_boost_user_date_time_lib="$withval" - fi - ], - [want_boost="yes"] - ) - - if test "x$want_boost" = "xyes"; then - AC_REQUIRE([AC_PROG_CC]) - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_CACHE_CHECK(whether the Boost::Date_Time library is available, - ax_cv_boost_date_time, - [AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include ]], - [[using namespace boost::gregorian; date d(2002,Jan,10); - return 0; - ]]), - ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no) - AC_LANG_POP([C++]) - ]) - if test "x$ax_cv_boost_date_time" = "xyes"; then - AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available]) - BN=boost_date_time - if test "x$ax_boost_user_date_time_lib" = "x"; then - for ax_lib in $BN $BN-st $BN-mt $BN-mt-s $BN-s \ - $BN-$CC $BN-$CC-st $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \ - lib$BN lib$BN-st lib$BN-mt lib$BN-mt-s lib$BN-s \ - lib$BN-$CC lib$BN-$CC-st lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \ - $BN-mgw $BN-mgw $BN-mgw-st $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do - AC_CHECK_LIB($ax_lib, main, [BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break], - [link_date_time="no"]) - done - else - for ax_lib in $ax_boost_user_date_time_lib $BN-$ax_boost_user_date_time_lib; do - AC_CHECK_LIB($ax_lib, main, - [BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break], - [link_date_time="no"]) - done - - fi - if test "x$link_date_time" = "xno"; then - AC_MSG_ERROR(Could not link against $ax_lib !) - fi - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" - fi -]) - - -dnl----------------------------------------------------------------------------- -dnl Macro to check for curl of sufficient version by looking at curl-config -dnl -dnl usage: -dnl AC_CHECK_CURL(version, action-if, action-not) -dnl -dnl defines CURL_LIBS, CURL_CFLAGS, see curl-config man page -dnl----------------------------------------------------------------------------- -AC_DEFUN([AC_CHECK_CURL], [ - succeeded=no - - if test -z "$CURL_CONFIG"; then - AC_PATH_PROG(CURL_CONFIG, curl-config, no) - fi - - if test "$CURL_CONFIG" = "no" ; then - echo "*** The curl-config script could not be found. Make sure it is" - echo "*** in your path, and that curl is properly installed." - echo "*** Or see http://curl.haxx.se/" - else - dnl curl-config --version returns "libcurl ", thus cut the number - CURL_VERSION=`$CURL_CONFIG --version | cut -d" " -f2` - AC_MSG_CHECKING(for curl >= $1) - VERSION_CHECK=`expr $CURL_VERSION \>\= $1` - if test "$VERSION_CHECK" = "1" ; then - AC_MSG_RESULT(yes) - succeeded=yes - - AC_MSG_CHECKING(CURL_CFLAGS) - CURL_CFLAGS=`$CURL_CONFIG --cflags` - AC_MSG_RESULT($CURL_CFLAGS) - - AC_MSG_CHECKING(CURL_LIBS) - CURL_LIBS=`$CURL_CONFIG --libs` - AC_MSG_RESULT($CURL_LIBS) - else - CURL_CFLAGS="" - CURL_LIBS="" - ## If we have a custom action on failure, don't print errors, but - ## do set a variable so people can do so. - ifelse([$3], ,echo "can't find curl >= $1",) - fi - - AC_SUBST(CURL_CFLAGS) - AC_SUBST(CURL_LIBS) - fi - - if test $succeeded = yes; then - ifelse([$2], , :, [$2]) - else - ifelse([$3], , AC_MSG_ERROR([Library requirements (curl) not met.]), [$3]) - fi -]) - - - diff --git a/src/modules/core/etc/audioClip.xml b/src/modules/core/etc/audioClip.xml deleted file mode 100644 index 7bb083628..000000000 --- a/src/modules/core/etc/audioClip.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - File Title txt - Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ - Keywords: qwe, asd, zcx - Abstract txt - 2004-05-21 - 2004-05-22 - 2004-05-23 - 2004-05-24 - 2004-05-25 - 00:18:30.000000 - online - Spatial Coverage - Temporal Coverage - - diff --git a/src/modules/core/etc/configure.ac b/src/modules/core/etc/configure.ac deleted file mode 100644 index 361b9b5b6..000000000 --- a/src/modules/core/etc/configure.ac +++ /dev/null @@ -1,135 +0,0 @@ -dnl----------------------------------------------------------------------------- -dnl Copyright (c) 2010 Sourcefabric O.P.S. -dnl -dnl This file is part of the Campcaster project. -dnl http://campcaster.sourcefabric.org/ -dnl -dnl Campcaster is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2 of the License, or -dnl (at your option) any later version. -dnl -dnl Campcaster is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with Campcaster; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -dnl -dnl----------------------------------------------------------------------------- - -dnl----------------------------------------------------------------------------- -dnl NOTE: Run all configure related scripts from the tmp directory of the -dnl project. -dnl This is due to the fact that configure spreads a lot of trash around, -dnl like atom4te cache directories, config.* files, etc. into the directory -dnl it is being run from. We clearly don't want these in our base directory. -dnl----------------------------------------------------------------------------- -AC_INIT(Core, 0.0, bugs@campware.org) -AC_PREREQ(2.59) -AC_COPYRIGHT([Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL]) -AC_REVISION($Revision$) - -AC_CONFIG_SRCDIR(../src/UniqueId.cxx) - -AC_CONFIG_HEADERS(configure.h) -AC_PROG_CXX() - -AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t], - HAVE_INTEGRAL_TYPES="yes", HAVE_INTEGRAL_TYPES="no") -if test "x${HAVE_INTEGRAL_TYPES}" = "xno" ; then - AC_MSG_ERROR([a required integral type is not available]) -fi - -AC_CHECK_HEADERS(getopt.h sys/time.h time.h sys/types.h pwd.h errno.h stdint.h) - - -dnl----------------------------------------------------------------------------- -dnl specify whether debug info should be compiled into the executable -dnl----------------------------------------------------------------------------- -AC_SUBST(CXXFLAGS) - -AC_ARG_ENABLE([debug], - AC_HELP_STRING([--enable-debug], [compile with debug info (no)]), - [], - [enable_debug=no]) - -if test "x${enable_debug}" = "xyes"; then - CXXFLAGS="-g -O0" - AC_DEFINE(YDEBUG, 1, [Debug is on]) -else - CXXFLAGS="-O3" -fi - -AC_MSG_RESULT([using compiler options: ${CXXFLAGS}]) - - -dnl----------------------------------------------------------------------------- -dnl specify the pkg-config path -dnl----------------------------------------------------------------------------- -AC_ARG_WITH([pkg-config-path], - AC_HELP_STRING([--with-pkg-config-path], - [use the pkg-config path (prefix/lib/pkgconfig)]), - [PKG_CONFIG_PATH=${withval}], - [PKG_CONFIG_PATH=${prefix}/lib/pkgconfig:$PKG_CONFIG_PATH]) - -AC_MSG_RESULT([using pkg-config path: ${PKG_CONFIG_PATH}]) - -export PKG_CONFIG_PATH - -export PATH=${prefix}/bin:${PATH} - - -AX_BOOST_BASE([1.33.1]) -if test "x${BOOST_CPPFLAGS}" != "x"; then - AX_BOOST_DATE_TIME - if test "x${BOOST_DATE_TIME_LIB}" = "x"; then - AC_MSG_ERROR([Boost date-time library not found]) - fi -else - AC_MSG_ERROR([Boost library >= 1.33.1 not found]) -fi - -PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.8.1]) -AC_SUBST(LIBXMLPP_CFLAGS) -AC_SUBST(LIBXMLPP_LIBS) - -AC_CHECK_CURL(7.12.3) -AC_SUBST(CURL_CFLAGS) -AC_SUBST(CURL_LIBS) - -AC_CHECK_TAGLIB(1.3.1) -AC_SUBST(TAGLIB_CFLAGS) -AC_SUBST(TAGLIB_LIBS) - -AC_CHECK_ICU(3.0) -AC_SUBST(ICU_CFLAGS) -AC_SUBST(ICU_CXXFLAGS) -AC_SUBST(ICU_LIBS) - -AC_PATH_PROG(GENRB, genrb) -AC_SUBST(GENRB) - - -dnl----------------------------------------------------------------------------- -dnl enable compilaton for code coverage data -dnl----------------------------------------------------------------------------- -AC_SUBST(COVERAGE_CXXFLAGS) - -AC_ARG_ENABLE( coverage, -[ --enable-coverage enable code coverage data generaton (no) ], - ENABLE_COVERAGE=${enableval}, ENABLE_COVERAGE="no" ) - -if test "x${ENABLE_COVERAGE}" == "xyes" ; then - COVERAGE_CXXFLAGS="-fprofile-arcs -ftest-coverage" - AC_MSG_RESULT([compiling in code coverage mode]) -else - AC_MSG_RESULT([not compiling in code coverage mode]) -fi - - -AC_CONFIG_FILES(../Makefile:../etc/Makefile.in) - -AC_OUTPUT() diff --git a/src/modules/core/etc/doxygen.config b/src/modules/core/etc/doxygen.config deleted file mode 100644 index f03486e9f..000000000 --- a/src/modules/core/etc/doxygen.config +++ /dev/null @@ -1,1139 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.sourcefabric.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- - -# Doxyfile 1.3.6 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = Campcaster - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = 0.0 - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = doc/doxygen - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en -# (Japanese with English messages), Korean, Korean-en, Norwegian, Polish, Portuguese, -# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is used -# as the annotated text. Otherwise, the brief description is used as-is. If left -# blank, the following values are used ("$name" is automatically replaced with the -# name of the entity): "The $name class" "The $name widget" "The $name file" -# "is" "provides" "specifies" "contains" "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = YES - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = include src - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = include - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superseded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes that -# lay further from the root node will be omitted. Note that setting this option to -# 1 or 2 may greatly reduce the computation time needed for large code bases. Also -# note that a graph may be further truncated if the graph's image dimensions are -# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). -# If 0 is used for the depth value (the default), the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/src/modules/core/etc/fadeInfo.xml b/src/modules/core/etc/fadeInfo.xml deleted file mode 100644 index a10bad613..000000000 --- a/src/modules/core/etc/fadeInfo.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - -]> - diff --git a/src/modules/core/etc/metadataType.xml b/src/modules/core/etc/metadataType.xml deleted file mode 100644 index 2a3ded6fb..000000000 --- a/src/modules/core/etc/metadataType.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - -]> - - - diff --git a/src/modules/core/etc/metadataTypeContainer.xml b/src/modules/core/etc/metadataTypeContainer.xml deleted file mode 100644 index e0f16dfb5..000000000 --- a/src/modules/core/etc/metadataTypeContainer.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - -]> - - - - - - - - 0 - 3000 - - - - - - - mp3 - mpeg - ogg - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/modules/core/etc/playlist.xml b/src/modules/core/etc/playlist.xml deleted file mode 100644 index c7c31c445..000000000 --- a/src/modules/core/etc/playlist.xml +++ /dev/null @@ -1,58 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -]> - - - - - - - - - - - - - - - - - diff --git a/src/modules/core/etc/playlistElement.xml b/src/modules/core/etc/playlistElement.xml deleted file mode 100644 index 543b3ec17..000000000 --- a/src/modules/core/etc/playlistElement.xml +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - - - - - - - - - - - - - - -]> - - - - - - - - - diff --git a/src/modules/core/etc/rdsContainer.xml b/src/modules/core/etc/rdsContainer.xml deleted file mode 100644 index 5a9023024..000000000 --- a/src/modules/core/etc/rdsContainer.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - -]> - - - - - - diff --git a/src/modules/core/etc/resourceBundle.xml b/src/modules/core/etc/resourceBundle.xml deleted file mode 100644 index 2af0d220f..000000000 --- a/src/modules/core/etc/resourceBundle.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - -]> - diff --git a/src/modules/core/etc/testResultToHtml.xsl b/src/modules/core/etc/testResultToHtml.xsl deleted file mode 100644 index f9e893521..000000000 --- a/src/modules/core/etc/testResultToHtml.xsl +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - Campcaster unit test results - - -

Preface

-This document is part of the -Campcaster -project, Copyright © 2004 Media -Development Loan Fund, under the GNU -GPL. -
-This is an automatically generated document. -

Scope

-This document contains the generated unit test results for the -Campcaster project. -

Summary

- - - - - - - - - - - - - - - - - - -
Total number of tests:
Tests passed:
Tests failed:
Test errors:
-
-

Tests

- - - - - - - - - - - - - -
test nametest status
failedpassed
- - -
- -
- diff --git a/src/modules/core/include/LiveSupport/Core/AsyncState.h b/src/modules/core/include/LiveSupport/Core/AsyncState.h deleted file mode 100644 index e087adc27..000000000 --- a/src/modules/core/include/LiveSupport/Core/AsyncState.h +++ /dev/null @@ -1,212 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_AsyncState_h -#define LiveSupport_Core_AsyncState_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#include -#include -#include "LiveSupport/Core/Ptr.h" - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class representing the state of an asynchronous process. - * - * It provides some constants, plus conversion methods to and from - * strings (used when sending through XML-RPC methods). - * - * There are two sets of conversion methods, because the states have - * different names in the storage server for backup-related stuff and - * general transport stuff. - */ -class AsyncState -{ - private: - - /** - * The possible states of an asynchronous process. - */ - typedef enum { innerInitState, - innerPendingState, - innerFinishedState, - innerClosedState, - innerFailedState, - innerInvalidState } InnerState; - /** - * The value of this state. - */ - InnerState value; - - /** - * A private constructor. - */ - AsyncState(InnerState state) throw () - : value(state) - { - } - - - public: - - /** - * Default constructor; sets the state to "invalid". - */ - AsyncState(void) throw () - : value(innerInvalidState) - { - } - - /** - * Constant instance: init. - */ - static const AsyncState initState; - - /** - * Constant instance: pending. - */ - static const AsyncState pendingState; - - /** - * Constant instance: finished. - */ - static const AsyncState finishedState; - - /** - * Constant instance: closed. - */ - static const AsyncState closedState; - - /** - * Constant instance: failed. - */ - static const AsyncState failedState; - - /** - * Constant instance: invalid. - */ - static const AsyncState invalidState; - - /** - * Construct from a transport string. - * - * @param transportString a string used by the getTransportInfo - * method of the storage server. - * @return an AsyncState with the corresponding value. - */ - static AsyncState - fromTransportString(const std::string & transportString) - throw (); - - /** - * Construct from a backup string. - * - * @param backupString a string used by the xxxxBackupCheck - * method of the storage server. - * @return an AsyncState with the corresponding value. - */ - static AsyncState - fromBackupString(const std::string & backupString) - throw (); - - /** - * Convert to a transport string. - * - * @return a string used by the getTransportInfo method of the - * storage server. - */ - Ptr::Ref - toTransportString(void) const throw (); - - /** - * Convert to a backup string. - * - * @return a string used by the xxxxBackupCheck method of the - * storage server. - */ - Ptr::Ref - toBackupString(void) const throw (); - - /** - * Check for equality. - * - * @param other the other AsyncState to compare with. - * @return true if the two states are equal. - */ - bool - operator==(const AsyncState & other) const throw () - { - return (value == other.value); - } - - /** - * Check for inequality. - * - * @param other the other AsyncState to compare with. - * @return true if the two states are not equal. - */ - bool - operator!=(const AsyncState & other) const throw () - { - return (value != other.value); - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -/** - * Print to an ostream. - * - * @param ostream the ostream to print to. - * @param state the AsyncState to print. - * @return a reference to the same ostream object. - */ -std::ostream& -operator<<(std::ostream& ostream, const LiveSupport::Core::AsyncState state) - throw (); - -#endif // LiveSupport_Core_AsyncState_h - diff --git a/src/modules/core/include/LiveSupport/Core/AudioClip.h b/src/modules/core/include/LiveSupport/Core/AudioClip.h deleted file mode 100644 index 23b6b24bd..000000000 --- a/src/modules/core/include/LiveSupport/Core/AudioClip.h +++ /dev/null @@ -1,611 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_AudioClip_h -#define LiveSupport_Core_AudioClip_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/UniqueId.h" -#include "LiveSupport/Core/Configurable.h" -#include "LiveSupport/Core/Playable.h" -#include "LiveSupport/Core/MetadataTypeContainer.h" - - -namespace LiveSupport { -namespace Core { - -using namespace std; -using namespace boost::posix_time; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class representing an audio clip. - * AudioClips contain the basic information about the audio clip. - * An AudioClip is contained in a PlaylistElement, which provides the - * relative offset and fade in/fade out information. A PlaylistElement, - * in turn, is contained in a Playlist. - * - * This object has to be configured with an XML configuration element - * called audioClip. This may look like the following: - * - *

- *  <audioClip id="1" 
- *             title="Name of the Song"
- *             playlength="00:18:30.000000"
- *             uri="file:var/test1.mp3" >
- *         <metadata
- *                   xmlns="http://mdlf.org/livesupport/elements/1.0/"
- *                   xmlns:ls="http://mdlf.org/livesupport/elements/1.0/"
- *                   xmlns:dc="http://purl.org/dc/elements/1.1/"
- *                   xmlns:dcterms="http://purl.org/dc/terms/"
- *                   xmlns:xml="http://www.w3.org/XML/1998/namespace" >
- *             <dc:title  >File Title txt</dc:title>
- *             <dcterms:extent  >00:02:30.000000</dcterms:extent>
- *             ...
- *         </metadata>
- *  </audioClip>
- *  
- * - * The metadata element is optional. The configure() method - * sets only those fields which had not been set previously: e.g., if we set - * some or all fields of the AudioClip in the constructor, then these fields - * in the XML element will be ignored by configure(). - * The title attribute and the <dc:title> - * element set the same field; if both are present, the title is set from - * the attribute and the element is ignored.. - * The same is true for the playlength attribute and the - * <dcterms:extent> element. - * It is required that by the end of the configure() method, the playlength - * is set somehow (from a constructor, the attribute or the element). - * If the title is not set by the end of the configure() method, it is then - * set to the empty string. - * Embedded XML elements are currently ignored: e.g., - *
  <group>
- *      <member1>value1</member1>
- *      <member2>value2</member2>
- *  </group>
- * produces a single metadata field group with an empty value, - * and ignores member1 and member2. - * TODO: fix this? - * - * The URI is not normally part of the XML element; it's only included - * as an optional attribute for testing purposes. - * - * The DTD for the above element is: - * - *

- *  <!ELEMENT audioClip (metadata?) >
- *  <!ATTLIST audioClip  id           NMTOKEN     #IMPLIED  >
- *  <!ATTLIST audioClip  title        CDATA       #IMPLIED  >
- *  <!ATTLIST audioClip  playlength   NMTOKEN     #IMPLIED  >
- *  <!ATTLIST audioClip  uri          CDATA       #IMPLIED   >
- *  
- */ -class AudioClip : public Configurable, - public Playable -{ - private: - /** - * The name of the configuration XML elmenent used by AudioClip. - */ - static const std::string configElementNameStr; - - /** - * The unique id of the audio clip. - */ - Ptr::Ref id; - - /** - * The title of the audio clip. - */ - Ptr::Ref title; - - /** - * The playling length of the audio clip. - */ - Ptr::Ref playlength; - - /** - * The location of the binary audio clip sound file. - */ - Ptr::Ref uri; - - /** - * The identifying token returned by the storage server. - */ - Ptr::Ref token; - - /** - * This audio clip in XML format. - */ - Ptr::Ref xmlAudioClip; - - /** - * Set the value of a metadata field in this audio clip. - * - * @param value the new value of the metadata field. - * @param name the name of the metadata field (without prefix) - * @param prefix the prefix of the metadata field - * @exception std::invalid_argument if the key is dcterms:extent, - * but the value is not a valid ISO-8601 time - */ - virtual void - setMetadata(Ptr::Ref value, - const std::string &name, const std::string &prefix) - throw (std::invalid_argument); - - /** - * Convert a time_duration to string, in format HH:MM:SS.ssssss. - */ - std::string - toFixedString(Ptr::Ref time) const throw () - { - if (time->fractional_seconds()) { - return to_simple_string(*time); - } else { - return to_simple_string(*time) + ".000000"; - } - } - - /** - * Set the playlength member of this audio clip. - * - * @param timeString the new playlength - * @exception std::invalid_argument if the argument is not - * a valid ISO-8601 time - */ - void - setPlaylength(Ptr::Ref timeString) - throw (std::invalid_argument); - - - public: - /** - * Copy constructor. - * - * Copies the pointers for all fields except xmlAudioClip. - * These fields are immutable; if you want to modify them, call the - * appropriate setter function with (a pointer to) an object - * with the new value. - * - * @param otherAudioClip the audio clip to be copied - */ - AudioClip(const AudioClip & otherAudioClip) throw (); - - /** - * Default constructor. - * - * This constructor creates an AudioClip with a null pointer - * for all (ID, playlength, title, uri) fields! It is meant for - * internal use only. If you want to upload a new audio clip to - * the storage, use the constructor with (title, playlength, uri) - * arguments. - */ - AudioClip(void) throw () - : Playable(AudioClipType) - { - } - - /** - * Create an audio clip by specifying its unique ID. - * The other fields will be filled in by configure(). - * - * This constructor creates an AudioClip with a null pointer - * for all fields except the ID! It is meant for internal use only. - * If you want to upload a new audio clip to the storage, - * use the constructor with (title, playlength, uri) arguments. - * - * @param id the id of the audio clip. - */ - AudioClip(Ptr::Ref id) throw () - : Playable(AudioClipType) - { - this->id = id; - } - - /** - * Create an audio clip by specifying all details, except - * for the title. The title is set to the empty string. - * - * This is used for testing purposes. - * If you want to upload a new audio clip to the storage, - * use the constructor with (title, playlength, uri) arguments. - * - * @param id the id of the audio clip. - * @param playlength the playing length of the audio clip. - * @param uri the location of the sound file corresponding to - * this audio clip object (optional) - */ - AudioClip(Ptr::Ref id, - Ptr::Ref playlength, - Ptr::Ref uri = Ptr::Ref()) - throw (); - - /** - * Create an audio clip by specifying all details. - * - * This is used for testing purposes. - * If you want to upload a new audio clip to the storage, - * use the constructor with (title, playlength, uri) arguments. - * - * @param id the id of the audio clip. - * @param title the title of the audio clip. - * @param playlength the playing length of the audio clip. - * @param uri the location of the sound file corresponding to - * this audio clip object (optional) - */ - AudioClip(Ptr::Ref id, - Ptr::Ref title, - Ptr::Ref playlength, - Ptr::Ref uri = Ptr::Ref()) - throw (); - - /** - * Create an audio clip by specifying all details which need - * to be set by the user. - * The ID is left blank (i.e., a null pointer), - * and can be set later using setId(). - * - * This constructor is used when a new audio clip is uploaded to - * the storage. For example: - *

-         *  Ptr::Ref
-         *          storageClientFactory = StorageClientFactory::getInstance();
-         *  Ptr::Ref
-         *          storageClient = storageClientFactory->getStorageClient();
-         *  Ptr::Ref
-         *          audioClip(new AudioClip(title, playlength, uri));
-         *  storageClient->storeAudioClip(sessionId, audioClip);
-         *  std::cerr << audioClip->getId()->getId();   // has been set by the
-         *                                              //   storage client
-         *  
- * - * @see StorageClient::StorageClientFactory - * @see StorageClient::StorageClientInterface - * - * @param playlength the playing length of the audio clip. - * @param title the title of the audio clip. - * @param uri the location of the sound file corresponding to - * this audio clip object. - */ - AudioClip(Ptr::Ref title, - Ptr::Ref playlength, - Ptr::Ref uri) - throw (); - - - /** - * Convert the audio clip to an XmlRpcValue (marshalling). - * - * @return an XmlRpcValue struct, containing a - * field named audioClip, with value of type string, - * which contains an XML document representing the audio clip. - */ - operator XmlRpc::XmlRpcValue() const - throw (); - - /** - * Construct an audio clip from an XmlRpcValue (demarshalling). - * - * @param xmlRpcValue an XmlRpcValue struct, containing a - * field named audioClip, with value of type string, - * which contains an XML document, the root node of which - * can be passed to the configure() method. - * @exception std::invalid_argument if the argument is invalid - */ - AudioClip(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~AudioClip(void) throw () - { - } - - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementNameStr; - } - - /** - * Configure the object based on the XML element supplied. - * The supplied element is expected to be of the name - * returned by configElementName(). - * - * @param element the XML element to configure the object from. - * @exception std::invalid_argument if the supplied XML element - * contains bad configuraiton information - */ - virtual void - configure(const xmlpp::Element & element) - throw (std::invalid_argument); - - /** - * Return the id of the audio clip. - * - * @return the unique id of the audio clip. - */ - virtual Ptr::Ref - getId(void) const throw () - { - return id; - } - - /** - * Set the ID of the object. This is only allowed if the ID was - * a null pointer; once the ID is set, it can not be changed. - * - * @param id the new unique id of the audio clip. - */ - void - setId(Ptr::Ref id) throw (std::invalid_argument) - { - if (!this->id) { - this->id = id; - } - else { - throw std::invalid_argument("can not set the ID twice"); - } - } - - /** - * Return the total playing length for this audio clip. - * - * @return the playing length in microseconds. - */ - virtual Ptr::Ref - getPlaylength(void) const throw () - { - return playlength; - } - - /** - * Return the URI of the binary sound file of this audio clip, - * which can be played by the audio player. - * - * @return the URI. - */ - virtual Ptr::Ref - getUri(void) const throw () - { - return uri; - } - - /** - * Set the URI of the binary sound file of this audio clip, - * which can be played by the audio player. - * - * @param uri the new URI. - */ - virtual void - setUri(Ptr::Ref uri) throw () - { - this->uri = uri; - } - - /** - * Return the token which is used to identify this audio clip - * to the storage server. - * - * @return the token. - */ - virtual Ptr::Ref - getToken(void) const throw () - { - return token; - } - - /** - * Set the token which is used to identify this audio clip - * to the storage server. - * - * @param token a new token. - */ - virtual void - setToken(Ptr::Ref token) - throw () - { - this->token = token; - } - - - /** - * Return the title of this audio clip. - * - * @return the title. - */ - virtual Ptr::Ref - getTitle(void) const throw () - { - return title; - } - - /** - * Set the title of this audio clip. - * - * @param title a new title. - */ - virtual void - setTitle(Ptr::Ref title) - throw (); - - /** - * Return the value of a metadata field in this audio clip. - * If the audio clip does not have this metadata field, returns a null - * pointer. - * - * @param key the name of the metadata field - * @return the value of the metadata field; 0 if there is - * no such field; - */ - virtual Ptr::Ref - getMetadata(const std::string &key) const - throw (); - - /** - * Set the value of a metadata field in this audio clip. - * - * @param value the new value of the metadata field. - * @param key the name of the metadata field - * @exception std::invalid_argument if the key is dcterms:extent, - * but the value is not a valid ISO-8601 time - */ - virtual void - setMetadata(Ptr::Ref value, - const std::string &key) - throw (std::invalid_argument); - - - /** - * Return a partial XML representation of this audio clip or playlist. - * - * This is a string containing a single or - * XML element, with minimal information (ID, title, playlength) - * only, without an XML header or any other metadata. - * - * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers, - * time durations have the format "hh:mm:ss.ssssss". - * - * @return a string representation of the audio clip as an XML element - */ - virtual Ptr::Ref - getXmlElementString(void) const throw (); - - - /** - * Return a complete XML representation of this audio clip. - * - * This is a string containing a an XML document with an - * root node, together with an XML header. - * - * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers, - * time durations have the format "hh:mm:ss.ssssss". - * - * The audio clip or playlist can be completely reconstructed from - * the string returned by this method: - *

-         *  Ptr::Ref         audioClip1 = ... something ...;
-         *  Ptr::Ref  parser;
-         *  parser->parse_memory(*audioClip1->getXmlDocumentString());
-         *  const xmlpp::Document*      document = parser->get_document();
-         *  const xmlpp::Element*       root     = document->get_root_node();
-         *  Ptr::Ref         audioClip2(new AudioClip());
-         *  audioClip2->configure(*root);
-         *  
- * results in two identical audio clips (and the same works for - * playlists, too). - * - * The XML document has the (pseudo-) DTD - *

-         *  <!ELEMENT audioClip (metadata) >
-         *  <!ATTLIST audioClip  id           NMTOKEN     #REQUIRED  >
-         *
-         *  <!ELEMENT metadata (dcterms:extent, dc:title, (ANY)*) >
-         *  <!ELEMENT dcterms:extent (NMTOKEN) >
-         *  <!ELEMENT dc:title       (CDATA) >
-         *  
- * - * If the audio clip has no metadata at all (this is possible if - * it was created by the default constructor or the constructor - * which takes a unique ID only), a null pointer is returned. - * - * @return a string representation of the audio clip as an XML document - */ - virtual Ptr::Ref - getXmlDocumentString(void) const throw (); - - - /** - * Read the metadata contained in the id3v2 tags of the mp3 sound - * file. If no id3v2 tags are found, the file is searched for other - * (id3v1, APE, XiphComment) tags. - * - * The tags are processed and translated into Dublin Core - * metadata fields using the MetadataTypeContainer object. - * - * @param metadataTypes contains a list of all supported - * metadata types. - * @exception std::invalid_argument if the AudioClip instance does not - * have a uri field, or the file name contained in the uri - * field is invalid. - */ - void - readTag(Ptr::Ref metadataTypes) - throw (std::invalid_argument); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - - /** - * Auxilliary method used by setMetadata() and getMetadata(). - */ - void - separateNameAndNameSpace(const std::string & key, - std::string & name, - std::string & nameSpace) - throw (); - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_AudioClip_h - diff --git a/src/modules/core/include/LiveSupport/Core/BaseTestMethod.h b/src/modules/core/include/LiveSupport/Core/BaseTestMethod.h deleted file mode 100644 index 62efd482e..000000000 --- a/src/modules/core/include/LiveSupport/Core/BaseTestMethod.h +++ /dev/null @@ -1,116 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_BaseTestMethod_h -#define LiveSupport_Core_BaseTestMethod_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A base class for the test methods. - * Subclass this class for the methods that use configuration files. - * This class gives helpers to access the configuration files - * from various locations (~/.campcaster, ./etc) - */ -class BaseTestMethod : public CPPUNIT_NS::TestFixture -{ - private: - /** - * Get the current working directory. - * - * @return the current working directory. - */ - static std::string - getCwd(void) throw (); - - public: - /** - * Return the full path for a configuration file. - * - * @param configFileName the name of the configuration file. - * @return the full path of the configuration file, found in the - * appropriate directory. - * @exception std::invalid_argument if the specified config file - * does not exist. - */ - static std::string - getConfigFile(const std::string configFileName) - throw (std::invalid_argument); - - /** - * Helper function to return an XML Document object based on - * a config file name. - * First, the proper location of the config file is found. - * - * @param parser the XML DOM parser to use for parsing. - * @param configFileName the name of the configuration file. - * @return an XML document, containing the contents of the - * config file - * @exception std::invalid_argument if the configuration file - * could not be found - * @exception std::exception on parsing errors. - */ - static const xmlpp::Document * - getConfigDocument(xmlpp::DomParser & parser, - const std::string configFileName) - throw (std::invalid_argument, - std::exception); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_BaseTestMethod_h - diff --git a/src/modules/core/include/LiveSupport/Core/Configurable.h b/src/modules/core/include/LiveSupport/Core/Configurable.h deleted file mode 100644 index c3eb51007..000000000 --- a/src/modules/core/include/LiveSupport/Core/Configurable.h +++ /dev/null @@ -1,98 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Configurable_h -#define LiveSupport_Core_Configurable_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * An interface marking a class configurable by an XML element. - */ -class Configurable -{ - public: - /** - * Configure the object based on the XML element supplied. - * The supplied element is expected to be of the name - * returned by configElementName(). - * - * @param element the XML element to configure the object from. - * @exception std::invalid_argument if the supplied XML element - * contains bad configuraiton information - * @exception std::logic_error if the object has already - * been configured, and can not be reconfigured. - */ - virtual void - configure(const xmlpp::Element & element) - throw (std::invalid_argument, - std::logic_error) - = 0; - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~Configurable(void) throw () - { - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_Configurable_h - diff --git a/src/modules/core/include/LiveSupport/Core/Debug.h b/src/modules/core/include/LiveSupport/Core/Debug.h deleted file mode 100644 index fa1ea82c9..000000000 --- a/src/modules/core/include/LiveSupport/Core/Debug.h +++ /dev/null @@ -1,269 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2003-2005 Max Howell - (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -#ifndef CAMPCASTER_DEBUG_H -#define CAMPCASTER_DEBUG_H - -#include "configure.h" - -#include -#include -#include -#include - -#ifndef DEBUG_PREFIX - #define CMP_PREFIX "" -#else - #define CMP_PREFIX "[" DEBUG_PREFIX "] " -#endif - -/** - * @namespace LiveSupport::Core::Debug - * @short A debug output API with indentation and block timing. - * @author Max Howell - * @author Ian Monroe - */ -namespace LiveSupport { - namespace Core { - namespace Debug { - static int indentAmount = 0; - } - } -} -using namespace LiveSupport; -using namespace LiveSupport::Core; - -#ifndef YDEBUG - class NoDebugStream; - - typedef NoDebugStream & (*NDBGFUNC)(NoDebugStream &); - - class NoDebugStream { - public: - /// Default constructor. - NoDebugStream() {} - ~NoDebugStream() {} - NoDebugStream& operator<<(NDBGFUNC) { return *this; } - - /** - * Does nothing. - * @return this stream - */ - NoDebugStream &operator<<(short int ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream &operator<<(unsigned short int ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream &operator<<(char ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream &operator<<(unsigned char ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream &operator<<(int ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream &operator<<(unsigned int ) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream &operator<<(const char *) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(const void *) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(void *) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(double) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(long) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(unsigned long) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(std::string) { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(boost::posix_time::ptime) - { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(boost::posix_time::time_duration) - { return *this; } - /** - * Does nothing. - * @return this stream - */ - NoDebugStream& operator<<(XmlRpc::XmlRpcValue) - { return *this; } - }; - static inline NoDebugStream debug() { return NoDebugStream(); } - static inline NoDebugStream warning() { return NoDebugStream(); } - static inline NoDebugStream error() { return NoDebugStream(); } - inline NoDebugStream &endl( NoDebugStream & s) { return s; } -#else - static inline std::ostream& debug() { return std::cout << std::string(Debug::indentAmount, ' ') << CMP_PREFIX; } - static inline std::ostream& warning() { return std::cout << std::string(Debug::indentAmount, ' ') << CMP_PREFIX << "[WARNING!] "; } - static inline std::ostream& error() { return std::cout << std::string(Debug::indentAmount, ' ') << CMP_PREFIX << "[ERROR!] "; } -#endif - -using std::endl; - -namespace LiveSupport { namespace Core { -namespace Debug -{ - /** - * @class Debug::Block - * @short Use this to label sections of your code - * - * Usage: - * #define DEBUG_PREFIX "Prefix" - * #include "LiveSupport/Core/Debug.h" - * - * void function() - * { - * ... - * { - * Debug::Block myBlock( "section" ); - * - * debug() << "output1" << endl; - * debug() << "output2" << endl; - * } - * ... - * } - * - * Will output: - * - * BEGIN: section - * [prefix] output1 - * [prefix] output2 - * END: section - Took 0.1s - * - * Its not thread-safe with the indentation count. But a race condition - * involving indentation width isn't a big deal. - */ - - class Block - { - public: - Block( std::string label ) - : m_label( label ) - { - gettimeofday( &m_start, 0 ); - debug() << "BEGIN: " << m_label << endl; - indentAmount += 2; //critical section - } - ~Block() - { - timeval end; - gettimeofday( &end, 0 ); - - end.tv_sec -= m_start.tv_sec; - if( end.tv_usec < m_start.tv_usec) { - // Manually carry a one from the seconds field. - end.tv_usec += 1000000; - end.tv_sec--; - } - end.tv_usec -= m_start.tv_usec; - - double duration = double(end.tv_sec) + (double(end.tv_usec) / 1000000.0); - - indentAmount -= 2; //critical section - debug() << "END__: " << m_label << " - Took " << duration << "s\n"; - } - private: - const std::string m_label; - timeval m_start; - }; - - /** - * @name Debug::stamp() - * @short To facilitate crash/freeze bugs, by making it easy to mark code that has been processed - * - * Usage: - * - * { - * Debug::stamp(); - * function1(); - * Debug::stamp(); - * function2(); - * Debug::stamp(); - * } - * - * Will output (assuming the crash occurs in function2() - * - * app: Stamp: 1 - * app: Stamp: 2 - * - */ - - inline void stamp() - { - static int n = 0; - debug() << "| Stamp: " << ++n << endl; - } -} -} } //LiveSupport and Core namespaces -#define DEBUG_BLOCK Debug::Block uniquelyNamedStackAllocatedStandardBlock( __PRETTY_FUNCTION__ ); - -/// Standard function announcer -#define DEBUG_FUNC_INFO { debug() << '[' << __PRETTY_FUNCTION__ << ']' << endl; } - -/// Announce a line -#define DEBUG_LINE_INFO { debug() << '[' << __PRETTY_FUNCTION__ << ']' << "Line: " << __LINE__ << endl; } - - -#endif //CAMPCASTER_DEBUG_H diff --git a/src/modules/core/include/LiveSupport/Core/FadeInfo.h b/src/modules/core/include/LiveSupport/Core/FadeInfo.h deleted file mode 100644 index 0270fcd6e..000000000 --- a/src/modules/core/include/LiveSupport/Core/FadeInfo.h +++ /dev/null @@ -1,255 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_FadeInfo_h -#define LiveSupport_Core_FadeInfo_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/UniqueId.h" -#include "LiveSupport/Core/Configurable.h" - - -namespace LiveSupport { -namespace Core { - -using namespace std; -using namespace boost::posix_time; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class representing fade in / fade out information of a playlist element. - * This is contained in a PlaylistElement, a list of which, in turn, is - * contained in a Playlist. - * - * This object has to be configured with an XML configuration element - * called fadeInfo. This may look like the following: - * - *

- *  <fadeInfo id="9901" 
- *            fadeIn="00:00:02.000000"
- *            fadeOut="00:00:01.500000" >
- *  </fadeInfo>
- *  
- * - * The DTD for the above element is: - * - *

- *  <!ELEMENT fadeInfo EMPTY >
- *  <!ATTLIST fadeInfo id         NMTOKEN     #REQUIRED  >
- *  <!ATTLIST fadeInfo fadeIn     NMTOKEN     #REQUIRED  >
- *  <!ATTLIST fadeInfo fadeIn     NMTOKEN     #REQUIRED  >
- *  
- */ -class FadeInfo : public Configurable -{ - private: - /** - * The name of the configuration XML elmenent used by FadeInfo. - */ - static const std::string configElementNameStr; - - /** - * The unique id of the fade info. - */ - Ptr::Ref id; - - /** - * The length of fade in period. - */ - Ptr::Ref fadeIn; - - /** - * The length of fade out period. - */ - Ptr::Ref fadeOut; - - /** - * Convert a time_duration to string, in format HH:MM:SS.ssssss. - */ - std::string - toFixedString(Ptr::Ref time) const throw () - { - if (time->fractional_seconds()) { - return to_simple_string(*time); - } else { - return to_simple_string(*time) + ".000000"; - } - } - - - public: - /** - * Default constructor. - */ - FadeInfo(void) throw () - { - } - - /** - * Create a fade info instance by specifying all details. - * This is used for testing purposes. - * - * @param id the id of the fade info. - * @param fadeIn the length of the fade in period. - * @param fadeOut the length of the fade in period. - */ - FadeInfo(Ptr::Ref id, - Ptr::Ref fadeIn, - Ptr::Ref fadeOut) throw() - { - this->id = id; - this->fadeIn = fadeIn; - this->fadeOut = fadeOut; - } - - /** - * Create a fade info instance by specifying the fade in and fade out. - * - * @param fadeIn the length of the fade in period. - * @param fadeOut the length of the fade in period. - */ - FadeInfo(Ptr::Ref fadeIn, - Ptr::Ref fadeOut) throw() - { - this->id = UniqueId::generateId(); - this->fadeIn = fadeIn; - this->fadeOut = fadeOut; - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~FadeInfo(void) throw () - { - } - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementNameStr; - } - - /** - * Configure the object based on the XML element supplied. - * The supplied element is expected to be of the name - * returned by configElementName(). - * - * @param element the XML element to configure the object from. - * @exception std::invalid_argument if the supplied XML element - * contains bad configuraiton information - */ - virtual void - configure(const xmlpp::Element & element) - throw (std::invalid_argument); - - /** - * Return the id of the fade info instance. - * - * @return the unique id of the fade info instance. - */ - Ptr::Ref - getId(void) const throw () - { - return id; - } - - /** - * Return the length of the fade in period. - * - * @return the length of the fade in period, in microseconds. - */ - Ptr::Ref - getFadeIn(void) const throw () - { - return fadeIn; - } - - /** - * Return the length of the fade in period. - * - * @return the length of the fade in period, in microseconds. - */ - Ptr::Ref - getFadeOut(void) const throw () - { - return fadeOut; - } - - /** - * Return an XML representation of this fadeInfo element. - * - * This is a string containing a single - * XML element, which is empty, and has a fadeIn and a fadeOut - * argument (of format hh:mm:ss.ssssss). - * - * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers, - * time durations have the format "hh:mm:ss.ssssss". - * - * @return a string representation of the audio clip as an XML element - */ - Ptr::Ref - getXmlElementString(void) throw (); - -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_FadeInfo_h - diff --git a/src/modules/core/include/LiveSupport/Core/FileTools.h b/src/modules/core/include/LiveSupport/Core/FileTools.h deleted file mode 100644 index ac52ae1ed..000000000 --- a/src/modules/core/include/LiveSupport/Core/FileTools.h +++ /dev/null @@ -1,157 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - To report bugs, send an e-mail to bugs@campware.org - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - - Author : $Author: fgerlits $ - Version : $Revision$ - Location : $URL: svn+ssh://fgerlits@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/modules/core/include/LiveSupport/Core/FileTools.h $ - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_FileTools_h -#define LiveSupport_Core_FileTools_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" - - -namespace LiveSupport { -namespace Core { - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A collection of tools for handling files and URLs. - * - * @author $Author: fgerlits $ - * @version $Revision$ - */ -class FileTools -{ - public: - /** - * Copy the contents of a URL to a local file. - * - * @param url the URL to read. - * @param path the local path where the file is saved. - * @exception std::runtime_error on errors. - */ - static void - copyUrlToFile(const std::string & url, - const std::string & path) - throw (std::runtime_error); - - /** - * Upload the contents of a local file to a writable URL. - * - * @param path the local path where the file is. - * @param url the URL to write. - * @exception std::runtime_error on errors. - */ - static void - copyFileToUrl(const std::string & path, - const std::string & url) - throw (std::runtime_error); - - /** - * Generate a temporary file name. - * - * @return a temporary file name. - */ - static const std::string - tempnam(void) throw (); - - /** - * Append a file to an existing tarball. - * - * @param tarFileName the name of the existing tar file - * @param newFileRealName the name of the new file to append - * @param newFileInTarball the name of the new file in the tarball - * @exception std::runtime_error on file / tarball handling issues. - */ - static void - appendFileToTarball(const std::string & tarFileName, - const std::string & newFileRealName, - const std::string & newFileInTarball) - throw (std::runtime_error); - - /** - * Check if a file exists in a given tarball. - * - * @param tarFileName the name of the existing tar file - * @param fileName the name of the file to check in the traball. - * @return true if a file named fileName exists in the tarball, - * false otherwise. - * @exception std::runtime_error on file / tarball handling issues. - */ - static bool - existsInTarball(const std::string & tarFileName, - const std::string & fileName) - throw (std::runtime_error); - - /** - * Extract a file from a tarball. - * - * @param tarFileName the name of the existing tar file. - * @param fileInTarball the name of the file to be extracted - * in the tarball. - * @param fileExtracted the name of the new file to create. - * @exception std::runtime_error on file / tarball handling issues. - */ - static void - extractFileFromTarball(const std::string & tarFileName, - const std::string & fileInTarball, - const std::string & fileExtracted) - throw (std::runtime_error); -}; - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_FileTools_h - diff --git a/src/modules/core/include/LiveSupport/Core/Installable.h b/src/modules/core/include/LiveSupport/Core/Installable.h deleted file mode 100644 index ab77b1355..000000000 --- a/src/modules/core/include/LiveSupport/Core/Installable.h +++ /dev/null @@ -1,135 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Installable_h -#define LiveSupport_Core_Installable_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include - -#include "LiveSupport/Core/Ptr.h" - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * An interface for having objects that can install themselves. - * The concept of installation means setting up for long-term use. - * When something installs, it creates databases, writes configuration - * files, etc. It sets up the object to be run. This is not to be - * confused with instance initialization, e.g. when a server is started - * or stopped. - * - * The following life cycle is expected from systems impelementing this - * interface: - * - *
    - *
  • install
  • - *
    • - *
    • start
    • - *
    • stop
    • - *
    • start
    • - *
    • stop
    • - *
  • - *
  • uninstall
  • - *
- * - * Later more stages will be added, and load/save (externalization) - * facilities. - */ -class Installable -{ - public: - /** - * Install the component. - * This step involves creating the environment in which the component - * will run. This may be creation of coniguration files, - * database tables, etc. - * - * @exception std::exception on installation problems. - */ - virtual void - install(void) throw (std::exception) - = 0; - - /** - * Check to see if the component has already been installed. - * - * @return true if the component is properly installed, - * false otherwise - * @exception std::exception on generic problems - */ - virtual bool - isInstalled(void) throw (std::exception) - = 0; - - /** - * Uninstall the component. - * Removes all the resources created in the install step. - * - * @exception std::exception on unistallation problems. - */ - virtual void - uninstall(void) throw (std::exception) - = 0; - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~Installable(void) throw () - { - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_Installable_h - diff --git a/src/modules/core/include/LiveSupport/Core/LocalizedConfigurable.h b/src/modules/core/include/LiveSupport/Core/LocalizedConfigurable.h deleted file mode 100644 index 2589dfe1a..000000000 --- a/src/modules/core/include/LiveSupport/Core/LocalizedConfigurable.h +++ /dev/null @@ -1,144 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_LocalizedConfigurable_h -#define LiveSupport_Core_LocalizedConfigurable_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/Configurable.h" -#include "LiveSupport/Core/LocalizedObject.h" - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A configurable element, that is also localized. Reads localization - * information from the configuration file itself. - * - * The configure() function expects the following XML element: - * - *

- *  
- *  
- * - *

- *  
- *  
- *  
- *
- *  ]>
- *  
- */ -class LocalizedConfigurable : public Configurable, public LocalizedObject -{ - private: - /** - * The path to the resource bundles. - */ - std::string bundlePath; - - - public: - /** - * The default constructor. - */ - LocalizedConfigurable(void) throw () - { - } - - /** - * A virtual destructor. - */ - virtual - ~LocalizedConfigurable(void) throw () - { - } - - /** - * Configure the object based on the XML element supplied. - * The supplied element is expected to be of the name - * returned by configElementName(). - * - * @param element the XML element to configure the object from. - * @exception std::invalid_argument if the supplied XML element - * contains bad configuraiton information - * @exception std::logic_error if the object has already - * been configured, and can not be reconfigured. - * @see LocalizedObject#getBundle - */ - virtual void - configure(const xmlpp::Element & element) - throw (std::invalid_argument, - std::logic_error); - - - /** - * Change the current locale, which was previously specified by - * configure(), to the new locale. This results in a replacement - * of the resource bundle, read from the same path as in the - * configuration element sent to configure(), but with the new - * locale id. - * - * @param newLocale the new locale id. - * @exception std::invalid_argument if there is no bundle by - * the specified locale - */ - virtual void - changeLocale(const std::string newLocale) - throw (std::invalid_argument); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_LocalizedConfigurable_h - diff --git a/src/modules/core/include/LiveSupport/Core/LocalizedObject.h b/src/modules/core/include/LiveSupport/Core/LocalizedObject.h deleted file mode 100644 index 809f42d85..000000000 --- a/src/modules/core/include/LiveSupport/Core/LocalizedObject.h +++ /dev/null @@ -1,491 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_LocalizedObject_h -#define LiveSupport_Core_LocalizedObject_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Base class for localized objects, containing some helper functions - * to make localized life easier. - */ -class LocalizedObject -{ - private: - /** - * The name of the configuration XML elmenent used by this object. - */ - static const std::string configElementNameStr; - - /** - * The resource bundle holding the localized resources for this - * object. - */ - Ptr::Ref bundle; - - - protected: - /** - * The default constructor. - */ - LocalizedObject(void) throw () - { - } - - - public: - /** - * Constructor. - * - * @param bundle the resource bundle holding the localized - * resources for this window - */ - LocalizedObject(Ptr::Ref bundle) throw () - { - this->bundle = bundle; - } - - /** - * Virtual destructor. - */ - virtual - ~LocalizedObject(void) throw () - { - } - - /** - * Return the name of the XML element that is expected - * to be sent to a call to getBundle(). - * - * @return the name of the expected XML configuration element. - * @see #getBundle(const xmlpp::Element &) - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementNameStr; - } - - /** - * Load a resource bundle based on an XML configuration element. - * - * The DTD for the lement to be supplied to this function is: - *

-         *  
-         *  
-         *  
-         *  ]>
-         *  
- * - * a sample configuration element is as follows: - * - *

-         *  
-         *  
- * - * for an overview of resource bundle parameters, see the ICU - * documentation on - * resource management - * - * @param element the XML configuration element - * @return the resource bundle, based on this element. - * @exception std::invalid_argument if the supplied element is not - * a proper resource bundle configuration element. - * @see http://oss.software.ibm.com/icu/userguide/ResourceManagement.html - */ - static Ptr::Ref - getBundle(const xmlpp::Element & element) - throw (std::invalid_argument); - - /** - * Get the resource bundle for this object. - * - * @return the resource bundle for this object. - */ - Ptr::Ref - getBundle(void) const throw () - { - return bundle; - } - - /** - * Change the resource bundle for this object. - * - * @param bundle the new resource bundle used by the object. - */ - virtual void - setBundle(Ptr::Ref bundle) throw () - { - this->bundle = bundle; - } - - /** - * Get a resource bundle nested inside our bundle. - * - * @param key the name of the resource bundle to get. - * @exception std::invalid_argument if there is no bundle by - * the specified key - */ - Ptr::Ref - getBundle(const Glib::ustring & key) - throw (std::invalid_argument) - { - return getBundle(getBundle(), key.c_str()); - } - - /** - * Get a resource bundle nested inside our bundle. - * - * @param key the name of the resource bundle to get. - * @exception std::invalid_argument if there is no bundle by - * the specified key - */ - Ptr::Ref - getBundle(const char * key) throw (std::invalid_argument) - { - return getBundle(getBundle(), key); - } - - /** - * Get a resource bundle nested inside our bundle. - * - * @param bundle the resource bundle containing the key. - * @param key the name of the nested resource bundle to get. - * @exception std::invalid_argument if there is no bundle by - * the specified key - */ - Ptr::Ref - getBundle(Ptr::Ref bundle, - const char * key) - throw (std::invalid_argument); - - /** - * Get a string from the resource bundle. - * - * @param key the key identifying the requested string. - * @return the requested string - * @exception std::invalid_argument if there is no string for the - * specified key. - */ - virtual Ptr::Ref - getResourceString(const char * key) - throw (std::invalid_argument) - { - return getResourceString(getBundle(), key); - } - - /** - * Get a string from the resource bundle. - * - * @param bundle the nested resource bundle containing the key. - * @param key the key identifying the requested string. - * @return the requested string - * @exception std::invalid_argument if there is no string for the - * specified key. - */ - virtual Ptr::Ref - getResourceString(const char * bundle, - const char * key) - throw (std::invalid_argument) - { - return getResourceString(getBundle(bundle), key); - } - - /** - * Get a string from the resource bundle. - * - * @param bundle the nested resource bundle containing the key. - * @param key the key identifying the requested string. - * @return the requested string - * @exception std::invalid_argument if there is no string for the - * specified key. - */ - virtual Ptr::Ref - getResourceString(Ptr::Ref bundle, - const char * key) - throw (std::invalid_argument); - - /** - * A convenience function to format a message. - * For more information, see the ICU MessageFormat class - * documentation. - * - * @param pattern the pattern to format - * @param arguments the arguments to use in the formatting - * @param nArguments the number of arguments supplied - * @return the formatted string - * @exception std::invalid_argument if the pattern is bad, or - * the arguments do not match - * @see http://oss.software.ibm.com/icu/apiref/classMessageFormat.html - */ - static Ptr::Ref - formatMessage(Ptr::Ref pattern, - Formattable * arguments, - unsigned int nArguments) - throw (std::invalid_argument); - - /** - * A convenience function to format a message, based on a pattern - * loaded from a resource. - * For more information, see the ICU MessageFormat class - * documentation. - * - * @param patternKey the key of the pattern to format - * @param arguments the arguments to use in the formatting - * @param nArguments the number of arguments supplied - * @return the formatted string - * @exception std::invalid_argument if the pattern is bad, or - * the arguments do not match, or there is no resource - * specified by patternKey - * @see http://oss.software.ibm.com/icu/apiref/classMessageFormat.html - */ - virtual Ptr::Ref - formatMessage(const char * patternKey, - Formattable * arguments, - unsigned int nArguments) - throw (std::invalid_argument); - - /** - * A convenience function to format a message, based on a pattern - * loaded from a resource. - * For more information, see the ICU MessageFormat class - * documentation. - * - * @param patternKey the key of the pattern to format - * @param arguments the arguments to use in the formatting - * @param nArguments the number of arguments supplied - * @return the formatted string - * @exception std::invalid_argument if the pattern is bad, or - * the arguments do not match, or there is no resource - * specified by patternKey - * @see http://oss.software.ibm.com/icu/apiref/classMessageFormat.html - */ - virtual Ptr::Ref - formatMessage(const std::string & patternKey, - Formattable * arguments, - unsigned int nArguments) - throw (std::invalid_argument) - { - return formatMessage(patternKey.c_str(), arguments, nArguments); - } - - /** - * A convenience function to format a message, based on a pattern - * loaded from a resource, with one argument. - * For more information, see the ICU MessageFormat class - * documentation. - * - * @param patternKey the key of the pattern to format - * @param argument1 the single argument to the message. - * @return the formatted string - * @exception std::invalid_argument if the pattern is bad, or - * the arguments do not match, or there is no resource - * specified by patternKey - * @see http://oss.software.ibm.com/icu/apiref/classMessageFormat.html - */ - virtual Ptr::Ref - formatMessage(const std::string & patternKey, - const Glib::ustring & argument1) - throw (std::invalid_argument); - - /** - * A convenience function to format a message, based on a pattern - * loaded from a resource, with two arguments. - * For more information, see the ICU MessageFormat class - * documentation. - * - * @param patternKey the key of the pattern to format - * @param argument1 the first argument to the message. - * @param argument2 the second argument to the message. - * @return the formatted string - * @exception std::invalid_argument if the pattern is bad, or - * the arguments do not match, or there is no resource - * specified by patternKey - * @see http://oss.software.ibm.com/icu/apiref/classMessageFormat.html - */ - virtual Ptr::Ref - formatMessage(const std::string & patternKey, - const Glib::ustring & argument1, - const Glib::ustring & argument2) - throw (std::invalid_argument); - - /** - * A convenience function to format a message, based on a pattern - * loaded from a resource, with three arguments. - * For more information, see the ICU MessageFormat class - * documentation. - * - * @param patternKey the key of the pattern to format - * @param argument1 the first argument to the message. - * @param argument2 the second argument to the message. - * @param argument3 the second argument to the message. - * @return the formatted string - * @exception std::invalid_argument if the pattern is bad, or - * the arguments do not match, or there is no resource - * specified by patternKey - * @see http://oss.software.ibm.com/icu/apiref/classMessageFormat.html - */ - virtual Ptr::Ref - formatMessage(const std::string & patternKey, - const Glib::ustring & argument1, - const Glib::ustring & argument2, - const Glib::ustring & argument3) - throw (std::invalid_argument); - - /** - * Convert an ICU unicode string to a Glib ustring. - * - * @param unicodeString the ICU unicode string to convert. - * @return the same string as supplied, in Glib ustring form. - */ - static Ptr::Ref - unicodeStringToUstring(Ptr::Ref unicodeString) - throw (); - - /** - * Convert a Glib ustring to an ICU unicode string. - * - * @param gString the Glib ustring to convert - * @return the same string as supplied, in ICU unicode form. - */ - static Ptr::Ref - ustringToUnicodeString(Ptr::Ref gString) - throw (); - - /** - * Convert a Glib ustring to an ICU unicode string. - * - * @param gString the Glib ustring to convert - * @return the same string as supplied, in ICU unicode form. - */ - static Ptr::Ref - ustringToUnicodeString(const Glib::ustring & gString) - throw (); - - /** - * Get a string from the resource bundle, as a Glib ustring. - * - * @param key the key identifying the requested string. - * @return the requested string - * @exception std::invalid_argument if there is no string for the - * specified key. - */ - Ptr::Ref - getResourceUstring(const char * key) - throw (std::invalid_argument) - { - return unicodeStringToUstring(getResourceString(key)); - } - - /** - * Get a string from the resource bundle, as a Glib ustring. - * - * @param key the key identifying the requested string. - * @return the requested string - * @exception std::invalid_argument if there is no string for the - * specified key. - */ - Ptr::Ref - getResourceUstring(const std::string &key) - throw (std::invalid_argument) - { - return unicodeStringToUstring(getResourceString(key.c_str())); - } - - /** - * Get a string from a resource bundle nested inside this bundle, - * as a Glib ustring. - * - * @param bundle the name of the resource bundle to get. - * @param key the key identifying the requested string. - * @return the requested string - * @exception std::invalid_argument if there is no string for the - * specified key. - */ - Ptr::Ref - getResourceUstring(const char * bundle, - const char * key) - throw (std::invalid_argument) - { - return unicodeStringToUstring(getResourceString(bundle, key) ); - } - - /** - * Get some binary data as a string. - * Reads the binary data either from a binary or from - * an import key, and returns it as a Glib::ustring. - * The binary data is assumed to be in UTF-8 encoding. - * - * @param key the key identifying the requested binary data. - * @return the requested binary data as a string. - * @exception std::invalid_argument if there is no such key, or the - * value is not of binary type, or it isn't valid UTF-8. - */ - Ptr::Ref - getBinaryResourceAsUstring(const char * key) - throw (std::invalid_argument); -}; - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_LocalizedObject_h - diff --git a/src/modules/core/include/LiveSupport/Core/Md5.h b/src/modules/core/include/LiveSupport/Core/Md5.h deleted file mode 100644 index cae454040..000000000 --- a/src/modules/core/include/LiveSupport/Core/Md5.h +++ /dev/null @@ -1,255 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - This class is based on the following with minor modifications - (see http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html). - - ------------------------------------------------------------------------------ - -// Md5.CC - source code for the C++/object oriented translation and -// modification of Md5. - -// Translation and modification (c) 1995 by Mordechai T. Abzug - -// This translation/ modification is provided "as is," without express or -// implied warranty of any kind. - -// The translator/ modifier does not claim (1) that Md5 will do what you think -// it does; (2) that this translation/ modification is accurate; or (3) that -// this software is "merchantible." (Language for this disclaimer partially -// copied from the disclaimer below). - - ------------------------------------------------------------------------------ - - Which was based on: - - ------------------------------------------------------------------------------ - - Md5.H - header file for Md5C.C - MDDRIVER.C - test driver for MD2, MD4 and Md5 - - Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. Md5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. Md5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Md5_h -#define LiveSupport_Core_Md5_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_STDINT_H -#include -#else -#error need stdint.h -#endif - - -#include -#include -#include -#include -#include -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class for generating md5 sums. - * - * First, one creates an Md5 object from a file, istream or string; then - * one can either call hexDigest() or simply convert the object to std::string - * in order to obtain the md5 sum in the form of 32 hexadecimal (lower case) - * digits. - * - * This is a trimmed version of the C++ class written by Mordechai T. Abzug - * on the basis of the original C code by RSA Data Security, Inc. See the - * header of the source file for further information. - */ -class Md5 -{ - private: - - // first, some types: - typedef unsigned int uint4; // assumes integer is 4 words long - typedef unsigned short int uint2; // assumes short integer is 2 words long - typedef unsigned char uint1; // assumes char is 1 word long - - // methods for controlled operation: - void update (uint1 *input, uint4 input_length); - void update (std::istream& stream); - void update (FILE *file); - void update (const std::string& s); - void finalize () throw(std::invalid_argument); - - // next, the private data: - uint4 state[4]; - uint4 count[2]; // number of *bits*, mod 2^64 - uint1 buffer[64]; // input buffer - uint1 digest[16]; - uint1 finalized; - - /** - * The low 64 bits of the checksum. - */ - uint64_t low64; - - /** - * The high 64 bits of the checksum. - */ - uint64_t high64; - - // last, the private methods, mostly static: - void init (); // called by all constructors - void transform (uint1 *buffer); // does the real update work. Note - // that length is implied to be 64. - - static void encode (uint1 *dest, uint4 *src, uint4 length); - static void decode (uint4 *dest, uint1 *src, uint4 length); - static void memcpy (uint1 *dest, uint1 *src, uint4 length); - static void memset (uint1 *start, uint1 val, uint4 length); - - static inline uint4 rotate_left (uint4 x, uint4 n); - static inline uint4 F (uint4 x, uint4 y, uint4 z); - static inline uint4 G (uint4 x, uint4 y, uint4 z); - static inline uint4 H (uint4 x, uint4 y, uint4 z); - static inline uint4 I (uint4 x, uint4 y, uint4 z); - static inline void FF (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void GG (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void HH (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - static inline void II (uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac); - - /** - * Calculate the lower and higher 64 bit values for the checksum - */ - void - calcNumericRepresentation(void) throw (); - - - public: - - /** - * Construct from a std::string - */ - Md5 (const std::string &s) throw(std::invalid_argument); - - - /** - * Construct from an istream - */ - Md5 (std::istream& stream) throw(std::invalid_argument); - - - /** - * Construct from a file - */ - Md5 (FILE *file) throw(std::invalid_argument); - - - /** - * Get the md5 sum as a 32 digit ascii-hex string - */ - std::string hexDigest () throw(); - - - /** - * Get the md5 sum as a 32 digit ascii-hex string - */ - operator std::string () throw(); - - /** - * Return the lower 64 bits of the checksum. - * - * @return the lower 64 bits of the checksum. - */ - uint64_t - low64bits(void) const throw () - { - return low64; - } - - /** - * Return the higher 64 bits of the checksum. - * - * @return the higher 64 bits of the checksum. - */ - uint64_t - high64bits(void) const throw () - { - return high64; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - - -#endif // LiveSupport_Core_Md5_h - diff --git a/src/modules/core/include/LiveSupport/Core/MetadataConstraint.h b/src/modules/core/include/LiveSupport/Core/MetadataConstraint.h deleted file mode 100644 index 59de4b6d3..000000000 --- a/src/modules/core/include/LiveSupport/Core/MetadataConstraint.h +++ /dev/null @@ -1,173 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_MetadataConstraint_h -#define LiveSupport_Core_MetadataConstraint_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/Configurable.h" - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class for representing a constraint on the values of a metadata type. - * - * This is an abstract-cum-factory class for constructing the concrete - * constraint subclasses. You construct and configure this class, which - * will transparently construct the concrete subclass desired, and delegate - * the actual value checking to it. - * - * This object has to be configured with an XML configuration element - * called constraint. This may look like the following: - * - *

- *  
- *      1
- *      12
- *  
- *  
- * - * The type attribute identifies this MetadataConstraint object as belonging - * to the subclass NumericRangeConstraint. Other subclasses are - * NumericConstraint, EnumerationConstraint etc. - * - * Each MetadataType object may contain an optional MetadataConstraint member - * object, which restricts the acceptable values for this metadata type. - * - * The DTD for the expected XML element looks like the following: - * - *

- *  
- *  
- *  
- *  
- * - * @see MetadataConstraintContainer - */ -class MetadataConstraint : public Configurable -{ - private: - /** - * The name of the configuration XML element used by MetadataConstraint. - */ - static const std::string configElementNameStr; - - /** - * A reference to a concrete subclass. - */ - Ptr::Ref concreteConstraint; - - - protected: - /** - * The name of the type attribute. - */ - static const std::string typeAttributeName; - - /** - * The name of the configuration element for the constraint values. - */ - static const std::string valueElementName; - - - public: - /** - * Constructor. - */ - MetadataConstraint() throw () - { - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~MetadataConstraint(void) throw () - { - } - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementNameStr; - } - - /** - * Configure the metadata object based on an XML configuration element. - * - * @param element the XML configuration element. - * @exception std::invalid_argument of the supplied XML element - * contains bad configuration information - */ - virtual void - configure(const xmlpp::Element & element) - throw (std::invalid_argument); - - /** - * Check that the given value satisfies the constraint. - * - * @param value the value to be checked against the constraint. - * @return true if the value satisfies the constraint. - * @exception std::logic_error if the object has not been - * configured yet. - */ - virtual bool - check(Ptr::Ref value) const - throw (std::logic_error); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_MetadataConstraint_h - diff --git a/src/modules/core/include/LiveSupport/Core/MetadataType.h b/src/modules/core/include/LiveSupport/Core/MetadataType.h deleted file mode 100644 index d3d15ffc7..000000000 --- a/src/modules/core/include/LiveSupport/Core/MetadataType.h +++ /dev/null @@ -1,291 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_MetadataType_h -#define LiveSupport_Core_MetadataType_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/Configurable.h" -#include "LiveSupport/Core/MetadataConstraint.h" - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -class MetadataTypeContainer; - - -/** - * A class for representing a metadata type. - * - * This object has to be configured with an XML configuration element - * called metadataType. This may look like the following: - * - *

- *  <metadataType dcName          = "dc:creator"
- *                id3Tag          = "TPE2"
- *                localizationKey = "dc_creator"
- *                tab             = "main" >
- *      <constraint     type = "numericRange" >
- *          <value>1</value>
- *          <value>12</value>
- *      </constraint>
- *  </metadataType>
- *  
- * - * The tab attribute (if present) must be one of "main", "music" or "voice" - * (all lowercase, case sensitive). - * This determines whether, at file upload, the metadata field appears in - * the Main, Music, or Voice tab. If the attribute is omitted, the metadata - * field will appear in none of the tabs. - * - * The optional constraint sub-element can give restrictions on the acceptable - * values for this type of metadata. See the MetadataConstraint class for - * more information, including the DTD of the <constraint> element. - * - * See the Studio config files for a list of all metadata types. - * - * The DTD for the expected XML element looks like the following: - * - *

- *  
- *  
- *  
- *  
- *  
- *  
- * - * @see MetadataTypeContainer - */ -class MetadataType : public Configurable -{ - friend class MetadataTypeContainer; - - public: - /** - * An enumeration of all possible metadata categories. - */ - typedef enum { noTab, - mainTab, - musicTab, - voiceTab } TabType; - - - private: - /** - * The name of the configuration XML element used by MetadataType. - */ - static const std::string configElementNameStr; - - /** - * A reference to a metadata type container. - */ - Ptr::Ref container; - - /** - * The Dublic Core name of this metadata type. - */ - Ptr::Ref dcName; - - /** - * The ID3v2 tag for this metadata type. - */ - Ptr::Ref id3Tag; - - /** - * The localization key for this metadata type. - */ - Ptr::Ref localizationKey; - - /** - * The localization key for this metadata type. - */ - TabType tab; - - /** - * The constraint object, if any. - */ - Ptr::Ref constraint; - - - protected: - /** - * Default constructor. - * - * @param container the container this metadata type is held in. - */ - MetadataType(Ptr::Ref container) - throw (); - - /** - * Constructor. - * - * @param container the container this metadata type is held in. - * @param dcName the Dublic Core metadata name. - * @param id3Tag the ID3v2 tag assciated with the metadata. - * @param localizationKey the key to get the localized name for - * the metadata - * @param tab in which tab to show this kind of metadata in the - * Upload File window (default: none of them). - */ - MetadataType(Ptr::Ref container, - Glib::ustring dcName, - Glib::ustring id3Tag, - Glib::ustring localizationKey, - TabType tab = noTab) - throw (); - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementNameStr; - } - - /** - * Configure the metadata object based on an XML configuration element. - * - * @param element the XML configuration element. - * @exception std::invalid_argument of the supplied XML element - * contains bad configuration information - */ - virtual void - configure(const xmlpp::Element &element) - throw (std::invalid_argument); - - - public: - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~MetadataType(void) throw () - { - } - - /** - * Return the Dublic Core name of the metadata type. - * - * @return the Dublic Core name of the metadata type. - */ - Ptr::Ref - getDcName(void) const throw () - { - return dcName; - } - - /** - * Return the ID3v2 tag name for the metadata type. - * - * @return the ID3v2 tag name for the metadata type, or a null - * pointer, if no ID3v2 tag exists for the metadata type. - */ - Ptr::Ref - getId3Tag(void) const throw () - { - return id3Tag; - } - - /** - * Return the localization key for the metadata type. - * - * @return the localization key for the metadata type. - */ - Ptr::Ref - getLocalizationKey(void) const throw () - { - return localizationKey; - } - - /** - * Return the localized name for the metadata type. - * - * @return the localized name for the metadata type. - * @exception std::invalid_argument if there is no localized - * name for this metadata type. - */ - Ptr::Ref - getLocalizedName(void) const throw (std::invalid_argument); - - /** - * Return the tab that this metadata type should appear in, - * when an audio clip is uploaded in the Studio client. - * - * @return the name of the tab for the metadata type. - */ - TabType - getTab(void) const throw () - { - return tab; - } - - /** - * Check that the given value satisfies the constraint. - * If the metadata type has no constraints, it returns true. - * If the constraint throws an exception, it returns false. - * - * @param value the value to be checked against the constraint. - * @return true if the value satisfies the constraint. - */ - bool - check(Ptr::Ref value) const throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_MetadataType_h - diff --git a/src/modules/core/include/LiveSupport/Core/MetadataTypeContainer.h b/src/modules/core/include/LiveSupport/Core/MetadataTypeContainer.h deleted file mode 100644 index e9782716d..000000000 --- a/src/modules/core/include/LiveSupport/Core/MetadataTypeContainer.h +++ /dev/null @@ -1,279 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_MetadataTypeContainer_h -#define LiveSupport_Core_MetadataTypeContainer_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/Configurable.h" -#include "LiveSupport/Core/LocalizedObject.h" -#include "LiveSupport/Core/MetadataType.h" - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Container holding MetadataType objects. - * - * This object has to be configured with an XML configuration element - * called metadataTypeContainer. This may look like the following: - * - *

- *  <metadataTypeContainer>
- *      <metadataType ... />
- *      <metadataType ... />
- *      ...
- *      <metadataType ... />
- *  </metadataTypeContainer>
- *  
- * - * The DTD for the expected XML element is the following: - * - *

- *  
- *  
- * - * For a description of the metadataType XML element, see the documentation - * for the MetadataType class. - * - * See the Studio config files for a list of all metadata types. - * - * @see MetadataType - */ -class MetadataTypeContainer : public Configurable, - public LocalizedObject, - public boost::enable_shared_from_this -{ - public: - /** - * A vector type holding contant MetadataType references. - */ - typedef std::vector::Ref> Vector; - - - private: - /** - * Map type for storing MetadataType objects by Glib::ustrings. - */ - typedef std::map::Ref> NameMap; - - /** - * The name of the configuration XML element used by - * MetadataTypeContainer. - */ - static const std::string configElementNameStr; - - /** - * A vector holding all MetadataType references. - */ - Vector vector; - - /** - * Map of MetadaType objects, stored by DC name. - */ - NameMap dcNameMap; - - /** - * Map of MetadaType objects, stored by ID3v2 tags. - */ - NameMap id3TagMap; - - - public: - /** - * Constructor. - * - * @param bundle the resource bundle holding the localized resources. - */ - MetadataTypeContainer(Ptr::Ref bundle) - throw () - : LocalizedObject(bundle) - { - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~MetadataTypeContainer(void) throw () - { - } - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementNameStr; - } - - /** - * Configure the metadata object based on an XML configuration element. - * - * @param element the XML configuration element. - * @exception std::invalid_argument of the supplied XML element - * contains bad configuration information - */ - virtual void - configure(const xmlpp::Element &element) - throw (std::invalid_argument); - - /** - * Return an interator holding all MetadataType objects. - * The iterator holds objects of type Ptr::Ref. - * - * @return an iterator holding the available metadata types. - */ - Vector::const_iterator - begin(void) const throw () - { - return vector.begin(); - } - - /** - * Return an interator pointing to the end of MetadataType objects. - * The iterator holds objects of type Ptr::Ref. - * - * @return an iterator pointing to the end of metadata types. - */ - Vector::const_iterator - end(void) const throw () - { - return vector.end(); - } - - /** - * Tells if a MetadataType object exists with the specified - * Dublic Core name. - * - * @param dcName the DC name of the metadata type. - * @return true if a metadata type exists with the specified name, - * false otherwise - */ - bool - existsByDcName(const Glib::ustring dcName) const throw (); - - /** - * Return a MetadataType object, by Dublic Core name. - * - * @param dcName the DC name of the metadata type. - * @return a MetadataType object with the supplied DC name - * @exception std::invalid_argument if no metadata type exists - * with the suplied name. - */ - Ptr::Ref - getByDcName(const Glib::ustring dcName) - throw (std::invalid_argument); - - /** - * Tells if a MetadataType object exists with the specified - * ID3v2 tag. - * - * @param id3Tag the ID3v2 tag of the metadata type. - * @return true if a metadata type exists with the specified tag name, - * false otherwise - */ - bool - existsById3Tag(const Glib::ustring id3Tag) const throw (); - - /** - * Return a MetadataType object, by ID3v2 tag. - * - * @param id3Tag the ID3v2 tag of the metadata type. - * @return a MetadataType object with the supplied ID3v2 tag name. - * @exception std::invalid_argument if no metadata type exists - * with the suplied tag name. - */ - Ptr::Ref - getById3Tag(const Glib::ustring id3Tag) - throw (std::invalid_argument); - - /** - * Return a MetadataType object, by index. - * - * @param index the index of the item in the metadata container. - * @return the MetadataType object at the supplied index. - * @exception std::invalid_argument if the index is out of range. - */ - Ptr::Ref - getByIndex(unsigned int index) const - throw (std::invalid_argument); - - /** - * Check that the given value satisfies the constraint of a metadata - * type. - * If the metadata type has no constraints, it returns true. - * If the constraint throws an exception, it returns false. - * - * @param value the value to be checked against the constraint. - * @param dcName the metadata type, by its Dublin Core name. - * @return true if the value satisfies the constraint. - * @exception std::invalid_argument if no metadata type exists - * with the suplied name. - */ - bool - check(Ptr::Ref value, - const Glib::ustring & dcName) - throw (std::invalid_argument); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_MetadataTypeContainer_h - diff --git a/src/modules/core/include/LiveSupport/Core/Mutex.h b/src/modules/core/include/LiveSupport/Core/Mutex.h deleted file mode 100644 index ab4a47c6e..000000000 --- a/src/modules/core/include/LiveSupport/Core/Mutex.h +++ /dev/null @@ -1,142 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Mutex_h -#define LiveSupport_Core_Mutex_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A simple wrapper for pthread_mutex_t. - */ -class Mutex -{ - private: - /** - * The mutex object. - */ - pthread_mutex_t * mutex; - - - public: - /** - * Default constructor. - */ - Mutex(void) throw () - { - mutex = new pthread_mutex_t; - pthread_mutex_init(mutex, NULL); - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~Mutex(void) throw () - { - pthread_mutex_destroy(mutex); - } - - /** - * Lock the mutex. - * If the mutex is already locked, it blocks until it becomes free. - */ - void - lock(void) throw () - { - pthread_mutex_lock(mutex); - } - - /** - * Unlock a mutex. - */ - void - unlock(void) throw () - { - pthread_mutex_unlock(mutex); - } - - /** - * Try to lock a mutex. - * If the mutex is already locked, it returns false. - * - * @return true if the mutex was successfully locked; false otherwise. - */ - bool - tryLock(void) throw () - { - return (pthread_mutex_trylock(mutex) == 0); - } - - /** - * Try to lock a mutex. - * If the mutex is already locked, it returns false. - * - *` @param errorCode return parameter for the error code; - * 0 for no error. - * @return true if the mutex was successfully locked; false otherwise. - */ - bool - tryLock(int & errorCode) throw () - { - errorCode = pthread_mutex_trylock(mutex); - return (errorCode == 0); - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - - -#endif // LiveSupport_Core_Mutex_h - diff --git a/src/modules/core/include/LiveSupport/Core/NumericTools.h b/src/modules/core/include/LiveSupport/Core/NumericTools.h deleted file mode 100644 index d883d60cc..000000000 --- a/src/modules/core/include/LiveSupport/Core/NumericTools.h +++ /dev/null @@ -1,100 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_NumericTools_h -#define LiveSupport_Core_NumericTools_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include - - -namespace LiveSupport { -namespace Core { - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A toolbox for various small numeric functions. - */ -class NumericTools -{ - public: - - /** - * Convert an integer to a string. - * - * @param number the number to be converted. - * @return the string value of the number (in base 10). - */ - static Glib::ustring - itoa(int number) throw (); - - /** - * Add a number to the end of a string. - * This is used in various GUI classes, to generate Glade widget - * names like "itemLabel1", "itemLabel2" etc. - * - * NOTE: the index parameter is 0-based (because this - * is normal in C++, for containers etc), but the return value is - * 1-based (because this is what Glade expects)! - * Thus addIndex("itemLabel", 0) returns "itemLabel1". - * - * @param baseString the string without the index. - * @param index the index to be added to the string (0-based). - * @return the new string, with the index added at the end (1-based). - */ - static Glib::ustring - addIndex(const Glib::ustring & baseString, - int index) throw (); -}; - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_NumericTools_h - diff --git a/src/modules/core/include/LiveSupport/Core/OptionsContainer.h b/src/modules/core/include/LiveSupport/Core/OptionsContainer.h deleted file mode 100644 index e45847d86..000000000 --- a/src/modules/core/include/LiveSupport/Core/OptionsContainer.h +++ /dev/null @@ -1,329 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - To report bugs, send an e-mail to bugs@campware.org - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - - Author : $Author $ - Version : $Revision $ - Location : $URL $ - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_OptionsContainer_h -#define LiveSupport_Core_OptionsContainer_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/RdsContainer.h" - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A container for the options in gLiveSupport.xml. - * - * It supports a number of named string options (see OptionItemString), - * plus two special kinds of options: keyboard shortcuts, and RDS strings. - * - * @author $Author $ - * @version $Revision $ - */ -class OptionsContainer -{ - public: - /** - * The list of string options one can set. - * - * These are options of type Glib::ustring; any string is accepted - * as value, no range checking is done. - */ - typedef enum { outputPlayerDeviceName, - cuePlayerDeviceName, - authenticationServer, - authenticationPort, - authenticationPath, - storageServer, - storagePort, - storagePath, - schedulerServer, - schedulerPort, - schedulerPath, - serialDeviceName } OptionItemString; - - - private: - /** - * The XML document containing the options. - */ - xmlpp::Document optionsDocument; - - /** - * The file name (including path) used by writeToFile(). - */ - Ptr::Ref configFileName; - - /** - * Remember if we have been touched. - */ - bool touched; - - /** - * Container for the RDS settings. - */ - Ptr::Ref rdsContainer; - - /** - * Default constructor. - */ - OptionsContainer(void) throw () - { - } - - /** - * Find the node corresponding to an OptionItemString value. - * - * If there is no matching node, it returns a 0 pointer. - * - * @param optionItem the name of the item to find the node for - * @param isAttribute return parameter; is set to true if the - * node is an attribute, false if it's - * a CDATA text - * @return a pointer to the node found, or 0 - * @exception std::invalid_argument thrown by getNode() [should - * never happen] - */ - xmlpp::Node * - selectNode(OptionItemString optionItem, - bool & isAttribute) - throw (std::invalid_argument); - - /** - * Find the node corresponding to a keyboard shortcut. - * - * If there is no matching node, it returns a 0 pointer. - * - * @param containerNo the number of the KeyboardShortcutContainer - * (starting with 1, as per XPath) - * @param shortcutNo the number of the KeyboardShortcut within - * this container (also starting with 1) - * @return a pointer to the node found, or 0 - * @exception std::invalid_argument thrown by getNode() [should - * never happen] - */ - xmlpp::Node * - selectKeyboardShortcutNode(int containerNo, - int shortcutNo) - throw (std::invalid_argument); - - /** - * Return the first node matching an XPath string. - * - * If there is no matching node, it returns a 0 pointer. - * - * @param xPath the XPath of the node (from the root node) - * @return a pointer to the node found, or 0 - * @exception std::invalid_argument if the XPath is not well formed - */ - xmlpp::Node * - getNode(const Glib::ustring & xPath) - throw (std::invalid_argument); - - /** - * Create a node corresponding to an option item. - * - * So far, this is only implemented for serialDeviceName; - * for all other option items, it returns a 0 pointer. - * The XML element or attribute is created with a value of "". - * - * TODO: implement this properly; ideally, the paths would be read - * from the DTD of the default config file, and added to the current - * config file as needed. - * - * @param optionItem the option item to be created. - * @return a pointer to the node created, or 0. - */ - xmlpp::Node * - createNode(OptionItemString optionItem) throw (); - - - public: - /** - * Constructor with XML element parameter. - * - * @param optionsElement the XML element containing the options - * @param configFileName the name (with path) of the configuration - * file used by writeToFile() - * @see writeToFile() - */ - OptionsContainer(const xmlpp::Element & optionsElement, - Ptr::Ref configFileName) - throw (); - - /** - * Report if the object has been touched. - * - * It returns true if there has been any calls to setOptionItem() - * since its construction or the last call to writeToFile(). - * - * @return whether the options have been touched - */ - bool - isTouched(void) throw () - { - return touched || (rdsContainer && rdsContainer->isTouched()); - } - - /** - * Set a string type option. - * - * @param optionItem which option to set - * @param value the new value of the option - * @exception std::invalid_argument if the option name is not found - */ - void - setOptionItem(OptionItemString optionItem, - Ptr::Ref value) - throw (std::invalid_argument); - - /** - * Get a string type option. - * - * @return the value of the option - * @exception std::invalid_argument if the option name is not found - */ - Ptr::Ref - getOptionItem(OptionItemString optionItem) - throw (std::invalid_argument); - - /** - * Set a keyboard shortcut type option. - * - * @param containerNo which container to modify - * @param shortcutNo which shortcut to modify within this - * container - * @param value the name of the new shortcut key - * @exception std::invalid_argument if the shortcut is not found - */ - void - setKeyboardShortcutItem(int containerNo, - int shortcutNo, - Ptr::Ref value) - throw (std::invalid_argument); - - /** - * Set the value of the RDS options. - * The key can be any of the RDS data codes, like PS, PI, PTY, RT, - * etc. If there is already a value set for this code, it gets - * overwritten, otherwise a new key-value pair is added. - * - * @param key which setting to modify - * @param value the new value of the RDS setting - * @param enabled the new enabled/disabled state of the - * RDS setting - */ - void - setRdsOptions(Ptr::Ref key, - Ptr::Ref value, - bool enabled) throw (); - - /** - * Get the value of an RDS string. - * The key can be any of the RDS data codes, like PS, PI, PTY, RT, - * etc. - * - * @param key which setting to modify - * @return the value of the RDS setting - * @exception std::invalid_argument if there is no such RDS option. - */ - Ptr::Ref - getRdsValue(Ptr::Ref key) - throw (std::invalid_argument); - - /** - * Get the enabled/disabled state of an RDS option. - * - * @param key which setting to modify - * @return true if the RDS option is enabled, false otherwise. - * @exception std::invalid_argument if there is no such RDS option. - */ - bool - getRdsEnabled(Ptr::Ref key) - throw (std::invalid_argument); - - /** - * Get a string containing all the RDS values. - * This string can be sent to the RDS encoder. - * - * @return a string which can be sent to the RDS encoder; - * a 0 pointer if no RDS options have been defined. - */ - Ptr::Ref - getCompleteRdsString(void) throw () - { - return rdsContainer ? rdsContainer->toString() - : Ptr::Ref(); - } - - /** - * Save the options to a file. - * - * This writes the options in XML format to the file specified in the - * constructor. The directory must already exist (it's OK if the file - * does not), otherwise nothing is written. - */ - void - writeToFile(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_OptionsContainer_h - diff --git a/src/modules/core/include/LiveSupport/Core/PlayLogEntry.h b/src/modules/core/include/LiveSupport/Core/PlayLogEntry.h deleted file mode 100644 index 4618190b2..000000000 --- a/src/modules/core/include/LiveSupport/Core/PlayLogEntry.h +++ /dev/null @@ -1,161 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_PlayLogEntry_h -#define LiveSupport_Core_PlayLogEntry_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/UniqueId.h" - - -namespace LiveSupport { -namespace Core { - -using namespace boost::posix_time; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class representing a play log entry. - * PlayLogEntries contain information about the audio clips played. - */ -class PlayLogEntry -{ - private: - /** - * The unique id of the play log entry. - */ - Ptr::Ref id; - - /** - * The id of the audio clip referenced by this play log entry. - */ - Ptr::Ref audioClipId; - - /** - * The time this audio clip was played. - */ - Ptr::Ref timestamp; - - - public: - /** - * Default constructor. - */ - PlayLogEntry(void) throw () - { - } - - /** - * Create a play log entry by specifying all details. - * - * @param id the ID of the play log entry. - * @param audioClipId the ID of the audio clip logged - * @param timestamp the time this audio clip was played. - */ - PlayLogEntry(Ptr::Ref id, - Ptr::Ref audioClipId, - Ptr::Ref timestamp) throw() - { - this->id = id; - this->audioClipId = audioClipId; - this->timestamp = timestamp; - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~PlayLogEntry(void) throw () - { - } - - /** - * Return the ID of the play log entry. - * - * @return the unique ID of the play log entry. - */ - Ptr::Ref - getId(void) const throw () - { - return id; - } - - /** - * Return the ID of the audio clip referenced by this entry. - * - * @return the unique ID of the audio clip. - */ - Ptr::Ref - getAudioClipId(void) const throw () - { - return audioClipId; - } - - /** - * Return the time this audio clip was played. - * - * @return the the time the audio clip was played. - */ - Ptr::Ref - getTimestamp(void) const throw () - { - return timestamp; - } - -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_PlayLogEntry_h - diff --git a/src/modules/core/include/LiveSupport/Core/Playable.h b/src/modules/core/include/LiveSupport/Core/Playable.h deleted file mode 100644 index 3be9ae49b..000000000 --- a/src/modules/core/include/LiveSupport/Core/Playable.h +++ /dev/null @@ -1,307 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Playable_h -#define LiveSupport_Core_Playable_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/UniqueId.h" -#include "LiveSupport/Core/Configurable.h" - - -namespace LiveSupport { -namespace Core { - -class AudioClip; // forward declarations to avoid circularity -class Playlist; - -using namespace boost::posix_time; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * An abstract class which is extended by AudioClip and Playlist. - * It contains the methods which are common to these classes. - */ -class Playable : public boost::enable_shared_from_this -{ - public: - - /** - * The sub-types a Playable object can belong to. - */ - enum Type { AudioClipType, PlaylistType }; - - private: - - /** - * The type of this playable object (audio clip or playlist). - */ - Type type; - - protected: - - /** - * Only my children are allowed to instantiate me. - * - * @param typeParam either AudioClipType or PlaylistType. - */ - Playable(Type typeParam) throw () - : type(typeParam) - { - } - - - public: - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~Playable(void) throw () - { - } - - /** - * Return the id of the audio clip or playlist. - * - * @return the unique id of the audio clip or playlist. - */ - virtual Ptr::Ref - getId(void) const throw () = 0; - - /** - * Return the total playing length for this audio clip or playlist. - * - * @return the playing length in microseconds. - */ - virtual Ptr::Ref - getPlaylength(void) const throw () = 0; - - - /** - * Return the URI of the sound file of this audio clip or - * playlist, which can be played by the audio player. This - * sound file can be an mp3 or a SMIL file. - * - * @return the URI. - */ - virtual Ptr::Ref - getUri(void) const throw () = 0; - - /** - * Set the URI of the sound file of this audio clip or - * playlist, which can be played by the audio player. This - * sound file can be an mp3 or a SMIL file. - * - * @param uri the new URI. - */ - virtual void - setUri(Ptr::Ref uri) throw () = 0; - - - /** - * Return the token which is used to identify this audio clip - * or playlist to the storage server. - * - * The token is set when the Playable object is acquired and - * unset (made null again) when it is released. - * - * @return the token. - */ - virtual Ptr::Ref - getToken(void) const throw () = 0; - - /** - * Set the token which is used to identify this audio clip - * or playlist to the storage server. - * - * The token is set when the Playable object is acquired and - * unset (made null again) when it is released. - * - * @param token a new token. - */ - virtual void - setToken(Ptr::Ref token) - throw () = 0; - - - /** - * Return the title of this audio clip or playlist. - * - * @return the title. - */ - virtual Ptr::Ref - getTitle(void) const throw () = 0; - - /** - * Set the title of this audio clip or playlist. - * - * @param title a new title. - */ - virtual void - setTitle(Ptr::Ref title) - throw () = 0; - - - /** - * Return the value of a metadata field in this audio clip or playlist. - * If the playable does not have this metadata field, returns a null - * pointer. - * - * @param key the name of the metadata field - * @return the value of the metadata field; 0 if there is - * no such field; - */ - virtual Ptr::Ref - getMetadata(const std::string &key) const - throw () = 0; - - /** - * Set the value of a metadata field in this audio clip or playlist. - * - * @param value the new value of the metadata field. - * @param key the name of the metadata field - * @exception std::invalid_argument if the key is dcterms:extent, - * but the value is not a valid ISO-8601 time - */ - virtual void - setMetadata(Ptr::Ref value, - const std::string &key) - throw (std::invalid_argument) - = 0; - - /** - * Return a partial XML representation of this audio clip or playlist. - * - * This is a string containing a single or - * XML element, with minimal information (ID, title, playlength) - * only, without an XML header or any other metadata. - * - * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers, - * time durations have the format "hh:mm:ss.ssssss". - * - * @return a string representation of the audio clip as an XML element - */ - virtual Ptr::Ref - getXmlElementString(void) const throw () = 0; - - - /** - * Return a complete XML representation of this audio clip or playlist. - * - * This is a string containing a an XML document with an - * or root node, together with an XML header and a - * element (in the case of playlists, for the outermost - * playlist only). - * - * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers, - * time durations have the format "hh:mm:ss.ssssss". - * - * The audio clip or playlist can be reconstructed from - * the string returned by this method: - *

-         *  Ptr::Ref         audioClip1 = ... something ...;
-         *  Ptr::Ref  parser;
-         *  parser->parse_memory(*audioClip1->getXmlDocumentString());
-         *  const xmlpp::Document*      document = parser->get_document();
-         *  const xmlpp::Element*       root     = document->get_root_node();
-         *  Ptr::Ref         audioClip2(new AudioClip());
-         *  audioClip2->configure(*root);
-         *  
- * results in two identical audio clips (this works for playlists, - * too, but see the note at Playlist::getXmlDocumentString()). - * - * @return a string representation of the audio clip as an XML document - */ - virtual Ptr::Ref - getXmlDocumentString(void) const throw () = 0; - - - /** - * Return the type of this object. - * - * @return either AudioClipType or PlaylistType. - */ - Type - getType(void) const throw () - { - return type; - } - - /** - * Return an audio clip pointer to this object. If the object's - * type is not AudioClipType, returns a zero pointer. - * - * @see getType() - * @return an audio clip pointer to this object. - */ - Ptr::Ref - getAudioClip(void) throw (); - - /** - * Return a playlist pointer to this object. If the object's - * type is not PlaylistType, returns a zero pointer. - * - * @see getType() - * @return a playlist pointer to this object. - */ - Ptr::Ref - getPlaylist(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_Playable_h - diff --git a/src/modules/core/include/LiveSupport/Core/Playlist.h b/src/modules/core/include/LiveSupport/Core/Playlist.h deleted file mode 100644 index 8b5ba3537..000000000 --- a/src/modules/core/include/LiveSupport/Core/Playlist.h +++ /dev/null @@ -1,927 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Playlist_h -#define LiveSupport_Core_Playlist_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/UniqueId.h" -#include "LiveSupport/Core/Configurable.h" -#include "LiveSupport/Core/Playable.h" -#include "LiveSupport/Core/PlaylistElement.h" - - -namespace LiveSupport { -namespace Core { - -using namespace boost::posix_time; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class representing playlist. - * Playlist are containers for AudioClips, with the additional - * information of when and how each audio clip is played inside - * the playlist. - * - * This object has to be configured with an XML configuration element - * called playlist. This may look like the following: - * - *

- *  <playlist id="0000000000000001"
- *            title="My Playlist" 
- *            playlength="00:18:30.000000">
- *      <playlistElement> ... </playlistElement>
- *      ...
- *      <playlistElement> ... </playlistElement>
- *      <metadata xmlns="http://mdlf.org/livesupport/elements/1.0/"
- *                 xmlns:ls="http://mdlf.org/livesupport/elements/1.0/"
- *                 xmlns:dc="http://purl.org/dc/elements/1.1/"
- *                 xmlns:dcterms="http://purl.org/dc/terms/"
- *                 xmlns:xml="http://www.w3.org/XML/1998/namespace">
- *          <dc:title>File Title txt</dc:title>
- *          <dcterms:extent>00:02:30.000000</dcterms:extent>
- *          ...
- *      </metadata>
- *  </playlist>
- *  
- * - * The DTD for the above element is: - * - *

- *  <!ELEMENT playlist (playlistElement*, metadata?) >
- *  <!ATTLIST playlist  id           NMTOKEN    #REQUIRED >
- *  <!ATTLIST playlist  title        CDATA      ""        >
- *  <!ATTLIST playlist  playlength   NMTOKEN    #IMPLIED  >
- *  
- * - * For detais of the playlistElement element, see the documentation - * for the PlaylistElement class. - * - * The metadata element is optional. The configure() method - * sets only those fields which had not been set previously: e.g., if we set - * some or all fields of the Playlist in the constructor, then these fields - * in the XML element will be ignored by configure(). - * The title attribute and the <dc:title> - * element set the same field; if both are present, the title is set from - * the attribute and the element is ignored.. - * The same is true for the playlength attribute and the - * <dcterms:extent> element. - * - * It is required that by the end of the configure() method, the playlength - * is set somehow (from a constructor, the attribute or the element). - * If the title is not set by the end of the configure() method, it is then - * set to the empty string. - * - * A Playlist can be of various kinds, depending on what we want to use it - * for, and how we got it from the StorageClientInterface: - *
    - *
  • A playlist obtained by getPlaylist() has its uri, - * token and editToken fields all unset - * (i.e., null). Such playlists contain sub-playlists which - * are just stubs, i.e., id, title, playlength triples, - * without actual references to its content objects.
  • - *
  • A playlist obtained by acquirePlaylist() has its uri - * and token fields set, but its editToken - * field unset. These are complete Playlist objects, and their - * sub-playlists contain references to all their sub-objects etc. - * The sub-playlists have their uri fields set, which - * allows them to be played by the audio player, but their - * token field is unset, because these sub-playlists - * are acquired and will be released recursively when the outermost - * playlist containing them is acquired and released.
  • - *
  • A playlist obtained by editPlaylist() has its editToken - * field set (but uri and token unset). - * The sub-playlists of these are also just stubs.
  • - *
- * - * The playlists are stored by the storage server in the format returned by - * the getXmlDocumentString() function: - *
    - *
  • The outermost <playlist> has an id attribute, - * a list of <playlistElement> children - * and a <metadata> child.
  • - *
  • Each <playlistElement> has an id - * and a relativeOffset attribute, - * either a <playlist> or an <audioClip> child, - * and optionally a <fadeInfo> child.
  • - *
  • Each <playlist> and <audioClip> has id, title - * and playlength attributes (and no children).
  • - *
  • Each <fadeInfo> has fadeIn and fadeOut attributes - * (and no children).
  • - *
  • The <metadata> element contains all the metadata of - * the outermost playlist. - * The dc:title and dcterms:extent elements are compulsory, - * everything else is optional.
  • - *
- * An example: - * - *

- *  <playlist id="0000000000000001">
- *      <playlistElement id="0000000000000101"
- *                       relativeOffset="00:00:00.000000">
- *          <audioClip id="0000000000010001" 
- *                    title="My Audio Clip"
- *                    playlength="00:02:30.000000"/>
- *          <fadeInfo id="0000000000009901" 
- *                    fadeIn="00:00:02.000000"
- *                    fadeOut="00:00:01.500000"/>
- *      </playlistElement>
- *      <playlistElement id="0000000000000102"
- *                       relativeOffset="00:02:30.000000">
- *          <playlist id="0000000000000002" 
- *                    title="Embedded Playlist"
- *                    playlength="00:18:30.000000"/>
- *      </playlistElement>
- *      <metadata xmlns="http://mdlf.org/livesupport/elements/1.0/"
- *                xmlns:ls="http://mdlf.org/livesupport/elements/1.0/"
- *                xmlns:dc="http://purl.org/dc/elements/1.1/"
- *                xmlns:dcterms="http://purl.org/dc/terms/"
- *                xmlns:xml="http://www.w3.org/XML/1998/namespace">
- *          <dc:title>My Playlist</dc:title>
- *          <dcterms:extent>00:21:00.000000</dcterms:extent>
- *          ...
- *      </metadata>
- *  </playlist>
- *  
- * - */ -class Playlist : public Configurable, - public Playable -{ - private: - /** - * The name of the configuration XML elmenent used by Playlist. - */ - static const std::string configElementNameStr; - - /** - * The unique id of the playlist. - */ - Ptr::Ref id; - - /** - * The title of the playlist. - */ - Ptr::Ref title; - - /** - * The playling length of the playlist. - */ - Ptr::Ref playlength; - - /** - * The uri of the SMIL file generated from this playlist (if any). - */ - Ptr::Ref uri; - - /** - * The token given to this playlist by the storage server when - * the playlist is acquired; removed when it is released. - */ - Ptr::Ref token; - - /** - * The token given to this playlist by the storage server when - * it is opened for editing; removed when it is saved or reverted. - */ - Ptr::Ref editToken; - - /** - * A map type for storing the playlist elements associated with - * this playlist, indexed by their relative offsets. - */ - typedef std::multimap::Ref> - PlaylistElementListType; - - /** - * The list of playlist elements for this playlist. - */ - Ptr::Ref elementList; - - /** - * A saved copy of this playlist. - */ - Ptr::Ref savedCopy; - - - /** - * This playlist in XML format. - */ - Ptr::Ref xmlPlaylist; - - /** - * Set the value of a metadata field in this playlist. - * - * @param value the new value of the metadata field. - * @param name the name of the metadata field (without prefix) - * @param prefix the prefix of the metadata field - * @exception std::invalid_argument if the key is dcterms:extent, - * but the value is not a valid ISO-8601 time - */ - void - setMetadata(Ptr::Ref value, - const std::string &name, const std::string &prefix) - throw (std::invalid_argument); - - /** - * Set the total playing length of this playlist. - * - * @param playlength the playing length in microseconds precision. - */ - void - setPlaylength(Ptr::Ref playlength) - throw (); - - /** - * Set the playlength member of this audio clip. - * - * @param timeString the playing length in microseconds precision. - * @exception std::invalid_argument if the argument is not - * a valid ISO-8601 time - */ - void - setPlaylength(Ptr::Ref timeString) - throw (std::invalid_argument); - - /** - * A private iterator type for internal use. It is non-constant; - * otherwise it is the same as Playlist::const_iterator. - */ - typedef PlaylistElementListType::iterator iterator; - - /** - * Get an iterator pointing to a playlist element with a given ID. - * - * @param playlistElementId (a pointer to) the ID of the - * playlist element. - * @return an iterator to the playlist element if it exists, - * or this->end() if it does not. - */ - iterator - find(Ptr::Ref playlistElementId) - throw (); - - /** - * Convert a time_duration to string, in format HH:MM:SS.ssssss. - */ - std::string - toFixedString(Ptr::Ref time) const - throw () - { - if (time->fractional_seconds()) { - return to_simple_string(*time); - } else { - return to_simple_string(*time) + ".000000"; - } - } - - - public: - /** - * Copy constructor. - * - * @param otherPlaylist the playlist to be copied - */ - Playlist(const Playlist & otherPlaylist) - throw (); - - /** - * Default constructor. - * - * NOTE: this constructor creates a Playlist with a null pointer - * for both the ID and the playlength fields! It is meant for - * internal use only. - * - * If you want to create an empty Playlist, use the storage client: - *

-         *  Ptr::Ref
-         *          storageClientFactory = StorageClientFactory::getInstance();
-         *  Ptr::Ref
-         *          storageClient = storageClientFactory->getStorageClient();
-         *  Ptr::Ref
-         *          playlist = storageClient->createPlaylist(sessionId);
-         *  
- * - * @see StorageClient::StorageClientFactory - * @see StorageClient::StorageClientInterface - */ - Playlist(void) throw () - : Playable(PlaylistType) - { - elementList.reset(new PlaylistElementListType); - } - - /** - * Create a playlist by specifying its ID only. - * - * For internal use; see the note at the default constructor. - */ - Playlist(Ptr::Ref id) throw () - : Playable(PlaylistType) - { - this->id = id; - - elementList.reset(new PlaylistElementListType); - } - - /** - * Create a playlist by specifying all details, except the title. - * - * This is used for testing purposes; - * see the note at the default constructor. - * - * @param id the id of the playlist. - * @param playlength the playing length of the playlist. - * @param uri the location of the SMIL file representing this - * playlist (optional) - */ - Playlist(Ptr::Ref id, - Ptr::Ref playlength, - Ptr::Ref uri = Ptr::Ref()) - throw (); - - /** - * Create a playlist by specifying all details. - * - * This is used for testing purposes; - * see the note at the default constructor. - * - * @param id the id of the playlist. - * @param title the title of the playlist. - * @param playlength the playing length of the playlist. - * @param uri the location of the SMIL file representing this - * playlist (optional) - */ - Playlist(Ptr::Ref id, - Ptr::Ref title, - Ptr::Ref playlength, - Ptr::Ref uri = Ptr::Ref()) - throw (); - - /** - * Convert the playlist to an XmlRpcValue (marshalling). - * - * @return an XmlRpcValue struct, containing a - * field named playlist, with value of type string, - * which contains an XML document representing the playlist. - */ - operator XmlRpc::XmlRpcValue() const - throw (); - - /** - * Construct a playlist from an XmlRpcValue (demarshalling). - * - * @param xmlRpcValue an XmlRpcValue struct, containing a - * field named playlist, with value of type string, - * which contains an XML document, the root node of which - * can be passed to the configure() method. - * @exception std::invalid_argument if the argument is invalid - */ - Playlist(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~Playlist(void) throw () - { - } - - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementNameStr; - } - - /** - * Configure the object based on the XML element supplied. - * The supplied element is expected to be of the name - * returned by configElementName(). - * - * @param element the XML element to configure the object from. - * @exception std::invalid_argument if the supplied XML element - * contains bad configuraiton information - */ - virtual void - configure(const xmlpp::Element & element) - throw (std::invalid_argument); - - /** - * Return the id of the playlist. - * - * @return the unique id of the playlist. - */ - virtual Ptr::Ref - getId(void) const throw () - { - return id; - } - - - /** - * Return the title of this playlist. - * - * @return the title. - */ - virtual Ptr::Ref - getTitle(void) const throw () - { - return title; - } - - /** - * Set the title of this playlist. - * - * @param title a new title. - */ - virtual void - setTitle(Ptr::Ref title) - throw (); - - - /** - * Return the total playing length for this playlist. - * - * @return the playing length in microseconds precision. - */ - virtual Ptr::Ref - getPlaylength(void) const throw () - { - return playlength; - } - - /** - * Return the URI of the SMIL file created from this - * playlist, which can be played by the audio player. - * - * @return the URI. - */ - virtual Ptr::Ref - getUri(void) const throw () - { - return uri; - } - - /** - * Set the URI of the SMIL file created from this - * playlist, which can be played by the audio player. - * - * @param uri the new URI. - */ - virtual void - setUri(Ptr::Ref uri) throw () - { - this->uri = uri; - } - - /** - * Return the token which is used to identify this - * playlist to the storage server. - * - * The token is set when the Playable object is acquired and - * unset (made null again) when it is released. - * - * @return the token. - */ - virtual Ptr::Ref - getToken(void) const throw () - { - return token; - } - - /** - * Set the token which is used to identify this - * playlist to the storage server. - * - * The token is set when the Playable object is acquired and - * unset (made null again) when it is released. - * - * @param token a new token. - */ - virtual void - setToken(Ptr::Ref token) - throw () - { - this->token = token; - } - - /** - * Return the token which is used to identify this - * playlist to the storage server. - * - * The edit token is set when the Playable object is opened for - * editing and unset (made null again) when it is saved or reverted. - * - * @return the token. - */ - virtual Ptr::Ref - getEditToken(void) const throw () - { - return editToken; - } - - /** - * Set the token which is used to identify this - * playlist to the storage server. - * - * The edit token is set when the Playable object is opened for - * editing and unset (made null again) when it is saved or reverted. - * - * @param token a new token. - */ - virtual void - setEditToken(Ptr::Ref token) - throw () - { - this->editToken = token; - } - - /** - * Test whether the playlist is locked for editing. - * - * @return true if the playlist is currently being edited - */ - bool - isLocked() const throw () - { - return (editToken.get() != 0); - } - - - /** - * The iterator type for this class. A Playlist::const_iterator - * is a (constant) pointer to a pair < time_duration, - * Ptr<PlaylistElement>::Ref >. - * If it is such an iterator, then it->second - * is the playlist element referenced by the iterator, and - * it->first is its relative offset in the playlist. - * The playlist elements are listed in the order of their relative - * offset (starting time). - * - * @see begin(), end(), find() - */ - typedef PlaylistElementListType::const_iterator const_iterator; - - /** - * Get an iterator pointing to the first playlist element. - */ - const_iterator - begin() const throw () - { - return elementList->begin(); - } - - /** - * Get an iterator pointing to one after the last playlist element. - */ - const_iterator - end() const throw () - { - return elementList->end(); - } - - /** - * Get an iterator pointing to the first playlist element at a given - * relative offset. - * - * @param relativeOffset (a pointer to) the relative offset where - * the playlist element is. - * @return a constant iterator to the playlist element if it exists, - * or this->end() if it does not. - */ - const_iterator - find(Ptr::Ref relativeOffset) const - throw () - { - return elementList->find(*relativeOffset); - } - - /** - * Return the number of playlist elements in the playlist. - */ - int - size() const throw () - { - return elementList->size(); - } - - /** - * Add a new audio clip or sub-playlist to the playlist. - * - * Checks the type of the playlist, and calls either addAudioClip() - * or addPlaylist(). - * - * @param playable the new playable item to be added - * @param relativeOffset the start of the playable item, relative - * to the start of the playlist - * @param fadeInfo the fade in / fade out info (optional) - * @return the ID of the new PlaylistElement - * @exception std::invalid_argument if playable is neither an AudioClip - * nor a Playlist - */ - Ptr::Ref - addPlayable(Ptr::Ref playable, - Ptr::Ref relativeOffset, - Ptr::Ref fadeInfo - = Ptr::Ref()) - throw (std::invalid_argument); - - /** - * Add a new audio clip to the playlist. - * - * The playlist is not checked for gaps (use valid() for that), - * but the playlength is adjusted if the new audio clip is added - * at the end of the playlist. - * - * @param audioClip the new audio clip to be added - * @param relativeOffset the start of the audio clip, relative - * to the start of the playlist - * @param fadeInfo the fade in / fade out info (optional) - * @return the ID of the new PlaylistElement - */ - Ptr::Ref - addAudioClip(Ptr::Ref audioClip, - Ptr::Ref relativeOffset, - Ptr::Ref fadeInfo - = Ptr::Ref()) - throw (); - - /** - * Add a new sub-playlist to the playlist. - * - * The playlist is not checked for gaps (use valid() for that), - * but the playlength is adjusted if the new sub-playlist is added - * at the end of the playlist. - * - * @param playlist the sub-playlist to be added - * @param relativeOffset the start of the sub-playlist, relative - * to the start of the containing playlist - * @param fadeInfo the fade in / fade out info (optional) - * @return the ID of the new PlaylistElement - */ - Ptr::Ref - addPlaylist(Ptr::Ref playlist, - Ptr::Ref relativeOffset, - Ptr::Ref fadeInfo - = Ptr::Ref()) - throw (); - - /** - * Add a new playlist element to the playlist. - * - * @param playlistElement the new playlist element to be added - */ - void - addPlaylistElement(Ptr::Ref playlistElement) - throw (); - - /** - * Set the fade in / fade out info for a playlist element. - * - * @param playlistElementId the ID of the playlist element - * @param fadeInfo the new fade in / fade out info - * @exception std::invalid_argument if there is no playlist element - * at the given relative offset - */ - void - setFadeInfo(Ptr::Ref playlistElementId, - Ptr::Ref fadeInfo) - throw (std::invalid_argument); - - /** - * Set clipStart for a playlist element. - * - */ - void - setClipStart(Ptr::Ref playlistElementId, - Ptr::Ref newStart) - throw (std::invalid_argument); - - /** - * Set clipEnd for a playlist element. - * - */ - void - setClipEnd(Ptr::Ref playlistElementId, - Ptr::Ref newEnd) - throw (std::invalid_argument); - - /** - * Remove a playlist element from the playlist. - * - * @param playlistElementId the ID of the playlist element - * @exception std::invalid_argument if the playlist element does not - * exist - */ - void - removePlaylistElement(Ptr::Ref playlistElementId) - throw (std::invalid_argument); - - /** - * Check if the playlist is valid. - * - * This means that - *
    - *
  • there are no gaps between the playlist elements - * (overlaps are allowed); and
  • - *
  • the length of the playlist is equal - * to the ending time of the last item in it.
  • - *
- * - * This is checked for the playlist itself, and all sub-playlists - * contained inside it. - * - * NOTE: all kinds of overlaps are allowed. - * TODO: restrict it somehow? - */ - bool - valid(void) const throw (); - - - /** - * Create a saved copy of this playlist. If a saved copy exists - * already, it is replaced by the current state. - */ - void - createSavedCopy(void) throw (); - - /** - * Delete the saved copy of the playlist, if exists (or do nothing). - */ - void - deleteSavedCopy(void) throw () - { - savedCopy.reset(); - } - - /** - * Revert to the saved copy of this playlist. If there is no - * saved copy, do nothing and throw an exception. - */ - void - revertToSavedCopy(void) throw (std::invalid_argument); - - - /** - * Return the value of a metadata field in this playlist. - * If the playlist does not have this metadata field, returns a null - * pointer. - * - * @param key the name of the metadata field - * @return the value of the metadata field; 0 if there is - * no such field; - */ - virtual Ptr::Ref - getMetadata(const std::string &key) const - throw (); - - /** - * Set the value of a metadata field in this playlist. - * - * @param value the new value of the metadata field. - * @param key the name of the metadata field - * @exception std::invalid_argument if the key is dcterms:extent, - * but the value is not a valid ISO-8601 time - */ - virtual void - setMetadata(Ptr::Ref value, - const std::string &key) - throw (std::invalid_argument); - - - /** - * Return a partial XML representation of this audio clip or playlist. - * - * This is a string containing a single <playlist> - * XML element, with minimal information { id, title, playlength } - * only, without an XML header or any other metadata. - * It does not contain the list of playlist elements in the playlist. - * - * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers, - * time durations have the format "hh:mm:ss.ssssss". - * - * @return a string representation of the playlist as an XML element - */ - virtual Ptr::Ref - getXmlElementString(void) const throw (); - - - /** - * Return a complete XML representation of this playlist. - * - * This is a string containing a an XML document with a - * <playlist> root node, together with an XML header and a - * <metadata> element (for the outermost playlist only). - * - * The playlist elements listed are only stubs returned by - * getXmlElementString(), i.e., { id, title, playlength } triples, - * without their contents. See the more detailed description at - * the top of this page. - * - * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers, - * time durations have the format "hh:mm:ss.ssssss". - * - * The uri, token and editToken fields are not - * part of the XML document string returned. - * - * @return a string representation of the playlist as an XML document - */ - virtual Ptr::Ref - getXmlDocumentString(void) const throw (); - - - /** - * Eliminate the gaps in the playlist. - * - * If there is a 2s gap between elements 2 and 3, then elements 3, - * 4, etc. are moved to 2s earlier. Elements 2 and 3 will not - * overlap, even if the first has a fade-out and the second has a - * fade-in. - * - * @return true if some gaps have been found and eliminated - */ - virtual bool - eliminateGaps(void) throw (); - - /** - * Find the playlist element at the specified offset. - * - * This is used by the Master Panel to display the contents - * of the currently playing Playlist. - * When there are more than one playlist elements at the given - * offset, the one with the greatest relativeOffset is chosen. - * Can return a 0 pointer if there is no playlist element at - * the given offset. - * - * @param offset the elapsed time relative to the Playlist. - * @return the playlist element at the given offset. - */ - Ptr::Ref - findAtOffset(Ptr::Ref offset) const - throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_Playlist_h - diff --git a/src/modules/core/include/LiveSupport/Core/PlaylistElement.h b/src/modules/core/include/LiveSupport/Core/PlaylistElement.h deleted file mode 100644 index 6a72d53b1..000000000 --- a/src/modules/core/include/LiveSupport/Core/PlaylistElement.h +++ /dev/null @@ -1,475 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_PlaylistElement_h -#define LiveSupport_Core_PlaylistElement_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include - -#include -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/UniqueId.h" -#include "LiveSupport/Core/Configurable.h" -#include "LiveSupport/Core/Playable.h" -#include "LiveSupport/Core/AudioClip.h" -#include "LiveSupport/Core/Playlist.h" -#include "LiveSupport/Core/FadeInfo.h" - - -namespace LiveSupport { -namespace Core { - -using namespace boost::posix_time; - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -// forward declaration to avoid circular reference -class Playlist; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * An item in a Playlist, consisting of an AudioClip or another Playlist - * and optional FadeInfo (fade in / fade out information). - * - * The contents of the playlist element can be accessed either by calling - * getPlayable(), or, if a specific type of element is needed, by checking - * getType() first, and then calling either getAudioClip() or getPlaylist(). - * - * This object has to be configured with an XML configuration element - * called playlistElement. This may look like the following: - * - *

- *  <playlistElement id="707" relativeOffset="00:12:34.000000" >
- *      <audioClip> ... </audioClip>
- *      <fadeInfo> ... </fadeInfo>
- *  </playlist>
- *  
- * - * For detais of the audioClip and fadeInfo elements, see the documentation - * for the AudioClip and FadeInfo classes. - * - * The DTD for the above element is: - * - *

- *  <!ELEMENT playlistElement ((audioClip|playlist), fadeInfo?) >
- *  <!ATTLIST playlistElement  id              NMTOKEN   #REQUIRED  >
- *  <!ATTLIST playlistElement  relativeOffset  NMTOKEN   #REQUIRED  >
- *  
- */ -class PlaylistElement : public Configurable -{ - public: - /** - * The possible types of the playlist element (audio clip or - * sub-playlist). - */ - enum Type { AudioClipType, PlaylistType }; - - private: - /** - * The name of the configuration XML element used by Playlist. - */ - static const std::string configElementNameStr; - - /** - * The id of the playlist element. - */ - Ptr::Ref id; - - /** - * The starting time of the event. - */ - Ptr::Ref relativeOffset; - Ptr::Ref clipStart; - Ptr::Ref clipEnd; - Ptr::Ref clipLength; - - /** - * The type of the entry (audio clip or sub-playlist). - */ - Type type; - - /** - * The generic playable object associated with the entry. - * This is either an audio clip or a playlist. - */ - Ptr::Ref playable; - - /** - * The audio clip associated with the entry. - */ - Ptr::Ref audioClip; - - /** - * The playlist associated with the entry. - */ - Ptr::Ref playlist; - - /** - * The fade in / fade out info associated with the entry. - */ - Ptr::Ref fadeInfo; - - /** - * Convert a time_duration to string, in format HH:MM:SS.ssssss. - */ - std::string - toFixedString(Ptr::Ref time) const throw () - { - if (time->fractional_seconds()) { - return to_simple_string(*time); - } else { - return to_simple_string(*time) + ".000000"; - } - } - - - public: - - /** - * The default constructor. - */ - PlaylistElement(void) throw (); - - /** - * Create a playlist element by specifying all details. - * This is used for testing purposes. - * - * @param id the id of the entry. - * @param relativeOffset the start time of this element, relative to - * the start of the playlist. - * @param audioClip (a pointer to) the audio clip associated - * with the playlist element. - * @param fadeInfo fade in / fade out information (optional) - */ - PlaylistElement(Ptr::Ref id, - Ptr::Ref relativeOffset, - Ptr::Ref clipLength, - Ptr::Ref audioClip, - Ptr::Ref fadeInfo - = Ptr::Ref()) - throw (); - - /** - * Create a new audio clip playlist element, with a new UniqueId, - * to be added to a playlist. - * - * @param relativeOffset the start time of this element, relative to - * the start of the playlist. - * @param audioClip (a pointer to) the audio clip associated - * with the playlist element. - * @param fadeInfo fade in / fade out information (optional) - */ - PlaylistElement(Ptr::Ref relativeOffset, - Ptr::Ref clipLength, - Ptr::Ref audioClip, - Ptr::Ref fadeInfo - = Ptr::Ref()) - throw (); - - /** - * Create a new sub-playlist playlist element, with a new UniqueId, - * to be added to a playlist. - * - * @param relativeOffset the start time of this element, relative to - * the start of the playlist. - * @param playlist (a pointer to) the sub-playlist associated - * with the playlist element. - * @param fadeInfo fade in / fade out information (optional) - */ - PlaylistElement(Ptr::Ref relativeOffset, - Ptr::Ref clipLength, - Ptr::Ref playlist, - Ptr::Ref fadeInfo - = Ptr::Ref()) - throw (); - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~PlaylistElement(void) throw (); - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementNameStr; - } - - /** - * Configure the object based on the XML element supplied. - * The supplied element is expected to be of the name - * returned by configElementName(). - * - * @param element the XML element to configure the object from. - * @exception std::invalid_argument if the supplied XML element - * contains bad configuration information - */ - virtual void - configure(const xmlpp::Element & element) - throw (std::invalid_argument); - - /** - * Return the id of the playlist element. - * - * @return the id of the playlist element. - */ - Ptr::Ref - getId(void) const throw () - { - return id; - } - - /** - * Set the relative offset of the playlist element. - * Note: this is very dangerous; use only if you know what you are - * doing. Never ever change the relative offset of a PlaylistElement - * which is contained in a Playlist. - * - * @param newOffset the new relative offset of the element. - */ - void - setRelativeOffset(Ptr::Ref newOffset) - throw () - { - relativeOffset = newOffset; - } - - /** - * Return the relative offset of the playlist element. - * - * @return the relative offset of the element. - */ - Ptr::Ref - getRelativeOffset(void) const throw () - { - return relativeOffset; - } - - /** - */ - void - setClipStart(Ptr::Ref newStart) - throw () - { - clipStart = newStart; - } - - /** - */ - Ptr::Ref - getClipStart(void) const throw () - { - return clipStart; - } - - /** - */ - void - setClipEnd(Ptr::Ref newEnd) - throw () - { - clipEnd = newEnd; - } - - /** - */ - Ptr::Ref - getClipEnd(void) const throw () - { - return clipEnd; - } - - /** - */ - void - setClipLength(Ptr::Ref newLength) - throw () - { - clipLength = newLength; - } - - /** - */ - Ptr::Ref - getClipLength(void) const throw () - { - return clipLength; - } - - /** - * Return the type of this playlist element. If the return - * value is PlaylistElement::AudioClipType (resp. PlaylistType), - * the getAudioClip() (resp. getPlaylist()) - * method is guaranteed to return a non-zero value. - * - * @return either AudioClipType or PlaylistType. - */ - Type - getType(void) const throw () - { - return type; - } - - /** - * Return the Playable instance (an AudioClip or a Playlist) - * associated with the playlist element. Use this if you don't - * care which type this playlist element is, e.g., you - * just want to play it in an audio player. - * - * @return the Playable instance associated with the element. - */ - Ptr::Ref - getPlayable(void) const throw () - { - return playable; - } - - /** - * Set the Playable instance (an AudioClip or a Playlist) - * associated with the playlist element. - * - * This is used by WebStorageClient::acquirePlaylist() to replace - * a stub (id, title, playlength only) sub-playlist with a full one. - * - * @param playable the new Playable object. - */ - void - setPlayable(Ptr::Ref playable) throw () - { - this->playable = playable; - switch (playable->getType()) { - case Playable::AudioClipType : - audioClip = playable->getAudioClip(); - type = AudioClipType; - break; - case Playable::PlaylistType : - playlist = playable->getPlaylist(); - type = PlaylistType; - break; - } - } - - /** - * Return the audio clip associated with the playlist element. - * - * @see getType() - * @return the audio clip associated with the element. - */ - Ptr::Ref - getAudioClip(void) const throw () - { - return audioClip; - } - - /** - * Return the sub-playlist associated with the playlist element. - * - * @see getType() - * @return the sub-playlist associated with the element. - */ - Ptr::Ref - getPlaylist(void) const throw () - { - return playlist; - } - - /** - * Set the fade info associated with the playlist element. - * - * @param fadeInfo the fade info to be associated with the element. - */ - void - setFadeInfo(Ptr::Ref fadeInfo) throw () - { - this->fadeInfo = fadeInfo; - } - - /** - * Return the fade info associated with the playlist element. - * - * @return the fade info associated with the element. - */ - Ptr::Ref - getFadeInfo(void) const throw () - { - return fadeInfo; - } - - - /** - * Return an XML representation of this playlist element. - * - * This is a string containing a single - * XML element, with its ID and relativeOffset attributes, - * plus an or XML element, - * plus an optional element. - * - * The encoding is UTF-8. IDs are 16-digit hexadecimal numbers, - * time durations have the format "hh:mm:ss.ssssss". - * - * @return a string representation of the audio clip as an XML element - */ - Ptr::Ref - getXmlElementString(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_PlaylistElement_h - diff --git a/src/modules/core/include/LiveSupport/Core/Ptr.h b/src/modules/core/include/LiveSupport/Core/Ptr.h deleted file mode 100644 index dd001c9d6..000000000 --- a/src/modules/core/include/LiveSupport/Core/Ptr.h +++ /dev/null @@ -1,99 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Ptr_h -#define LiveSupport_Core_Ptr_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A placeholder class for holidng typedefs to smart pointers. - * This is a workaround, as unfortunately typedfs in themselves may - * not be templated. For a discussion on the issue, see - * http://www.gotw.ca/gotw/079.htm - * - * The smart pointers here are typedefs to the smart pointers in the - * boost library. For documentation of the boost smart pointers, - * see http://www.boost.org/libs/smart_ptr/ - */ -template -class Ptr -{ - private: - /** - * Default constructor. - */ - Ptr(void) throw () - { - } - - - public: - /** - * This is actually a typedef to the boost shared_ptr, which - * is a reference counting shared smart pointer. - * For more on boost::shared_ptr, see - * http://www.boost.org/libs/smart_ptr/shared_ptr.htm - * - * To use this pointer, define as follows: - * - * Ptr::Ref myPointer; - * - */ - typedef boost::shared_ptr Ref; -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_Ptr_h - diff --git a/src/modules/core/include/LiveSupport/Core/RdsContainer.h b/src/modules/core/include/LiveSupport/Core/RdsContainer.h deleted file mode 100644 index d896dd69f..000000000 --- a/src/modules/core/include/LiveSupport/Core/RdsContainer.h +++ /dev/null @@ -1,239 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_RdsContainer_h -#define LiveSupport_Core_RdsContainer_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/Configurable.h" - -#include "LiveSupport/Core/RdsItem.h" - - -namespace LiveSupport { -namespace Core { - -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Container holding RdsItem objects. - * - * It is used by the OptionContainer class to hold RDS strings - * (see http://en.wikipedia.org/wiki/Radio_Data_System). - * - * This object has to be configured with an XML configuration element - * called rdsContainer. This may look like the following: - * - *

- *  <rdsContainer>
- *      <rdsItem> ... </rdsItem>
- *      <rdsItem> ... </rdsItem>
- *      ...
- *      <rdsItem> ... </rdsItem>
- *  </rdsContainer>
- *  
- * - * The DTD for the expected XML element is the following: - * - *

- *  
- *  
- * - * For a description of the rdsItem XML element, see the documentation - * of the RdsItem class. - * - * @see KeyboardShortcut - */ -class RdsContainer : public Configurable -{ - private: - /** - * The name of the configuration XML element used by - * RdsContainer. - */ - static const std::string configElementName; - - /** - * A vector type holding contant KeyboardShortcut references. - */ - typedef std::vector::Ref> - RdsItemListType; - - /** - * The list of all RdsItem references. - */ - RdsItemListType rdsItemList; - - /** - * An XML document used by toXmlElement(). - */ - Ptr::Ref xmlDocument; - - /** - * Set to true by setRdsString(), and to false by toXmlElement(). - */ - bool touched; - - - public: - /** - * Constructor. - */ - RdsContainer() throw () - : touched(false) - { - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~RdsContainer(void) throw () - { - } - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementName; - } - - /** - * Configure the object based on an XML configuration element. - * - * @param element the XML configuration element. - * @exception std::invalid_argument if the supplied XML element - * contains bad configuration information. - */ - virtual void - configure(const xmlpp::Element &element) - throw (std::invalid_argument); - - /** - * Set the value of the RDS options. - * The key can be any of the RDS data codes, like PS, PI, PTY, RT, - * etc. If there is already a value set for this code, it gets - * overwritten, otherwise a new key-value pair is added. - * - * @param key which setting to modify. - * @param value the new value of the RDS setting. - * @param enabled whether this value will be broadcast. - */ - void - setRdsOptions(Ptr::Ref key, - Ptr::Ref value, - bool enabled) throw (); - - /** - * Get the value of an RDS string. - * The key can be any of the RDS data codes, like PS, PI, PTY, RT, - * etc. - * - * @param key which setting to modify. - * @return the value of the RDS setting. - * @exception std::invalid_argument if there is no such RDS option. - */ - Ptr::Ref - getRdsValue(Ptr::Ref key) - throw (std::invalid_argument); - - /** - * Get the enabled/disabled state of an RDS option. - * - * @param key which setting to modify. - * @return true if the RDS option is enabled, false otherwise. - * @exception std::invalid_argument if there is no such RDS option. - */ - bool - getRdsEnabled(Ptr::Ref key) - throw (std::invalid_argument); - - /** - * Convert the object to a string. - * - * @return a string which can be sent to the RDS encoder. - */ - Ptr::Ref - toString(void) throw (); - - /** - * Convert the object to XML. - * - * @return an XML Element, which can be passed to configure() - * to create an object identical to this one. - */ - const xmlpp::Element * - toXmlElement(void) throw (); - - /** - * Tells you whether the object has been touched since the last save. - * Starts out false; set to true by setRdsString() and set back to - * false by toXmlElement(). - * - * @return whether the object has been touched. - */ - bool - isTouched(void) throw () - { - return touched; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_RdsContainer_h - diff --git a/src/modules/core/include/LiveSupport/Core/RdsItem.h b/src/modules/core/include/LiveSupport/Core/RdsItem.h deleted file mode 100644 index e09e3de61..000000000 --- a/src/modules/core/include/LiveSupport/Core/RdsItem.h +++ /dev/null @@ -1,277 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_RdsItem_h -#define LiveSupport_Core_RdsItem_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/Configurable.h" - - -namespace LiveSupport { -namespace Core { - -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class for representing an RDS key - value pair. - * - * This object has to be configured with an XML configuration element - * called rdsItem. This may look like the following: - * - *

- *  <rdsItem     key     = "PS"
- *                  value   = "BBC Four"
- *                  enabled = "1" />
- *  
- * - * The possible key values are PS, PI, RT, etc - * (see http://en.wikipedia.org/wiki/Radio_Data_System). - * - * There value attribute can be any string. - * - * The enabled attribute is either 0 (disabled) or 1 (enabled). - * - * The DTD for the expected XML element looks like the following: - * - *

- *  <!ELEMENT rdsItem   EMPTY >
- *  <!ATTLIST rdsItem   key      CDATA   #REQUIRED >
- *  <!ATTLIST rdsItem   value    CDATA   #REQUIRED >
- *  <!ATTLIST rdsItem   enabled  CDATA   #REQUIRED >
- *  
- * - * @see RdsItemContainer - */ -class RdsItem : public Configurable -{ - private: - /** - * The name of the configuration XML element used by RdsItem. - */ - static const std::string configElementName; - - /** - * The key for this RDS item. - */ - Ptr::Ref key; - - /** - * The value for this RDS item. - */ - Ptr::Ref value; - - /** - * The enabled/disabled attribute for this RDS item. - */ - bool enabled; - - /** - * An XML document used by toXmlElement(). - */ - Ptr::Ref xmlDocument; - - /** - * Set to true by setValue(), and to false by toXmlElement(). - */ - bool touched; - - - public: - /** - * Default constructor. - */ - RdsItem() throw () - : enabled(false), - touched(false) - { - } - - /** - * Constructor which sets the variables. - */ - RdsItem(Ptr::Ref key, - Ptr::Ref value, - bool enabled = false) throw () - : key(key), - value(value), - enabled(enabled), - touched(false) - { - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~RdsItem(void) throw () - { - } - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return configElementName; - } - - /** - * Configure the object based on an XML configuration element. - * - * @param element the XML configuration element. - * @exception std::invalid_argument if the supplied XML element - * contains bad configuration information - */ - virtual void - configure(const xmlpp::Element &element) - throw (std::invalid_argument); - - /** - * Get the key. - * The key can be a 0 pointer if the object has not been - * configured yet. - * - * @return the key of this RDS item. - */ - Ptr::Ref - getKey(void) throw () - { - return key; - } - - /** - * Get the value. - * The value can be a 0 pointer if the object has not been - * configured yet. - * - * @return the key of this RDS item. - */ - Ptr::Ref - getValue(void) throw () - { - return value; - } - - /** - * Set the value. - * - * @param value the new value of this RDS item. - */ - void - setValue(Ptr::Ref value) throw () - { - this->value = value; - touched = true; - } - - /** - * Get the enabled/disabled flag. - * - * @return true if the RDS item is enabled, false if not. - */ - bool - getEnabled(void) throw () - { - return enabled; - } - - /** - * Set the enabled/disabled flag. - * - * @param enabled the new value of the flag. - */ - void - setEnabled(bool enabled) throw () - { - this->enabled = enabled; - touched = true; - } - - /** - * Convert the object to a string. - * - * @return a string which can be sent to the RDS encoder. - */ - Ptr::Ref - toString(void) throw (); - - /** - * Convert the object to XML. - * - * @return an XML Element, which can be passed to configure() - * to create an object identical to this one. - */ - const xmlpp::Element * - toXmlElement(void) throw (); - - /** - * Tells you whether the object has been touched since the last save. - * Starts out false; set to true by setValue() and setEnabled(); - * set back to false by toXmlElement(). - * - * @return whether the object has been touched. - */ - bool - isTouched(void) throw () - { - return touched; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_RdsItem_h - diff --git a/src/modules/core/include/LiveSupport/Core/RunnableInterface.h b/src/modules/core/include/LiveSupport/Core/RunnableInterface.h deleted file mode 100644 index d44ef384f..000000000 --- a/src/modules/core/include/LiveSupport/Core/RunnableInterface.h +++ /dev/null @@ -1,100 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_RunnableInterface_h -#define LiveSupport_Core_RunnableInterface_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A Runnable object, that can form the main execution body of a thread. - * - * @see Thread - */ -class RunnableInterface -{ - public: - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~RunnableInterface(void) throw () - { - } - - /** - * The main execution loop for the thread. - */ - virtual void - run(void) throw () = 0; - - /** - * Send a signal to the runnable object. - * - * @param userData user-specific parameter for the signal. - */ - virtual void - signal(int userData) throw () = 0; - - /** - * Signal the thread to stop, gracefully. - * This is just a call to signal the execution to stop, eventually. - */ - virtual void - stop(void) throw () = 0; -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - - -#endif // LiveSupport_Core_RunnableInterface_h - diff --git a/src/modules/core/include/LiveSupport/Core/ScheduleEntry.h b/src/modules/core/include/LiveSupport/Core/ScheduleEntry.h deleted file mode 100644 index 9f151097e..000000000 --- a/src/modules/core/include/LiveSupport/Core/ScheduleEntry.h +++ /dev/null @@ -1,272 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_ScheduleEntry_h -#define LiveSupport_Core_ScheduleEntry_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include -#include -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/UniqueId.h" - - -namespace LiveSupport { -namespace Core { - -using namespace boost::posix_time; - -using namespace LiveSupport; - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A scheduled event. - */ -class ScheduleEntry -{ - private: - /** - * The name of the schedule entry element - */ - static const std::string scheduleEntryElementName; - - /** - * The name of the id attribute in the schedule entry element - */ - static const std::string idAttrName; - - /** - * The name of the playlist attribute in the schedule entry element - */ - static const std::string playlistIdAttrName; - - /** - * The name of the startTime attribute in the schedule entry element - */ - static const std::string startTimeAttrName; - - /** - * The name of the endTime attribute in the schedule entry element - */ - static const std::string endTimeAttrName; - - /** - * The name of the playlength attribute in the schedule entry element - */ - static const std::string playlengthAttrName; - - /** - * The id of the schedule entry. - */ - Ptr::Ref id; - - /** - * The id of the playlist associated with the entry. - */ - Ptr::Ref playlistId; - - /** - * The starting time of the event. - */ - Ptr::Ref startTime; - - /** - * The end time for the event. - */ - Ptr::Ref endTime; - - /** - * The playling length of the event. - */ - Ptr::Ref playlength; - - /** - * The default constructor. - */ - ScheduleEntry(void) throw () - { - } - - - public: - - /** - * A constructor with initialization values. - * - * @param id the id of the entry. - * @param playlistId the id of the playlist associated with the entry. - * @param startTime the starting time for the entry. - * @param endTime the ending time for the entry. - */ - ScheduleEntry(Ptr::Ref id, - Ptr::Ref playlistId, - Ptr::Ref startTime, - Ptr::Ref endTime) - throw () - { - this->id = id; - this->playlistId = playlistId; - this->startTime = startTime; - this->endTime = endTime; - - playlength.reset(new time_duration(*endTime - *startTime)); - } - - /** - * A constructor based on a DOM element - * - * @param element a DOM element returned earlier by a - * toDom() call from another schedule entry. - * @throws std::invalid_argument in case of a bad DOM element - * @see #getElementName - * @see #toDom - */ - ScheduleEntry(xmlpp::Element * element) - throw (std::invalid_argument); - - /** - * Return the name of the DOM element used to export / import - * a schedule entry. - * - * @return the DOM element name used at export / import. - */ - static const std::string - getElementName(void) throw () - { - return scheduleEntryElementName; - } - - /** - * Return the id of the entry. - * - * @return the id of the entry. - */ - Ptr::Ref - getId(void) const throw () - { - return id; - } - - /** - * Return the id of the playlist associated with the entry. - * - * @return the id of the playlist associated with the entry. - */ - Ptr::Ref - getPlaylistId(void) const throw () - { - return playlistId; - } - - /** - * Return the starting time for the entry. - * - * @return the starting time for the entry. - */ - Ptr::Ref - getStartTime(void) const throw () - { - return startTime; - } - - /** - * Return the ending time for the entry. - * - * @return the ending time for the entry. - */ - Ptr::Ref - getEndTime(void) const throw () - { - return endTime; - } - - /** - * Return the playlength of the schedule entry. - * - * @return the playing length of the schedule entry. - */ - Ptr::Ref - getPlaylength(void) const throw () - { - return playlength; - } - - /** - * Return a DOM representation of this object. - * Can be used to serialize or generate another object with - * a DOM-based constructor. - * - * @param element the new DOM node will be a new child of this - * element. - * @see #getElementName - */ - void - toDom(xmlpp::Element * element) const throw (); - - /** - * Compare a schedule entry to another one. - * - * @param other the other entry to compare to. - */ - bool - operator==(const ScheduleEntry & other) const throw () - { - return *id == *other.id - && *playlistId == *other.playlistId - && *startTime == *other.startTime - && *endTime == *other.endTime - && *playlength == *other.playlength; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_ScheduleEntry_h - diff --git a/src/modules/core/include/LiveSupport/Core/SearchCriteria.h b/src/modules/core/include/LiveSupport/Core/SearchCriteria.h deleted file mode 100644 index 853e2246b..000000000 --- a/src/modules/core/include/LiveSupport/Core/SearchCriteria.h +++ /dev/null @@ -1,396 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_SearchCriteria_h -#define LiveSupport_Core_SearchCriteria_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" - -// forward declaration of friend class -namespace LiveSupport { -namespace StorageClient { - class TestStorageClient; -} } - -namespace LiveSupport { -namespace Core { - -using namespace boost::posix_time; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * An object which contains a collection of search conditions. - * - * Its fields are: - *
    - *
  • type - values in (audioClip | playlist | all); the default is - * all
  • - *
  • operator - values in (and | or); the default is and
  • - *
  • condition1 : { key : string, comparison: string, value : string } - * - a search condition, where key is one of the - * fields in the metadata, and comparison is - * one of ("=" | "partial" | "prefix" - * | "<" | "<=" | ">" | ">=")
  • - *
  • ...
  • - *
  • conditionN
  • - *
  • limit : int - the maximum number of results to be returned; - * the default is 0, which means unlimited
  • - *
  • offset : int - ignore the first offset matches; - * the default is 0.
  • - *
- * - * Usage: construct a SearchCriteria object either directly using the - * constructor with 4 string arguments, or in several steps using - * addCondition() and the setter methods; - * then pass this object to StorageClientInterface::search() - * to search the local storage. - * - * The key and value fields are case-sensitive, all the other - * strings (type, operator names) are case-insensitive. - */ -class SearchCriteria -{ - public: - - /** - * A type to hold a single search condition. - */ - struct SearchConditionType - { - std::string key; - std::string comparisonOperator; - std::string value; - - SearchConditionType(const std::string & key, - const std::string & comparisonOperator, - const std::string & value) - : key(key), comparisonOperator(comparisonOperator), value(value) - { - } - }; - - private: - - /** - * The kind of object we are searching for. - */ - std::string type; - - /** - * The logical operator joining the conditions: "and" or "or". - */ - std::string logicalOperator; - - /** - * A type to hold the list of search conditions. - */ - typedef std::vector - SearchConditionListType; - - /** - * The vector of search conditions. - */ - SearchConditionListType searchConditions; - - /** - * The mtime to use for "ls:mtime". - */ - Ptr::Ref mtimeValue; - - /** - * The comparison operator to use for "ls:mtime". - */ - std::string mtimeComparisonOperator; - - /** - * The maximum number of conditions to be returned. - */ - int limit; - - /** - * The index of the first matching condition to be returned. - */ - int offset; - - /** - * Lowercase a string. - */ - std::string - lowerCase(const std::string & s) throw() - { - std::string returnValue; - std::string::const_iterator it = s.begin(); - while (it != s.end()) { - returnValue += std::tolower(*it); - ++it; - } - return returnValue; - } - - /** - * Give access of private members to the TestStorageClient. - */ - friend class LiveSupport::StorageClient::TestStorageClient; - - /** - * Add a search condition. - * - * @param xmlRpcValue the condition to add. - * @exception std::invalid_argument on syntax errors. - */ - void - addCondition(const XmlRpc::XmlRpcValue & xmlRpcValue) - throw(std::invalid_argument); - - - public: - - /** - * Construct an empty SearchCriteria object. - * This also works as a default constructor. - * - * @param type one of "audioClip" (default), "playlist" or "all" - * @param logicalOperator either "and" (default) or "or" - * @exception std::invalid_argument on syntax errors. - */ - SearchCriteria(const std::string & type = "all", - const std::string & logicalOperator = "and") - throw(std::invalid_argument) - : limit(0), offset(0) - { - setType(type); - setLogicalOperator(logicalOperator); - } - - /** - * Construct a SearchCriteria object with a single condition. - * - * @param type one of "audioClip", "playlist" or "all" - * @param key the metadata field to search in - * @param comparisonOperator one of "=", "partial", "prefix", - * "<", "<=", ">" or ">=" - * @param value the value to compare to - * @exception std::invalid_argument on syntax errors. - */ - SearchCriteria(const std::string & type, - const std::string & key, - const std::string & comparisonOperator, - const std::string & value) - throw(std::invalid_argument); - - /** - * Construct a SearchCriteria object from an XmlRpcValue. - * - * @param xmlRpcValue an XmlRpcValue struct, containing - * the search criteria. - * @exception std::invalid_argument on syntax errors. - */ - SearchCriteria(const XmlRpc::XmlRpcValue & xmlRpcValue) - throw(std::invalid_argument); - - /** - * Set the type field. - * - * @param type one of "audioClip", "playlist" or "all" - * @exception std::invalid_argument on syntax errors. - */ - void - setType(const std::string & type) - throw(std::invalid_argument) - { - std::string lowerCaseType = lowerCase(type); - if (lowerCaseType == "audioclip" - || lowerCaseType == "playlist" - || lowerCaseType == "all") { - this->type = lowerCaseType; - } else { - throw std::invalid_argument("bad type argument"); - } - - } - - /** - * Set the logical operator field. - * - * @param logicalOperator either "and" or "or" - * @exception std::invalid_argument on syntax errors. - */ - void - setLogicalOperator(const std::string & logicalOperator) - throw(std::invalid_argument) - { - std::string lowerCaseOp = lowerCase(logicalOperator); - if (lowerCaseOp == "and" || lowerCaseOp == "or") { - this->logicalOperator = lowerCaseOp; - } else { - throw std::invalid_argument("bad logical operator argument"); - } - } - - /** - * Add a search condition. - * - * @param key the metadata field to search in - * @param comparisonOperator one of "=", "partial", "prefix", - * "<", "<=", ">" or ">=" - * @param value the value to compare to - * @exception std::invalid_argument on syntax errors. - */ - void - addCondition(const std::string & key, - const std::string & comparisonOperator, - const std::string & value) - throw(std::invalid_argument); - - /** - * Add a search condition specifying the mtime (modified-at time). - * - * @param comparisonOperator one of "=", "partial", "prefix", - * "<", "<=", ">" or ">=" - * @param value the value of the mtime to compare to - * @exception std::invalid_argument on syntax errors. - */ - void - addMtimeCondition(const std::string & comparisonOperator, - Ptr::Ref value) - throw(std::invalid_argument); - - /** - * Add a search condition. - * - * @param condition the search condition to add - * @exception std::invalid_argument on syntax errors. - */ - void - addCondition(const Ptr::Ref condition) - throw(std::invalid_argument) - { - addCondition(condition->key, - condition->comparisonOperator, - condition->value); - } - - /** - * Get the limit field. - * - * @return the maximum number of search results to be returned - */ - int - getLimit() throw() - { - return limit; - } - - /** - * Set the limit field. - * - * @param limit the maximum number of search results to be returned - * @exception std::invalid_argument on syntax errors. - */ - void - setLimit(const int limit) - throw(std::invalid_argument) - { - if (limit >= 0) { - this->limit = limit; - } else { - throw std::invalid_argument("bad argument: less than zero"); - } - } - - /** - * Get the offset field. - * - * @return the index of the first matching condition - * to be returned (first = 0) - */ - int - getOffset() throw() - { - return offset; - } - - /** - * Set the offset field. - * - * @param offset the index of the first matching condition - * to be returned (first = 0) - * @exception std::invalid_argument on syntax errors. - */ - void - setOffset(const int offset) - throw(std::invalid_argument) - { - if (offset >= 0) { - this->offset = offset; - } else { - throw std::invalid_argument("bad argument: less than zero"); - } - } - - /** - * Convert to an XmlRpc::XmlRpcValue. - */ - operator XmlRpc::XmlRpcValue() const throw(); - - /** - * Check two SearchCriteria objects for equality. - */ - bool - operator ==(const SearchCriteria & other) const throw(); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_SearchCriteria_h - diff --git a/src/modules/core/include/LiveSupport/Core/SessionId.h b/src/modules/core/include/LiveSupport/Core/SessionId.h deleted file mode 100644 index ecae2e15c..000000000 --- a/src/modules/core/include/LiveSupport/Core/SessionId.h +++ /dev/null @@ -1,151 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_SessionId_h -#define LiveSupport_Core_SessionId_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class representing session identifiers. - */ -class SessionId -{ - private: - /** - * The value of the session ID. - */ - std::string id; - - /** - * Default constructor. - */ - SessionId(void) throw () - { - } - - - public: - /** - * The type for the value the session id is represented in. - */ - typedef std::string IdType; - - /** - * Constructor to create a SessionId with a specific value. - * - * @param id the value of the created id object. - */ - SessionId(const IdType id) throw () - { - this->id = id; - } - - /** - * Compare this is with an other one. - * - * @param otherId the other unqiue id to compare to. - * @return true if this another sessionId have the same value, - * false otherwise. - */ - bool - operator==(const SessionId & otherId) const - throw () - { - return this->id == otherId.id; - } - - /** - * Compare this is with an other one. - * - * @param otherId the other unqiue id to compare to. - * @return true if this another sessionId do not have the same value, - * false otherwise. - */ - bool - operator!=(const SessionId & otherId) const - throw () - { - return this->id != otherId.id; - } - - /** - * Compare this id with an other one. - * - * @param otherId the other session id to compare to. - * @return true if this id is smaller than the other one, - * false otherwise. - */ - bool - operator<(const SessionId & otherId) const - throw () - { - return this->id < otherId.id; - } - - /** - * Return the (string) value of this session ID. - * - * @return the value of this id. - */ - const IdType - getId(void) const throw () - { - return id; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_SessionId_h - diff --git a/src/modules/core/include/LiveSupport/Core/Thread.h b/src/modules/core/include/LiveSupport/Core/Thread.h deleted file mode 100644 index 5c88f7e5f..000000000 --- a/src/modules/core/include/LiveSupport/Core/Thread.h +++ /dev/null @@ -1,173 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Thread_h -#define LiveSupport_Core_Thread_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/RunnableInterface.h" - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A generic thread executor class. - * - * @see RunnableInterface - */ -class Thread -{ - private: - /** - * The POSIX thread for this object. - */ - pthread_t thread; - - /** - * The Runnable object, that constitutes the main running body - * of the thread. - */ - Ptr::Ref runnable; - - /** - * Default constructor. - */ - Thread(void) throw () - { - } - - /** - * The thread function for the POSIX thread interface. - * - * @param thread pointer to this thread instance. - * @return always 0 - */ - static void * - posixThreadFunction(void * thread) throw (); - - public: - /** - * Constructor. - * - * @param runnable the Runnable object making up the execution - * part of the thread. - */ - Thread(Ptr::Ref runnable) throw (); - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~Thread(void) throw () - { - } - - /** - * Start the execution of the thread. - * This funcion will create a new thread and starts executing - * it by the run() function of the Runnable object. Start will - * return immediately. - * - * @exception std::exception if the thread could not be started. - */ - virtual void - start(void) throw (std::exception); - - /** - * Signal the thread to stop, gracefully. - * This is just a call to signal the execution to stop, eventually. - * The thread still has to be joined after calling stop(). - * - * @see #join - */ - virtual void - stop(void) throw () - { - runnable->stop(); - } - - /** - * Force the current thread to relinquish use of its processor. - * So that other threads get a chance to run. - */ - static void - yield(void) throw () - { - pthread_yield(); - } - - /** - * Join the thread. - * Wait for the thread to terminate and free up all its resources. - */ - virtual void - join(void) throw (); - - /** - * Send a signal to the runnable object inside this thread. - * - * @param userData user-specific parameter for the signal. - */ - virtual void - signal(int userData) throw () - { - runnable->signal(userData); - } - -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - - -#endif // LiveSupport_Core_Thread_h - diff --git a/src/modules/core/include/LiveSupport/Core/TimeConversion.h b/src/modules/core/include/LiveSupport/Core/TimeConversion.h deleted file mode 100644 index e7f9bf659..000000000 --- a/src/modules/core/include/LiveSupport/Core/TimeConversion.h +++ /dev/null @@ -1,280 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_TimeConversion_h -#define LiveSupport_Core_TimeConversion_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_SYS_TIME_H -#include -#else -#error need sys/time.h -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" - - -namespace LiveSupport { -namespace Core { - -using namespace boost::posix_time; - -using namespace LiveSupport; - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A helper object holding static time conversion functions. - * - * TODO: clean this up, and use the boost conversion functions, instead of - * converting stuff manually - * (see http://boost.org/doc/html/date_time/posix_time.html). - * - */ -class TimeConversion -{ - private: - /** - * Parse a time string. - * - * It cuts off the portion between the end of the string and the last - * occurrence of the separator character. For example, if called with - * the parameters "00:01:02" and ':', the function returns "02" and - * truncates the original string to "00:01". - * - * If the separator character is not found in timeString, - * a copy of the whole timeString is returned, and the - * original timeString is changed to the empty string. - * - * @param timeString the input argument; on return, the rest of the - * string, after the return value cut off - * @param separator a separator character, usually ':' - * @return the part of the string which was cut off - */ - static Ptr::Ref - nextNumberFromEnd(Ptr::Ref timeString, - char separator) throw (); - - /** - * Parse a decimal string. - * - * It cuts off the portion between the end of the string and the last - * occurrence of the separator character. For example, if called with - * the parameters "1.23" and '.', the function returns "23" and - * truncates the original string to "1". - * - * If the separator character is not found in timeString, - * then an empty string is returned, and the - * original timeString remains unchanged. - * - * @param decimalString the input argument; on return, the rest of - * the string, after the return value cut off - * @param separator a separator character, usually '.' - * @return the part of the string which was cut off - */ - static Ptr::Ref - nextNumberFromStart(Ptr::Ref decimalString, - char separator) throw (); - - /** - * The default constructor. - */ - TimeConversion(void) throw () - { - } - - - public: - /** - * Convert a struct timeval to a boost::posix_time::ptime, - * with microsecond precision. - * - * @param timeval the struct timeval to convert. - * @return a boost::posix_time::ptime, holding the same time. - * @exception std::out_of_range if timeval represents a time that - * can not be handled by ptime - */ - static Ptr::Ref - timevalToPtime(const struct timeval *timeval) - throw (std::out_of_range); - - /** - * Convert a struct tm to a boost::posix_time::ptime, - * with second precision. - * - * @param time the struct tm to convert. - * @return a boost::posix_time::ptime, holding the same time. - * @exception std::out_of_range if time represents a time that - * can not be handled by ptime - */ - static Ptr::Ref - tmToPtime(const struct tm *time) - throw (std::out_of_range); - - /** - * Convert a boost::posix_time::ptime to a struct tm, - * with second precision. - * - * @param convertFrom the boost::posix_time::ptime to convert. - * @param convertTo holds the result of the conversion - * @return a struct tm, holding the same time. - */ - static void - ptimeToTm(Ptr::Ref convertFrom, struct tm & convertTo) - throw (); - - /** - * Return the current time, with microsecond precision. - * - * @return the current time, with microsecond precision. - */ - static Ptr::Ref - now(void) throw (); - - /** - * Return the current time, with microsecond precision, as a string. - * - * @return the current time, with microsecond precision. - */ - static Ptr::Ref - nowString(void) throw (); - - /** - * Sleep for the specified time duration, with microsecond precision. - * - * @param duration sleep for this duration. - */ - static void - sleep(Ptr::Ref duration) throw (); - - /** - * Convert a time_duration to a format used in SMILs. - * This means number of seconds, rounded to the nearest millisecond. - * For example: "1234.567s", "0.890s", or "3.000s". - * - * @param duration the time duration to convert. - */ - static Ptr::Ref - timeDurationToSmilString(Ptr::Ref duration) - throw (); - - /** - * Convert a time_duration to a rounded format used on the screen. - * - * This means a hh:mm:ss format, rounded to the nearest second. - * - * For example: "01:02:03" or "00:10:00". The hours field can be - * more than two characters wide, e.g.: "8765:48:45". - * - * @param duration the time duration to convert. - * @return the time duration in string format - */ - static Ptr::Ref - timeDurationToHhMmSsString(Ptr::Ref duration) - throw (); - - /** - * Convert a time_duration to a format used for fade info. - * - * This means a hh:mm:ss.ffffff format, with hours, minutes and - * fractions left off when zero. - * - * For example: 01:02:03.004, 1:02 (meaning 1m 2s), 3 (meaning 3s), - * 0.002 (meaning 2ms). Zero is represented as 0. - * - * @param duration the time duration to convert. - * @return the time duration in string format - */ - static Ptr::Ref - timeDurationToShortString(Ptr::Ref duration) - throw (); - - /** - * Parse a string to a time_duration. - * Similar to boost::posix_time::duration_from_string(), only - * not broken quite as badly. - * - * Parsing is right-to-left, starting with seconds: for example, - * 5 means 5 seconds; 01:02.03 means 1m 2.03s; 1:2:3 means 1h 2m 3s. - * - * If the time format is invalid, no exception is thrown, but the - * result is undefined (usually 00:00:00). - * TODO: fix this, by adding a format check - * - * @param durationString the duration as string - * @return the duration as a time_duration - */ - static Ptr::Ref - parseTimeDuration(Ptr::Ref durationString) - throw (); - - /** - * Get the number of digits used for fractional seconds - * in time durations. - * @return the constant 6, for microsecond precision. - */ - static int - getNumberOfDigitsPrecision(void) throw (); - - /** - * Round the time duration to the nearest second. - * - * @param duration the time to be rounded; it will not be - * modified. - * @return the rounded value. - */ - static Ptr::Ref - roundToNearestSecond(Ptr::Ref duration) - throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_TimeConversion_h - diff --git a/src/modules/core/include/LiveSupport/Core/UniqueId.h b/src/modules/core/include/LiveSupport/Core/UniqueId.h deleted file mode 100644 index 587c2d9ef..000000000 --- a/src/modules/core/include/LiveSupport/Core/UniqueId.h +++ /dev/null @@ -1,246 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_UniqueId_h -#define LiveSupport_Core_UniqueId_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include -#include -#include -#include "LiveSupport/Core/Ptr.h" - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class representing globally unique identifiers. - */ -class UniqueId -{ - public: - /** - * The type for the numeric value the unique id is represented in. - * This is set to 'long long int', i.e., 64-bit signed integers. - * TODO: change this into something not quite as non-portable. - */ - typedef long long int IdType; - - private: - /** - * The value of the id. - */ - IdType id; - - /** - * A string representation of the id, in hexadecimal notation. - */ - std::string idAsString; - - /** - * Default constructor. - */ - UniqueId(void) throw () - { - } - - - public: - /** - * Constructor to create a UniqueId with a specific integer value. - * The argument is expected to be between 0 and 2^31-1 (inclusive). - * - * @param id the numeric value of the created id object. - */ - UniqueId(const IdType id) throw () - { - this->id = id; - std::stringstream idWriter; - idWriter << std::hex << std::setw(16) << std::setfill('0') << id; - this->idAsString = idWriter.str(); - } - - /** - * Constructor to create a UniqueId with a specific string value. - * If the argument is not a valid hexadecimal number between 0 and - * 2^31-1 (inclusive), the integer value of the UniqueId will be - * bogus. - * - * @param idAsString the string value of the created id object, - * in hexadecimal notation. - */ - UniqueId(const std::string idAsString) throw () - { - this->idAsString = idAsString; - // TODO: add error checking - std::stringstream idReader(idAsString); - idReader >> std::hex >> this->id; - } - - /** - * Create a UniqueId from a numeric value, which is a string - * representation of the id, in base 10. - * If the argument is not a valid decimal number between 0 and - * 2^31-1 (inclusive), the value of the UniqueId will be - * bogus. - * - * @param idStr the id in base 10, in string from. - * @return a new UniqueId with the specified ID value. - */ - static Ptr::Ref - fromDecimalString(const std::string idStr) throw () - { - IdType id; - // TODO: error checking - std::stringstream idReader(idStr); - idReader >> id; - - Ptr::Ref uid(new UniqueId(id)); - return uid; - } - - /** - * Return the UniqueId as a string in base 10. - * - * @return a new string containing the value of the UniqueId. - */ - Ptr::Ref - toDecimalString(void) const throw () - { - std::stringstream idWriter; - idWriter << std::dec << id; - Ptr::Ref idString(new std::string( - idWriter.str() )); - return idString; - } - - /** - * Compare this is with an other one. - * - * @param otherId the other unqiue id to compare to. - * @return true if this an otherId have the same ID value, - * false otherwise. - */ - bool - operator==(const UniqueId & otherId) const throw () - { - return this->id == otherId.id; - } - - /** - * Compare this is with an other one. - * - * @param otherId the other unqiue id to compare to. - * @return true if this an otherId do not have the same ID value, - * false otherwise. - */ - bool - operator!=(const UniqueId & otherId) const throw () - { - return this->id != otherId.id; - } - - /** - * Compare this id with an other one. - * - * @param otherId the other unique id to compare to. - * @return true if this id is smaller than the other one, - * false otherwise. - */ - bool - operator<(const UniqueId & otherId) const throw () - { - return this->id < otherId.id; - } - - /** - * Generate a globally unique id. This is used for testing. - * In real life, unique IDs are generated by the storage server. - */ - static Ptr::Ref - generateId(void) throw (); - - /** - * Return the numeric value of this globally unique id. - * - * @return the numeric value of this id. - */ - const IdType - getId(void) const throw () - { - return id; - } - - /** - * Return the numeric value of this globally unique id - * (alternative syntax). - * - * @return the numeric value of this id. - */ - operator IdType() const throw () - { - return id; - } - - /** - * Return the string value of this globally unique id. - * - * @return the string value of this id. - */ - operator std::string() const throw () - { - return idAsString; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_UniqueId_h - diff --git a/src/modules/core/include/LiveSupport/Core/Uuid.h b/src/modules/core/include/LiveSupport/Core/Uuid.h deleted file mode 100644 index e3e72af08..000000000 --- a/src/modules/core/include/LiveSupport/Core/Uuid.h +++ /dev/null @@ -1,312 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - - This code is based upon the Leach working draft for UUIDs, - http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt - and the sample code therein. - The original copyright message of the sample code is the following: - -** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc. -** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. & -** Digital Equipment Corporation, Maynard, Mass. -** Copyright (c) 1998 Microsoft. -** To anyone who acknowledges that this file is provided "AS IS" -** without any express or implied warranty: permission to use, copy, -** modify, and distribute this file for any purpose is hereby -** granted without fee, provided that the above copyright notices and -** this notice appears in all source code copies, and that none of -** the names of Open Software Foundation, Inc., Hewlett-Packard -** Company, or Digital Equipment Corporation be used in advertising -** or publicity pertaining to distribution of the software without -** specific, written prior permission. Neither Open Software -** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment -** Corporation makes any representations about the suitability of -** this software for any purpose. - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_Uuid_h -#define LiveSupport_Core_Uuid_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_STDINT_H -#include -#else -#error need stdint.h -#endif - - -#include -#include "LiveSupport/Core/Ptr.h" - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class representing globally unique identifiers. - * This implementation is based on the Leach UUID/GUID draft: - * http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt - * - * @see http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt - */ -class Uuid -{ - private: - /** - * The raw time type - */ - typedef uint64_t UuidTime; - - /** - * Structure holding a 6-byte system node id. - */ - typedef struct { - char nodeId[6]; - } UuidNode; - - /** - * The value of the id. - */ - long long int id; - - /** - * A string representation of the id, in hexadecimal notation. - */ - std::string idAsString; - - /** - * The low part of time. - */ - uint32_t timeLow; - - /** - * The middle part of time. - */ - uint16_t timeMid; - - /** - * The high part of time, with version included. - */ - uint16_t timeHiAndVersion; - - /** - * Clock sequence number high and reserved parts. - */ - uint8_t clockSeqHiAndReserved; - - /** - * Clock sequenc number, low part. - */ - uint8_t clockSeqLow; - - /** - * The 6 byte system node id. - */ - uint8_t node[6]; - - /** - * Default constructor. - */ - Uuid(void) throw () - { - } - - /** - * Compare two UUIDs - * - * @param id1 one id to compare - * @param id2 the other id to compare - * @return true if they are equal, false otherwise - */ - static bool - compare(const Uuid & id1, - const Uuid & id2) throw (); - - /** - * Return the current time, but always return a different value, - * even if the system clock granularity is not fine enough. - * - * @param timestamp an out parameter for the current time. - */ - static void - getCurrentTime(UuidTime * timestamp) throw (); - - /** - * Try to generate a truely random number (which is not possible, - * of course). - * - * @return a random number - */ - static uint16_t - trueRandom(void) throw (); - - /** - * Read the last saved state of the UUID generator from - * non-volatile storage. - * - * @param clockSeq out parameter for the clock sequence - * @param timestamp out parameter for the timestamp - * @param node out parameter for the system node id - */ - int - readState(uint16_t * clockSeq, - UuidTime * timestamp, - UuidNode * node) throw (); - - /** - * Write the last saved state of the UUID generator to - * non-volatile storage. - * - * @param clockSeq the clock sequence - * @param timestamp the timestamp - * @param node the system node id - */ - void - writeState(uint16_t clockSeq, - UuidTime timestamp, - UuidNode node) throw (); - - /** - * Generate a type 1 UUID. - * This function will fill out the object's internal attributes - * for it to become a proper UUID. - * - * For UUID types, see - * http://www.webdav.org/specs/draft-leach-uuids-guids-01.txt - * - * @param clockSeq the clock sequence - * @param timestamp the time stamp - * @param node the system node id - */ - void - format(uint16_t clockSeq, - UuidTime timestamp, - UuidNode node) throw (); - - /** - * Get the system time in the UUID UTC base time, - * which is October 15, 1582. - * - * @param uuidTime an out parameter for the time. - */ - static void - getSystemTime(UuidTime * uuidTime) throw (); - - /** - * Return the IEEE node id. - * - * @param node an out parameter for the node id. - */ - static void - getIeeeNodeIdentifier(UuidNode * node) throw (); - - /** - * Create a string representation of the UUID. - * Store the result in the idAsString attribute. - */ - void - representAsString(void) throw (); - - - public: - /** - * Generate a globally unique id. This is used for testing. - * In real life, unique IDs are generated by the storage server. - */ - static Ptr::Ref - generateId(void) throw (); - - /** - * Compare this is with an other one. - * - * @param otherId the other unqiue id to compare to. - * @return true if this an otherId have the same ID value, - * false otherwise. - */ - bool - operator==(const Uuid & otherId) const throw () - { - return compare(*this, otherId); - } - - /** - * Compare this is with an other one. - * - * @param otherId the other unqiue id to compare to. - * @return true if this an otherId do not have the same ID value, - * false otherwise. - */ - bool - operator!=(const Uuid & otherId) const throw () - { - return !compare(*this, otherId); - } - - /** - * Return the string value of this globally unique id. - * - * @return the string value of this id. - */ - operator std::string() const throw () - { - return idAsString; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - -inline std::ostream & -operator<< (std::ostream & os, - const Uuid & id) -{ - os << (std::string) id; - - return os; -} - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_Uuid_h - diff --git a/src/modules/core/include/LiveSupport/Core/XmlRpcCommunicationException.h b/src/modules/core/include/LiveSupport/Core/XmlRpcCommunicationException.h deleted file mode 100644 index 79410f602..000000000 --- a/src/modules/core/include/LiveSupport/Core/XmlRpcCommunicationException.h +++ /dev/null @@ -1,113 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_XmlRpcCommunicationException_h -#define LiveSupport_Core_XmlRpcCommunicationException_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/XmlRpcException.h" - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Exception signaling an XML-RPC problem: could not find the XML-RPC server, - * the server responded 'no such method', or the method response could not be - * parsed. - */ -class XmlRpcCommunicationException : public XmlRpcException -{ - public: - /** - * Constructor based on a string. - * - * @param msg the message of the exception. - */ - XmlRpcCommunicationException(const std::string &msg) throw () - : XmlRpcException(msg) - { - } - - /** - * Constructor based on a parent exception. - * - * @param parent the parent exception to this one. - */ - XmlRpcCommunicationException(const std::exception & parent) - throw () - : XmlRpcException(parent) - { - } - - /** - * Constructor based on a message ant a parent exception. - * - * @param msg the message of the exception. - * @param parent the parent exception. - */ - XmlRpcCommunicationException(const std::string & msg, - const std::exception & parent) - throw () - : XmlRpcException(msg, parent) - { - } - - /** - * Virtual destructor. - */ - ~XmlRpcCommunicationException(void) throw () - { - } - -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_XmlRpcCommunicationException_h - diff --git a/src/modules/core/include/LiveSupport/Core/XmlRpcException.h b/src/modules/core/include/LiveSupport/Core/XmlRpcException.h deleted file mode 100644 index e29b05cad..000000000 --- a/src/modules/core/include/LiveSupport/Core/XmlRpcException.h +++ /dev/null @@ -1,153 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_XmlRpcException_h -#define LiveSupport_Core_XmlRpcException_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Common parent of exception classes for XML-RPC related problems. - */ -class XmlRpcException : public std::exception -{ - private: - /** - * The message of the exception. - */ - Ptr::Ref message; - - /** - * A possible embedded exception. - */ - const std::exception & parent; - - public: - /** - * Constructor based on a string. - * - * @param msg the message of the exception. - */ - XmlRpcException(const std::string &msg) throw () - : parent(*this) - { - message.reset(new std::string(msg)); - } - - /** - * Constructor based on a parent exception. - * - * @param parent the parent exception to this one. - */ - XmlRpcException(const std::exception & parent) throw () - : parent(parent) - { - message.reset(new std::string(parent.what())); - } - - /** - * Constructor based on a message ant a parent exception. - * - * @param msg the message of the exception. - * @param parent the parent exception. - */ - XmlRpcException(const std::string & msg, - const std::exception & parent) throw (); - - /** - * Virtual destructor. - */ - ~XmlRpcException(void) throw () - { - } - - /** - * Set the message of the exception. - * - * @param msg the new message of the exception. - */ - void - setMessage(const std::string & msg) throw () - { - message.reset(new std::string(msg)); - } - - /** - * Get the message of the exception. - * - * @return the message of the exception. - */ - virtual const char * - what(void) const throw () - { - return message->c_str(); - } - - /** - * Get the parent exception. - * - * @return the parent exception, which may be null. - */ - virtual const std::exception * - getParent(void) const throw () - { - return &parent == this ? 0 : &parent; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_XmlRpcException_h - diff --git a/src/modules/core/include/LiveSupport/Core/XmlRpcIOException.h b/src/modules/core/include/LiveSupport/Core/XmlRpcIOException.h deleted file mode 100644 index e7a394f67..000000000 --- a/src/modules/core/include/LiveSupport/Core/XmlRpcIOException.h +++ /dev/null @@ -1,112 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_XmlRpcIOException_h -#define LiveSupport_Core_XmlRpcIOException_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/XmlRpcException.h" - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Exception signaling an XML-RPC problem: there was a problem with a local - * I/O operation. - */ -class XmlRpcIOException : public XmlRpcException -{ - public: - /** - * Constructor based on a string. - * - * @param msg the message of the exception. - */ - XmlRpcIOException(const std::string &msg) throw () - : XmlRpcException(msg) - { - } - - /** - * Constructor based on a parent exception. - * - * @param parent the parent exception to this one. - */ - XmlRpcIOException(const std::exception & parent) - throw () - : XmlRpcException(parent) - { - } - - /** - * Constructor based on a message ant a parent exception. - * - * @param msg the message of the exception. - * @param parent the parent exception. - */ - XmlRpcIOException(const std::string & msg, - const std::exception & parent) - throw () - : XmlRpcException(msg, parent) - { - } - - /** - * Virtual destructor. - */ - ~XmlRpcIOException(void) throw () - { - } - -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_XmlRpcIOException_h - diff --git a/src/modules/core/include/LiveSupport/Core/XmlRpcInvalidArgumentException.h b/src/modules/core/include/LiveSupport/Core/XmlRpcInvalidArgumentException.h deleted file mode 100644 index 91774a4c0..000000000 --- a/src/modules/core/include/LiveSupport/Core/XmlRpcInvalidArgumentException.h +++ /dev/null @@ -1,113 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_XmlRpcInvalidArgumentException_h -#define LiveSupport_Core_XmlRpcInvalidArgumentException_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/XmlRpcException.h" - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Exception signaling an XML-RPC problem: invalid argument (functions which - * throw an XmlRpcException throw this when they would normally throw a - * std::invalid_argument). - */ -class XmlRpcInvalidArgumentException : public XmlRpcException -{ - public: - /** - * Constructor based on a string. - * - * @param msg the message of the exception. - */ - XmlRpcInvalidArgumentException(const std::string &msg) throw () - : XmlRpcException(msg) - { - } - - /** - * Constructor based on a parent exception. - * - * @param parent the parent exception to this one. - */ - XmlRpcInvalidArgumentException(const std::exception & parent) - throw () - : XmlRpcException(parent) - { - } - - /** - * Constructor based on a message ant a parent exception. - * - * @param msg the message of the exception. - * @param parent the parent exception. - */ - XmlRpcInvalidArgumentException(const std::string & msg, - const std::exception & parent) - throw () - : XmlRpcException(msg, parent) - { - } - - /** - * Virtual destructor. - */ - ~XmlRpcInvalidArgumentException(void) throw () - { - } - -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_XmlRpcInvalidArgumentException_h - diff --git a/src/modules/core/include/LiveSupport/Core/XmlRpcInvalidDataException.h b/src/modules/core/include/LiveSupport/Core/XmlRpcInvalidDataException.h deleted file mode 100644 index c80ac2c86..000000000 --- a/src/modules/core/include/LiveSupport/Core/XmlRpcInvalidDataException.h +++ /dev/null @@ -1,112 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_XmlRpcInvalidDataException_h -#define LiveSupport_Core_XmlRpcInvalidDataException_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/XmlRpcException.h" - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Exception signaling an XML-RPC problem: invalid data returned by the method. - * This could be a malformed AudioClip or Playlist, for example. - */ -class XmlRpcInvalidDataException : public XmlRpcException -{ - public: - /** - * Constructor based on a string. - * - * @param msg the message of the exception. - */ - XmlRpcInvalidDataException(const std::string &msg) throw () - : XmlRpcException(msg) - { - } - - /** - * Constructor based on a parent exception. - * - * @param parent the parent exception to this one. - */ - XmlRpcInvalidDataException(const std::exception & parent) - throw () - : XmlRpcException(parent) - { - } - - /** - * Constructor based on a message ant a parent exception. - * - * @param msg the message of the exception. - * @param parent the parent exception. - */ - XmlRpcInvalidDataException(const std::string & msg, - const std::exception & parent) - throw () - : XmlRpcException(msg, parent) - { - } - - /** - * Virtual destructor. - */ - ~XmlRpcInvalidDataException(void) throw () - { - } - -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_XmlRpcInvalidDataException_h - diff --git a/src/modules/core/include/LiveSupport/Core/XmlRpcMethodFaultException.h b/src/modules/core/include/LiveSupport/Core/XmlRpcMethodFaultException.h deleted file mode 100644 index d3accc9cc..000000000 --- a/src/modules/core/include/LiveSupport/Core/XmlRpcMethodFaultException.h +++ /dev/null @@ -1,166 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_XmlRpcMethodFaultException_h -#define LiveSupport_Core_XmlRpcMethodFaultException_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/XmlRpcException.h" - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - -namespace { - -/*------------------------------------------------------------------------------ - * The default fault code, the value when no fault code is set. - *----------------------------------------------------------------------------*/ -const int defaultFaultCode = -1; - -} - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Exception signaling an XML-RPC problem: the XML-RPC method returned a fault - * response. - */ -class XmlRpcMethodFaultException : public XmlRpcException -{ - private: - /** - * The XML-RPC faultCode of the exception. - */ - int faultCode; - - - public: - /** - * Constructor based on a string. - * - * @param msg the message of the exception. - */ - XmlRpcMethodFaultException(const std::string &msg) throw () - : XmlRpcException(msg), - faultCode(defaultFaultCode) - { - } - - /** - * Constructor based on a parent exception. - * - * @param parent the parent exception to this one. - */ - XmlRpcMethodFaultException(const std::exception & parent) - throw () - : XmlRpcException(parent), - faultCode(defaultFaultCode) - { - } - - /** - * Constructor based on a message and a parent exception. - * - * @param msg the message of the exception. - * @param parent the parent exception. - */ - XmlRpcMethodFaultException(const std::string & msg, - const std::exception & parent) - throw () - : XmlRpcException(msg, parent), - faultCode(defaultFaultCode) - { - } - - /** - * Constructor based on a fault code, fault string pair. - * - * @param methodName the name of the method throwing the exception. - * @param faultCode the code of the exception. - * @param faultString the message of the exception. - */ - XmlRpcMethodFaultException(const std::string & methodName, - int faultCode, - const std::string & faultString) - throw () - : XmlRpcException(""), - faultCode(faultCode) - { - std::stringstream msg; - msg << "XML-RPC method '" - << methodName - << "' returned error message:\n" - << faultCode - << " - " - << faultString; - setMessage(msg.str()); - } - - /** - * Virtual destructor. - */ - ~XmlRpcMethodFaultException(void) throw () - { - } - - /** - * Get the XML-RPC faultCode of the exception. - * - * @return the fault code, if one is set; or -1 if not. - */ - int - getFaultCode(void) const throw () - { - return faultCode; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_XmlRpcMethodFaultException_h - diff --git a/src/modules/core/include/LiveSupport/Core/XmlRpcMethodResponseException.h b/src/modules/core/include/LiveSupport/Core/XmlRpcMethodResponseException.h deleted file mode 100644 index 5a5c6b2e2..000000000 --- a/src/modules/core/include/LiveSupport/Core/XmlRpcMethodResponseException.h +++ /dev/null @@ -1,112 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_XmlRpcMethodResponseException_h -#define LiveSupport_Core_XmlRpcMethodResponseException_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/XmlRpcException.h" - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Exception signaling an XML-RPC problem: the XML-RPC method call completed - * normally, but the response received has incorrect syntax. - */ -class XmlRpcMethodResponseException : public XmlRpcException -{ - public: - /** - * Constructor based on a string. - * - * @param msg the message of the exception. - */ - XmlRpcMethodResponseException(const std::string &msg) throw () - : XmlRpcException(msg) - { - } - - /** - * Constructor based on a parent exception. - * - * @param parent the parent exception to this one. - */ - XmlRpcMethodResponseException(const std::exception & parent) - throw () - : XmlRpcException(parent) - { - } - - /** - * Constructor based on a message ant a parent exception. - * - * @param msg the message of the exception. - * @param parent the parent exception. - */ - XmlRpcMethodResponseException(const std::string & msg, - const std::exception & parent) - throw () - : XmlRpcException(msg, parent) - { - } - - /** - * Virtual destructor. - */ - ~XmlRpcMethodResponseException(void) throw () - { - } - -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_XmlRpcMethodResponseException_h - diff --git a/src/modules/core/include/LiveSupport/Core/XmlRpcTools.h b/src/modules/core/include/LiveSupport/Core/XmlRpcTools.h deleted file mode 100644 index f307a3176..000000000 --- a/src/modules/core/include/LiveSupport/Core/XmlRpcTools.h +++ /dev/null @@ -1,746 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_XmlRpcTools_h -#define LiveSupport_Core_XmlRpcTools_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/SessionId.h" -#include "LiveSupport/Core/Playlist.h" -#include "LiveSupport/Core/ScheduleEntry.h" -#include "LiveSupport/Core/PlayLogEntry.h" -#include "LiveSupport/Core/SearchCriteria.h" -#include "LiveSupport/Core/AsyncState.h" - - -namespace LiveSupport { -namespace Core { - -using namespace LiveSupport; -using namespace LiveSupport::Core; -using namespace LiveSupport::StorageClient; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A toolbox for converting between inner representations of classes - * and XmlRpcValues. Used by almost all XmlRpcServerMethod subclasses - * in the Scheduler. - */ -class XmlRpcTools -{ - private: - - /** - * Convert a boost::posix_time::ptime to an XmlRpcValue - * - * @param ptime the ptime to convert - * @param xmlRpcValue the output parameter holding the value of - * the conversion. - */ - static void - ptimeToXmlRpcValue(Ptr::Ref ptime, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (); - - /** - * Convert a PlayLogEntry to an XmlRpcValue - * - * @param playLogEntry the PlayLogEntry to convert. - * @param xmlRpcValue the output parameter holding the result of - * the conversion. - */ - static void - playLogEntryToXmlRpcValue(Ptr::Ref playLogEntry, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - public: - /** - * Extract the schedule entry id from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a UniqueId that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no UniqueId - * in xmlRpcValue - */ - static Ptr::Ref - extractScheduleEntryId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the generic 'id' from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a UniqueId that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no playlistId - * member in xmlRpcValue - */ - static Ptr::Ref - extractId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the playlist ID from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a UniqueId that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no playlistId - * member in xmlRpcValue - */ - static Ptr::Ref - extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the playlist element ID from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a UniqueId that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no playlistElementId - * member in xmlRpcValue - */ - static Ptr::Ref - extractPlaylistElementId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the audio clip id from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a UniqueId that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no audioClipId - * member in xmlRpcValue - */ - static Ptr::Ref - extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the relative offset from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a time_duration that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no relativeOffset - * member in xmlRpcValue - */ - static Ptr::Ref - extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the relative offset from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a time_duration that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no relativeOffset - * member in xmlRpcValue - */ - static Ptr::Ref - extractClipStart(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the relative offset from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a time_duration that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no relativeOffset - * member in xmlRpcValue - */ - static Ptr::Ref - extractClipEnd(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the relative offset from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a time_duration that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no relativeOffset - * member in xmlRpcValue - */ - static Ptr::Ref - extractClipLength(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert a Playlist to an XmlRpcValue - * - * @param playlist the Playlist to convert. - * @param xmlRpcValue the output parameter holding the result of - * the conversion. - */ - static void - playlistToXmlRpcValue(Ptr::Ref playlist, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (); - - /** - * Convert a vector of Playlists to an XML-RPC return value. - * - * @param playlistVector a list of Playlists. - * @param returnValue the output parameter holding an XML-RPC - * representation of the list of Playlists. - */ - static void - playlistVectorToXmlRpcValue( - const Ptr::Ref> >::Ref playlistVector, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Convert an AudioClip to an XmlRpcValue - * - * @param audioClip the AudioClip to convert. - * @param xmlRpcValue the output parameter holding the result of - * the conversion. - */ - static void - audioClipToXmlRpcValue(Ptr::Ref audioClip, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (); - - /** - * Convert a vector of AudioClips to an XML-RPC return value. - * - * @param audioClipVector a list of AudioClips. - * @param returnValue the output parameter holding an XML-RPC - * representation of the list of AudioClips. - */ - static void - audioClipVectorToXmlRpcValue( - const Ptr::Ref> >::Ref audioClipVector, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Extract a Playlist from an XML-RPC parameter. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return the extracted Playlist. - */ - static Ptr::Ref - extractPlaylist(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract a vector of Playlists from an XML-RPC parameter. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a list of Playlists. - */ - static Ptr::Ref> >::Ref - extractPlaylistVector(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract an AudioClip from an XML-RPC parameter. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return the extracted AudioClip. - */ - static Ptr::Ref - extractAudioClip(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract a vector of AudioClips from an XML-RPC parameter. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a list of AudioClips. - */ - static Ptr::Ref> >::Ref - extractAudioClipVector(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert an error code, message pair to an XML-RPC fault response. - * This is done by throwing an XmlRpc::XmlRpcException. The client - * receives a fault response, and the return value is set to a - * { faultCode, faultString } structure holding the error code and - * message. - * - * @param errorCode the numerical code of the error. - * @param errorMessage a short English description of the error. - * @param xmlRpcValue remains here from an earlier version - * TODO: remove this later. - */ - static void - markError(int errorCode, const std::string errorMessage, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (XmlRpc::XmlRpcException); - - /** - * Convert the valid status of a playlist to an XmlRpcValue - * - * @param validStatus true if the playlist is valid, false otherwise. - * @param xmlRpcValue the output parameter holding the result of - * the conversion. - */ - static void - validStatusToXmlRpcValue(bool validStatus, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (); - - /** - * Extract the 'from' time parameter from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return the time value for the 'from' parameter - * @exception std::invalid_argument if there was no from parameter - * in xmlRpcValue - */ - static Ptr::Ref - extractFromTime(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the 'to' parameter from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return the time value for the 'to' parameter - * @exception std::invalid_argument if there was no to parameter - * in xmlRpcValue - */ - static Ptr::Ref - extractToTime(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the 'start' parameter from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return the time value for the 'start' parameter - * @exception std::invalid_argument if there was no to parameter - * in xmlRpcValue - */ - static Ptr::Ref - extractStartTime(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the 'end' parameter from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return the time value for the 'end' parameter - * @exception std::invalid_argument if there was no to parameter - * in xmlRpcValue - */ - static Ptr::Ref - extractEndTime(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Add a 'from' time value to an XmlRpcValue. - * - * @param from the 'from' time value to add. - * @param returnValue an output parameter, which has the - * 'from' time added after the function returns. - */ - static void - fromTimeToXmlRpcValue( - Ptr::Ref from, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Add a 'to' time value to an XmlRpcValue. - * - * @param to the 'to' time value to add. - * @param returnValue an output parameter, which has the - * 'to' time added after the function returns. - */ - static void - toTimeToXmlRpcValue( - Ptr::Ref to, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Extract the playtime from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return the playing time, as stored in the XML-RPC parameter - * @exception std::invalid_argument if there was no playtime - * in xmlRpcValue - */ - static Ptr::Ref - extractPlayschedule(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the fade in time from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a time_duration that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no fadeIn - * member in xmlRpcValue - */ - static Ptr::Ref - extractFadeIn(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the fade out time from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a time_duration that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no fadeOut - * member in xmlRpcValue - */ - static Ptr::Ref - extractFadeOut(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert a vector of ScheduleEntries to an XML-RPC return value. - * - * @param scheduleEntries a list of ScheduleEntries. - * @param returnValue the output parameter holding an XML-RPC - * representation of the suppied schedule entires. - */ - static void - scheduleEntriesToXmlRpcValue( - Ptr::Ref> >::Ref scheduleEntries, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Convert an XmlRpcValue array, holding schedule entries, - * to a vector of ScheduleEntry object references. - * - * @param xmlRpcValue the XML-RPC array holding the schedule entry - * data - * @return a vector of ScheduleEntry object references, holding - * the same data. - */ - static Ptr::Ref> >::Ref - extractScheduleEntries(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (); - - /** - * Convert a schedule entry ID (a UniqueId) to an XmlRpcValue - * - * @param scheduleEntryId the UniqueId to convert. - * @param returnValue the output parameter holding the result of - * the conversion. - */ - static void - scheduleEntryIdToXmlRpcValue( - Ptr::Ref scheduleEntryId, - XmlRpc::XmlRpcValue & returnValue) throw (); - - /** - * Add a session id to an XmlRpcValue - * - * @param sessionId the session id to add to the XmlRpcValue - * @param returnValue an output parameter, which has the - * session id added after the function returns. - */ - static void - sessionIdToXmlRpcValue( - Ptr::Ref sessionId, - XmlRpc::XmlRpcValue & returnValue) throw (); - - /** - * Add a playlist ID to an XmlRpcValue - * - * @param playlistId the playlist ID to add to the XmlRpcValue - * @param returnValue an output parameter, which has the - * playlist ID added after the function returns. - */ - static void - playlistIdToXmlRpcValue( - Ptr::Ref playlistId, - XmlRpc::XmlRpcValue & returnValue) throw (); - - /** - * Add an audio clip ID to an XmlRpcValue - * - * @param audioClipId the audio clip ID to add to the XmlRpcValue - * @param returnValue an output parameter, which has the - * audio clip ID added after the function returns. - */ - static void - audioClipIdToXmlRpcValue( - Ptr::Ref audioClipId, - XmlRpc::XmlRpcValue & returnValue) throw (); - - /** - * Add a playlist element ID to an XmlRpcValue - * - * @param playlistElementId the playlist element ID - * to add to the XmlRpcValue - * @param returnValue an output parameter, which has the - * playlist element ID added after the function returns. - */ - static void - playlistElementIdToXmlRpcValue( - Ptr::Ref playlistElementId, - XmlRpc::XmlRpcValue & returnValue) throw (); - - /** - * Add a playtime value to an XmlRpcValue. - * - * @param playtime the playtime to add to the XmlRpcValue - * @param returnValue an output parameter, which has the - * playtime added after the function returns. - */ - static void - playtimeToXmlRpcValue( - Ptr::Ref playtime, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Convert a vector of PlayLogEntries to an XML-RPC return value. - * - * @param playLogVector a list of PlayLogEntries. - * @param returnValue the output parameter holding an XML-RPC - * representation of the list of PlayLogEntries. - */ - static void - playLogVectorToXmlRpcValue( - Ptr::Ref> >::Ref - playLogVector, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Extract the session ID from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a SessionId that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no sessionId - * member in xmlRpcValue - */ - static Ptr::Ref - extractSessionId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the login name from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a std::string that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no login - * member in xmlRpcValue - */ - static Ptr::Ref - extractLoginName(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the password from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a std::string that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no sessionId - * member in xmlRpcValue - */ - static Ptr::Ref - extractPassword(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Extract the search criteria from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a search criteria that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no criteria - * member in xmlRpcValue. - */ - static Ptr::Ref - extractSearchCriteria(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert a SearchCriteria to an XmlRpcValue. - * - * @param criteria the SearchCriteria to convert. - * @param returnValue the output parameter holding the result of - * the conversion. - */ - static void - searchCriteriaToXmlRpcValue( - Ptr::Ref criteria, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Extract a token from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a string token that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no token - * member in xmlRpcValue. - */ - static Ptr::Ref - extractToken(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert a string token to an XmlRpcValue. - * - * @param token the string token to convert. - * @param returnValue the output parameter holding the result of - * the conversion. - */ - static void - tokenToXmlRpcValue(Ptr::Ref token, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Extract the backup status from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return an AsyncState that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no "status" - * member in xmlRpcValue. - */ - static AsyncState - extractBackupStatus(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert an AsyncState returned by one - * of the backup methods to an XmlRpcValue. - * - * @param status the AsyncState to convert. - * @param returnValue the output parameter holding the result of - * the conversion. - */ - static void - backupStatusToXmlRpcValue(AsyncState status, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Extract a URL string from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a URL string that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no "url" - * member in xmlRpcValue. - */ - static Ptr::Ref - extractUrl(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert a URL string to an XmlRpcValue. - * - * @param url the URL string to convert. - * @param returnValue the output parameter holding the result of - * the conversion. - */ - static void - urlToXmlRpcValue(Ptr::Ref url, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Extract a path string from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a path string that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no "path" - * member in xmlRpcValue. - */ - static Ptr::Ref - extractPath(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert a path string to an XmlRpcValue. - * - * @param path the path string to convert. - * @param returnValue the output parameter holding the result of - * the conversion. - */ - static void - pathToXmlRpcValue(Ptr::Ref path, - XmlRpc::XmlRpcValue & returnValue) - throw (); - - /** - * Extract a fault string from the XML-RPC parameters. - * - * @param xmlRpcValue the XML-RPC parameter to extract from. - * @return a fault string that was found in the XML-RPC parameter. - * @exception std::invalid_argument if there was no "faultString" - * member in xmlRpcValue. - */ - static Ptr::Ref - extractFaultString(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument); - - /** - * Convert a fault string to an XmlRpcValue. - * - * @param faultString the fault string to convert. - * @param xmlRpcValue the output parameter holding the result of - * the conversion. - */ - static void - faultStringToXmlRpcValue(Ptr::Ref faultString, - XmlRpc::XmlRpcValue & returnValue) - throw (); -}; - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_XmlRpcTools_h - diff --git a/src/modules/core/lib/.keepme b/src/modules/core/lib/.keepme deleted file mode 100644 index e0808fa16..000000000 --- a/src/modules/core/lib/.keepme +++ /dev/null @@ -1 +0,0 @@ -keep me diff --git a/src/modules/core/src/AsyncState.cxx b/src/modules/core/src/AsyncState.cxx deleted file mode 100644 index 728c13541..000000000 --- a/src/modules/core/src/AsyncState.cxx +++ /dev/null @@ -1,195 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include "LiveSupport/Core/AsyncState.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * Constant instance: init. - *----------------------------------------------------------------------------*/ -const AsyncState AsyncState::initState(innerInitState); - -/*------------------------------------------------------------------------------ - * Constant instance: pending. - *----------------------------------------------------------------------------*/ -const AsyncState AsyncState::pendingState(innerPendingState); - -/*------------------------------------------------------------------------------ - * Constant instance: finished. - *----------------------------------------------------------------------------*/ -const AsyncState AsyncState::finishedState(innerFinishedState); - -/*------------------------------------------------------------------------------ - * Constant instance: closed. - *----------------------------------------------------------------------------*/ -const AsyncState AsyncState::closedState(innerClosedState); - -/*------------------------------------------------------------------------------ - * Constant instance: failed. - *----------------------------------------------------------------------------*/ -const AsyncState AsyncState::failedState(innerFailedState); - -/*------------------------------------------------------------------------------ - * Constant instance: invalid. - *----------------------------------------------------------------------------*/ -const AsyncState AsyncState::invalidState(innerInvalidState); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Construct from a transport string. - *----------------------------------------------------------------------------*/ -AsyncState -AsyncState :: fromTransportString(const std::string & transportString) - throw () -{ - if (transportString == "init") { - return initState; - - } else if (transportString == "pending" || transportString == "waiting") { - return pendingState; - - } else if (transportString == "finished") { - return finishedState; - - } else if (transportString == "closed") { - return closedState; - - } else if (transportString == "failed") { - return failedState; - } - - return invalidState; -} - - -/*------------------------------------------------------------------------------ - * Construct from a backup string. - *----------------------------------------------------------------------------*/ -AsyncState -AsyncState :: fromBackupString(const std::string & backupString) - throw () -{ - if (backupString == "working") { - return pendingState; - - } else if (backupString == "success") { - return finishedState; - - } else if (backupString == "fault") { - return failedState; - } - - return invalidState; -} - - -/*------------------------------------------------------------------------------ - * Convert to a transport string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -AsyncState :: toTransportString(void) const throw () -{ - Ptr::Ref transportString(new std::string()); - - switch (value) { - case innerInitState: *transportString = "init"; - break; - - case innerPendingState: *transportString = "pending"; - break; - - case innerFinishedState: *transportString = "finished"; - break; - - case innerClosedState: *transportString = "closed"; - break; - - case innerFailedState: *transportString = "failed"; - break; - - case innerInvalidState: *transportString = "(invalid)"; - break; - } - - return transportString; -} - - -/*------------------------------------------------------------------------------ - * Convert to a backup string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -AsyncState :: toBackupString(void) const throw () -{ - Ptr::Ref backupString(new std::string()); - - switch (value) { - case innerInitState: *backupString = "(init)"; - break; - - case innerPendingState: *backupString = "working"; - break; - - case innerFinishedState: *backupString = "success"; - break; - - case innerClosedState: *backupString = "(closed)"; - break; - - case innerFailedState: *backupString = "fault"; - break; - - case innerInvalidState: *backupString = "(invalid)"; - break; - } - - return backupString; -} - - -/*------------------------------------------------------------------------------ - * Print to an ostream. - *----------------------------------------------------------------------------*/ -std::ostream & -operator<<(std::ostream & ostream, const LiveSupport::Core::AsyncState state) - throw () -{ - Ptr::Ref transportState = state.toTransportString(); - ostream << *transportState; - return ostream; -} - diff --git a/src/modules/core/src/AsyncStateTest.cxx b/src/modules/core/src/AsyncStateTest.cxx deleted file mode 100644 index 95d08a581..000000000 --- a/src/modules/core/src/AsyncStateTest.cxx +++ /dev/null @@ -1,127 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include -#include - -#include "LiveSupport/Core/AsyncState.h" -#include "AsyncStateTest.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(AsyncStateTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -AsyncStateTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -AsyncStateTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test the basic conversions. - *----------------------------------------------------------------------------*/ -void -AsyncStateTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - AsyncState state = AsyncState::invalidState; - Ptr::Ref transportString; - Ptr::Ref backupString; - - state = AsyncState::initState; - transportString = state.toTransportString(); - CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString), - state); - - state = AsyncState::pendingState; - transportString = state.toTransportString(); - backupString = state.toBackupString(); - CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString), - state); - CPPUNIT_ASSERT_EQUAL(AsyncState::fromBackupString(*backupString), - state); - - state = AsyncState::finishedState; - transportString = state.toTransportString(); - backupString = state.toBackupString(); - CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString), - state); - CPPUNIT_ASSERT_EQUAL(AsyncState::fromBackupString(*backupString), - state); - - state = AsyncState::closedState; - transportString = state.toTransportString(); - CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString), - state); - - state = AsyncState::failedState; - transportString = state.toTransportString(); - backupString = state.toBackupString(); - CPPUNIT_ASSERT_EQUAL(AsyncState::fromTransportString(*transportString), - state); - CPPUNIT_ASSERT_EQUAL(AsyncState::fromBackupString(*backupString), - state); - -} - - -/*------------------------------------------------------------------------------ - * Test the printing to an ostream. - *----------------------------------------------------------------------------*/ -void -AsyncStateTest :: ostreamTest(void) - throw (CPPUNIT_NS::Exception) -{ - std::ostringstream stream; - AsyncState state = AsyncState::finishedState; - - stream << state; - CPPUNIT_ASSERT(stream.str() == "finished"); -} - diff --git a/src/modules/core/src/AsyncStateTest.h b/src/modules/core/src/AsyncStateTest.h deleted file mode 100644 index 0133d3080..000000000 --- a/src/modules/core/src/AsyncStateTest.h +++ /dev/null @@ -1,104 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef AsyncStateTest_h -#define AsyncStateTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the AsyncState class. - * - * @see AsyncState - */ -class AsyncStateTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(AsyncStateTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST(ostreamTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * Test the basic conversions. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the printing to an ostream. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - ostreamTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // AsyncStateTest_h - diff --git a/src/modules/core/src/AudioClip.cxx b/src/modules/core/src/AudioClip.cxx deleted file mode 100644 index 272bba47c..000000000 --- a/src/modules/core/src/AudioClip.cxx +++ /dev/null @@ -1,742 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include // for TagLib -#include // for TagLib -#include // for TagLib -#include // for TagLib - -#include "LiveSupport/Core/TimeConversion.h" -#include "LiveSupport/Core/AudioClip.h" - -using namespace boost::posix_time; - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/** - * The name of the config element for this class - */ -const std::string AudioClip::configElementNameStr = "audioClip"; - -/** - * The name of the attribute to get the id of the audio clip. - */ -static const std::string idAttrName = "id"; - -/** - * The name of the attribute to get the URI of the audio clip. - */ -static const std::string uriAttrName = "uri"; - -/** - * The name of the attribute to get the playlength of the audio clip. - */ -static const std::string playlengthAttrName = "playlength"; - -/** - * The name of the attribute to get the title of the audio clip. - */ -static const std::string titleAttrName = "title"; - -/** - * The name of the metadata child element. - */ -static const std::string metadataElementName = "metadata"; - -/** - * The prefix of the extent (length) metadata element. - */ -static const std::string extentElementPrefix = "dcterms"; - -/** - * The name of the extent (length) metadata element. - */ -static const std::string extentElementName = "extent"; - -/** - * The prefix of the title metadata element. - */ -static const std::string titleElementPrefix = "dc"; - -/** - * The name of the title metadata element. - */ -static const std::string titleElementName = "title"; - -/** - * The prefix for the Live Support extension elements. - */ -static const std::string liveSupportNamespacePrefix = "ls"; - -/** - * The prefix for the "xml:" prefix elements. - */ -static const std::string xmlNamespacePrefix = "xml"; - -/** - * The URI identifier for the default namespace - */ -static const std::string defaultNamespaceUri - = "http://mdlf.org/livesupport/elements/1.0/"; - -/** - * The URI identifier for the "ls" prefix. - */ -static const std::string liveSupportNamespaceUri - = "http://mdlf.org/livesupport/elements/1.0/"; - -/** - * The URI identifier for the "dc" prefix - */ -static const std::string dcNamespaceUri - = "http://purl.org/dc/elements/1.1/"; - -/** - * The URI identifier for the "dcterms" prefix - */ -static const std::string dctermsNamespaceUri - = "http://purl.org/dc/terms/"; - -/** - * The URI identifier for the "xml" prefix - */ -static const std::string xmlNamespaceUri - = "http://www.w3.org/XML/1998/namespace"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Copy constructor. - *----------------------------------------------------------------------------*/ -AudioClip :: AudioClip(const AudioClip & otherAudioClip) throw () - : Playable(AudioClipType) -{ - this->id = otherAudioClip.id; - this->title = otherAudioClip.title; - this->playlength = otherAudioClip.playlength; - this->uri = otherAudioClip.uri; - this->token = otherAudioClip.token; - - if (otherAudioClip.xmlAudioClip) { - xmlAudioClip.reset(new xmlpp::Document); - xmlAudioClip->create_root_node_by_import( - otherAudioClip.xmlAudioClip->get_root_node(), - true); // true == recursive - } -} - - -/*------------------------------------------------------------------------------ - * Test constructor without title. - *----------------------------------------------------------------------------*/ -AudioClip :: AudioClip(Ptr::Ref id, - Ptr::Ref playlength, - Ptr::Ref uri) - throw () - : Playable(AudioClipType) -{ - this->id = id; - this->title.reset(new Glib::ustring("")); - this->playlength = playlength; - this->uri = uri; - - setMetadata(title, titleElementName, titleElementPrefix); - - Ptr::Ref playlengthString(new const Glib::ustring( - toFixedString(playlength) )); - setMetadata(playlengthString, extentElementName, extentElementPrefix); -} - - -/*------------------------------------------------------------------------------ - * Test constructor with title. - *----------------------------------------------------------------------------*/ -AudioClip :: AudioClip(Ptr::Ref id, - Ptr::Ref title, - Ptr::Ref playlength, - Ptr::Ref uri) - throw () - : Playable(AudioClipType) -{ - this->id = id; - this->title = title; - this->playlength = playlength; - this->uri = uri; - - setMetadata(title, titleElementName, titleElementPrefix); - - Ptr::Ref playlengthString(new const Glib::ustring( - toFixedString(playlength) )); - setMetadata(playlengthString, extentElementName, extentElementPrefix); -} - - -/*------------------------------------------------------------------------------ - * Constructor without ID. - *----------------------------------------------------------------------------*/ -AudioClip :: AudioClip(Ptr::Ref title, - Ptr::Ref playlength, - Ptr::Ref uri) - throw () - : Playable(AudioClipType) -{ - this->title = title; - this->playlength = playlength; - this->uri = uri; - - setMetadata(title, titleElementName, titleElementPrefix); - - Ptr::Ref playlengthString(new const Glib::ustring( - toFixedString(playlength) )); - setMetadata(playlengthString, extentElementName, extentElementPrefix); -} - - -/*------------------------------------------------------------------------------ - * Convert to an XmlRpcValue. - *----------------------------------------------------------------------------*/ -AudioClip :: operator XmlRpc::XmlRpcValue() const - throw() -{ - XmlRpc::XmlRpcValue xmlRpcValue; - xmlRpcValue[configElementNameStr] = std::string(*getXmlDocumentString()); - - return xmlRpcValue; -} - - -/*------------------------------------------------------------------------------ - * Construct from an XmlRpcValue. - *----------------------------------------------------------------------------*/ -AudioClip :: AudioClip(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) - : Playable(AudioClipType) -{ - if (!xmlRpcValue.hasMember(configElementNameStr)) { - throw std::invalid_argument("no audio clip data found in XmlRpcValue"); - } - - xmlpp::DomParser parser; - try { - parser.parse_memory(std::string(xmlRpcValue[configElementNameStr])); - } catch (xmlpp::exception &e) { - throw std::invalid_argument("error parsing XML document"); - } - - configure(*parser.get_document()->get_root_node()); // may throw -} - - -/*------------------------------------------------------------------------------ - * Set the value of the title field. - *----------------------------------------------------------------------------*/ -void -AudioClip :: setTitle(Ptr::Ref title) - throw () -{ - this->title = title; - setMetadata(title, titleElementName, titleElementPrefix); -} - - -/*------------------------------------------------------------------------------ - * Set the value of the playlength from a string (private). - *----------------------------------------------------------------------------*/ -void -AudioClip :: setPlaylength(Ptr::Ref timeString) - throw (std::invalid_argument) -{ - try { - playlength = TimeConversion::parseTimeDuration(timeString); - } catch (std::exception &e) { - std::string eMsg = "bad time format in playlength: "; - eMsg += e.what(); - throw std::invalid_argument(eMsg); - } -} - - -/*------------------------------------------------------------------------------ - * Create an audio clip object based on an XML element. - *----------------------------------------------------------------------------*/ -void -AudioClip :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementNameStr) { - std::string eMsg = "bad configuration element "; - eMsg += element.get_name(); - throw std::invalid_argument(eMsg); - } - - const xmlpp::Attribute * attribute = 0; - - if (!id) { - if (!(attribute = element.get_attribute(idAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - id.reset(new UniqueId(attribute->get_value())); - } - - if (!playlength - && (attribute = element.get_attribute(playlengthAttrName))) { - Ptr::Ref playlengthString(new const Glib::ustring( - attribute->get_value() )); - setMetadata(playlengthString, extentElementName, extentElementPrefix); - } - - if (!title - && (attribute = element.get_attribute(titleAttrName))) { - title.reset(new const Glib::ustring(attribute->get_value())); - setMetadata(title, titleElementName, titleElementPrefix); - } - - if (!uri - && (attribute = element.get_attribute(uriAttrName))) { - uri.reset(new const std::string(attribute->get_value())); - } - - xmlpp::Node::NodeList childNodes - = element.get_children(metadataElementName); - xmlpp::Node::NodeList::iterator it = childNodes.begin(); - - if (it != childNodes.end()) { - const xmlpp::Element * metadataElement - = dynamic_cast (*it); - - xmlAudioClip.reset(new xmlpp::Document); - xmlpp::Element* root = xmlAudioClip->create_root_node( - configElementNameStr); - root->set_attribute(idAttrName, std::string(*id)); - root->import_node(metadataElement, true); // true = recursive - - const xmlpp::Node::NodeList dataFieldList - = metadataElement->get_children(); - xmlpp::Node::NodeList::const_iterator listIt = dataFieldList.begin(); - - while (listIt != dataFieldList.end()) { - const xmlpp::Node* dataNode = *listIt; - std::string prefix = dataNode->get_namespace_prefix(); - std::string name = dataNode->get_name(); - const xmlpp::Element* - dataElement - = dynamic_cast (dataNode); - if (!dataElement) { - ++listIt; - continue; - } - - if (!playlength && prefix == extentElementPrefix - && name == extentElementName) { - if (dataElement->has_child_text()) { - Ptr::Ref playlengthString(new std::string( - dataElement->get_child_text() - ->get_content() )); - setPlaylength(playlengthString); - } else { // or just leave blank? bad either way - playlength.reset(new time_duration(0,0,0,0)); - } - } - - if (!title && prefix == titleElementPrefix - && name == titleElementName) { - Glib::ustring value; - if (dataElement->has_child_text()) { - value = dataElement->get_child_text()->get_content(); - } else { - value = ""; - } - Ptr::Ref ptrToValue( - new const Glib::ustring(value)); - title = ptrToValue; - } - - ++listIt; - } - - ++it; - if (it != childNodes.end()) { - std::string eMsg = "more than one "; - eMsg += metadataElementName; - eMsg += " XML element"; - throw std::invalid_argument(eMsg); - } - } - - if (!playlength) { - std::string eMsg = "missing attribute "; - eMsg += playlengthAttrName; - eMsg += " or metadata element "; - eMsg += extentElementPrefix + ":" + extentElementName; - throw std::invalid_argument(eMsg); - } - - if (!title) { - title.reset(new const Glib::ustring("")); - } -} - - -/*------------------------------------------------------------------------------ - * Return the value of a metadata field. - *----------------------------------------------------------------------------*/ -Ptr::Ref -AudioClip :: getMetadata(const std::string & key) const - throw () -{ - std::string name, prefix; - separateNameAndNameSpace(key, name, prefix); - - Ptr::Ref value; - - if (! xmlAudioClip) { - return value; - } - xmlpp::Element* rootNode = xmlAudioClip->get_root_node(); - if (! rootNode) { - return value; - } - xmlpp::Node::NodeList rootList = rootNode->get_children( - metadataElementName); - if (rootList.size() == 0) { - return value; - } - - xmlpp::Node* metadata = rootList.front(); - xmlpp::Node::NodeList nodeList = metadata->get_children(name); - xmlpp::Node::NodeList::iterator it = nodeList.begin(); - - while (it != nodeList.end()) { - xmlpp::Node* node = *it; - if (node->get_namespace_prefix() == prefix) { - xmlpp::Element* element = dynamic_cast (node); - xmlpp::TextNode* textNode = element->get_child_text(); - if (textNode) { - value.reset(new Glib::ustring(textNode->get_content())); - } else { - value.reset(new Glib::ustring("")); - } - return value; - } - ++it; - } - - return value; -} - - -/*------------------------------------------------------------------------------ - * Set the value of a metadata field (public). - *----------------------------------------------------------------------------*/ -void -AudioClip :: setMetadata(Ptr::Ref value, - const std::string &key) - throw (std::invalid_argument) -{ - std::string name; - std::string prefix; - - separateNameAndNameSpace(key, name, prefix); - setMetadata(value, name, prefix); -} - - -/*------------------------------------------------------------------------------ - * Set the value of a metadata field (private). - *----------------------------------------------------------------------------*/ -void -AudioClip :: setMetadata(Ptr::Ref value, - const std::string &name, const std::string &prefix) - throw (std::invalid_argument) -{ - if (prefix == extentElementPrefix && name == extentElementName) { - Ptr::Ref valueString(new const std::string( - *value)); - setPlaylength(valueString); // may throw invalid_argument - } - - if (prefix == titleElementPrefix && name == titleElementName) { - title = value; - } - - // create a new xmlpp::Document for the metadata if necessary - if (! xmlAudioClip) { - xmlAudioClip.reset(new xmlpp::Document); - } - xmlpp::Element* rootNode = xmlAudioClip->get_root_node(); - if (! rootNode) { - rootNode = xmlAudioClip->create_root_node(configElementNameStr); - if (id) { - rootNode->set_attribute(idAttrName, std::string(*id)); - } - } - xmlpp::Node::NodeList rootList = rootNode->get_children( - metadataElementName); - xmlpp::Element* metadata; - if (rootList.size() > 0) { - metadata = dynamic_cast (rootList.front()); - } else { - metadata = rootNode->add_child(metadataElementName); - metadata->set_namespace_declaration(defaultNamespaceUri); - metadata->set_namespace_declaration(liveSupportNamespaceUri, - liveSupportNamespacePrefix); - metadata->set_namespace_declaration(dcNamespaceUri, - titleElementPrefix); - metadata->set_namespace_declaration(dctermsNamespaceUri, - extentElementPrefix); - metadata->set_namespace_declaration(xmlNamespaceUri, - xmlNamespacePrefix); - } - - // find the element to be modified - xmlpp::Node::NodeList nodeList = metadata->get_children(name); - xmlpp::Node::NodeList::iterator it = nodeList.begin(); - xmlpp::Element* element = 0; - - while (it != nodeList.end()) { - xmlpp::Node* node = *it; - if (node->get_namespace_prefix() == prefix) { - element = dynamic_cast (nodeList.front()); - break; - } - ++it; - } - - // or add it if it did not exist before - if (it == nodeList.end()) { - element = metadata->add_child(name); - try { - element->set_namespace(prefix); - } - catch (xmlpp::exception &e) { - // this namespace has not been declared; well OK, do nothing then - } - } - - element->set_child_text(*value); -} - - -/*------------------------------------------------------------------------------ - * Return a string containing the essential fields of this object, in XML. - *----------------------------------------------------------------------------*/ -Ptr::Ref -AudioClip :: getXmlElementString(void) const throw () -{ - Ptr::Ref xmlString(new Glib::ustring); - - xmlString->append("<"); - xmlString->append(configElementNameStr + " "); - xmlString->append(idAttrName + "=\"" - + std::string(*id) - + "\" "); - xmlString->append(Glib::ustring(titleAttrName) + "=\"" - + *title - + "\" "); - xmlString->append(playlengthAttrName + "=\"" - + toFixedString(playlength) - + "\"/>"); - return xmlString; -} - - -/*------------------------------------------------------------------------------ - * Return a string containing an XML representation of this audio clip. - *----------------------------------------------------------------------------*/ -Ptr::Ref -AudioClip :: getXmlDocumentString() const throw () -{ - Ptr::Ref localDocument; - - if (xmlAudioClip) { - localDocument = xmlAudioClip; - } else { - localDocument.reset(new xmlpp::Document()); - xmlpp::Element* rootNode = localDocument->create_root_node( - configElementNameStr); - if (id) { - rootNode->set_attribute(idAttrName, std::string(*id)); - } - - xmlpp::Element* metadata = rootNode->add_child(metadataElementName); - metadata->set_namespace_declaration(defaultNamespaceUri); - metadata->set_namespace_declaration(liveSupportNamespaceUri, - liveSupportNamespacePrefix); - metadata->set_namespace_declaration(dcNamespaceUri, - titleElementPrefix); - metadata->set_namespace_declaration(dctermsNamespaceUri, - extentElementPrefix); - metadata->set_namespace_declaration(xmlNamespaceUri, - xmlNamespacePrefix); - } - - Ptr::Ref metadataString(new Glib::ustring( - localDocument->write_to_string() )); - return metadataString; -} - - -/*------------------------------------------------------------------------------ - * Read the metadata contained in the id3v2 tag of the binary sound file. - *----------------------------------------------------------------------------*/ -void -AudioClip :: readTag(Ptr::Ref metadataTypes) - throw (std::invalid_argument) -{ - if (!getUri()) { - throw std::invalid_argument("audio clip has no uri field"); - } - - std::string uri = *getUri(); - if (uri.substr(0,7) == "file://") { - uri = uri.substr(7); - } else if (uri.substr(0,5) == "file:") { - uri = uri.substr(5); - } - - if (!TagLib::File::isReadable(uri.c_str())) { - throw std::invalid_argument("binary sound file not found"); - } - - TagLib::MPEG::File mpegFile(uri.c_str()); - TagLib::ID3v2::Tag* id3v2Tag = mpegFile.ID3v2Tag(); - if (id3v2Tag) { - Ptr::Ref metadata; - Ptr::Ref value; - - TagLib::ID3v2::FrameListMap frameListMap = id3v2Tag->frameListMap(); - TagLib::ID3v2::FrameListMap::ConstIterator it; - - for (it = frameListMap.begin(); it != frameListMap.end(); ++it) { - std::string keyString(it->first.data(), 4); - try { - metadata = metadataTypes->getById3Tag(keyString); - TagLib::ID3v2::FrameList frameList = it->second; - if (!frameList.isEmpty()) { - value.reset(new const Glib::ustring( - frameList.front()->toString().to8Bit(true))); - setMetadata(value, *metadata->getDcName()); - } - } catch (std::invalid_argument &e) { - // id3v2 tag name not found in MetadataTypeContainer - // TODO: print warning? - } - } - return; - } - - TagLib::FileRef genericFileRef(uri.c_str()); - TagLib::Tag* tag = genericFileRef.tag(); - if (tag) { - TagLib::String stringValue; - TagLib::uint intValue; - Ptr::Ref value; - - stringValue = tag->artist(); - if (!stringValue.isNull()) { - value.reset(new const Glib::ustring(stringValue.to8Bit(true))); - setMetadata(value, "dc:creator"); - } - - stringValue = tag->title(); - if (!stringValue.isNull()) { - value.reset(new const Glib::ustring(stringValue.to8Bit(true))); - setMetadata(value, "dc:title"); - } - - stringValue = tag->album(); - if (!stringValue.isNull()) { - value.reset(new const Glib::ustring(stringValue.to8Bit(true))); - setMetadata(value, "dc:source"); - } - - stringValue = tag->comment(); - if (!stringValue.isNull()) { - value.reset(new const Glib::ustring(stringValue.to8Bit(true))); - setMetadata(value, "dc:description"); - } - - stringValue = tag->genre(); - if (!stringValue.isNull()) { - value.reset(new const Glib::ustring(stringValue.to8Bit(true))); - setMetadata(value, "dc:type"); - } - - intValue = tag->year(); - if (intValue != 0) { - std::stringstream yearString; - yearString << intValue; - value.reset(new const Glib::ustring(yearString.str())); - setMetadata(value, "ls:year"); - } - - intValue = tag->track(); - if (intValue != 0) { - std::stringstream trackString; - trackString << intValue; - value.reset(new const Glib::ustring(trackString.str())); - setMetadata(value, "ls:track_num"); - } - } -} - - -/*------------------------------------------------------------------------------ - * Separate a key into the metadata name and its namespace - *----------------------------------------------------------------------------*/ -void -LiveSupport::Core :: separateNameAndNameSpace(const std::string & key, - std::string & name, - std::string & prefix) - throw () -{ - unsigned int colonPosition = key.find(':'); - - if (colonPosition != std::string::npos) { // there is a colon - prefix = key.substr(0, colonPosition); - name = key.substr(colonPosition+1); - } else { // no colon found - prefix = ""; - name = key; - } -} - diff --git a/src/modules/core/src/AudioClipTest.cxx b/src/modules/core/src/AudioClipTest.cxx deleted file mode 100644 index 2f470a598..000000000 --- a/src/modules/core/src/AudioClipTest.cxx +++ /dev/null @@ -1,272 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/AudioClip.h" -#include "LiveSupport/Core/Playlist.h" -#include "AudioClipTest.h" - - -using namespace std; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(AudioClipTest); - -/** - * The name of the configuration file for the audio clip. - */ -static const std::string configFileName = "etc/audioClip.xml"; - -/** - * The name of the configuration file for the resource bundle. - */ -static const std::string bundleConfigFileName = "etc/resourceBundle.xml"; - -/** - * The name of the configuration file for the metadata type container. - */ -static const std::string metadataConfigFileName - = "etc/metadataTypeContainer.xml"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -AudioClipTest :: setUp(void) throw (CPPUNIT_NS::Exception) -{ - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, false)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - audioClip.reset(new AudioClip()); - audioClip->configure(*root); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in audio clip configuration file"); - } catch (xmlpp::exception &e) { - std::string eMsg = "error parsing audio clip configuration file\n"; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } - - Ptr::Ref bundle; - try { - Ptr::Ref parser( - new xmlpp::DomParser(bundleConfigFileName, false)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - bundle = LocalizedObject::getBundle(*root); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in configuration file"); - } catch (std::exception &e) { - std::string eMsg = "error parsing audio clip configuration file\n"; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } - CPPUNIT_ASSERT(bundle); - - try { - Ptr::Ref parser( - new xmlpp::DomParser(metadataConfigFileName, false)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - metadataTypes.reset(new MetadataTypeContainer(bundle)); - metadataTypes->configure(*root); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in metadata configuration file"); - } catch (xmlpp::exception &e) { - std::string eMsg = "error parsing metadata configuration file\n"; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -AudioClipTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the singleton Hello object is accessible - *----------------------------------------------------------------------------*/ -void -AudioClipTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - CPPUNIT_ASSERT(audioClip); - CPPUNIT_ASSERT(audioClip->getId()); - CPPUNIT_ASSERT(audioClip->getId()->getId() == 0x1); - Ptr::Ref duration - = audioClip->getPlaylength(); - CPPUNIT_ASSERT(duration); - CPPUNIT_ASSERT(duration->hours() == 0); - CPPUNIT_ASSERT(duration->minutes() == 18); - CPPUNIT_ASSERT(duration->seconds() == 30); - - Ptr::Ref title = audioClip->getTitle(); - CPPUNIT_ASSERT(title); - CPPUNIT_ASSERT(*title == "File Title txt"); - - Ptr::Ref subject = audioClip - ->getMetadata("dc:subject"); - CPPUNIT_ASSERT(subject); - CPPUNIT_ASSERT(*subject == "Keywords: qwe, asd, zcx"); - - Ptr::Ref alternativeTitle = audioClip - ->getMetadata("dcterms:alternative"); - CPPUNIT_ASSERT(alternativeTitle); - CPPUNIT_ASSERT(*alternativeTitle == - "Alternative File Title ín sőmé %$#@* LÁNGŰAGÉ"); - - CPPUNIT_ASSERT(audioClip->getXmlElementString()); - CPPUNIT_ASSERT(*audioClip->getXmlElementString() == - ""); -} - - -/*------------------------------------------------------------------------------ - * Test conversion to and from Playable - *----------------------------------------------------------------------------*/ -void -AudioClipTest :: conversionTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref playable = audioClip; - CPPUNIT_ASSERT(playable->getType() == Playable::AudioClipType); - - Ptr::Ref otherAudioClip = playable->getAudioClip(); - CPPUNIT_ASSERT(otherAudioClip == audioClip); - - Ptr::Ref playlist = playable->getPlaylist(); - CPPUNIT_ASSERT(!playlist); -} - - -/*------------------------------------------------------------------------------ - * Test id3v2 tag extraction - *----------------------------------------------------------------------------*/ -void -AudioClipTest :: tagTest(void) - throw (CPPUNIT_NS::Exception) -{ - // should work with either plain file path... - Ptr::Ref uri(new std::string("var/test10001.mp3")); - audioClip->setUri(uri); - try { - audioClip->readTag(metadataTypes); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - - Ptr::Ref title - = audioClip->getMetadata("dc:title"); - CPPUNIT_ASSERT(*title == "Theme Song"); - - Ptr::Ref artist - = audioClip->getMetadata("dc:creator"); - CPPUNIT_ASSERT(*artist == "The Muppets"); - - Ptr::Ref album - = audioClip->getMetadata("dc:source"); - CPPUNIT_ASSERT(*album == "מוישה אופניק"); - - // ... or with URI - uri.reset(new std::string("file:var/test10001.mp3")); - audioClip->setUri(uri); - try { - audioClip->readTag(metadataTypes); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - - title = audioClip->getMetadata("dc:title"); - CPPUNIT_ASSERT(*title == "Theme Song"); - - artist = audioClip->getMetadata("dc:creator"); - CPPUNIT_ASSERT(*artist == "The Muppets"); - - album = audioClip->getMetadata("dc:source"); - CPPUNIT_ASSERT(*album == "מוישה אופניק"); - // Moshe Offnik is the Israeli/Palestinian version of Oscar The Grouch -} - - -/*------------------------------------------------------------------------------ - * Marshalling test - *----------------------------------------------------------------------------*/ -void -AudioClipTest :: marshallingTest(void) - throw (CPPUNIT_NS::Exception) -{ - XmlRpc::XmlRpcValue xmlRpcValue = *audioClip; - CPPUNIT_ASSERT(xmlRpcValue.hasMember("audioClip")); - - Ptr::Ref otherAudioClip; - CPPUNIT_ASSERT_NO_THROW(otherAudioClip.reset(new AudioClip(xmlRpcValue))); - - CPPUNIT_ASSERT(*audioClip->getId() == *otherAudioClip->getId()); - CPPUNIT_ASSERT(*audioClip->getTitle() - == *otherAudioClip->getTitle()); - CPPUNIT_ASSERT(*audioClip->getPlaylength() - == *otherAudioClip->getPlaylength()); -} - diff --git a/src/modules/core/src/AudioClipTest.h b/src/modules/core/src/AudioClipTest.h deleted file mode 100644 index c51b05b12..000000000 --- a/src/modules/core/src/AudioClipTest.h +++ /dev/null @@ -1,138 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef AudioClipTest_h -#define AudioClipTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include "LiveSupport/Core/AudioClip.h" - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the AudioClip class. - * - * @see AudioClip - */ -class AudioClipTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(AudioClipTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST(conversionTest); - CPPUNIT_TEST(tagTest); - CPPUNIT_TEST(marshallingTest); - CPPUNIT_TEST_SUITE_END(); - - private: - /** - * The audio clip to test. - */ - Ptr::Ref audioClip; - - /** - * The list of supported metadata types. - */ - Ptr::Ref metadataTypes; - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing conversion to and from Playable. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - conversionTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Id3v2 tag extraction test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - tagTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing conversion to and from XmlRpcValue. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - marshallingTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (CPPUNIT_NS::Exception); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // AudioClipTest_h - diff --git a/src/modules/core/src/BaseTestMethod.cxx b/src/modules/core/src/BaseTestMethod.cxx deleted file mode 100644 index fb26c1360..000000000 --- a/src/modules/core/src/BaseTestMethod.cxx +++ /dev/null @@ -1,144 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_SYS_TYPES_H -#include -#else -#error need sys/types.h -#endif - -#ifdef HAVE_PWD_H -#include -#else -#error need pwd.h -#endif - -#ifdef HAVE_ERRNO_H -#include -#else -#error need errno.h -#endif - -#include - -#include "LiveSupport/Core/BaseTestMethod.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Return the current working directory - *----------------------------------------------------------------------------*/ -std::string -BaseTestMethod :: getCwd(void) throw () -{ - size_t size = 100; - char * buffer; - - while (true) { - buffer = new char[size]; - if (getcwd(buffer, size)) { - break; - } - delete[] buffer; - if (errno != ERANGE) { - return ""; - } - size *= 2; - } - - std::string cwd(buffer); - delete[] buffer; - return cwd; -} - - -/*------------------------------------------------------------------------------ - * Return the full path for a configuration file. - *----------------------------------------------------------------------------*/ -std::string -BaseTestMethod :: getConfigFile(const std::string configFileName) - throw (std::invalid_argument) -{ - std::string fileName; - std::ifstream file; - - // first, try with ~/.campcaster/configFileName - struct passwd * pwd = getpwuid(getuid()); - if (pwd) { - fileName += pwd->pw_dir; - fileName += "/.campcaster/" + configFileName; - file.open(fileName.c_str()); - if (file.good()) { - file.close(); - return fileName; - } - file.close(); - file.clear(); - } - - // second, try with ./etc/configFileName - fileName = getCwd() + "/etc/" + configFileName; - file.open(fileName.c_str()); - if (file.good()) { - file.close(); - return fileName; - } - file.close(); - - throw std::invalid_argument("can't find config file " + configFileName); -} - - -/*------------------------------------------------------------------------------ - * Return a configuration document - *----------------------------------------------------------------------------*/ -const xmlpp::Document * -BaseTestMethod :: getConfigDocument(xmlpp::DomParser & parser, - const std::string configFileName) - throw (std::invalid_argument, - std::exception) -{ - std::string realFileName = getConfigFile(configFileName); - parser.set_validate(); - parser.parse_file(realFileName); - return parser.get_document(); -} - diff --git a/src/modules/core/src/EnumerationConstraint.cxx b/src/modules/core/src/EnumerationConstraint.cxx deleted file mode 100644 index e657df9e4..000000000 --- a/src/modules/core/src/EnumerationConstraint.cxx +++ /dev/null @@ -1,128 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include "EnumerationConstraint.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -namespace { - -/*------------------------------------------------------------------------------ - * The value of the type attribute for this class. - *----------------------------------------------------------------------------*/ -const std::string typeAttributeValue = "enumeration"; - -} - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create a constraint element object based on an XML element. - *----------------------------------------------------------------------------*/ -void -EnumerationConstraint :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != getConfigElementName()) { - throw std::invalid_argument("bad configuration element " - + element.get_name()); - } - - const xmlpp::Attribute* typeAttribute; - if (!(typeAttribute = element.get_attribute(typeAttributeName))) { - throw std::invalid_argument("missing attribute " + typeAttributeName); - } - std::string type = typeAttribute->get_value(); - - if (type != typeAttributeValue) { - throw std::invalid_argument(typeAttributeValue - + " constraint configured with a" - + " constraint element of type " - + type); - } - - xmlpp::Node::NodeList childNodes = element.get_children(valueElementName); - xmlpp::Node::NodeList::iterator it = childNodes.begin(); - - if (it == childNodes.end()) { - throw std::invalid_argument("empty enumeration constraint"); - } - - for (; it != childNodes.end(); ++it) { - readValue(*it); - } -} - - -/*------------------------------------------------------------------------------ - * Read an enumeration value from an XML node. - *----------------------------------------------------------------------------*/ -void -EnumerationConstraint :: readValue(const xmlpp::Node * node) - throw (std::invalid_argument) -{ - const xmlpp::Element * valueElement - = dynamic_cast (node); - if (valueElement) { - allowedValues.push_back(valueElement->get_child_text() - ->get_content() ); - } else { - throw std::invalid_argument("bad sub-element found in constraint"); - } -} - - -/*------------------------------------------------------------------------------ - * Check that the given value satisfies the constraint. - *----------------------------------------------------------------------------*/ -bool -EnumerationConstraint :: check(Ptr::Ref value) const - throw (std::logic_error) -{ - if (!value) { - throw std::logic_error("EnumerationConstraint::check() called with " - "a 0 pointer value"); - } - - ListType::const_iterator it; - for (it = allowedValues.begin(); it != allowedValues.end(); ++it) { - if (*it == *value) { - return true; - } - } - - return false; -} - diff --git a/src/modules/core/src/EnumerationConstraint.h b/src/modules/core/src/EnumerationConstraint.h deleted file mode 100644 index d10d24ac4..000000000 --- a/src/modules/core/src/EnumerationConstraint.h +++ /dev/null @@ -1,166 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_EnumerationConstraint_h -#define LiveSupport_Core_EnumerationConstraint_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#include "LiveSupport/Core/MetadataConstraint.h" - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class for representing a metadata constraint allowing only strings from - * a given list of values. - * - * This is a concrete subclass of MetadataConstraint. Do not explicitly - * instantiate this class; create a MetadataConstraint object instead, and - * configure it with an XML element with the appropriate type attribute. - * - * This object has to be configured with an XML configuration element - * called constraint. This may look like the following: - * - *

- *  
- *      Monday
- *      ...
- *      Sunday
- *  
- *  
- * - * A metadata type with this kind of constraint can only accept one of the - * strings listed in the value elements (in a case-sensitive way). - * - * The DTD for the expected XML element looks like the following: - * - *

- *  
- *  
- *  
- *  
- * - * @see EnumerationConstraintContainer - */ -class EnumerationConstraint : public MetadataConstraint -{ - private: - /** - * The type for storing the enumeration values. - */ - typedef std::vector ListType; - - /** - * The list of allowed enumeration values. - */ - ListType allowedValues; - - /** - * Read an enumeration value from an XML node. - * - * @param node the node containing the value. - * @exception std::invalid_argument if the XML node is not - * of the expected form. - */ - void - readValue(const xmlpp::Node * node) throw (std::invalid_argument); - - - public: - /** - * Constructor. - */ - EnumerationConstraint() throw () - { - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~EnumerationConstraint(void) throw () - { - } - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return MetadataConstraint::getConfigElementName(); - } - - /** - * Configure the metadata object based on an XML configuration element. - * - * @param element the XML configuration element. - * @exception std::invalid_argument of the supplied XML element - * contains bad configuration information - */ - virtual void - configure(const xmlpp::Element &element) - throw (std::invalid_argument); - - /** - * Check that the given value satisfies the constraint. - * - * @param value the value to be checked against the constraint. - * @return true if the value satisfies the constraint. - * @exception std::logic_error if the parameter is a 0 pointer. - */ - virtual bool - check(Ptr::Ref value) const - throw (std::logic_error); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_EnumerationConstraint_h - diff --git a/src/modules/core/src/FadeInfo.cxx b/src/modules/core/src/FadeInfo.cxx deleted file mode 100644 index b2dc869d6..000000000 --- a/src/modules/core/src/FadeInfo.cxx +++ /dev/null @@ -1,133 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/TimeConversion.h" -#include "LiveSupport/Core/FadeInfo.h" - -using namespace boost::posix_time; - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * The name of the config element for this class - *----------------------------------------------------------------------------*/ -const std::string FadeInfo::configElementNameStr = "fadeInfo"; - -/** - * The name of the attribute to get the id of the audio clip. - */ -static const std::string idAttrName = "id"; - -/** - * The name of the attribute to get the fade in. - */ -static const std::string fadeInAttrName = "fadeIn"; - -/** - * The name of the attribute to get the fade out. - */ -static const std::string fadeOutAttrName = "fadeOut"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create a fade info object based on an XML element. - *----------------------------------------------------------------------------*/ -void -FadeInfo :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementNameStr) { - std::string eMsg = "bad configuration element "; - eMsg += element.get_name(); - throw std::invalid_argument(eMsg); - } - - const xmlpp::Attribute * attribute = 0; - - if (!(attribute = element.get_attribute(idAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - id.reset(new UniqueId(attribute->get_value())); - - if (!(attribute = element.get_attribute(fadeInAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - Ptr::Ref fadeInString(new std::string( - attribute->get_value() )); - fadeIn = TimeConversion::parseTimeDuration(fadeInString); - - if (!(attribute = element.get_attribute(fadeOutAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - Ptr::Ref fadeOutString(new std::string( - attribute->get_value() )); - fadeOut = TimeConversion::parseTimeDuration(fadeOutString); -} - - -/*------------------------------------------------------------------------------ - * Return a string containing the essential fields of this object, in XML. - *----------------------------------------------------------------------------*/ -Ptr::Ref -FadeInfo :: getXmlElementString(void) throw () -{ - Ptr::Ref xmlString(new Glib::ustring); - - xmlString->append("<"); - xmlString->append(configElementNameStr + " "); - xmlString->append(idAttrName + "=\"" - + std::string(*id) - + "\" "); - xmlString->append(fadeInAttrName + "=\"" - + toFixedString(fadeIn) - + "\" "); - xmlString->append(fadeOutAttrName + "=\"" - + toFixedString(fadeOut) - + "\"/>"); - return xmlString; -} - diff --git a/src/modules/core/src/FadeInfoTest.cxx b/src/modules/core/src/FadeInfoTest.cxx deleted file mode 100644 index 5e7163c9d..000000000 --- a/src/modules/core/src/FadeInfoTest.cxx +++ /dev/null @@ -1,128 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/FadeInfo.h" -#include "FadeInfoTest.h" - - -using namespace std; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(FadeInfoTest); - -/** - * The name of the configuration file for the audio clip. - */ -static const std::string configFileName = "etc/fadeInfo.xml"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -FadeInfoTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -FadeInfoTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the singleton Hello object is accessible - *----------------------------------------------------------------------------*/ -void -FadeInfoTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - Ptr::Ref fadeInfo(new FadeInfo()); - - fadeInfo->configure(*root); - - CPPUNIT_ASSERT(fadeInfo->getId()->getId() == 0x9901); - - Ptr::Ref - fadeIn = fadeInfo->getFadeIn(); - CPPUNIT_ASSERT(fadeIn->hours() == 0); - CPPUNIT_ASSERT(fadeIn->minutes() == 0); - CPPUNIT_ASSERT(fadeIn->seconds() == 2); - - Ptr::Ref - fadeOut = fadeInfo->getFadeOut(); - CPPUNIT_ASSERT(fadeOut->hours() == 0); - CPPUNIT_ASSERT(fadeOut->minutes() == 0); - CPPUNIT_ASSERT(fadeOut->seconds() == 1); - CPPUNIT_ASSERT(fadeOut->fractional_seconds() == 500); - - CPPUNIT_ASSERT(*fadeInfo->getXmlElementString() == - ""); - - } catch (std::invalid_argument &e) { - std::string eMsg = "semantic error in configuration file:\n"; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } catch (xmlpp::exception &e) { - std::string eMsg = "error parsing configuration file:\n"; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } -} diff --git a/src/modules/core/src/FadeInfoTest.h b/src/modules/core/src/FadeInfoTest.h deleted file mode 100644 index ceed7031a..000000000 --- a/src/modules/core/src/FadeInfoTest.h +++ /dev/null @@ -1,99 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef FadeInfoTest_h -#define FadeInfoTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the FadeInfo class. - * - * @see FadeInfo - */ -class FadeInfoTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(FadeInfoTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // FadeInfoTest_h - diff --git a/src/modules/core/src/FileTools.cxx b/src/modules/core/src/FileTools.cxx deleted file mode 100644 index f0199f82c..000000000 --- a/src/modules/core/src/FileTools.cxx +++ /dev/null @@ -1,332 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - To report bugs, send an e-mail to bugs@campware.org - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - - Author : $Author: fgerlits $ - Version : $Revision$ - Location : $URL: svn+ssh://fgerlits@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/modules/core/src/FileTools.cxx $ - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_TIME_H -#include -#else -#error need time.h -#endif - -#ifdef HAVE_TIME_H -#include -#else -#error need stdio.h -#endif - - -#include -#include - -#include - -#include -#include -#include - -#include "LiveSupport/Core/FileTools.h" - - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Copy the contents of a URL to a local file. - *----------------------------------------------------------------------------*/ -void -FileTools :: copyUrlToFile(const std::string & url, - const std::string & path) - throw (std::runtime_error) -{ - FILE* file = fopen(path.c_str(), "wb"); - if (!file) { - throw std::runtime_error("File location is not writable."); - } - - CURL* handle = curl_easy_init(); - if (!handle) { - fclose(file); - throw std::runtime_error("Could not obtain curl handle."); - } - - int status = curl_easy_setopt(handle, CURLOPT_URL, url.c_str()); - status |= curl_easy_setopt(handle, CURLOPT_WRITEDATA, file); - status |= curl_easy_setopt(handle, CURLOPT_HTTPGET, 1); - - if (status) { - fclose(file); - throw std::runtime_error("Could not set curl options."); - } - - status = curl_easy_perform(handle); - - if (status) { - fclose(file); - throw std::runtime_error("Error downloading file."); - } - - curl_easy_cleanup(handle); - fclose(file); -} - - -/*------------------------------------------------------------------------------ - * Upload the contents of a local file to a writable URL. - *----------------------------------------------------------------------------*/ -void -FileTools :: copyFileToUrl(const std::string & path, - const std::string & url) - throw (std::runtime_error) -{ - FILE* file = fopen(path.c_str(), "rb"); - if (!file) { - throw std::runtime_error("File not found."); - } - fseek(file, 0, SEEK_END); - long fileSize = ftell(file); - rewind(file); - - CURL* handle = curl_easy_init(); - if (!handle) { - throw std::runtime_error("Could not obtain curl handle."); - } - - int status = curl_easy_setopt(handle, CURLOPT_READDATA, file); - status |= curl_easy_setopt(handle, CURLOPT_INFILESIZE, fileSize); - // works for files of size up to 2 GB - status |= curl_easy_setopt(handle, CURLOPT_PUT, 1); - status |= curl_easy_setopt(handle, CURLOPT_URL, url.c_str()); -// status |= curl_easy_setopt(handle, CURLOPT_HEADER, 1); -// status |= curl_easy_setopt(handle, CURLOPT_ENCODING, "deflate"); - - if (status) { - throw std::runtime_error("Could not set curl options."); - } - - status = curl_easy_perform(handle); - - if (status) { - throw std::runtime_error("Error uploading file."); - } - - curl_easy_cleanup(handle); - fclose(file); -} - - -/*------------------------------------------------------------------------------ - * Create a temporary file name - *----------------------------------------------------------------------------*/ -const std::string -FileTools :: tempnam(void) throw () -{ - std::string fileName(::tempnam(NULL, NULL)); - - return fileName; -} - - -/*------------------------------------------------------------------------------ - * Append a file to an existing tarball - *----------------------------------------------------------------------------*/ -void -FileTools :: appendFileToTarball(const std::string & tarFileName, - const std::string & newFileRealName, - const std::string & newFileInTarball) - throw (std::runtime_error) -{ - TAR * tar; - off_t tarFileEnd; // keeps read position it tarball - - // first chop off the existing EOF from the tarball - - // open for reading first to determine where EOT block begins - if (tar_open(&tar, - (char*) tarFileName.c_str(), - NULL, - O_RDONLY, - 0, - 0) == -1) { - throw std::runtime_error("can't open tarball"); - } - - // go through all files in tarball and record end position - // of the last file read - tarFileEnd = 0; - while (th_read(tar) == 0) { - if (TH_ISREG(tar)) { - tar_skip_regfile(tar); - } - tarFileEnd = lseek(tar->fd, 0, SEEK_CUR); - } - - // at this point, tarFileEnd is position where EOT block begins - tar_close(tar); // close for reading - - //truncate EOT from the tarball - if (truncate(tarFileName.c_str(), tarFileEnd) == -1) { - throw std::runtime_error("can't truncate tarball"); - } - - // and now append the new file, and put an EOF at the end - - // open truncated tarball (without EOT block) for writing and append - if (tar_open(&tar, - (char*) tarFileName.c_str(), - NULL, - O_WRONLY | O_APPEND, - 0666, - 0) == -1) { - throw std::runtime_error("can't open tarball"); - } - - // add the new file - if (tar_append_file(tar, - (char*) newFileRealName.c_str(), - (char*) newFileInTarball.c_str()) == -1) { - tar_close(tar); - throw std::runtime_error("can't append file to tarball"); - } - - // add EOT at the end and close tarball - tar_append_eof(tar); - tar_close(tar); -} - - -/*------------------------------------------------------------------------------ - * Check if a file is in the tarball - *----------------------------------------------------------------------------*/ -bool -FileTools :: existsInTarball(const std::string & tarFileName, - const std::string & fileName) - throw (std::runtime_error) -{ - TAR * tar; - bool result = false; - - if (tar_open(&tar, - (char*) tarFileName.c_str(), - NULL, - O_RDONLY, - 0, - 0) == -1) { - throw std::runtime_error("can't open tarball"); - } - - while (th_read(tar) == 0) { - if (TH_ISREG(tar)) { - char * path = th_get_pathname(tar); - - if (fileName == path) { - result = true; - break; - } - - tar_skip_regfile(tar); - } - } - - // at this point, tarFileEnd is position where EOT block begins - tar_close(tar); // close for reading - - return result; -} - - -/*------------------------------------------------------------------------------ - * Extract a file from a tarball. - *----------------------------------------------------------------------------*/ -void -FileTools :: extractFileFromTarball(const std::string & tarFileName, - const std::string & fileInTarball, - const std::string & fileExtracted) - throw (std::runtime_error) -{ - TAR * tar; - bool found = false; - - if (tar_open(&tar, - (char*) tarFileName.c_str(), - NULL, - O_RDONLY, - 0, - 0) == -1) { - throw std::runtime_error("can't open tarball"); - } - - while (th_read(tar) == 0) { - if (TH_ISREG(tar)) { - char * path = th_get_pathname(tar); - - if (fileInTarball == path) { - found = true; - if (tar_extract_file(tar, - (char *) fileExtracted.c_str()) != 0) { - std::string errorMsg = "can't extract file "; - errorMsg += fileInTarball; - errorMsg += " from tarball "; - errorMsg += tarFileName; - throw std::runtime_error(errorMsg); - } - break; - } - - tar_skip_regfile(tar); - } - } - - // at this point, tarFileEnd is position where EOT block begins - tar_close(tar); // close for reading - - if (!found) { - std::string errorMsg = "could not find file "; - errorMsg += fileInTarball; - errorMsg += " in the tarball "; - errorMsg += tarFileName; - throw std::runtime_error(errorMsg); - } -} - diff --git a/src/modules/core/src/FileToolsTest.cxx b/src/modules/core/src/FileToolsTest.cxx deleted file mode 100644 index 9f23f8112..000000000 --- a/src/modules/core/src/FileToolsTest.cxx +++ /dev/null @@ -1,149 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - To report bugs, send an e-mail to bugs@campware.org - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - - Author : $Author: fgerlits $ - Version : $Revision: 1871 $ - Location : $URL: svn+ssh://maroy@code.campware.org/home/svn/repo/livesupport/trunk/livesupport/src/modules/core/src/FileToolsTest.cxx $ - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/FileTools.h" -#include "LiveSupport/Core/Playlist.h" -#include "FileToolsTest.h" - - -using namespace std; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(FileToolsTest); - -namespace { - -/** - * The name of the test tar file - */ -const std::string tarFileName = "var/hello.tar"; - -/** - * The name of the test file in the tar file - */ -const std::string fileInTarName = "hello"; - -/** - * The name of the test file after extraction - */ -const std::string fileExtracted = "tmp/hello.txt"; - -} - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -FileToolsTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -FileToolsTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the sample hello tarfile is accessible - *----------------------------------------------------------------------------*/ -void -FileToolsTest :: existsInTarTest(void) - throw (CPPUNIT_NS::Exception) -{ - CPPUNIT_ASSERT(FileTools::existsInTarball(tarFileName, fileInTarName)); - CPPUNIT_ASSERT(!FileTools::existsInTarball(tarFileName, "foobar")); -} - - -/*------------------------------------------------------------------------------ - * Test to see if the sample hello tarfile is accessible - *----------------------------------------------------------------------------*/ -void -FileToolsTest :: extractFileFromTarballTest(void) - throw (CPPUNIT_NS::Exception) -{ - FILE * file; - - remove(fileExtracted.c_str()); - file = fopen(fileExtracted.c_str(), "r"); - CPPUNIT_ASSERT(file == 0); - - CPPUNIT_ASSERT_NO_THROW( - FileTools::extractFileFromTarball(tarFileName, - fileInTarName, - fileExtracted) - ); - - file = fopen(fileExtracted.c_str(), "r"); - CPPUNIT_ASSERT(file != 0); - CPPUNIT_ASSERT(fclose(file) == 0); - - CPPUNIT_ASSERT(remove(fileExtracted.c_str()) == 0); - file = fopen(fileExtracted.c_str(), "r"); - CPPUNIT_ASSERT(file == 0); - - CPPUNIT_ASSERT_THROW( - FileTools::extractFileFromTarball(tarFileName, - "foobar", - fileExtracted), - std::runtime_error - ); -} - diff --git a/src/modules/core/src/FileToolsTest.h b/src/modules/core/src/FileToolsTest.h deleted file mode 100644 index 1ca7dbda3..000000000 --- a/src/modules/core/src/FileToolsTest.h +++ /dev/null @@ -1,111 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef FileToolsTest_h -#define FileToolsTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include "LiveSupport/Core/FileTools.h" - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the FileTools class. - * - * @see FileTools - */ -class FileToolsTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(FileToolsTest); - CPPUNIT_TEST(existsInTarTest); - CPPUNIT_TEST(extractFileFromTarballTest); - CPPUNIT_TEST_SUITE_END(); - - private: - - protected: - - /** - * Test the existsInTarball() function. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - existsInTarTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the extractFileFromTarball() function. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - extractFileFromTarballTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // FileToolsTest_h - diff --git a/src/modules/core/src/LocalizedConfigurable.cxx b/src/modules/core/src/LocalizedConfigurable.cxx deleted file mode 100644 index dca0d9172..000000000 --- a/src/modules/core/src/LocalizedConfigurable.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/LocalizedConfigurable.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/** - * The name of the attribute to get the path of the resource bundle. - */ -static const std::string pathAttrName = "path"; - -/** - * The name of the attribute to get the locale of the resource bundle. - */ -static const std::string localeAttrName = "locale"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Load a resource bunlde based on an XML configuration element. - *----------------------------------------------------------------------------*/ -void -LocalizedConfigurable :: configure(const xmlpp::Element & element) - throw (std::invalid_argument, - std::logic_error) -{ - if (element.get_name() != LocalizedObject::getConfigElementName()) { - std::string eMsg = "Bad configuration element "; - eMsg += element.get_name(); - throw std::invalid_argument(eMsg); - } - - const xmlpp::Attribute * attribute = 0; - - if (!(attribute = element.get_attribute(pathAttrName))) { - std::string eMsg = "Missing attribute "; - eMsg += pathAttrName; - throw std::invalid_argument(eMsg); - } - bundlePath = attribute->get_value(); - - if (!(attribute = element.get_attribute(localeAttrName))) { - std::string eMsg = "Missing attribute "; - eMsg += localeAttrName; - throw std::invalid_argument(eMsg); - } - std::string locale = attribute->get_value(); - - changeLocale(locale); -} - - -/*------------------------------------------------------------------------------ - * Change the resource bundle to reflect the specified locale - *----------------------------------------------------------------------------*/ -void -LocalizedConfigurable :: changeLocale(const std::string newLocale) - throw (std::invalid_argument) -{ - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref resourceBundle( - new ResourceBundle(bundlePath.c_str(), - newLocale.c_str(), - status)); - if (!U_SUCCESS(status)) { - throw std::invalid_argument("opening resource bundle a failure"); - } - - setBundle(resourceBundle); -} - - diff --git a/src/modules/core/src/LocalizedConfigurableTest.cxx b/src/modules/core/src/LocalizedConfigurableTest.cxx deleted file mode 100644 index 87cbee3a3..000000000 --- a/src/modules/core/src/LocalizedConfigurableTest.cxx +++ /dev/null @@ -1,167 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include - -#include "LiveSupport/Core/LocalizedConfigurable.h" -#include "LocalizedConfigurableTest.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(LocalizedConfigurableTest); - -/** - * The name of the configuration file for the resource bundle. - */ -static const std::string configFileName = "etc/resourceBundle.xml"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -LocalizedConfigurableTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -LocalizedConfigurableTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * A simple smoke test. - *----------------------------------------------------------------------------*/ -void -LocalizedConfigurableTest :: simpleTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref locConf(new LocalizedConfigurable()); - - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - locConf->configure(*root); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in configuration file"); - } catch (std::exception &e) { - CPPUNIT_FAIL(e.what()); - } - - try { - Ptr::Ref section1(new LocalizedObject( - locConf->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->compare("fou") == 0); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } -} - - -/*------------------------------------------------------------------------------ - * A test to see if chaning the locale works. - *----------------------------------------------------------------------------*/ -void -LocalizedConfigurableTest :: changeLocaleTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref locConf(new LocalizedConfigurable()); - - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - locConf->configure(*root); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in configuration file"); - } catch (std::exception &e) { - CPPUNIT_FAIL(e.what()); - } - - // see if all is OK in english - try { - Ptr::Ref section1(new LocalizedObject( - locConf->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->compare("fou") == 0); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - - // see if all is OK when changing to hungarian. - try { - locConf->changeLocale("hu"); - - Ptr::Ref section1(new LocalizedObject( - locConf->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->charAt(0) == 0x0066); // 'f' - CPPUNIT_ASSERT(foo->charAt(1) == 0x00fa); // 'u' with acute - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - - // see if all is OK when changing to japanese. - try { - locConf->changeLocale("jp"); - - Ptr::Ref section1(new LocalizedObject( - locConf->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->charAt(0) == 0x3075); // hiragana fu - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } -} - - diff --git a/src/modules/core/src/LocalizedConfigurableTest.h b/src/modules/core/src/LocalizedConfigurableTest.h deleted file mode 100644 index 279b0ad0b..000000000 --- a/src/modules/core/src/LocalizedConfigurableTest.h +++ /dev/null @@ -1,108 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LocalizedConfigurableTest_h -#define LocalizedConfigurableTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the LocalizedConfigurable class. - * - * @see LocalizedObject - */ -class LocalizedConfigurableTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(LocalizedConfigurableTest); - CPPUNIT_TEST(simpleTest); - CPPUNIT_TEST(changeLocaleTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple smoke test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - simpleTest(void) throw (CPPUNIT_NS::Exception); - - /** - * A test to see if changing the locale works. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - changeLocaleTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LocalizedConfigurableTest_h - diff --git a/src/modules/core/src/LocalizedObject.cxx b/src/modules/core/src/LocalizedObject.cxx deleted file mode 100644 index 37e5c4a14..000000000 --- a/src/modules/core/src/LocalizedObject.cxx +++ /dev/null @@ -1,335 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include "LiveSupport/Core/LocalizedObject.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * The name of the config element for this class - *----------------------------------------------------------------------------*/ -const std::string LocalizedObject::configElementNameStr = "resourceBundle"; - -/** - * The name of the attribute to get the path of the resource bundle. - */ -static const std::string pathAttrName = "path"; - -/** - * The name of the attribute to get the locale of the resource bundle. - */ -static const std::string localeAttrName = "locale"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Load a resource bunlde based on an XML configuration element. - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: getBundle(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementNameStr) { - std::string eMsg = "Bad configuration element "; - eMsg += element.get_name(); - throw std::invalid_argument(eMsg); - } - - const xmlpp::Attribute * attribute = 0; - - if (!(attribute = element.get_attribute(pathAttrName))) { - std::string eMsg = "Missing attribute "; - eMsg += pathAttrName; - throw std::invalid_argument(eMsg); - } - std::string path = attribute->get_value(); - - if (!(attribute = element.get_attribute(localeAttrName))) { - std::string eMsg = "Missing attribute "; - eMsg += localeAttrName; - throw std::invalid_argument(eMsg); - } - std::string locale = attribute->get_value(); - - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref resourceBundle( - new ResourceBundle(path.c_str(), - locale.c_str(), - status)); - if (!U_SUCCESS(status)) { - throw std::invalid_argument("opening resource bundle a failure"); - } - - return resourceBundle; -} - - -/*------------------------------------------------------------------------------ - * Get a resource bundle by the specified key - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: getBundle(Ptr::Ref bundle, - const char * key) - throw (std::invalid_argument) -{ - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref resourceBundle(new ResourceBundle( - bundle->getWithFallback(key, status))); - if (!U_SUCCESS(status)) { - std::string eMsg = "can't get resource bundle for key '"; - eMsg += key; - eMsg += "' and locale '"; - eMsg += bundle->getLocale().getName(); - eMsg += "'"; - throw std::invalid_argument(eMsg); - } - - return resourceBundle; -} - - -/*------------------------------------------------------------------------------ - * Get a string from a resource bundle in the ICU string format - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: getResourceString(Ptr::Ref bundle, - const char * key) - throw (std::invalid_argument) -{ - Ptr::Ref rb = getBundle(bundle, key); - if (rb->getType() == URES_STRING) { - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref str(new UnicodeString(rb->getString(status))); - if (!U_SUCCESS(status)) { - throw std::invalid_argument("requested resource not a string"); - } - - return str; - } else { - throw std::invalid_argument("requested resource not a string"); - } -} - - -/*------------------------------------------------------------------------------ - * Format a message - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: formatMessage(Ptr::Ref pattern, - Formattable * arguments, - unsigned int nArguments) - throw (std::invalid_argument) -{ - Ptr::Ref message(new UnicodeString()); - UErrorCode err = U_ZERO_ERROR; - MessageFormat::format(*pattern, arguments, nArguments, *message, err); - if (!U_SUCCESS(err)) { - throw std::invalid_argument("can't format string"); - } - - return message; -} - - -/*------------------------------------------------------------------------------ - * Format a message, based on a resource key for its pattern - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: formatMessage(const char * patternKey, - Formattable * arguments, - unsigned int nArguments) - throw (std::invalid_argument) -{ - return unicodeStringToUstring( - formatMessage(getResourceString(patternKey), arguments, nArguments)); -} - - -/*------------------------------------------------------------------------------ - * Format a message, based on a resource key for its pattern - * and one argument for formatting. - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: formatMessage(const std::string & patternKey, - const Glib::ustring & argument1) - throw (std::invalid_argument) -{ - Ptr::Ref uArgument1 = ustringToUnicodeString(argument1); - Formattable arguments[] = { *uArgument1 }; - - return formatMessage(patternKey, arguments, 1); -} - - -/*------------------------------------------------------------------------------ - * Format a message, based on a resource key for its pattern - * and two arguments for formatting. - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: formatMessage(const std::string & patternKey, - const Glib::ustring & argument1, - const Glib::ustring & argument2) - throw (std::invalid_argument) -{ - Ptr::Ref uArgument1 = ustringToUnicodeString(argument1); - Ptr::Ref uArgument2 = ustringToUnicodeString(argument2); - Formattable arguments[] = { *uArgument1, - *uArgument2 }; - - return formatMessage(patternKey, arguments, 2); -} - - -/*------------------------------------------------------------------------------ - * Format a message, based on a resource key for its pattern - * and one argument for formatting. - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: formatMessage(const std::string & patternKey, - const Glib::ustring & argument1, - const Glib::ustring & argument2, - const Glib::ustring & argument3) - throw (std::invalid_argument) -{ - Ptr::Ref uArgument1 = ustringToUnicodeString(argument1); - Ptr::Ref uArgument2 = ustringToUnicodeString(argument2); - Ptr::Ref uArgument3 = ustringToUnicodeString(argument3); - Formattable arguments[] = { *uArgument1, - *uArgument2, - *uArgument3 }; - return formatMessage(patternKey, arguments, 3); -} - - -/*------------------------------------------------------------------------------ - * Create a Glib ustring from an ICU UnicodeString - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: unicodeStringToUstring( - Ptr::Ref unicodeString) - throw () -{ - const UChar * uchars = unicodeString->getBuffer(); - int32_t length = unicodeString->length(); - Ptr::Ref ustr(new Glib::ustring()); - ustr->reserve(length); - - while (length--) { - ustr->push_back((gunichar) (*(uchars++))); - } - - return ustr; -} - - -/*------------------------------------------------------------------------------ - * Create an ICU UnicodeString from a Glib ustring - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: ustringToUnicodeString( - Ptr::Ref gString) - throw () -{ - Ptr::Ref uString(new UnicodeString()); - - Glib::ustring::const_iterator it = gString->begin(); - Glib::ustring::const_iterator end = gString->end(); - while (it < end) { - uString->append((UChar32) *it++); - } - - return uString; -} - - -/*------------------------------------------------------------------------------ - * Create an ICU UnicodeString from a Glib ustring - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: ustringToUnicodeString(const Glib::ustring & gString) - throw () -{ - Ptr::Ref uString(new UnicodeString()); - - Glib::ustring::const_iterator it = gString.begin(); - Glib::ustring::const_iterator end = gString.end(); - while (it < end) { - uString->append((UChar32) *it++); - } - - return uString; -} - - -/*------------------------------------------------------------------------------ - * Get a string from a resource bundle in the ICU string format - *----------------------------------------------------------------------------*/ -Ptr::Ref -LocalizedObject :: getBinaryResourceAsUstring(const char * key) - throw (std::invalid_argument) -{ - Ptr::Ref rb = getBundle(key); - if (rb->getType() == URES_BINARY) { - int32_t length; - UErrorCode status = U_ZERO_ERROR; - const uint8_t * data = rb->getBinary(length, status); - if (!U_SUCCESS(status)) { - throw std::invalid_argument("could not get requested " - "binary resource"); - } - char * strBuf = new char[length + 1]; - memcpy(strBuf, data, length); - strBuf[length] = 0; - Ptr::Ref string(new Glib::ustring(strBuf)); - if (string->validate()) { - return string; - } else { - std::string errorMessage = "invalid UTF-8 sequence found "; - errorMessage += "in resource '"; - errorMessage += key; - errorMessage += "'"; - throw std::invalid_argument(errorMessage); - } - } else { - throw std::invalid_argument("requested resource is not a binary value"); - } -} - diff --git a/src/modules/core/src/LocalizedObjectTest.cxx b/src/modules/core/src/LocalizedObjectTest.cxx deleted file mode 100644 index c334cd196..000000000 --- a/src/modules/core/src/LocalizedObjectTest.cxx +++ /dev/null @@ -1,342 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include - -#include "LiveSupport/Core/LocalizedObject.h" -#include "LocalizedObjectTest.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(LocalizedObjectTest); - -/** - * The name of the configuration file for the resource bundle. - */ -static const std::string configFileName = "etc/resourceBundle.xml"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * A simple smoke test. - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: simpleTest(void) - throw (CPPUNIT_NS::Exception) -{ - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref bundle(new ResourceBundle("./tmp/" PACKAGE_NAME, - "root", - status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - - try { - Ptr::Ref locObj(new LocalizedObject(bundle)); - Ptr::Ref section1(new LocalizedObject( - locObj->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->compare("foo") == 0); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } -} - - -/*------------------------------------------------------------------------------ - * A test to see different locales and fallback to work. - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: fallbackTest(void) - throw (CPPUNIT_NS::Exception) -{ - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref rootBundle; - Ptr::Ref enBundle; - - rootBundle.reset(new ResourceBundle("./tmp/" PACKAGE_NAME, "root", status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - enBundle.reset(new ResourceBundle("./tmp/" PACKAGE_NAME, "en", status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - - // first, see the root bundle - try { - Ptr::Ref locObj(new LocalizedObject(rootBundle)); - Ptr::Ref section1(new LocalizedObject( - locObj->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->compare("foo") == 0); - Ptr::Ref bar = section1->getResourceString("bar"); - CPPUNIT_ASSERT(bar->compare("bar") == 0); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - - // now, the en bundle - try { - Ptr::Ref locObj(new LocalizedObject(enBundle)); - Ptr::Ref section1(new LocalizedObject( - locObj->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->compare("fou") == 0); - Ptr::Ref bar = section1->getResourceString("bar"); - CPPUNIT_ASSERT(bar->compare("bar") == 0); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } -} - - -/*------------------------------------------------------------------------------ - * A test to see funny unicode characters to work. - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: unicodeTest(void) - throw (CPPUNIT_NS::Exception) -{ - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref huBundle; - Ptr::Ref jpBundle; - - huBundle.reset(new ResourceBundle("./tmp/" PACKAGE_NAME, "hu", status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - try { - Ptr::Ref locObj(new LocalizedObject(huBundle)); - Ptr::Ref section1(new LocalizedObject( - locObj->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->charAt(0) == 0x0066); // 'f' - CPPUNIT_ASSERT(foo->charAt(1) == 0x00fa); // 'u' with acute - Ptr::Ref bar = section1->getResourceString("bar"); - CPPUNIT_ASSERT(bar->charAt(0) == 0x0062); // 'b' - CPPUNIT_ASSERT(bar->charAt(1) == 0x00e1); // 'a' with acute - CPPUNIT_ASSERT(bar->charAt(2) == 0x0072); // 'r' - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - - jpBundle.reset(new ResourceBundle("./tmp/" PACKAGE_NAME, "jp", status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - try { - Ptr::Ref locObj(new LocalizedObject(jpBundle)); - Ptr::Ref section1(new LocalizedObject( - locObj->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->charAt(0) == 0x3075); // hiragana fu - Ptr::Ref bar = section1->getResourceString("bar"); - CPPUNIT_ASSERT(bar->charAt(0) == 0x3070); // hiragana ba - CPPUNIT_ASSERT(bar->charAt(1) == 0x308b); // hiragana ru - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } -} - - -/*------------------------------------------------------------------------------ - * Test message formatting. - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: formatMessageTest(void) - throw (CPPUNIT_NS::Exception) -{ - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref bundle(new ResourceBundle("./tmp/" PACKAGE_NAME, - "root", - status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - - try { - Ptr::Ref message; - Ptr::Ref locObj(new LocalizedObject(bundle)); - Ptr::Ref messages(new LocalizedObject( - locObj->getBundle("messages"))); - Formattable arguments[] = { "p1", "p2" }; - - // test formatting through a key - message = messages->formatMessage("aMessage", arguments, 2); - CPPUNIT_ASSERT(*message == "parameter 0: p1, parameter 1: p2"); - - // test formatting through an explicit pattern - Ptr::Ref uMessage; - Ptr::Ref pattern(new UnicodeString( - "only 1 parameter: {0}")); - uMessage = LocalizedObject::formatMessage(pattern, arguments, 1); - CPPUNIT_ASSERT(uMessage->compare("only 1 parameter: p1") == 0); - - // test formatting through a key, and a fixed number of parameters - message = messages->formatMessage("aMessage3Args", "p0"); - CPPUNIT_ASSERT(*message == "p0: p0, p2: {2}, p1: {1}"); - message = messages->formatMessage("aMessage3Args", "p0", "p1"); - CPPUNIT_ASSERT(*message == "p0: p0, p2: {2}, p1: p1"); - message = messages->formatMessage("aMessage3Args", "p0", "p1", "p2"); - CPPUNIT_ASSERT(*message == "p0: p0, p2: p2, p1: p1"); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } -} - - -/*------------------------------------------------------------------------------ - * Test to see if resource bundle can be loaded based on a config file - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: loadFromConfigTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref bundle; - - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - bundle = LocalizedObject::getBundle(*root); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in configuration file"); - } catch (std::exception &e) { - CPPUNIT_FAIL(e.what()); - } - CPPUNIT_ASSERT(bundle.get()); - - // now, see if this really is the en bundle - try { - Ptr::Ref locObj(new LocalizedObject(bundle)); - Ptr::Ref section1(new LocalizedObject( - locObj->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceString("foo"); - CPPUNIT_ASSERT(foo->compare("fou") == 0); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } -} - - -/*------------------------------------------------------------------------------ - * Test the ustring related functions. - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: ustringTest(void) - throw (CPPUNIT_NS::Exception) -{ - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref bundle(new ResourceBundle("./tmp/" PACKAGE_NAME, - "root", - status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - - // test getting an ustring resource - try { - Ptr::Ref locObj(new LocalizedObject(bundle)); - Ptr::Ref section1(new LocalizedObject( - locObj->getBundle("section1"))); - Ptr::Ref foo = section1->getResourceUstring("foo"); - CPPUNIT_ASSERT(*foo == "foo"); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - - // test message formatting to ustring - try { - Ptr::Ref message; - Ptr::Ref locObj(new LocalizedObject(bundle)); - Ptr::Ref messages(new LocalizedObject( - locObj->getBundle("messages"))); - Formattable arguments[] = { "p1", "p2" }; - - // test formatting through a key - message = messages->formatMessage("aMessage", arguments, 2); - CPPUNIT_ASSERT(*message == "parameter 0: p1, parameter 1: p2"); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } -} - - -/*------------------------------------------------------------------------------ - * Test the ustring related functions in problematic situations - * see http://bugs.campware.org/view.php?id=792 - *----------------------------------------------------------------------------*/ -void -LocalizedObjectTest :: ustringNegativeTest(void) - throw (CPPUNIT_NS::Exception) -{ - bool gotException; - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref bundle(new ResourceBundle("./tmp/" PACKAGE_NAME, - "root", - status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - - // test getting a missing ustring resource - gotException = false; - try { - Ptr::Ref locObj(new LocalizedObject(bundle)); - Ptr::Ref section1(new LocalizedObject( - locObj->getBundle("section1"))); - Ptr::Ref foo = - section1->getResourceUstring("nonexistentKey"); - } catch (std::invalid_argument &e) { - gotException = true; - } - CPPUNIT_ASSERT(gotException); -} - - diff --git a/src/modules/core/src/LocalizedObjectTest.h b/src/modules/core/src/LocalizedObjectTest.h deleted file mode 100644 index 7fdeeba35..000000000 --- a/src/modules/core/src/LocalizedObjectTest.h +++ /dev/null @@ -1,156 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LocalizedObjectTest_h -#define LocalizedObjectTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the LocalizedObject class. - * - * @see LocalizedObject - */ -class LocalizedObjectTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(LocalizedObjectTest); - CPPUNIT_TEST(simpleTest); - CPPUNIT_TEST(fallbackTest); - CPPUNIT_TEST(unicodeTest); - CPPUNIT_TEST(formatMessageTest); - CPPUNIT_TEST(loadFromConfigTest); - CPPUNIT_TEST(ustringTest); - CPPUNIT_TEST(ustringNegativeTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple smoke test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - simpleTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test to see if multiple locales work, and they fall back to - * more generic values. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - fallbackTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test to see if funny unicode characters work properly. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - unicodeTest(void) throw (CPPUNIT_NS::Exception); - - /** - * A test to see if message formatting works all right. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - formatMessageTest(void) throw (CPPUNIT_NS::Exception); - - /** - * A test to see if a resource bundle can be loaded based on a - * configuration file - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - loadFromConfigTest(void) throw (CPPUNIT_NS::Exception); - - /** - * A test to check the Glib::ustring related functions. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - ustringTest(void) throw (CPPUNIT_NS::Exception); - - /** - * A test to check the Glib::ustring related function beaviour - * in problematic situations. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - ustringNegativeTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LocalizedObjectTest_h - diff --git a/src/modules/core/src/Md5.cxx b/src/modules/core/src/Md5.cxx deleted file mode 100644 index edf0f2d3b..000000000 --- a/src/modules/core/src/Md5.cxx +++ /dev/null @@ -1,586 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - ------------------------------------------------------------------------------ - - This class is based on the following with minor modifications - (see http://userpages.umbc.edu/~mabzug1/cs/md5/md5.html). - - ------------------------------------------------------------------------------ - -// Md5.CC - source code for the C++/object oriented translation and -// modification of Md5. - -// Translation and modification (c) 1995 by Mordechai T. Abzug - -// This translation/ modification is provided "as is," without express or -// implied warranty of any kind. - -// The translator/ modifier does not claim (1) that Md5 will do what you think -// it does; (2) that this translation/ modification is accurate; or (3) that -// this software is "merchantible." (Language for this disclaimer partially -// copied from the disclaimer below). - - ------------------------------------------------------------------------------ - - Which was based on: - - ------------------------------------------------------------------------------ - - Md5.H - header file for Md5C.C - MDDRIVER.C - test driver for MD2, MD4 and Md5 - - Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. - -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. Md5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. - -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. Md5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. - -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. - -These notices must be retained in any copies of any part of this -documentation and/or software. - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include "LiveSupport/Core/Md5.h" - -#include -#include -#include - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Construct from a string. - *----------------------------------------------------------------------------*/ -Md5::Md5(const std::string &s) throw(std::invalid_argument) -{ - init(); - update (s); - finalize(); - calcNumericRepresentation(); -} - - -/*------------------------------------------------------------------------------ - * Construct from an istream. - *----------------------------------------------------------------------------*/ -Md5::Md5(std::istream& stream) throw(std::invalid_argument) -{ - init(); - update (stream); - finalize(); - calcNumericRepresentation(); -} - - -/*------------------------------------------------------------------------------ - * Construct from a file. - *----------------------------------------------------------------------------*/ -Md5::Md5(FILE *file) throw(std::invalid_argument) -{ - init(); - update(file); - finalize (); - calcNumericRepresentation(); -} - - -/*------------------------------------------------------------------------------ - * Output the md5 sum as a hexadecimal string. - *----------------------------------------------------------------------------*/ -std::string Md5::hexDigest() throw() -{ - std::stringstream strStr; - - for (int i=0; i<16; i++) { - strStr << std::hex << std::setw(2) << std::setfill('0') - << int(digest[i]); - } - - return strStr.str(); -} - - -/*------------------------------------------------------------------------------ - * Calculate the numeric representation of the checksum - *----------------------------------------------------------------------------*/ -void -Md5 :: calcNumericRepresentation(void) throw () -{ - low64 = (uint64_t) digest[15]; - low64 |= ((uint64_t) digest[14]) << 8; - low64 |= ((uint64_t) digest[13]) << 16; - low64 |= ((uint64_t) digest[12]) << 24; - low64 |= ((uint64_t) digest[11]) << 32; - low64 |= ((uint64_t) digest[10]) << 40; - low64 |= ((uint64_t) digest[9]) << 48; - low64 |= ((uint64_t) digest[8]) << 56; - - high64 = (uint64_t) digest[7]; - high64 |= ((uint64_t) digest[6]) << 8; - high64 |= ((uint64_t) digest[5]) << 16; - high64 |= ((uint64_t) digest[4]) << 24; - high64 |= ((uint64_t) digest[3]) << 32; - high64 |= ((uint64_t) digest[2]) << 40; - high64 |= ((uint64_t) digest[1]) << 48; - high64 |= ((uint64_t) digest[0]) << 56; -} - - -/*------------------------------------------------------------------------------ - * Convert the md5 sum to a hexadecimal string. - *----------------------------------------------------------------------------*/ -Md5::operator std::string() throw() -{ - return hexDigest(); -} - - -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private methods */ - -// Md5 block update operation. Continues an Md5 message-digest -// operation, processing another message block, and updating the -// context. - -void Md5::update (uint1 *input, uint4 input_length) -{ - uint4 input_index, buffer_index; - uint4 buffer_space; // how much space is left in buffer - - if (finalized){ // so we can't update! - throw std::invalid_argument("Md5::update: " - "Can't update a finalized digest!"); - } - - // Compute number of bytes mod 64 - buffer_index = (unsigned int)((count[0] >> 3) & 0x3F); - - // Update number of bits - if ( (count[0] += ((uint4) input_length << 3))<((uint4) input_length << 3) ) - count[1]++; - - count[1] += ((uint4)input_length >> 29); - - - buffer_space = 64 - buffer_index; // how much space is left in buffer - - // Transform as many times as possible. - if (input_length >= buffer_space) { // ie. we have enough to fill the buffer - // fill the rest of the buffer and transform - memcpy (buffer + buffer_index, input, buffer_space); - transform (buffer); - - // now, transform each 64-byte piece of the input, bypassing the buffer - for (input_index = buffer_space; input_index + 63 < input_length; - input_index += 64) { - transform (input+input_index); - } - buffer_index = 0; // so we can buffer remaining - } else { - input_index=0; // so we can buffer the whole input - } - - // and here we do the buffering: - memcpy(buffer+buffer_index, input+input_index, input_length-input_index); -} - - - -// Md5 update for files. -// Like above, except that it works on files (and uses above as a primitive.) - -void Md5::update(FILE *file) -{ - uint1 buffer[1024]; - uint4 len; - - while ((len=fread(buffer, 1, 1024, file))) - update(buffer, len); - -// deleted by me (fgerlits) to make it work more like the istream version -// fclose (file); -} - - - - - - -// Md5 update for istreams. -// Like update for files; see above. - -void Md5::update(std::istream& stream) -{ - uint1 buffer[1024]; - uint4 len; - - while (stream.good()){ // note that return value of read is unusable. - stream.read((char *)buffer, 1024); - len=stream.gcount(); - update(buffer, len); - } -} - - - - - - -// Md5 update for strings. -// Like update for files; see above. - -void Md5::update(const std::string &s) -{ - uint1 buffer[1024]; - uint4 len; - uint4 pos = 0; - - while (pos < s.size()){ - len = s.copy((char *)buffer, 1024, pos); - update(buffer, len); - pos += len; - } -} - - - - - - -// Md5 finalization. Ends an Md5 message-digest operation, writing the -// the message digest and zeroizing the context. - - -void Md5::finalize () throw (std::invalid_argument) -{ - uint1 bits[8]; - uint4 index, padLen; - static uint1 PADDING[64]={ - 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - if (finalized){ - throw std::invalid_argument("Md5::finalize: " - "Already finalized this digest!"); - } - - // Save number of bits - encode (bits, count, 8); - - // Pad out to 56 mod 64. - index = (uint4) ((count[0] >> 3) & 0x3f); - padLen = (index < 56) ? (56 - index) : (120 - index); - update (PADDING, padLen); - - // Append length (before padding) - update (bits, 8); - - // Store state in digest - encode (digest, state, 16); - - // Zeroize sensitive information - memset (buffer, 0, sizeof(*buffer)); - - finalized=1; -} - - - - -// PRIVATE METHODS: - - - -void Md5::init(){ - finalized=0; // we just started! - - // Nothing counted, so count=0 - count[0] = 0; - count[1] = 0; - - // Load magic initialization constants. - state[0] = 0x67452301; - state[1] = 0xefcdab89; - state[2] = 0x98badcfe; - state[3] = 0x10325476; -} - - - -// Constants for Md5Transform routine. -// Although we could use C++ style constants, defines are actually better, -// since they let us easily evade scope clashes. - -#define S11 7 -#define S12 12 -#define S13 17 -#define S14 22 -#define S21 5 -#define S22 9 -#define S23 14 -#define S24 20 -#define S31 4 -#define S32 11 -#define S33 16 -#define S34 23 -#define S41 6 -#define S42 10 -#define S43 15 -#define S44 21 - - - - -// Md5 basic transformation. Transforms state based on block. -void Md5::transform (uint1 block[64]){ - - uint4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; - - decode (x, block, 64); - - assert(!finalized); // not just a user error, since the method is private - - /* Round 1 */ - FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */ - FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */ - FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */ - FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */ - FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */ - FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */ - FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */ - FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */ - FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */ - FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */ - FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */ - FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */ - FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */ - FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */ - FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */ - FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */ - - /* Round 2 */ - GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */ - GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */ - GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */ - GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */ - GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */ - GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */ - GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */ - GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */ - GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */ - GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */ - GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */ - GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */ - GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */ - GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */ - GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */ - GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */ - - /* Round 3 */ - HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */ - HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */ - HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */ - HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */ - HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */ - HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */ - HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */ - HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */ - HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */ - HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */ - HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */ - HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */ - HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */ - HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */ - HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */ - HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */ - - /* Round 4 */ - II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */ - II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */ - II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */ - II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */ - II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */ - II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */ - II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */ - II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */ - II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */ - II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */ - II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */ - II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */ - II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */ - II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */ - II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */ - II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */ - - state[0] += a; - state[1] += b; - state[2] += c; - state[3] += d; - - // Zeroize sensitive information. - memset ( (uint1 *) x, 0, sizeof(x)); - -} - - - -// Encodes input (UINT4) into output (unsigned char). Assumes len is -// a multiple of 4. -void Md5::encode (uint1 *output, uint4 *input, uint4 len) { - - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) { - output[j] = (uint1) (input[i] & 0xff); - output[j+1] = (uint1) ((input[i] >> 8) & 0xff); - output[j+2] = (uint1) ((input[i] >> 16) & 0xff); - output[j+3] = (uint1) ((input[i] >> 24) & 0xff); - } -} - - - - -// Decodes input (unsigned char) into output (UINT4). Assumes len is -// a multiple of 4. -void Md5::decode (uint4 *output, uint1 *input, uint4 len){ - - unsigned int i, j; - - for (i = 0, j = 0; j < len; i++, j += 4) - output[i] = ((uint4)input[j]) | (((uint4)input[j+1]) << 8) | - (((uint4)input[j+2]) << 16) | (((uint4)input[j+3]) << 24); -} - - - - - -// Note: Replace "for loop" with standard memcpy if possible. -void Md5::memcpy (uint1 *output, uint1 *input, uint4 len){ - - unsigned int i; - - for (i = 0; i < len; i++) - output[i] = input[i]; -} - - - -// Note: Replace "for loop" with standard memset if possible. -void Md5::memset (uint1 *output, uint1 value, uint4 len){ - - unsigned int i; - - for (i = 0; i < len; i++) - output[i] = value; -} - - - -// ROTATE_LEFT rotates x left n bits. - -inline unsigned int Md5::rotate_left (uint4 x, uint4 n){ - return (x << n) | (x >> (32-n)) ; -} - - - - -// F, G, H and I are basic Md5 functions. - -inline unsigned int Md5::F (uint4 x, uint4 y, uint4 z){ - return (x & y) | (~x & z); -} - -inline unsigned int Md5::G (uint4 x, uint4 y, uint4 z){ - return (x & z) | (y & ~z); -} - -inline unsigned int Md5::H (uint4 x, uint4 y, uint4 z){ - return x ^ y ^ z; -} - -inline unsigned int Md5::I (uint4 x, uint4 y, uint4 z){ - return y ^ (x | ~z); -} - - - -// FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4. -// Rotation is separate from addition to prevent recomputation. - - -inline void Md5::FF(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac){ - a += F(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -inline void Md5::GG(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac){ - a += G(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -inline void Md5::HH(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac){ - a += H(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - -inline void Md5::II(uint4& a, uint4 b, uint4 c, uint4 d, uint4 x, - uint4 s, uint4 ac){ - a += I(b, c, d) + x + ac; - a = rotate_left (a, s) +b; -} - - - - diff --git a/src/modules/core/src/Md5Test.cxx b/src/modules/core/src/Md5Test.cxx deleted file mode 100644 index 63b8eda5e..000000000 --- a/src/modules/core/src/Md5Test.cxx +++ /dev/null @@ -1,113 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/Md5.h" -#include "Md5Test.h" - - -using namespace std; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(Md5Test); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -Md5Test :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -Md5Test :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if we can construct some simple md5 sums - *----------------------------------------------------------------------------*/ -void -Md5Test :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - // test the construction from string - Md5 emptyString(""); - CPPUNIT_ASSERT(emptyString.hexDigest() - == "d41d8cd98f00b204e9800998ecf8427e"); - - Md5 someString("Some other random string."); - CPPUNIT_ASSERT(someString.hexDigest() - == "9007a3599f5d3ae2ac11a29308f964eb"); - - std::string s = someString; - CPPUNIT_ASSERT(s == "9007a3599f5d3ae2ac11a29308f964eb"); - CPPUNIT_ASSERT(someString.low64bits() == 0xac11a29308f964ebLL); - CPPUNIT_ASSERT(someString.high64bits() == 0x9007a3599f5d3ae2LL); - - // test the construction from a FILE* - FILE *f = fopen("var/md5test.data", "r"); - Md5 testFile(f); - CPPUNIT_ASSERT(testFile.hexDigest() - == "fc359d2b366cc110db86c3d68bdf39c4"); - fclose(f); - - // test the construction from an istream - std::ifstream ifs("var/md5test.data"); - Md5 testFileStream(ifs); - CPPUNIT_ASSERT(testFileStream.hexDigest() - == "fc359d2b366cc110db86c3d68bdf39c4"); - ifs.close(); -} - diff --git a/src/modules/core/src/Md5Test.h b/src/modules/core/src/Md5Test.h deleted file mode 100644 index 0fb3c821d..000000000 --- a/src/modules/core/src/Md5Test.h +++ /dev/null @@ -1,99 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef Md5Test_h -#define Md5Test_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the Md5 class. - * - * @see Md5 - */ -class Md5Test : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(Md5Test); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // Md5Test_h - diff --git a/src/modules/core/src/MetadataConstraint.cxx b/src/modules/core/src/MetadataConstraint.cxx deleted file mode 100644 index 1f18a1363..000000000 --- a/src/modules/core/src/MetadataConstraint.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include "NumericConstraint.h" -#include "NumericRangeConstraint.h" -#include "EnumerationConstraint.h" - -#include "LiveSupport/Core/MetadataConstraint.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * The name of the config element for this class - *----------------------------------------------------------------------------*/ -const std::string MetadataConstraint::configElementNameStr = "constraint"; - -/*------------------------------------------------------------------------------ - * The name of the type attribute. - *----------------------------------------------------------------------------*/ -const std::string MetadataConstraint::typeAttributeName = "type"; - -/*------------------------------------------------------------------------------ - * The name of the configuration element for the constraint values. - *----------------------------------------------------------------------------*/ -const std::string MetadataConstraint::valueElementName = "value"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create a constraint element object based on an XML element. - *----------------------------------------------------------------------------*/ -void -MetadataConstraint :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementNameStr) { - throw std::invalid_argument("bad configuration element " - + element.get_name()); - } - - const xmlpp::Attribute* typeAttribute; - if (!(typeAttribute = element.get_attribute(typeAttributeName))) { - throw std::invalid_argument("missing attribute " + typeAttributeName); - } - std::string type = typeAttribute->get_value(); - - if (type == "numeric") { - concreteConstraint.reset(new NumericConstraint()); - concreteConstraint->configure(element); - - } else if (type == "numericRange") { - concreteConstraint.reset(new NumericRangeConstraint()); - concreteConstraint->configure(element); - - } else if (type == "enumeration") { - concreteConstraint.reset(new EnumerationConstraint()); - concreteConstraint->configure(element); - - } else { - throw std::invalid_argument("unknown metadata constraint" + type); - } -} - - -/*------------------------------------------------------------------------------ - * Check that the given value satisfies the constraint. - *----------------------------------------------------------------------------*/ -inline bool -MetadataConstraint :: check(Ptr::Ref value) const - throw (std::logic_error) -{ - if (concreteConstraint) { - return concreteConstraint->check(value); - } else { - throw std::logic_error("MetadataConstraint not configured yet"); - } -} - diff --git a/src/modules/core/src/MetadataType.cxx b/src/modules/core/src/MetadataType.cxx deleted file mode 100644 index 27a3339f6..000000000 --- a/src/modules/core/src/MetadataType.cxx +++ /dev/null @@ -1,195 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/MetadataTypeContainer.h" -#include "LiveSupport/Core/MetadataType.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * The name of the config element for this class - *----------------------------------------------------------------------------*/ -const std::string MetadataType::configElementNameStr = "metadataType"; - -/** - * The name of the attribute of the DC name in the metadataType element. - */ -static const std::string dcNameAttrName = "dcName"; - -/** - * The name of the attribute of the ID3v2 tag in the metadataType element - */ -static const std::string id3TagAttrName = "id3Tag"; - -/** - * The name of the attribute of the localization key in the - * metadataType element. - */ -static const std::string localizationKeyAttrName = "localizationKey"; - -/** - * The name of the attribute of the tab name in the metadataType element - */ -static const std::string tabAttrName = "tab"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -MetadataType :: MetadataType(Ptr::Ref container) - throw () - : container(container), - tab(noTab) -{ -} - - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -MetadataType :: MetadataType(Ptr::Ref container, - Glib::ustring dcName, - Glib::ustring id3Tag, - Glib::ustring localizationKey, - TabType tab) - throw () - : container(container), - tab(tab) -{ - this->dcName.reset(new Glib::ustring(dcName)); - this->id3Tag.reset(new Glib::ustring(id3Tag)); - this->localizationKey.reset(new Glib::ustring(localizationKey)); -} - - -/*------------------------------------------------------------------------------ - * Create a metadata type element object based on an XML element. - *----------------------------------------------------------------------------*/ -void -MetadataType :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementNameStr) { - throw std::invalid_argument("bad configuration element " - + element.get_name()); - } - - const xmlpp::Attribute* attribute; - - // set the DC name - if (!(attribute = element.get_attribute(dcNameAttrName))) { - throw std::invalid_argument("missing attribute " + dcNameAttrName); - } - dcName.reset(new Glib::ustring(attribute->get_value())); - - // get the ID3v2 tag name, optional - if ((attribute = element.get_attribute(id3TagAttrName))) { - id3Tag.reset(new Glib::ustring(attribute->get_value())); - } - - // get the localization key - if (!(attribute = element.get_attribute(localizationKeyAttrName))) { - throw std::invalid_argument("missing attribute " - + localizationKeyAttrName); - } - localizationKey.reset(new Glib::ustring(attribute->get_value())); - - // get the tab, optional - tab = noTab; - if ((attribute = element.get_attribute(tabAttrName))) { - Glib::ustring tabString = attribute->get_value(); - if (tabString == "main") { - tab = mainTab; - } else if (tabString == "music") { - tab = musicTab; - } else if (tabString == "voice") { - tab = voiceTab; - } - } - - // get the constraint, optional - xmlpp::Node::NodeList childNodes = element.get_children( - MetadataConstraint::getConfigElementName()); - xmlpp::Node::NodeList::iterator it = childNodes.begin(); - - if (it != childNodes.end()) { - const xmlpp::Element * constraintElement - = dynamic_cast (*it); - if (constraintElement) { - constraint.reset(new MetadataConstraint()); - constraint->configure(*constraintElement); - } - } -} - - -/*------------------------------------------------------------------------------ - * Return the localized name for this metadata type. - *----------------------------------------------------------------------------*/ -Ptr::Ref -MetadataType :: getLocalizedName(void) const - throw (std::invalid_argument) -{ - return container->getResourceUstring(*localizationKey); -} - - -/*------------------------------------------------------------------------------ - * Check that the given value satisfies the constraint. - *----------------------------------------------------------------------------*/ -bool -MetadataType :: check(Ptr::Ref value) const - throw () -{ - if (!value) { - return false; - } - - if (constraint) { - try { - return constraint->check(value); - } catch (std::logic_error &e) { - return false; - } - } else { - return true; - } -} - diff --git a/src/modules/core/src/MetadataTypeContainer.cxx b/src/modules/core/src/MetadataTypeContainer.cxx deleted file mode 100644 index 182801876..000000000 --- a/src/modules/core/src/MetadataTypeContainer.cxx +++ /dev/null @@ -1,181 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/MetadataTypeContainer.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * The name of the config element for this class - *----------------------------------------------------------------------------*/ -const std::string MetadataTypeContainer::configElementNameStr - = "metadataTypeContainer"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create a metadata type container element object based on an XML element. - *----------------------------------------------------------------------------*/ -void -MetadataTypeContainer :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementNameStr) { - throw std::invalid_argument("bad configuration element " - + element.get_name()); - } - - // get the metadataType child elements, and process them - xmlpp::Node::NodeList childNodes = element.get_children( - MetadataType::getConfigElementName()); - xmlpp::Node::NodeList::iterator it = childNodes.begin(); - xmlpp::Node::NodeList::iterator end = childNodes.end(); - - while (it != end) { - const xmlpp::Element * metadataTypeElement - = dynamic_cast (*it); - Ptr::Ref metadataType( - new MetadataType(shared_from_this())); - - metadataType->configure(*metadataTypeElement); - - if (dcNameMap.find(*metadataType->getDcName()) != dcNameMap.end()) { - throw std::invalid_argument("trying to insert duplicate metadata " - "type: " + *metadataType->getDcName()); - } - if (metadataType->getId3Tag().get()) { - if (id3TagMap.find(*metadataType->getId3Tag()) != id3TagMap.end()) { - throw std::invalid_argument("trying to insert duplicate " - "metadata by ID3v2 tag: " - + *metadataType->getId3Tag()); - } - } - - dcNameMap[*metadataType->getDcName()] = metadataType; - if (metadataType->getId3Tag().get()) { - id3TagMap[*metadataType->getId3Tag()] = metadataType; - } - vector.push_back(metadataType); - - ++it; - } -} - - -/*------------------------------------------------------------------------------ - * Tell if a metadata type object by the Dublin Core name exists - *----------------------------------------------------------------------------*/ -bool -MetadataTypeContainer :: existsByDcName(const Glib::ustring dcName) const - throw () -{ - return dcNameMap.find(dcName) != dcNameMap.end(); -} - - -/*------------------------------------------------------------------------------ - * Look for a metadata type object by the Dublin Core name - *----------------------------------------------------------------------------*/ -Ptr::Ref -MetadataTypeContainer :: getByDcName(const Glib::ustring dcName) - throw (std::invalid_argument) -{ - if (!existsByDcName(dcName)) { - throw std::invalid_argument("no metadata type by the DC name " +dcName); - } - - return dcNameMap[dcName]; -} - - -/*------------------------------------------------------------------------------ - * Tell if a metadata type object by the ID3v2 tag name exists. - *----------------------------------------------------------------------------*/ -bool -MetadataTypeContainer :: existsById3Tag(const Glib::ustring id3Tag) const - throw () -{ - return id3TagMap.find(id3Tag) != id3TagMap.end(); -} - - -/*------------------------------------------------------------------------------ - * Look for a metadata type object by the ID3v2 tag name. - *----------------------------------------------------------------------------*/ -Ptr::Ref -MetadataTypeContainer :: getById3Tag(const Glib::ustring id3Tag) - throw (std::invalid_argument) -{ - if (!existsById3Tag(id3Tag)) { - throw std::invalid_argument("no metadata type by the ID3v2 Tag " - + id3Tag); - } - - return id3TagMap[id3Tag]; -} - - -/*------------------------------------------------------------------------------ - * Look for a metadata type object by the ID3v2 tag name. - *----------------------------------------------------------------------------*/ -Ptr::Ref -MetadataTypeContainer :: getByIndex(unsigned int index) const - throw (std::invalid_argument) -{ - if (index < 0 || index >= vector.size()) { - throw std::invalid_argument("index out of range in " - "MetadataTypeContainer::getByIndex()"); - } - - return vector.at(index); -} - - -/*------------------------------------------------------------------------------ - * Check that the given value satisfies the constraint of a metadata type. - *----------------------------------------------------------------------------*/ -bool -MetadataTypeContainer :: check(Ptr::Ref value, - const Glib::ustring & dcName) - throw (std::invalid_argument) -{ - Ptr::Ref metadataType = getByDcName(dcName); - return metadataType->check(value); -} - diff --git a/src/modules/core/src/MetadataTypeContainerTest.cxx b/src/modules/core/src/MetadataTypeContainerTest.cxx deleted file mode 100644 index fa0b43fb6..000000000 --- a/src/modules/core/src/MetadataTypeContainerTest.cxx +++ /dev/null @@ -1,337 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/MetadataTypeContainer.h" - -#include "MetadataTypeContainerTest.h" - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(MetadataTypeContainerTest); - -/** - * The name of the configuration file for the resource bundle. - */ -static const std::string bundleConfigFileName = "etc/resourceBundle.xml"; - -/** - * The name of the configuration file for the metadataType element. - */ -static const std::string metadataTypeConfigFileName = "etc/metadataType.xml"; - -/** - * The name of the configuration file for the metadataTypeContainer element. - */ -static const std::string configFileName = "etc/metadataTypeContainer.xml"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -MetadataTypeContainerTest :: setUp(void) throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref rootBundle; - try { - Ptr::Ref parser( - new xmlpp::DomParser(bundleConfigFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - rootBundle = LocalizedObject::getBundle(*root); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in bundle configuration file"); - } catch (std::exception &e) { - CPPUNIT_FAIL(std::string("XML error in bundle configuration file:\n") - + e.what()); - } - CPPUNIT_ASSERT(rootBundle); - - UErrorCode icuError = U_ZERO_ERROR; - bundle.reset(new ResourceBundle(rootBundle->get("metadata", icuError))); - CPPUNIT_ASSERT(U_SUCCESS(icuError)); - CPPUNIT_ASSERT(bundle); - - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - container.reset(new MetadataTypeContainer(bundle)); - container->configure(*root); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(std::string("semantic error in metadata container" - " configuration file:\n") - + e.what()); - } catch (xmlpp::exception &e) { - CPPUNIT_FAIL(std::string("XML error in metadata container" - " configuration file:\n") - + e.what()); - } - -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -MetadataTypeContainerTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the singleton Hello object is accessible - *----------------------------------------------------------------------------*/ -void -MetadataTypeContainerTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref metadataType; - bool gotException; - - // test double-configuration - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - gotException = false; - try { - container->configure(*root); - } catch (std::invalid_argument &e) { - gotException = true; - } - CPPUNIT_ASSERT(gotException); - - } catch (xmlpp::exception &e) { - CPPUNIT_FAIL(std::string("XML error in configuration file:\n") - + e.what()); - } - - // a simple positive check on the DC name - CPPUNIT_ASSERT(container->existsByDcName("dc:creator")); - metadataType = container->getByDcName("dc:creator"); - - CPPUNIT_ASSERT(*metadataType->getDcName() == "dc:creator"); - CPPUNIT_ASSERT(*metadataType->getId3Tag() == "TPE1"); - CPPUNIT_ASSERT(*metadataType->getLocalizationKey() == "creator"); - - // a negative check on the DC name - CPPUNIT_ASSERT(!container->existsByDcName("dc:nonExistent")); - - gotException = false; - try { - container->getByDcName("dc:nonExistent"); - } catch (std::invalid_argument &e) { - gotException = true; - } - CPPUNIT_ASSERT(gotException); - - // a simple positive check on the ID3v2 tag - CPPUNIT_ASSERT(container->existsById3Tag("TPE1")); - metadataType = container->getById3Tag("TPE1"); - - CPPUNIT_ASSERT(*metadataType->getDcName() == "dc:creator"); - CPPUNIT_ASSERT(*metadataType->getId3Tag() == "TPE1"); - CPPUNIT_ASSERT(*metadataType->getLocalizationKey() == "creator"); - - // a negative check on the ID3v2 tag - CPPUNIT_ASSERT(!container->existsById3Tag("NonExistentTag")); - - gotException = false; - try { - container->getById3Tag("NonExistentTag"); - } catch (std::invalid_argument &e) { - gotException = true; - } - CPPUNIT_ASSERT(gotException); - - // two simple positive checks on the tab attribute - CPPUNIT_ASSERT(container->existsByDcName("dc:title")); - metadataType = container->getByDcName("dc:title"); - CPPUNIT_ASSERT(metadataType->getTab() == MetadataType::mainTab); - - CPPUNIT_ASSERT(container->existsByDcName("ls:buycdurl")); - metadataType = container->getByDcName("ls:buycdurl"); - CPPUNIT_ASSERT(metadataType->getTab() == MetadataType::noTab); -} - - -/*------------------------------------------------------------------------------ - * Test the iterator feature of the container. - *----------------------------------------------------------------------------*/ -void -MetadataTypeContainerTest :: iteratorTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref metadataType; - MetadataTypeContainer::Vector::const_iterator it; - MetadataTypeContainer::Vector::const_iterator end; - - // check the first two elements in the container - it = container->begin(); - end = container->end(); - - CPPUNIT_ASSERT(it != end); - metadataType = (Ptr::Ref) *it; - CPPUNIT_ASSERT(*metadataType->getDcName() == "dc:title"); - CPPUNIT_ASSERT(*metadataType->getId3Tag() == "TIT2"); - CPPUNIT_ASSERT(*metadataType->getLocalizationKey() == "title"); - - ++it; - CPPUNIT_ASSERT(it != end); - metadataType = (Ptr::Ref) *it; - CPPUNIT_ASSERT(*metadataType->getDcName() == "dc:creator"); - CPPUNIT_ASSERT(*metadataType->getId3Tag() == "TPE1"); - CPPUNIT_ASSERT(*metadataType->getLocalizationKey() == "creator"); - - // test on an empty container - container.reset(new MetadataTypeContainer(bundle)); - it = container->begin(); - end = container->end(); - CPPUNIT_ASSERT(it == end); -} - - -/*------------------------------------------------------------------------------ - * Test localized metadata type names. - *----------------------------------------------------------------------------*/ -void -MetadataTypeContainerTest :: localizedTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref metadataType; - - CPPUNIT_ASSERT(container->existsByDcName("dc:creator")); - metadataType = container->getByDcName("dc:creator"); - - CPPUNIT_ASSERT(*metadataType->getLocalizedName() == "Creator"); - - UErrorCode status = U_ZERO_ERROR; - Ptr::Ref rootBundle; - Ptr::Ref huBundle; - Ptr::Ref jpBundle; - Ptr::Ref ustr; - - // test with hungarian - rootBundle.reset(new ResourceBundle("./tmp/" PACKAGE_NAME, "hu", status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - huBundle.reset(new ResourceBundle(rootBundle->get("metadata", status))); - CPPUNIT_ASSERT(U_SUCCESS(status)); - container->setBundle(huBundle); - - ustr = metadataType->getLocalizedName(); - CPPUNIT_ASSERT(ustr->length() == 6); - CPPUNIT_ASSERT((*ustr)[0] == 0x0045); // 'E' - CPPUNIT_ASSERT((*ustr)[1] == 0x006C); // 'l' - CPPUNIT_ASSERT((*ustr)[2] == 0x0151); // 'o' with double acute - CPPUNIT_ASSERT((*ustr)[3] == 0x0061); // 'a' - CPPUNIT_ASSERT((*ustr)[4] == 0x0064); // 'd' - CPPUNIT_ASSERT((*ustr)[5] == 0x00F3); // 'o' with acute - - // test with japanese - rootBundle.reset(new ResourceBundle("./tmp/" PACKAGE_NAME, "jp", status)); - CPPUNIT_ASSERT(U_SUCCESS(status)); - jpBundle.reset(new ResourceBundle(rootBundle->get("metadata", status))); - CPPUNIT_ASSERT(U_SUCCESS(status)); - container->setBundle(jpBundle); - - ustr = metadataType->getLocalizedName(); - CPPUNIT_ASSERT(ustr->length() == 6); - CPPUNIT_ASSERT((*ustr)[0] == 0x30af); // katakana ku - CPPUNIT_ASSERT((*ustr)[1] == 0x30ea); // katakana ri - CPPUNIT_ASSERT((*ustr)[2] == 0x30a8); // katakana e - CPPUNIT_ASSERT((*ustr)[3] == 0x30fc); // katakana '-' - CPPUNIT_ASSERT((*ustr)[4] == 0x30bf); // katakana ta - CPPUNIT_ASSERT((*ustr)[5] == 0x30fc); // katakana '-' -} - - -/*------------------------------------------------------------------------------ - * Test to see if the constraints work. - *----------------------------------------------------------------------------*/ -void -MetadataTypeContainerTest :: constraintTest(void) - throw (CPPUNIT_NS::Exception) -{ - // test the case of no constraint; everything is OK - Ptr::Ref title; - CPPUNIT_ASSERT(!container->check(title, "dc:title")); // except a 0 pointer - title.reset(new Glib::ustring("Some title")); - CPPUNIT_ASSERT(container->check(title, "dc:title")); - - // test the numeric constraint; [0-9]+ required - Ptr::Ref bpm(new Glib::ustring ("1000")); - CPPUNIT_ASSERT(container->check(bpm, "ls:bpm")); - bpm->assign("2000 or more"); - CPPUNIT_ASSERT(!container->check(bpm, "ls:bpm")); - bpm->assign(""); - CPPUNIT_ASSERT(!container->check(bpm, "ls:bpm")); - - // test the numeric range constraint; [0-9]+ required, between 0 and 3000 - Ptr::Ref year(new Glib::ustring ("1000")); - CPPUNIT_ASSERT(container->check(year, "ls:year")); - year->assign("1066 AD"); - CPPUNIT_ASSERT(!container->check(year, "ls:year")); - year->assign("20066"); - CPPUNIT_ASSERT(!container->check(year, "ls:year")); - - // test the enumeration constraint; "mp3", "mpeg" or "ogg" are allowed - Ptr::Ref format(new Glib::ustring ("mp3")); - CPPUNIT_ASSERT(container->check(format, "dc:format")); - format->assign("wma"); - CPPUNIT_ASSERT(!container->check(format, "dc:format")); -} - diff --git a/src/modules/core/src/MetadataTypeContainerTest.h b/src/modules/core/src/MetadataTypeContainerTest.h deleted file mode 100644 index 5c82fe50d..000000000 --- a/src/modules/core/src/MetadataTypeContainerTest.h +++ /dev/null @@ -1,136 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef MetadataTypeContainerTest_h -#define MetadataTypeContainerTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the MetadataTypeContainer class. - * - * @see MetadataTypeContainer - */ -class MetadataTypeContainerTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(MetadataTypeContainerTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST(iteratorTest); - CPPUNIT_TEST(localizedTest); - CPPUNIT_TEST(constraintTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * The resource bundle used by the container. - */ - Ptr::Ref bundle; - - /** - * The metadata container used in the tests. - */ - Ptr::Ref container; - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing the iterators available from the container. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - iteratorTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test to see if localized metadata type names work. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - localizedTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test to see if the constraints work. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - constraintTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (CPPUNIT_NS::Exception); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // MetadataTypeContainerTest_h - diff --git a/src/modules/core/src/NumericConstraint.cxx b/src/modules/core/src/NumericConstraint.cxx deleted file mode 100644 index f1736900b..000000000 --- a/src/modules/core/src/NumericConstraint.cxx +++ /dev/null @@ -1,104 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include "NumericConstraint.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -namespace { - -/*------------------------------------------------------------------------------ - * The value of the type attribute for this class. - *----------------------------------------------------------------------------*/ -const std::string typeAttributeValue = "numeric"; - -} - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create a constraint element object based on an XML element. - *----------------------------------------------------------------------------*/ -void -NumericConstraint :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != getConfigElementName()) { - throw std::invalid_argument("bad configuration element " - + element.get_name()); - } - - const xmlpp::Attribute* typeAttribute; - if (!(typeAttribute = element.get_attribute(typeAttributeName))) { - throw std::invalid_argument("missing attribute " + typeAttributeName); - } - std::string type = typeAttribute->get_value(); - - if (type != typeAttributeValue) { - throw std::invalid_argument(typeAttributeValue - + " constraint configured with a" - + " constraint element of type " - + type); - } -} - - -/*------------------------------------------------------------------------------ - * Check that the given value satisfies the constraint. - *----------------------------------------------------------------------------*/ -bool -NumericConstraint :: check(Ptr::Ref value) const - throw (std::logic_error) -{ - if (!value) { - throw std::logic_error("NumericConstraint::check() called with " - "a 0 pointer value"); - } - - Glib::ustring::const_iterator it = value->begin(); - - if (it == value->end()) { // the empty string is not a number - return false; - } - - for (; it != value->end(); ++it) { - if (*it < '0' || *it > '9') { - return false; - } - } - - return true; -} - diff --git a/src/modules/core/src/NumericConstraint.h b/src/modules/core/src/NumericConstraint.h deleted file mode 100644 index 871e539e8..000000000 --- a/src/modules/core/src/NumericConstraint.h +++ /dev/null @@ -1,138 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_NumericConstraint_h -#define LiveSupport_Core_NumericConstraint_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#include "LiveSupport/Core/MetadataConstraint.h" - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class for representing a numeric metadata constraint. - * - * This is a concrete subclass of MetadataConstraint. Do not explicitly - * instantiate this class; create a MetadataConstraint object instead, and - * configure it with an XML element with the appropriate type attribute. - * - * This object has to be configured with an XML configuration element - * called constraint. This may look like the following: - * - *

- *  
- *  
- * - * A metadata type with this kind of constraint can only accept (decimal, - * non-negative) integer values, i.e., [0-9]+. - * - * The DTD for the expected XML element looks like the following: - * - *

- *  
- *  
- *  
- * - * @see NumericConstraintContainer - */ -class NumericConstraint : public MetadataConstraint -{ - public: - /** - * Constructor. - */ - NumericConstraint() throw () - { - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~NumericConstraint(void) throw () - { - } - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return MetadataConstraint::getConfigElementName(); - } - - /** - * Configure the metadata object based on an XML configuration element. - * - * @param element the XML configuration element. - * @exception std::invalid_argument of the supplied XML element - * contains bad configuration information - */ - virtual void - configure(const xmlpp::Element &element) - throw (std::invalid_argument); - - /** - * Check that the given value satisfies the constraint. - * - * @param value the value to be checked against the constraint. - * @return true if the value satisfies the constraint. - * @exception std::logic_error if the parameter is a 0 pointer. - */ - virtual bool - check(Ptr::Ref value) const - throw (std::logic_error); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_NumericConstraint_h - diff --git a/src/modules/core/src/NumericRangeConstraint.cxx b/src/modules/core/src/NumericRangeConstraint.cxx deleted file mode 100644 index 4122df5e2..000000000 --- a/src/modules/core/src/NumericRangeConstraint.cxx +++ /dev/null @@ -1,155 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include - -#include "NumericConstraint.h" - -#include "NumericRangeConstraint.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -namespace { - -/*------------------------------------------------------------------------------ - * The value of the type attribute for this class. - *----------------------------------------------------------------------------*/ -const std::string typeAttributeValue = "numericRange"; - -} - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create a constraint element object based on an XML element. - *----------------------------------------------------------------------------*/ -void -NumericRangeConstraint :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != getConfigElementName()) { - throw std::invalid_argument("bad configuration element " - + element.get_name()); - } - - const xmlpp::Attribute* typeAttribute; - if (!(typeAttribute = element.get_attribute(typeAttributeName))) { - throw std::invalid_argument("missing attribute " + typeAttributeName); - } - std::string type = typeAttribute->get_value(); - - if (type != typeAttributeValue) { - throw std::invalid_argument(typeAttributeValue - + " constraint configured with a" - + " constraint element of type " - + type); - } - - xmlpp::Node::NodeList childNodes = element.get_children(valueElementName); - xmlpp::Node::NodeList::iterator it = childNodes.begin(); - - if (it != childNodes.end()) { - minValue = readNumberFromNode(*it); - } else { - throw std::invalid_argument("sub-element not found in constraint"); - } - - ++it; - if (it != childNodes.end()) { - maxValue = readNumberFromNode(*it); - } else { - throw std::invalid_argument("sub-element not found in constraint"); - } -} - - -/*------------------------------------------------------------------------------ - * Read a number from an xml element. - *----------------------------------------------------------------------------*/ -NumericRangeConstraint :: ValueType -NumericRangeConstraint :: readNumberFromNode( - const xmlpp::Node * node) const - throw (std::invalid_argument) -{ - const xmlpp::Element * valueElement - = dynamic_cast (node); - if (valueElement) { - Ptr::Ref value(new Glib::ustring( - valueElement->get_child_text() - ->get_content() )); - return readNumber(value); - } else { - throw std::invalid_argument("bad sub-element found in constraint"); - } -} - - -/*------------------------------------------------------------------------------ - * Read a number from a string. - *----------------------------------------------------------------------------*/ -NumericRangeConstraint :: ValueType -NumericRangeConstraint :: readNumber( - Ptr::Ref value) const - throw (std::invalid_argument) -{ - NumericConstraint numericConstraint; - if (!numericConstraint.check(value)) { - throw std::invalid_argument("bad number found in constraint"); - } - - std::istringstream valueStream(*value); - ValueType valueNumber; - valueStream >> valueNumber; - - return valueNumber; -} - - -/*------------------------------------------------------------------------------ - * Check that the given value satisfies the constraint. - *----------------------------------------------------------------------------*/ -bool -NumericRangeConstraint :: check(Ptr::Ref value) const - throw (std::logic_error) -{ - ValueType valueNumber = readNumber(value); - - if (valueNumber >= minValue && valueNumber <= maxValue) { - return true; - } else { - return false; - } -} - diff --git a/src/modules/core/src/NumericRangeConstraint.h b/src/modules/core/src/NumericRangeConstraint.h deleted file mode 100644 index ba49a626b..000000000 --- a/src/modules/core/src/NumericRangeConstraint.h +++ /dev/null @@ -1,186 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_Core_NumericRangeConstraint_h -#define LiveSupport_Core_NumericRangeConstraint_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#include "LiveSupport/Core/MetadataConstraint.h" - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A class for representing a metadata constraint which allows numbers between - * two given values (inclusive). - * - * This is a concrete subclass of MetadataConstraint. Do not explicitly - * instantiate this class; create a MetadataConstraint object instead, and - * configure it with an XML element with the appropriate type attribute. - * - * This object has to be configured with an XML configuration element - * called constraint. This may look like the following: - * - *

- *  
- *      1
- *      12
- *  
- *  
- * - * A metadata type with this kind of constraint can only accept (decimal, - * non-negative) integer values, i.e., [0-9]+, which are greater than or - * equal to the first value given, and less than or equal to the second - * value given. - * - * The DTD for the expected XML element looks like the following: - * - *

- *  
- *  
- *  
- *  
- * - * @see NumericRangeConstraintContainer - */ -class NumericRangeConstraint : public MetadataConstraint -{ - private: - /** - * The integer type used by the constraint. - */ - typedef unsigned long long ValueType; - - /** - * The smallest value allowed by the constraint. - */ - ValueType minValue; - - /** - * The largest value allowed by the constraint. - */ - ValueType maxValue; - - /** - * Read a number from an XML node. - * - * @param node the node containing the number. - * @return the number read from the node. - * @exception std::invalid_argument if the XML node is not - * of the expected form. - */ - ValueType - readNumberFromNode(const xmlpp::Node * node) const - throw (std::invalid_argument); - - /** - * Read a number from a string. - * - * @param value the string containing the number. - * @return the number read from the string. - * @exception std::invalid_argument if the string does not contain - * a number. - */ - ValueType - readNumber(Ptr::Ref value) const - throw (std::invalid_argument); - - - public: - /** - * Constructor. - */ - NumericRangeConstraint() throw () - { - } - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~NumericRangeConstraint(void) throw () - { - } - - /** - * Return the name of the XML element this object expects - * to be sent to a call to configure(). - * - * @return the name of the expected XML configuration element. - */ - static const std::string - getConfigElementName(void) throw () - { - return MetadataConstraint::getConfigElementName(); - } - - /** - * Configure the metadata object based on an XML configuration element. - * - * @param element the XML configuration element. - * @exception std::invalid_argument of the supplied XML element - * contains bad configuration information - */ - virtual void - configure(const xmlpp::Element &element) - throw (std::invalid_argument); - - /** - * Check that the given value satisfies the constraint. - * - * @param value the value to be checked against the constraint. - * @return true if the value satisfies the constraint. - * @exception std::logic_error if the parameter is a 0 pointer. - */ - virtual bool - check(Ptr::Ref value) const - throw (std::logic_error); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // LiveSupport_Core_NumericRangeConstraint_h - diff --git a/src/modules/core/src/NumericTools.cxx b/src/modules/core/src/NumericTools.cxx deleted file mode 100644 index 15999393a..000000000 --- a/src/modules/core/src/NumericTools.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/NumericTools.h" - - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Convert an integer to a string. - *----------------------------------------------------------------------------*/ -Glib::ustring -NumericTools :: itoa(int number) throw () -{ - std::ostringstream stream; - stream << number; - Glib::ustring string = stream.str(); - return string; -} - - -/*------------------------------------------------------------------------------ - * Add a number to the end of a string. - *----------------------------------------------------------------------------*/ -Glib::ustring -NumericTools :: addIndex(const Glib::ustring & baseString, - int index) throw () -{ - std::ostringstream stream; - stream << baseString - << (index + 1); - return stream.str(); -} - diff --git a/src/modules/core/src/NumericToolsTest.cxx b/src/modules/core/src/NumericToolsTest.cxx deleted file mode 100644 index 0affab324..000000000 --- a/src/modules/core/src/NumericToolsTest.cxx +++ /dev/null @@ -1,95 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/NumericTools.h" -#include "NumericToolsTest.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(NumericToolsTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -NumericToolsTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -NumericToolsTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test the itoa() function. - *----------------------------------------------------------------------------*/ -void -NumericToolsTest :: itoaTest(void) - throw (CPPUNIT_NS::Exception) -{ - int i = 3142874; - Glib::ustring a = NumericTools::itoa(i); - CPPUNIT_ASSERT(a == "3142874"); -} - - -/*------------------------------------------------------------------------------ - * Test the addIndex() function. - *----------------------------------------------------------------------------*/ -void -NumericToolsTest :: addIndexTest(void) - throw (CPPUNIT_NS::Exception) -{ - Glib::ustring base = "itemLabel"; - int index = 123; - Glib::ustring result = NumericTools::addIndex(base, index); - CPPUNIT_ASSERT(result == "itemLabel124"); - - Glib::ustring second = NumericTools::addIndex("second", 0); - CPPUNIT_ASSERT(second == "second1"); -} - diff --git a/src/modules/core/src/NumericToolsTest.h b/src/modules/core/src/NumericToolsTest.h deleted file mode 100644 index 046ff76fc..000000000 --- a/src/modules/core/src/NumericToolsTest.h +++ /dev/null @@ -1,111 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef NumericToolsTest_h -#define NumericToolsTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the NumericTools class. - * - * @see NumericTools - */ -class NumericToolsTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(NumericToolsTest); - CPPUNIT_TEST(itoaTest); - CPPUNIT_TEST(addIndexTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * Test the itoa() function. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - itoaTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the addIndex() function. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - addIndexTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // NumericToolsTest_h - diff --git a/src/modules/core/src/OptionsContainer.cxx b/src/modules/core/src/OptionsContainer.cxx deleted file mode 100644 index 784b0deaa..000000000 --- a/src/modules/core/src/OptionsContainer.cxx +++ /dev/null @@ -1,405 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - To report bugs, send an e-mail to bugs@campware.org - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - - Author : $Author $ - Version : $Revision $ - Location : $URL $ - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include -#include - -#include "LiveSupport/Core/OptionsContainer.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -OptionsContainer :: OptionsContainer( - const xmlpp::Element & optionsElement, - Ptr::Ref configFileName) - throw () - : configFileName(configFileName), - touched(false) -{ - optionsDocument.create_root_node_by_import(&optionsElement, true); - // true == recursive - - xmlpp::Node::NodeList nodes = optionsElement.get_children( - RdsContainer::getConfigElementName()); - if (nodes.size() > 0) { - rdsContainer.reset(new RdsContainer()); - rdsContainer->configure( - *dynamic_cast(nodes.front())); - } -} - - -/*------------------------------------------------------------------------------ - * Set a string type option. - *----------------------------------------------------------------------------*/ -void -OptionsContainer :: setOptionItem(OptionItemString optionItem, - Ptr::Ref value) - throw (std::invalid_argument) -{ - bool isAttribute = false; // text node or attr node - xmlpp::Node * targetNode = selectNode(optionItem, isAttribute); - - if (!targetNode) { - targetNode = createNode(optionItem); - } - - if (isAttribute) { - xmlpp::Attribute * attr = dynamic_cast(targetNode); - if (attr != 0) { - attr->set_value(*value); - touched = true; - return; - } - } else { - xmlpp::TextNode * text = dynamic_cast(targetNode); - if (text != 0) { - text->set_content(*value); - touched = true; - return; - } - } - - throw std::invalid_argument("option item not found"); -} - - -/*------------------------------------------------------------------------------ - * Get a string type option. - *----------------------------------------------------------------------------*/ -Ptr::Ref -OptionsContainer :: getOptionItem(OptionItemString optionItem) - throw (std::invalid_argument) -{ - bool isAttribute = false; // text node or attr node - const xmlpp::Node * targetNode = selectNode(optionItem, isAttribute); - - if (isAttribute) { - const xmlpp::Attribute * - attr = dynamic_cast(targetNode); - if (attr != 0) { - Ptr::Ref value(new Glib::ustring( - attr->get_value() )); - return value; - } - } else { - const xmlpp::TextNode * - text = dynamic_cast(targetNode); - if (text != 0) { - Ptr::Ref value(new Glib::ustring( - text->get_content() )); - return value; - } - } - - throw std::invalid_argument("option item not found"); -} - - -/*------------------------------------------------------------------------------ - * Set a keyboard shortcut type option. - *----------------------------------------------------------------------------*/ -void -OptionsContainer :: setKeyboardShortcutItem( - int containerNo, - int shortcutNo, - Ptr::Ref value) - throw (std::invalid_argument) -{ - xmlpp::Node * targetNode = selectKeyboardShortcutNode( - containerNo, shortcutNo); - - xmlpp::Attribute * attr = dynamic_cast(targetNode); - if (attr != 0) { - attr->set_value(*value); - touched = true; - return; - - } else { - throw std::invalid_argument("keyboard shortcut not found"); - } -} - - -/*------------------------------------------------------------------------------ - * Set the value of an RDS string. - *----------------------------------------------------------------------------*/ -void -OptionsContainer :: setRdsOptions(Ptr::Ref key, - Ptr::Ref value, - bool enabled) - throw () -{ - if (!rdsContainer) { - rdsContainer.reset(new RdsContainer()); - } - - rdsContainer->setRdsOptions(key, value, enabled); -} - - -/*------------------------------------------------------------------------------ - * Get the value of an RDS string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -OptionsContainer :: getRdsValue(Ptr::Ref key) - throw (std::invalid_argument) -{ - if (rdsContainer) { - return rdsContainer->getRdsValue(key); - } else { - throw std::invalid_argument("no RDS container found"); - } -} - - -/*------------------------------------------------------------------------------ - * Get the enabled/disabled state of an RDS option. - *----------------------------------------------------------------------------*/ -bool -OptionsContainer :: getRdsEnabled(Ptr::Ref key) - throw (std::invalid_argument) -{ - if (rdsContainer) { - return rdsContainer->getRdsEnabled(key); - } else { - throw std::invalid_argument("no RDS container found"); - } -} - - -/*------------------------------------------------------------------------------ - * Find the node corresponding to an OptionItemString value. - *----------------------------------------------------------------------------*/ -xmlpp::Node * -OptionsContainer :: selectNode(OptionItemString optionItem, - bool & isAttribute) - throw (std::invalid_argument) -{ - xmlpp::Node * targetNode = 0; - - switch (optionItem) { - case outputPlayerDeviceName : - targetNode = getNode("outputPlayer/audioPlayer/gstreamerPlayer/" - "@audioDevice"); - isAttribute = true; - break; - - case cuePlayerDeviceName : - targetNode = getNode("cuePlayer/audioPlayer/gstreamerPlayer/" - "@audioDevice"); - isAttribute = true; - break; - - case authenticationServer : - targetNode = getNode("authenticationClientFactory/" - "webAuthentication/location/@server"); - isAttribute = true; - break; - - case authenticationPort : - targetNode = getNode("authenticationClientFactory/" - "webAuthentication/location/@port"); - isAttribute = true; - break; - - case authenticationPath : - targetNode = getNode("authenticationClientFactory/" - "webAuthentication/location/@path"); - isAttribute = true; - break; - - case storageServer : - targetNode = getNode("storageClientFactory/" - "webStorage/location/@server"); - isAttribute = true; - break; - - case storagePort : - targetNode = getNode("storageClientFactory/" - "webStorage/location/@port"); - isAttribute = true; - break; - - case storagePath : - targetNode = getNode("storageClientFactory/" - "webStorage/location/@path"); - isAttribute = true; - break; - - case schedulerServer : - targetNode = getNode("schedulerClientFactory/" - "schedulerDaemonXmlRpcClient/@xmlRpcHost"); - isAttribute = true; - break; - - case schedulerPort : - targetNode = getNode("schedulerClientFactory/" - "schedulerDaemonXmlRpcClient/@xmlRpcPort"); - isAttribute = true; - break; - - case schedulerPath : - targetNode = getNode("schedulerClientFactory/" - "schedulerDaemonXmlRpcClient/@xmlRpcUri"); - isAttribute = true; - break; - - case serialDeviceName : - targetNode = getNode("serialPort/@path"); - isAttribute = true; - break; - } - - return targetNode; -} - - -/*------------------------------------------------------------------------------ - * Find the node corresponding to a keyboard shortcut. - *----------------------------------------------------------------------------*/ -xmlpp::Node * -OptionsContainer :: selectKeyboardShortcutNode(int containerNo, - int shortcutNo) - throw (std::invalid_argument) -{ - std::stringstream xPathStream; - xPathStream << "keyboardShortcutList/keyboardShortcutContainer[" - << containerNo - << "]/keyboardShortcut[" - << shortcutNo - << "]/@key"; - return getNode(xPathStream.str()); -} - - -/*------------------------------------------------------------------------------ - * Return the first node matching an XPath string. - *----------------------------------------------------------------------------*/ -xmlpp::Node * -OptionsContainer :: getNode(const Glib::ustring & xPath) - throw (std::invalid_argument) -{ - xmlpp::Element * rootNode = optionsDocument.get_root_node(); - xmlpp::NodeSet nodes; - - try { - nodes = rootNode->find(xPath); - - } catch (xmlpp::exception &e) { - throw std::invalid_argument(e.what()); - } - - std::vector::iterator it = nodes.begin(); - if (it != nodes.end()) { - return *it; - } else { - return 0; - } -} - - -/*------------------------------------------------------------------------------ - * Create the node corresponding to an OptionItemString value. - *----------------------------------------------------------------------------*/ -xmlpp::Node * -OptionsContainer :: createNode(OptionItemString optionItem) throw () -{ - xmlpp::Element * rootNode = optionsDocument.get_root_node(); - xmlpp::Element * element = 0; - xmlpp::Attribute * attribute = 0; - - // only supports the serialDeviceName option item, for now - switch (optionItem) { - case serialDeviceName : - element = dynamic_cast( - getNode("serialPort")); - if (!element) { - element = rootNode->add_child("serialPort"); - } - attribute = dynamic_cast( - getNode("serialPort/@path")); - if (!attribute) { - attribute = element->set_attribute("path", ""); - } - return attribute; - - default: - return 0; - } -} - - -/*------------------------------------------------------------------------------ - * Save the options to a file. - *----------------------------------------------------------------------------*/ -void -OptionsContainer :: writeToFile(void) throw () -{ - if (configFileName) { - if (rdsContainer && rdsContainer->isTouched()) { - xmlpp::Element * rootNode = optionsDocument.get_root_node(); - xmlpp::Node::NodeList nodes = rootNode->get_children( - RdsContainer::getConfigElementName()); - if (nodes.size() > 0) { - rootNode->remove_child(nodes.front()); - } - rootNode->import_node(rdsContainer->toXmlElement(), true); - } - - std::ofstream file(configFileName->c_str()); - if (file.good()) { - optionsDocument.write_to_stream_formatted(file, "utf-8"); - touched = false; - } - file.close(); - } -} - diff --git a/src/modules/core/src/Playable.cxx b/src/modules/core/src/Playable.cxx deleted file mode 100644 index 9a977f612..000000000 --- a/src/modules/core/src/Playable.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include "LiveSupport/Core/AudioClip.h" -#include "LiveSupport/Core/Playlist.h" - -#include "LiveSupport/Core/Playable.h" - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Return an audio clip pointer to this object. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playable :: getAudioClip(void) throw () -{ - Ptr::Ref audioClip; - if (type == AudioClipType) { - audioClip = boost::dynamic_pointer_cast - (shared_from_this()); - } - return audioClip; -} - - -/*------------------------------------------------------------------------------ - * Return a playlist pointer to this object. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playable :: getPlaylist(void) throw () -{ - Ptr::Ref playlist; - if (type == PlaylistType) { - playlist = boost::dynamic_pointer_cast - (shared_from_this()); - } - return playlist; -} - diff --git a/src/modules/core/src/Playlist.cxx b/src/modules/core/src/Playlist.cxx deleted file mode 100644 index c05f6da50..000000000 --- a/src/modules/core/src/Playlist.cxx +++ /dev/null @@ -1,971 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/TimeConversion.h" -#include "LiveSupport/Core/Playlist.h" - -using namespace boost::posix_time; - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/** - * The name of the config element for this class - */ -const std::string Playlist::configElementNameStr = "playlist"; - -/** - * The name of the attribute to get the id of the playlist. - */ -static const std::string idAttrName = "id"; - -/** - * The name of the attribute to get the playlength of the playlist. - */ -static const std::string playlengthAttrName = "playlength"; - -/** - * The name of the attribute to get the title of the playlist. - */ -static const std::string titleAttrName = "title"; - -/** - * The name of playlist element child nodes. - */ -static const std::string elementListAttrName = "playlistElement"; - -/** - * The name of the metadata child element. - */ -static const std::string metadataElementName = "metadata"; - -/** - * The prefix of the extent (length) metadata element. - */ -static const std::string extentElementPrefix = "dcterms"; - -/** - * The name of the extent (length) metadata element. - */ -static const std::string extentElementName = "extent"; - -/** - * The prefix of the title metadata element. - */ -static const std::string titleElementPrefix = "dc"; - -/** - * The name of the title metadata element. - */ -static const std::string titleElementName = "title"; - -/** - * The prefix for the Live Support extension elements. - */ -static const std::string liveSupportNamespacePrefix = "ls"; - -/** - * The prefix for the "xml:" prefix elements. - */ -static const std::string xmlNamespacePrefix = "xml"; - -/** - * The URI identifier for the default namespace - */ -static const std::string defaultNamespaceUri - = "http://mdlf.org/livesupport/elements/1.0/"; - -/** - * The URI identifier for the "ls" prefix. - */ -static const std::string liveSupportNamespaceUri - = "http://mdlf.org/livesupport/elements/1.0/"; - -/** - * The URI identifier for the "dc" prefix - */ -static const std::string dcNamespaceUri - = "http://purl.org/dc/elements/1.1/"; - -/** - * The URI identifier for the "dcterms" prefix - */ -static const std::string dctermsNamespaceUri - = "http://purl.org/dc/terms/"; - -/** - * The URI identifier for the "xml" prefix - */ -static const std::string xmlNamespaceUri - = "http://www.w3.org/XML/1998/namespace"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Copy constructor. - *----------------------------------------------------------------------------*/ -Playlist :: Playlist(const Playlist & otherPlaylist) - throw () - : Playable(PlaylistType), - id (otherPlaylist.id), - title (otherPlaylist.title), - playlength(otherPlaylist.playlength), - uri (otherPlaylist.uri), - token (otherPlaylist.token) -{ - elementList.reset(new PlaylistElementListType); - const_iterator it; - for (it = otherPlaylist.begin(); it != otherPlaylist.end(); ++it) { - Ptr::Ref otherElement(new PlaylistElement( - *it->second )); - elementList->insert(std::make_pair(it->first, otherElement)); - } - - if (otherPlaylist.savedCopy) { - savedCopy.reset(new Playlist(*otherPlaylist.savedCopy)); - } - - if (otherPlaylist.xmlPlaylist) { - xmlPlaylist.reset(new xmlpp::Document); - xmlPlaylist->create_root_node_by_import( - otherPlaylist.xmlPlaylist->get_root_node(), - true); // true == recursive - } -} - - -/*------------------------------------------------------------------------------ - * Test constructor without title. - *----------------------------------------------------------------------------*/ -Playlist :: Playlist(Ptr::Ref id, - Ptr::Ref playlength, - Ptr::Ref uri) - throw () - : Playable(PlaylistType), - id(id), - uri(uri) -{ - this->title.reset(new Glib::ustring("")); - - elementList.reset(new PlaylistElementListType); - - setTitle(title); - setPlaylength(playlength); -} - - -/*------------------------------------------------------------------------------ - * Test constructor with title. - *----------------------------------------------------------------------------*/ -Playlist :: Playlist(Ptr::Ref id, - Ptr::Ref title, - Ptr::Ref playlength, - Ptr::Ref uri) - throw () - : Playable(PlaylistType), - id(id), - uri(uri) -{ - elementList.reset(new PlaylistElementListType); - - setTitle(title); - setPlaylength(playlength); -} - - -/*------------------------------------------------------------------------------ - * Convert to an XmlRpcValue. - *----------------------------------------------------------------------------*/ -Playlist :: operator XmlRpc::XmlRpcValue() const - throw() -{ - XmlRpc::XmlRpcValue xmlRpcValue; - xmlRpcValue[configElementNameStr] = std::string(*getXmlDocumentString()); - - return xmlRpcValue; -} - - -/*------------------------------------------------------------------------------ - * Construct from an XmlRpcValue. - *----------------------------------------------------------------------------*/ -Playlist :: Playlist(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) - : Playable(PlaylistType) -{ - elementList.reset(new PlaylistElementListType); - - if (!xmlRpcValue.hasMember(configElementNameStr)) { - throw std::invalid_argument("no playlist data found in XmlRpcValue"); - } - - xmlpp::DomParser parser; - try { - parser.parse_memory(std::string(xmlRpcValue[configElementNameStr])); - } catch (xmlpp::exception &e) { - throw std::invalid_argument("error parsing XML document"); - } - - configure(*parser.get_document()->get_root_node()); // may throw -} - - -/*------------------------------------------------------------------------------ - * Set the value of the title field. - *----------------------------------------------------------------------------*/ -void -Playlist :: setTitle(Ptr::Ref title) - throw () -{ - setMetadata(title, titleElementName, titleElementPrefix); -} - - -/*------------------------------------------------------------------------------ - * Set the value of the playlength field (private). - *----------------------------------------------------------------------------*/ -void -Playlist :: setPlaylength(Ptr::Ref playlength) - throw () -{ - Ptr::Ref playlengthString(new const Glib::ustring( - toFixedString(playlength) )); - setMetadata(playlengthString, extentElementName, extentElementPrefix); -} - - -/*------------------------------------------------------------------------------ - * Set the value of the playlength from a string (private). - *----------------------------------------------------------------------------*/ -void -Playlist :: setPlaylength(Ptr::Ref timeString) - throw (std::invalid_argument) -{ - try { - playlength = TimeConversion::parseTimeDuration(timeString); - } catch (std::exception &e) { - std::string eMsg = "bad time format in playlength: "; - eMsg += e.what(); - throw std::invalid_argument(eMsg); - } -} - - -/*------------------------------------------------------------------------------ - * Create a playlist object based on an XML element. - *----------------------------------------------------------------------------*/ -void -Playlist :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementNameStr) { - std::string eMsg = "bad configuration element "; - eMsg += element.get_name(); - throw std::invalid_argument(eMsg); - } - - const xmlpp::Attribute * attribute = 0; - - if (!id) { - if (!(attribute = element.get_attribute(idAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - id.reset(new UniqueId(attribute->get_value())); - } - - if (!playlength - && (attribute = element.get_attribute(playlengthAttrName))) { - Ptr::Ref playlengthString(new Glib::ustring( - attribute->get_value() )); - setMetadata(playlengthString, extentElementName, extentElementPrefix); - } - - if (!title - && (attribute = element.get_attribute(titleAttrName))) { - title.reset(new const Glib::ustring(attribute->get_value())); - setMetadata(title, titleElementName, titleElementPrefix); - } - - xmlpp::Node::NodeList childNodes - = element.get_children(elementListAttrName); - xmlpp::Node::NodeList::iterator it = childNodes.begin(); - - while (it != childNodes.end()) { - Ptr::Ref newPlaylistElement(new PlaylistElement); - const xmlpp::Element * childElement - = dynamic_cast (*it); - newPlaylistElement->configure(*childElement); // may throw exception - addPlaylistElement(newPlaylistElement); - ++it; - } - - childNodes = element.get_children(metadataElementName); - it = childNodes.begin(); - - if (it != childNodes.end()) { - const xmlpp::Element * metadataElement - = dynamic_cast (*it); - - xmlPlaylist.reset(new xmlpp::Document); - xmlpp::Element* root = xmlPlaylist->create_root_node( - configElementNameStr); - root->set_attribute(idAttrName, std::string(*id)); - root->import_node(metadataElement, true); // true = recursive - - const xmlpp::Node::NodeList dataFieldList - = metadataElement->get_children(); - xmlpp::Node::NodeList::const_iterator listIt = dataFieldList.begin(); - - while (listIt != dataFieldList.end()) { - const xmlpp::Node* dataNode = *listIt; - std::string prefix = dataNode->get_namespace_prefix(); - std::string name = dataNode->get_name(); - const xmlpp::Element* - dataElement - = dynamic_cast (dataNode); - if (!dataElement) { - ++listIt; - continue; - } - - if (!playlength && prefix == extentElementPrefix - && name == extentElementName) { - if (dataElement->has_child_text()) { - Ptr::Ref playlengthString( - new std::string(dataElement->get_child_text() - ->get_content() )); - setPlaylength(playlengthString); - } else { // or just leave blank? bad either way - playlength.reset(new time_duration(0,0,0,0)); - } - } - - if (!title && prefix == titleElementPrefix - && name == titleElementName) { - Glib::ustring value; - if (dataElement->has_child_text()) { - value = dataElement->get_child_text()->get_content(); - } else { - value = ""; - } - Ptr::Ref ptrToValue( - new const Glib::ustring(value)); - title = ptrToValue; - } - - ++listIt; - } - - ++it; - if (it != childNodes.end()) { - std::string eMsg = "more than one "; - eMsg += metadataElementName; - eMsg += " XML element"; - throw std::invalid_argument(eMsg); - } - } - - if (!playlength) { - std::string eMsg = "missing attribute "; - eMsg += playlengthAttrName; - eMsg += " or metadata element "; - eMsg += extentElementPrefix + ":" + extentElementName; - throw std::invalid_argument(eMsg); - } - - if (!title) { - title.reset(new const Glib::ustring("")); - } -} - - -/*------------------------------------------------------------------------------ - * Add a new playlist element to the playlist. - *----------------------------------------------------------------------------*/ -void -Playlist::addPlaylistElement(Ptr::Ref playlistElement) - throw () -{ - Ptr::Ref relativeOffset - = playlistElement->getRelativeOffset(); - elementList->insert(std::make_pair(*relativeOffset, playlistElement)); -} - - -/*------------------------------------------------------------------------------ - * Add a new audio clip or sub-playlist to the playlist. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playlist::addPlayable(Ptr::Ref playable, - Ptr::Ref relativeOffset, - Ptr::Ref fadeInfo) - throw (std::invalid_argument) -{ - Ptr::Ref audioClip; - Ptr::Ref playlist; - - switch (playable->getType()) { - case Playable::AudioClipType : - audioClip = boost::dynamic_pointer_cast(playable); - return addAudioClip(audioClip, relativeOffset, fadeInfo); - - case Playable::PlaylistType : - playlist = boost::dynamic_pointer_cast(playable); - return addPlaylist(playlist, relativeOffset, fadeInfo); - - default : - throw std::invalid_argument("Playable object is neither AudioClip" - " nor Playlist?!"); - } -} - - -/*------------------------------------------------------------------------------ - * Add a new audio clip to the playlist. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playlist::addAudioClip(Ptr::Ref audioClip, - Ptr::Ref relativeOffset, - Ptr::Ref fadeInfo) - throw () -{ - Ptr::Ref playlistElement(new PlaylistElement( - relativeOffset, audioClip->getPlaylength(), audioClip, fadeInfo)); - elementList->insert(std::make_pair(*relativeOffset, playlistElement)); - - Ptr::Ref endOffset(new time_duration( - *relativeOffset - + *audioClip->getPlaylength())); - if (*endOffset > *playlength) { - setPlaylength(endOffset); - } - - return playlistElement->getId(); -} - - -/*------------------------------------------------------------------------------ - * Add a new sub-playlist to the playlist. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playlist::addPlaylist(Ptr::Ref playlist, - Ptr::Ref relativeOffset, - Ptr::Ref fadeInfo) - throw () -{ - Ptr::Ref playlistElement(new PlaylistElement( - relativeOffset, playlist->getPlaylength(), playlist, fadeInfo)); - elementList->insert(std::make_pair(*relativeOffset, playlistElement)); - - Ptr::Ref endOffset(new time_duration( - *relativeOffset - + *playlist->getPlaylength())); - if (*endOffset > *playlength) { - setPlaylength(endOffset); - } - - return playlistElement->getId(); -} - - -/*------------------------------------------------------------------------------ - * Get an iterator pointing to a playlist element with a given ID. - *----------------------------------------------------------------------------*/ -Playlist::iterator -Playlist::find(Ptr::Ref playlistElementId) - throw () -{ - Playlist::iterator it = elementList->begin(); - while (it != elementList->end() - && *(it->second->getId()) != *playlistElementId) { - ++it; - } - return it; -} - - -/*------------------------------------------------------------------------------ - * Change the fade in / fade out info of a playlist element. - *----------------------------------------------------------------------------*/ -void -Playlist::setFadeInfo(Ptr::Ref playlistElementId, - Ptr::Ref fadeInfo) - throw (std::invalid_argument) -{ - Playlist::iterator it = this->find(playlistElementId); - - if (it == this->end()) { - throw std::invalid_argument("no playlist element with this ID"); - } - - it->second->setFadeInfo(fadeInfo); -} - -/*------------------------------------------------------------------------------ - * Change clipStart of a playlist element. - *----------------------------------------------------------------------------*/ -void -Playlist::setClipStart(Ptr::Ref playlistElementId, - Ptr::Ref newStart) - throw (std::invalid_argument) -{ - Playlist::iterator it = this->find(playlistElementId); - - if (it == this->end()) { - throw std::invalid_argument("no playlist element with this ID"); - } - - Ptr::Ref endOffset(new time_duration( - *it->second->getRelativeOffset() - + *it->second->getPlayable()->getPlaylength() - *newStart)); - setPlaylength(endOffset); - - it->second->setClipStart(newStart); -} - -/*------------------------------------------------------------------------------ - * Change clipEnd of a playlist element. - *----------------------------------------------------------------------------*/ -void -Playlist::setClipEnd(Ptr::Ref playlistElementId, - Ptr::Ref newEnd) - throw (std::invalid_argument) -{ - Playlist::iterator it = this->find(playlistElementId); - - if (it == this->end()) { - throw std::invalid_argument("no playlist element with this ID"); - } - - Ptr::Ref endOffset(new time_duration( - *it->second->getRelativeOffset() - + *newEnd - *it->second->getClipStart())); - setPlaylength(endOffset); - - it->second->setClipEnd(newEnd); -} - - -/*------------------------------------------------------------------------------ - * Remove a playlist element from the playlist. - *----------------------------------------------------------------------------*/ -void -Playlist::removePlaylistElement(Ptr::Ref playlistElementId) - throw (std::invalid_argument) -{ - Playlist::iterator it = this->find(playlistElementId); - - if (it == this->end()) { - throw std::invalid_argument("no playlist element with this ID"); - } - - elementList->erase(it); -} - - -/*------------------------------------------------------------------------------ - * Validate the playlist. - *----------------------------------------------------------------------------*/ -bool -Playlist::valid(void) const throw () -{ - time_duration runningTime(0,0,0,0); - - PlaylistElementListType::const_iterator it = elementList->begin(); - while (it != elementList->end()) { - Ptr::Ref playlistElement = it->second; - - if (playlistElement->getType() == PlaylistElement::PlaylistType - && !playlistElement->getPlaylist()->valid()) { - return false; - } - - time_duration relativeOffset = *playlistElement->getRelativeOffset(); - if (runningTime < relativeOffset) { - return false; // found a gap in the playlist - } - - time_duration endTime = - relativeOffset - + *playlistElement->getPlayable()->getPlaylength(); - if (endTime > runningTime) { - runningTime = endTime; - } - - ++it; - } - - if (runningTime != *getPlaylength()) { - return false; - } - - return true; -} - - -/*------------------------------------------------------------------------------ - * Create a saved copy of the playlist. - *----------------------------------------------------------------------------*/ -void -Playlist::createSavedCopy(void) throw () -{ - savedCopy = Ptr::Ref(new Playlist(*this)); -} - - -/*------------------------------------------------------------------------------ - * Revert to a saved copy of the playlist. - *----------------------------------------------------------------------------*/ -void -Playlist::revertToSavedCopy(void) throw (std::invalid_argument) -{ - if (savedCopy == 0) { - throw (std::invalid_argument("playlist has no saved copy")); - } - - this->id = savedCopy->id; - this->title = savedCopy->title; - this->playlength = savedCopy->playlength; - this->uri = savedCopy->uri; - this->token = savedCopy->token; - this->elementList = savedCopy->elementList; - this->xmlPlaylist = savedCopy->xmlPlaylist; - - savedCopy.reset(); -} - - -/*------------------------------------------------------------------------------ - * Return the value of a metadata field. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playlist :: getMetadata(const std::string & key) const - throw () -{ - std::string name, prefix; - separateNameAndNameSpace(key, name, prefix); - - Ptr::Ref value; - - if (! xmlPlaylist) { - return value; - } - xmlpp::Element* rootNode = xmlPlaylist->get_root_node(); - if (! rootNode) { - return value; - } - xmlpp::Node::NodeList rootList = rootNode->get_children( - metadataElementName); - if (rootList.size() == 0) { - return value; - } - - xmlpp::Node* metadata = rootList.front(); - xmlpp::Node::NodeList nodeList = metadata->get_children(name); - xmlpp::Node::NodeList::iterator it = nodeList.begin(); - - while (it != nodeList.end()) { - xmlpp::Node* node = *it; - if (node->get_namespace_prefix() == prefix) { - xmlpp::Element* element = dynamic_cast (node); - xmlpp::TextNode* textNode = element->get_child_text(); - if (textNode) { - value.reset(new Glib::ustring(textNode->get_content())); - } else { - value.reset(new Glib::ustring("")); - } - return value; - } - ++it; - } - - return value; -} - - -/*------------------------------------------------------------------------------ - * Set the value of a metadata field (public). - *----------------------------------------------------------------------------*/ -void -Playlist :: setMetadata(Ptr::Ref value, - const std::string &key) - throw (std::invalid_argument) -{ - std::string name, prefix; - separateNameAndNameSpace(key, name, prefix); - setMetadata(value, name, prefix); -} - - -/*------------------------------------------------------------------------------ - * Set the value of a metadata field (private). - *----------------------------------------------------------------------------*/ -void -Playlist :: setMetadata(Ptr::Ref value, - const std::string &name, const std::string &prefix) - throw (std::invalid_argument) -{ - if (prefix == extentElementPrefix && name == extentElementName) { - Ptr::Ref valueString(new const std::string( - *value)); - setPlaylength(valueString); - } - - if (prefix == titleElementPrefix && name == titleElementName) { - title = value; - } - - // create a new xmlpp::Document for the metadata if necessary - if (! xmlPlaylist) { - xmlPlaylist.reset(new xmlpp::Document); - } - xmlpp::Element* rootNode = xmlPlaylist->get_root_node(); - if (! rootNode) { - rootNode = xmlPlaylist->create_root_node(configElementNameStr); - if (id) { - rootNode->set_attribute(idAttrName, std::string(*id)); - } - } - xmlpp::Node::NodeList rootList = rootNode->get_children( - metadataElementName); - xmlpp::Element* metadata; - if (rootList.size() > 0) { - metadata = dynamic_cast (rootList.front()); - } else { - metadata = rootNode->add_child(metadataElementName); - metadata->set_namespace_declaration(defaultNamespaceUri); - metadata->set_namespace_declaration(liveSupportNamespaceUri, - liveSupportNamespacePrefix); - metadata->set_namespace_declaration(dcNamespaceUri, - titleElementPrefix); - metadata->set_namespace_declaration(dctermsNamespaceUri, - extentElementPrefix); - metadata->set_namespace_declaration(xmlNamespaceUri, - xmlNamespacePrefix); - } - - // find the element to be modified - xmlpp::Node::NodeList nodeList = metadata->get_children(name); - xmlpp::Node::NodeList::iterator it = nodeList.begin(); - xmlpp::Element* element = 0; - - while (it != nodeList.end()) { - xmlpp::Node* node = *it; - if (node->get_namespace_prefix() == prefix) { - element = dynamic_cast (nodeList.front()); - break; - } - ++it; - } - - // or add it if it did not exist before - if (it == nodeList.end()) { - element = metadata->add_child(name); - try { - element->set_namespace(prefix); - } - catch (xmlpp::exception &e) { - // this namespace has not been declared; well OK, do nothing then - } - } - - element->set_child_text(*value); -} - - -/*------------------------------------------------------------------------------ - * Return a string containing the essential fields of this object, in XML. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playlist :: getXmlElementString(void) const throw () -{ - Ptr::Ref xmlString(new Glib::ustring); - - xmlString->append("<"); - xmlString->append(configElementNameStr + " "); - xmlString->append(idAttrName + "=\"" - + std::string(*getId()) - + "\" "); - xmlString->append(Glib::ustring(titleAttrName) + "=\"" - + *getTitle() - + "\" "); - xmlString->append(playlengthAttrName + "=\"" - + toFixedString(getPlaylength()) - + "\"/>"); - - return xmlString; -} - - -/*------------------------------------------------------------------------------ - * Return a string containing an XML representation of this playlist. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playlist :: getXmlDocumentString() const throw () -{ - Ptr::Ref localDocument; - - if (xmlPlaylist) { - localDocument = xmlPlaylist; - } else { - localDocument.reset(new xmlpp::Document()); - xmlpp::Element* rootNode = localDocument->create_root_node( - configElementNameStr); - if (id) { - rootNode->set_attribute(idAttrName, std::string(*id)); - } - - xmlpp::Element* metadata = rootNode->add_child(metadataElementName); - metadata->set_namespace_declaration(defaultNamespaceUri); - metadata->set_namespace_declaration(liveSupportNamespaceUri, - liveSupportNamespacePrefix); - metadata->set_namespace_declaration(dcNamespaceUri, - titleElementPrefix); - metadata->set_namespace_declaration(dctermsNamespaceUri, - extentElementPrefix); - metadata->set_namespace_declaration(xmlNamespaceUri, - xmlNamespacePrefix); - } - - Glib::ustring playlistElementsXmlString("\n"); - Playlist::const_iterator it = this->begin(); - while (it != this->end()) { - playlistElementsXmlString += *(it->second->getXmlElementString()); - playlistElementsXmlString += '\n'; - ++it; - } - - Ptr::Ref metadataString(new Glib::ustring( - localDocument->write_to_string() )); - unsigned int insertPosition = metadataString->find(metadataElementName); - insertPosition = metadataString->rfind('<', insertPosition); - metadataString->insert(insertPosition, playlistElementsXmlString); - - return metadataString; -} - - -/*------------------------------------------------------------------------------ - * Eliminate the gaps in the playlist. - *----------------------------------------------------------------------------*/ -bool -Playlist :: eliminateGaps(void) throw () -{ - bool didSomething = false; - - Playlist::const_iterator it = this->begin(); - while (it != this->end()) { - Ptr::Ref playlistElement = it->second; - if (playlistElement->getType() == PlaylistElement::PlaylistType) { - Ptr::Ref playlist = playlistElement->getPlaylist(); - didSomething |= playlist->eliminateGaps(); - } - ++it; - } - - time_duration position(0,0,0,0); - time_duration gapsFound(0,0,0,0); - - it = this->begin(); - while (it != this->end()) { - Ptr::Ref playlistElement = it->second; - Ptr::Ref startTime - = playlistElement->getRelativeOffset(); - Ptr::Ref newStartTime; - - if (*startTime - gapsFound > position) { - newStartTime.reset(new time_duration(position)); - playlistElement->setRelativeOffset(newStartTime); - gapsFound = *startTime - position; - didSomething = true; - - } else if (gapsFound.total_microseconds() != 0) { - newStartTime.reset(new time_duration(*startTime - gapsFound)); - playlistElement->setRelativeOffset(newStartTime); - - } else { - newStartTime = startTime; - } - - position = *newStartTime + *playlistElement->getPlayable() - ->getPlaylength(); - ++it; - } - - if (didSomething || position != *getPlaylength()) { - Ptr::Ref newPlaylength(new time_duration(position)); - setPlaylength(newPlaylength); - return true; - } else { - return false; - } -} - - -/*------------------------------------------------------------------------------ - * Find the playlist element at the specified offset. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Playlist :: findAtOffset(Ptr::Ref offset) const - throw () -{ - Ptr::Ref playlistElement; - - PlaylistElementListType::const_reverse_iterator it; - PlaylistElementListType::const_reverse_iterator rend - = elementList->rend(); - for (it = elementList->rbegin(); it != rend; ++it) { - time_duration currentStart = it->first; - if (currentStart <= *offset) { - Ptr::Ref - currentElement = it->second; - time_duration currentEnd = currentStart - + *currentElement->getPlayable() - ->getPlaylength(); - if (currentEnd > *offset) { - playlistElement = currentElement; - } - } - } - - return playlistElement; -} - diff --git a/src/modules/core/src/PlaylistElement.cxx b/src/modules/core/src/PlaylistElement.cxx deleted file mode 100644 index b10fc4def..000000000 --- a/src/modules/core/src/PlaylistElement.cxx +++ /dev/null @@ -1,342 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/TimeConversion.h" -#include "LiveSupport/Core/Playlist.h" -#include "LiveSupport/Core/PlaylistElement.h" - -using namespace boost::posix_time; - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * The name of the config element for this class - *----------------------------------------------------------------------------*/ -const std::string PlaylistElement::configElementNameStr = "playlistElement"; - -/** - * The name of the attribute of the id of the playlist element. - */ -static const std::string idAttrName = "id"; - -/** - * The name of the attribute of the relative offset of the playlist element. - */ -static const std::string relativeOffsetAttrName = "relativeOffset"; - -/** - */ -static const std::string clipStartAttrName = "clipStart"; - -/** - */ -static const std::string clipEndAttrName = "clipEnd"; - -/** - */ -static const std::string clipLengthAttrName = "clipLength"; - -/** - * The name of the audio clip child element of the playlist element. - */ -static const std::string audioClipElementName = "audioClip"; - -/** - * The name of the playlist child element of the playlist element. - */ -static const std::string playlistElementName = "playlist"; - -/** - * The name of the fade info child element of the playlist element. - */ -static const std::string fadeInfoElementName = "fadeInfo"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * The default constructor. - *----------------------------------------------------------------------------*/ -PlaylistElement :: PlaylistElement(void) throw () -{ -} - -/*------------------------------------------------------------------------------ - * Create a playlist element by specifying all details. - *----------------------------------------------------------------------------*/ -PlaylistElement :: PlaylistElement(Ptr::Ref id, - Ptr::Ref relativeOffset, - Ptr::Ref clipLength, - Ptr::Ref audioClip, - Ptr::Ref fadeInfo) - throw () -{ - this->id = id; - this->relativeOffset = relativeOffset; - this->clipLength = clipLength; - this->audioClip = audioClip; - this->playable = audioClip; - this->fadeInfo = fadeInfo; - this->type = AudioClipType; - - setClipStart(Ptr::Ref(new time_duration(0,0,0,0))); - setClipEnd(Ptr::Ref(new time_duration(0,0,0,0))); -} - - -/*------------------------------------------------------------------------------ - * Create a new audio clip playlist element, with a new UniqueId, - * to be added to a playlist. - *----------------------------------------------------------------------------*/ -PlaylistElement :: PlaylistElement(Ptr::Ref relativeOffset, - Ptr::Ref clipLength, - Ptr::Ref audioClip, - Ptr::Ref fadeInfo) - throw () -{ - this->id = UniqueId::generateId(); - this->relativeOffset = relativeOffset; - this->clipLength = clipLength; - this->audioClip = audioClip; - this->playable = audioClip; - this->fadeInfo = fadeInfo; - this->type = AudioClipType; - - setClipStart(Ptr::Ref(new time_duration(0,0,0,0))); - setClipEnd(Ptr::Ref(new time_duration(0,0,0,0))); -} - - -/*------------------------------------------------------------------------------ - * Create a new sub-playlist playlist element, with a new UniqueId, - * to be added to a playlist. - *----------------------------------------------------------------------------*/ -PlaylistElement :: PlaylistElement(Ptr::Ref relativeOffset, - Ptr::Ref clipLength, - Ptr::Ref playlist, - Ptr::Ref fadeInfo) - throw () -{ - this->id = UniqueId::generateId(); - this->relativeOffset = relativeOffset; - this->clipLength = clipLength; - this->playlist = playlist; - this->playable = playlist; - this->fadeInfo = fadeInfo; - this->type = PlaylistType; - - setClipStart(Ptr::Ref(new time_duration(0,0,0,0))); - setClipEnd(Ptr::Ref(new time_duration(0,0,0,0))); -} - - -/*------------------------------------------------------------------------------ - * A virtual destructor, as this class has virtual functions. - *----------------------------------------------------------------------------*/ -PlaylistElement :: ~PlaylistElement(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Create a playlist element object based on an XML element. - *----------------------------------------------------------------------------*/ -void -PlaylistElement :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementNameStr) { - std::string eMsg = "bad configuration element "; - eMsg += element.get_name(); - throw std::invalid_argument(eMsg); - } - - // set id - const xmlpp::Attribute* attribute; - - if (!(attribute = element.get_attribute(idAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - id.reset(new UniqueId(attribute->get_value())); - - // set relative offset - if (!(attribute = element.get_attribute(relativeOffsetAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += relativeOffsetAttrName; - throw std::invalid_argument(eMsg); - } - Ptr::Ref relativeOffsetString(new std::string( - attribute->get_value() )); - relativeOffset = TimeConversion::parseTimeDuration(relativeOffsetString); - - // set clip start - if (attribute = element.get_attribute(clipStartAttrName)) { - Ptr::Ref clipStartString(new std::string( - attribute->get_value() )); - clipStart = TimeConversion::parseTimeDuration(clipStartString); - } else { - setClipStart(Ptr::Ref(new time_duration(0,0,0,0))); - } - - // set clip end - if (attribute = element.get_attribute(clipEndAttrName)) { - Ptr::Ref clipEndString(new std::string( - attribute->get_value() )); - clipEnd = TimeConversion::parseTimeDuration(clipEndString); - } else { - setClipEnd(Ptr::Ref(new time_duration(0,0,0,0))); - } - - // set clip length - if (attribute = element.get_attribute(clipLengthAttrName)) { - Ptr::Ref clipLengthString(new std::string( - attribute->get_value() )); - clipLength = TimeConversion::parseTimeDuration(clipLengthString); - } else { - setClipLength(Ptr::Ref(new time_duration(0,0,0,0))); - } - - // set audio clip - xmlpp::Node::NodeList childNodes - = element.get_children(audioClipElementName); - xmlpp::Node::NodeList::iterator it = childNodes.begin(); - - if (it != childNodes.end()) { - const xmlpp::Element * audioClipElement - = dynamic_cast (*it); - type = AudioClipType; - audioClip.reset(new AudioClip); - playable = audioClip; - audioClip->configure(*audioClipElement); // may throw exception - - ++it; - if (it != childNodes.end()) { - std::string eMsg = "more than one "; - eMsg += audioClipElementName; - eMsg += " XML element"; - throw std::invalid_argument(eMsg); - } - } else { - childNodes = element.get_children(playlistElementName); - it = childNodes.begin(); - if (it != childNodes.end()) { - const xmlpp::Element * playlistElement - = dynamic_cast (*it); - type = PlaylistType; - playlist.reset(new Playlist); - playable = playlist; - playlist->configure(*playlistElement); // may throw exception - ++it; - if (it != childNodes.end()) { - std::string eMsg = "more than one "; - eMsg += playlistElementName; - eMsg += " XML element"; - throw std::invalid_argument(eMsg); - } - } else { - std::string eMsg = "missing "; - eMsg += audioClipElementName; - eMsg += " or "; - eMsg += playlistElementName; - eMsg += " XML element in PlaylistElement configuration"; - throw std::invalid_argument(eMsg); - } - } - - // set fade info - childNodes = element.get_children(fadeInfoElementName); - it = childNodes.begin(); - - if (it == childNodes.end()) { // no fade info is OK - return; - } - - const xmlpp::Element * fadeInfoElement - = dynamic_cast (*it); - fadeInfo.reset(new FadeInfo); - fadeInfo->configure(*fadeInfoElement); // may throw exception - - ++it; - if (it != childNodes.end()) { - std::string eMsg = "more than one "; - eMsg += fadeInfoElementName; - eMsg += " XML element"; - throw std::invalid_argument(eMsg); - } -} - - -/*------------------------------------------------------------------------------ - * Return a string containing the essential fields of this object, in XML. - *----------------------------------------------------------------------------*/ -Ptr::Ref -PlaylistElement :: getXmlElementString(void) throw () -{ - Ptr::Ref xmlString(new Glib::ustring); - - xmlString->append("<"); - xmlString->append(configElementNameStr + " "); - xmlString->append(idAttrName + "=\"" - + std::string(*id) - + "\" "); - xmlString->append(relativeOffsetAttrName + "=\"" - + toFixedString(relativeOffset) - + "\" "); - xmlString->append(clipStartAttrName + "=\"" - + toFixedString(clipStart) - + "\" "); - xmlString->append(clipEndAttrName + "=\"" - + toFixedString(clipEnd) - + "\" "); - xmlString->append(clipLengthAttrName + "=\"" - + toFixedString(clipLength) - + "\">\n"); - - xmlString->append(*getPlayable()->getXmlElementString() + "\n"); - if (fadeInfo) { - xmlString->append(*fadeInfo->getXmlElementString() + "\n"); - } - xmlString->append("append(configElementNameStr + ">"); - - return xmlString; -} - diff --git a/src/modules/core/src/PlaylistElementTest.cxx b/src/modules/core/src/PlaylistElementTest.cxx deleted file mode 100644 index fd24625d6..000000000 --- a/src/modules/core/src/PlaylistElementTest.cxx +++ /dev/null @@ -1,173 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/Playlist.h" -#include "LiveSupport/Core/PlaylistElement.h" - -#include "PlaylistElementTest.h" - -using namespace std; -using namespace LiveSupport::Core; -using namespace boost::posix_time; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(PlaylistElementTest); - -/** - * The name of the configuration file for the playlist element. - */ -static const std::string configFileName = "etc/playlistElement.xml"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -PlaylistElementTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -PlaylistElementTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the singleton Hello object is accessible - *----------------------------------------------------------------------------*/ -void -PlaylistElementTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref playlistElement(new PlaylistElement); - try { - - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - playlistElement->configure(*root); - - // the playlist element - CPPUNIT_ASSERT(playlistElement->getId()->getId() == 0x103); - Ptr::Ref relativeOffset - = playlistElement->getRelativeOffset(); - CPPUNIT_ASSERT(relativeOffset->total_seconds() == 11); - - CPPUNIT_ASSERT(playlistElement->getFadeInfo()->getId()->getId() - == 0x9901); - Ptr::Ref fadeIn - = playlistElement->getFadeInfo() - ->getFadeIn(); - CPPUNIT_ASSERT(fadeIn->total_milliseconds() == 2000); - Ptr::Ref fadeOut - = playlistElement->getFadeInfo() - ->getFadeOut(); - CPPUNIT_ASSERT(fadeOut->total_milliseconds() == 1500); - - CPPUNIT_ASSERT(playlistElement->getType() - == PlaylistElement::PlaylistType); - - // check that we can access the playlist inside the playlist element - // as a Playable instance - CPPUNIT_ASSERT(playlistElement->getPlaylist() - == playlistElement->getPlayable()); - - // the playlist inside the playlist element - CPPUNIT_ASSERT(playlistElement->getPlaylist()->getId()->getId() - == 0x2); - Ptr::Ref playlist = playlistElement->getPlaylist(); - Playlist::const_iterator it = playlist->begin(); - CPPUNIT_ASSERT(it != playlist->end()); - playlistElement = it->second; - ++it; - CPPUNIT_ASSERT(it == playlist->end()); - - // the playlist element inside the playlist - CPPUNIT_ASSERT(playlistElement->getId()->getId() == 0x111); - relativeOffset = playlistElement->getRelativeOffset(); - CPPUNIT_ASSERT(relativeOffset->total_seconds() == 0); - - CPPUNIT_ASSERT(playlistElement->getType() - == PlaylistElement::AudioClipType); - - CPPUNIT_ASSERT(*playlistElement->getXmlElementString() == - "\n" - "\n" - ""); - - // and the audio clip inside the playlist element - CPPUNIT_ASSERT(playlistElement->getAudioClip()->getId()->getId() - == 0x10003); - - // check that we can access this audio clip as a Playable instance - CPPUNIT_ASSERT(playlistElement->getAudioClip() - == playlistElement->getPlayable()); - - } catch (std::invalid_argument &e) { - std::string eMsg = "semantic error in configuration file:\n"; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } catch (xmlpp::exception &e) { - std::string eMsg = "error parsing configuration file:\n"; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } -} diff --git a/src/modules/core/src/PlaylistElementTest.h b/src/modules/core/src/PlaylistElementTest.h deleted file mode 100644 index b74f8e490..000000000 --- a/src/modules/core/src/PlaylistElementTest.h +++ /dev/null @@ -1,99 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef PlaylistElementTest_h -#define PlaylistElementTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the PlaylistElement class. - * - * @see PlaylistElement - */ -class PlaylistElementTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(PlaylistElementTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // PlaylistElementTest_h - diff --git a/src/modules/core/src/PlaylistTest.cxx b/src/modules/core/src/PlaylistTest.cxx deleted file mode 100644 index 34451345f..000000000 --- a/src/modules/core/src/PlaylistTest.cxx +++ /dev/null @@ -1,520 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/Playlist.h" -#include "PlaylistTest.h" - - -using namespace std; -using namespace LiveSupport::Core; - - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(PlaylistTest); - -/** - * The name of the configuration file for the playlist. - */ -static const std::string configFileName = "etc/playlist.xml"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: setUp(void) throw () -{ - playlist.reset(new Playlist); - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - playlist->configure(*root); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in configuration file"); - } catch (xmlpp::exception &e) { - CPPUNIT_FAIL("error parsing configuration file"); - } -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the singleton Hello object is accessible - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - CPPUNIT_ASSERT(playlist->getId()->getId() == 0x1); - Ptr::Ref duration - = playlist->getPlaylength(); - CPPUNIT_ASSERT(duration->total_seconds() == 34); - - CPPUNIT_ASSERT(playlist->valid()); - CPPUNIT_ASSERT(*playlist->getXmlElementString() == - ""); - Playlist::const_iterator it = playlist->begin(); - CPPUNIT_ASSERT(it != playlist->end()); - Ptr::Ref playlistElement = it->second; - CPPUNIT_ASSERT(playlistElement->getId()->getId() == 0x101); - Ptr::Ref relativeOffset - = playlistElement->getRelativeOffset(); - CPPUNIT_ASSERT(relativeOffset->total_seconds() == 0); - CPPUNIT_ASSERT(playlistElement->getType() - == PlaylistElement::AudioClipType); - CPPUNIT_ASSERT(playlistElement->getAudioClip()->getId()->getId() - == 0x10001); - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - playlistElement = it->second; - CPPUNIT_ASSERT(playlistElement->getId()->getId() == 0x102); - relativeOffset = playlistElement->getRelativeOffset(); - CPPUNIT_ASSERT(relativeOffset->total_seconds() == 11); - CPPUNIT_ASSERT(playlistElement->getType() - == PlaylistElement::AudioClipType); - CPPUNIT_ASSERT(playlistElement->getAudioClip()->getId()->getId() - == 0x10002); - - ++it; - ++it; - CPPUNIT_ASSERT(it == playlist->end()); -} - - -/*------------------------------------------------------------------------------ - * Test to see if we can add or remove an audio clip - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: audioClipTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref clipId(new UniqueId("20001")); - Ptr::Ref clipLength(new time_duration(0,30,0,0)); - Ptr::Ref audioClip(new AudioClip(clipId, clipLength)); - - Ptr::Ref relativeOffset(new time_duration(0,10,0,0)); - // hour, min, sec, frac_sec - try { - playlist->addAudioClip(audioClip, relativeOffset); - } catch (std::invalid_argument &e) { - string eMsg = "addAudioClip returned with error: "; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } - - CPPUNIT_ASSERT(playlist->getPlaylength()); - CPPUNIT_ASSERT(*playlist->getPlaylength() == *relativeOffset + *clipLength); - - CPPUNIT_ASSERT(!playlist->valid()); // big gap in playlist - - Playlist::const_iterator it = playlist->begin(); - CPPUNIT_ASSERT(it != playlist->end()); - - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - - Ptr::Ref playlistElement = it->second; - CPPUNIT_ASSERT(playlistElement->getType() - == PlaylistElement::AudioClipType); - CPPUNIT_ASSERT(playlistElement->getAudioClip()->getId()->getId() - == 0x20001); - - Ptr::Ref otherRelativeOffset - = playlistElement->getRelativeOffset(); - CPPUNIT_ASSERT(otherRelativeOffset->total_seconds() == 10*60); - - ++it; - CPPUNIT_ASSERT(it == playlist->end()); - - try { - playlist->removePlaylistElement(playlistElement->getId()); - } catch (std::invalid_argument &e) { - string eMsg = "removePlaylistElement returned with error: "; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } - - it = playlist->begin(); - CPPUNIT_ASSERT(it != playlist->end()); - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - ++it; - CPPUNIT_ASSERT(it == playlist->end()); - - Ptr::Ref phonyPlaylistElementId(new UniqueId(9999)); - try { - playlist->removePlaylistElement(phonyPlaylistElementId); - CPPUNIT_FAIL("removePlaylistElement allowed to remove " - "non-existent audio clip"); - } catch (std::invalid_argument &e) { - } -} - - -/*------------------------------------------------------------------------------ - * Test the "save/revert to current state" mechanism - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: savedCopyTest(void) - throw (CPPUNIT_NS::Exception) -{ - try { - playlist->revertToSavedCopy(); - CPPUNIT_FAIL("allowed to revert to non-existent state"); - } catch (std::invalid_argument &e) { - } - - playlist->createSavedCopy(); - playlist->removePlaylistElement(playlist->begin()->second->getId()); - playlist->removePlaylistElement(playlist->begin()->second->getId()); - playlist->removePlaylistElement(playlist->begin()->second->getId()); - CPPUNIT_ASSERT(playlist->begin() == playlist->end()); - - try { - playlist->revertToSavedCopy(); - } catch (std::logic_error &e) { - CPPUNIT_FAIL("could not revert to saved state"); - } - - Playlist::const_iterator it = playlist->begin(); - CPPUNIT_ASSERT(it != playlist->end()); - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - Ptr::Ref playlistElement = it->second; - CPPUNIT_ASSERT(playlistElement->getType() - == PlaylistElement::AudioClipType); - CPPUNIT_ASSERT(playlistElement->getAudioClip()->getId()->getId() - == 0x10002); - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - ++it; - CPPUNIT_ASSERT(it == playlist->end()); - - playlist->deleteSavedCopy(); - try { - playlist->revertToSavedCopy(); - CPPUNIT_FAIL("allowed to revert to deleted state"); - } catch (std::logic_error &e) { - } -} - - -/*------------------------------------------------------------------------------ - * Test to see if we can add a fade info - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: fadeInfoTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref playlistElementOne, - playlistElementTwo; - - Playlist::const_iterator it = playlist->begin(); - CPPUNIT_ASSERT(it != playlist->end()); - playlistElementOne = it->second; - CPPUNIT_ASSERT(playlistElementOne->getFadeInfo().get() == 0); - - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - playlistElementTwo = it->second; - CPPUNIT_ASSERT(playlistElementTwo->getFadeInfo()->getFadeIn() - ->total_milliseconds() == 2000); - CPPUNIT_ASSERT(playlistElementTwo->getFadeInfo()->getFadeOut() - ->total_milliseconds() == 1500); - - ++it; - CPPUNIT_ASSERT(it != playlist->end()); - ++it; - CPPUNIT_ASSERT(it == playlist->end()); - - Ptr::Ref fadeIn (new time_duration(0,0,3,200000)); - Ptr::Ref fadeOut(new time_duration(0,0,4,0)); - Ptr::Ref fadeInfo(new FadeInfo(fadeIn, fadeOut)); - - try { - playlist->setFadeInfo(playlistElementOne->getId(), fadeInfo); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("could not add new fade info"); - } - - try { - playlist->setFadeInfo(playlistElementTwo->getId(), fadeInfo); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("could not update fade info"); - } - - it = playlist->begin(); - playlistElementOne = it->second; - CPPUNIT_ASSERT(playlistElementOne->getFadeInfo()->getFadeIn() - ->total_milliseconds() == 3200); - CPPUNIT_ASSERT(playlistElementOne->getFadeInfo()->getFadeOut() - ->total_milliseconds() == 4000); - ++it; - playlistElementTwo = it->second; - CPPUNIT_ASSERT(playlistElementTwo->getFadeInfo()->getFadeIn() - ->total_milliseconds() == 3200); - CPPUNIT_ASSERT(playlistElementTwo->getFadeInfo()->getFadeOut() - ->total_milliseconds() == 4000); - - Ptr::Ref phonyPlaylistElementId(new UniqueId(9999)); - try { - playlist->setFadeInfo(phonyPlaylistElementId, fadeInfo); - CPPUNIT_FAIL("allowed to set fade info for non-existent element"); - } catch (std::invalid_argument &e) { - } -} - - -/*------------------------------------------------------------------------------ - * Test conversion to and from Playable - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: conversionTest(void) - throw (CPPUNIT_NS::Exception) -{ - CPPUNIT_ASSERT(playlist.use_count() == 1); - - Ptr::Ref playable = playlist; - CPPUNIT_ASSERT(playable->getType() == Playable::PlaylistType); - CPPUNIT_ASSERT(playlist.use_count() == 2); - - Ptr::Ref otherPlaylist = playable->getPlaylist(); - CPPUNIT_ASSERT(otherPlaylist == playlist); - CPPUNIT_ASSERT(playlist.use_count() == 3); - - Ptr::Ref audioClip = playable->getAudioClip(); - CPPUNIT_ASSERT(!audioClip); -} - - -/*------------------------------------------------------------------------------ - * Marshalling test - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: marshallingTest(void) - throw (CPPUNIT_NS::Exception) -{ - XmlRpc::XmlRpcValue xmlRpcValue = *playlist; - CPPUNIT_ASSERT(xmlRpcValue.hasMember("playlist")); - - Ptr::Ref otherPlaylist; - CPPUNIT_ASSERT_NO_THROW(otherPlaylist.reset(new Playlist(xmlRpcValue))); - - CPPUNIT_ASSERT(*playlist->getId() == *otherPlaylist->getId()); - CPPUNIT_ASSERT(*playlist->getTitle() - == *otherPlaylist->getTitle()); - CPPUNIT_ASSERT(*playlist->getPlaylength() - == *otherPlaylist->getPlaylength()); -} - - -/*------------------------------------------------------------------------------ - * Testing the addPlayable() method - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: addPlayableTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref newPlaylist(new Playlist(*playlist)); - // make a copy - - Ptr::Ref clipId(new UniqueId("20001")); - Ptr::Ref clipLength(new time_duration(0,0,10,0)); - Ptr::Ref audioClip(new AudioClip(clipId, clipLength)); - - Ptr::Ref firstOffset(new time_duration(0,0,30,0)); - // hour, min, sec, frac_sec - try { - newPlaylist->addPlayable(audioClip, firstOffset); - } catch (std::invalid_argument &e) { - string eMsg = "addPlayable returned with error: "; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } - - CPPUNIT_ASSERT(newPlaylist->getPlaylength()); - CPPUNIT_ASSERT(*newPlaylist->getPlaylength() == *firstOffset - + *audioClip->getPlaylength()); - - Ptr::Ref secondOffset(new time_duration(0,0,40,0)); - try { - newPlaylist->addPlayable(playlist, secondOffset); - } catch (std::invalid_argument &e) { - string eMsg = "addPlayable returned with error: "; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } - - CPPUNIT_ASSERT(newPlaylist->getPlaylength()); - CPPUNIT_ASSERT(*newPlaylist->getPlaylength() == *secondOffset - + *playlist->getPlaylength()); -} - - -/*------------------------------------------------------------------------------ - * Testing the eliminateGaps() method - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: eliminateGapsTest(void) - throw (CPPUNIT_NS::Exception) -{ - // a simple negative test - bool result = playlist->eliminateGaps(); - CPPUNIT_ASSERT(result == false); - - // a simple positive test - Ptr::Ref secondElement(new UniqueId("101")); - try { - playlist->removePlaylistElement(secondElement); - } catch (std::invalid_argument &e) { - string eMsg = "removePlaylistElement() returned with error: "; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } - CPPUNIT_ASSERT(!playlist->valid()); // big gap in playlist - CPPUNIT_ASSERT(playlist->getPlaylength()); - CPPUNIT_ASSERT(*playlist->getPlaylength() == seconds(34)); - - result = playlist->eliminateGaps(); - CPPUNIT_ASSERT(result == true); - CPPUNIT_ASSERT(playlist->valid()); // the gap is gone - CPPUNIT_ASSERT(playlist->getPlaylength()); - CPPUNIT_ASSERT(*playlist->getPlaylength() == seconds(23)); -} - - -/*------------------------------------------------------------------------------ - * A second test of the eliminateGaps() method - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: eliminateGapsLastItemTest(void) - throw (CPPUNIT_NS::Exception) -{ - // the same thing as above, but now we remove the last item - Ptr::Ref secondElement(new UniqueId("103")); - try { - playlist->removePlaylistElement(secondElement); - } catch (std::invalid_argument &e) { - string eMsg = "removePlaylistElement() returned with error: "; - eMsg += e.what(); - CPPUNIT_FAIL(eMsg); - } - CPPUNIT_ASSERT(!playlist->valid()); // big gap in playlist - CPPUNIT_ASSERT(playlist->getPlaylength()); - CPPUNIT_ASSERT(*playlist->getPlaylength() == seconds(34)); - - bool result = playlist->eliminateGaps(); - CPPUNIT_ASSERT(result == true); - CPPUNIT_ASSERT(playlist->valid()); // the gap is gone - CPPUNIT_ASSERT(playlist->getPlaylength()); - CPPUNIT_ASSERT(*playlist->getPlaylength() == seconds(23)); - -} - - -/*------------------------------------------------------------------------------ - * Test the findAtOffset() method. - *----------------------------------------------------------------------------*/ -void -PlaylistTest :: findAtOffsetTest(void) throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref offset(new time_duration()); - Ptr::Ref playlistElement; - - *offset = seconds(-1); - playlistElement = playlist->findAtOffset(offset); - CPPUNIT_ASSERT(!playlistElement); - - *offset = seconds(0); - playlistElement = playlist->findAtOffset(offset); - CPPUNIT_ASSERT(playlistElement); - CPPUNIT_ASSERT(playlistElement->getPlayable()->getId()->getId() == 0x10001); - - *offset = seconds(11); - playlistElement = playlist->findAtOffset(offset); - CPPUNIT_ASSERT(playlistElement); - CPPUNIT_ASSERT(playlistElement->getPlayable()->getId()->getId() == 0x10002); - - *offset = seconds(20); - playlistElement = playlist->findAtOffset(offset); - CPPUNIT_ASSERT(playlistElement); - CPPUNIT_ASSERT(playlistElement->getPlayable()->getId()->getId() == 0x10002); - - *offset = microseconds(30123456); - playlistElement = playlist->findAtOffset(offset); - CPPUNIT_ASSERT(playlistElement); - CPPUNIT_ASSERT(playlistElement->getPlayable()->getId()->getId() == 0x2); - - *offset = seconds(34); - playlistElement = playlist->findAtOffset(offset); - CPPUNIT_ASSERT(!playlistElement); - - *offset = hours(1); - playlistElement = playlist->findAtOffset(offset); - CPPUNIT_ASSERT(!playlistElement); -} - diff --git a/src/modules/core/src/PlaylistTest.h b/src/modules/core/src/PlaylistTest.h deleted file mode 100644 index cc8f75151..000000000 --- a/src/modules/core/src/PlaylistTest.h +++ /dev/null @@ -1,187 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef PlaylistTest_h -#define PlaylistTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the UploadPlaylistMetohd class. - * - * @see Playlist - */ -class PlaylistTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(PlaylistTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST(audioClipTest); - CPPUNIT_TEST(savedCopyTest); - CPPUNIT_TEST(fadeInfoTest); - CPPUNIT_TEST(conversionTest); - CPPUNIT_TEST(marshallingTest); - CPPUNIT_TEST(addPlayableTest); - CPPUNIT_TEST(eliminateGapsTest); - CPPUNIT_TEST(eliminateGapsLastItemTest); - CPPUNIT_TEST(findAtOffsetTest); - CPPUNIT_TEST_SUITE_END(); - - private: - - /** - * A playlist to play with. - */ - Ptr::Ref playlist; - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Trying to add a new audio clip. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - audioClipTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing the "save/revert to current state" mechanism. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - savedCopyTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Trying to add a new fade info. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - fadeInfoTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing conversion to and from Playable. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - conversionTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing conversion to and from XmlRpcValue. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - marshallingTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing the addPlayable() method. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - addPlayableTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing the eliminateGaps() method. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - eliminateGapsTest(void) throw (CPPUNIT_NS::Exception); - - /** - * A second test of the eliminateGaps() method. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - eliminateGapsLastItemTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the findAtOffset() method. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - findAtOffsetTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // PlaylistTest_h - diff --git a/src/modules/core/src/RdsContainer.cxx b/src/modules/core/src/RdsContainer.cxx deleted file mode 100644 index eefa7354e..000000000 --- a/src/modules/core/src/RdsContainer.cxx +++ /dev/null @@ -1,192 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/RdsContainer.h" - - -using namespace LiveSupport::Core; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/** - * The name of the config element for this class - */ -const std::string RdsContainer::configElementName = "rdsContainer"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create an RDS container object based on an XML element. - *----------------------------------------------------------------------------*/ -void -RdsContainer :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementName) { - throw std::invalid_argument("bad coniguration element " - + element.get_name()); - } - - xmlpp::Node::NodeList childNodes = element.get_children( - RdsItem::getConfigElementName()); - xmlpp::Node::NodeList::const_iterator it; - - rdsItemList.clear(); - for (it = childNodes.begin(); it != childNodes.end(); ++it) { - const xmlpp::Element * rdsItemElement - = dynamic_cast (*it); - - Ptr::Ref rdsItem(new RdsItem()); - rdsItem->configure(*rdsItemElement); - - rdsItemList.push_back(rdsItem); - } -} - - -/*------------------------------------------------------------------------------ - * Set the RDS options. - *----------------------------------------------------------------------------*/ -void -RdsContainer :: setRdsOptions(Ptr::Ref key, - Ptr::Ref value, - bool enabled) - throw () -{ - RdsItemListType::const_iterator it; - - bool found = false; - for(it = rdsItemList.begin(); it != rdsItemList.end(); ++it) { - Ptr::Ref rdsItem = *it; - if (*rdsItem->getKey() == *key) { - found = true; - rdsItem->setValue(value); - rdsItem->setEnabled(enabled); - break; - } - } - - if (!found) { - Ptr::Ref rdsItem(new RdsItem(key, value, enabled)); - rdsItemList.push_back(rdsItem); - } - - touched = true; -} - - -/*------------------------------------------------------------------------------ - * Get the value of an RDS string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -RdsContainer :: getRdsValue(Ptr::Ref key) - throw (std::invalid_argument) -{ - RdsItemListType::const_iterator it; - for(it = rdsItemList.begin(); it != rdsItemList.end(); ++it) { - Ptr::Ref rdsItem = *it; - if (*rdsItem->getKey() == *key) { - return rdsItem->getValue(); - } - } - - Glib::ustring safeKey = key ? *key : "(null)"; - throw std::invalid_argument("RDS option " + safeKey + "not found."); -} - - -/*------------------------------------------------------------------------------ - * Get the enabled/disabled state of an RDS option. - *----------------------------------------------------------------------------*/ -bool -RdsContainer :: getRdsEnabled(Ptr::Ref key) - throw (std::invalid_argument) -{ - RdsItemListType::const_iterator it; - for(it = rdsItemList.begin(); it != rdsItemList.end(); ++it) { - Ptr::Ref rdsItem = *it; - if (*rdsItem->getKey() == *key) { - return rdsItem->getEnabled(); - } - } - - Glib::ustring safeKey = key ? *key : "(null)"; - throw std::invalid_argument("RDS option " + safeKey + "not found."); -} - - -/*------------------------------------------------------------------------------ - * Convert the object to a string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -RdsContainer :: toString(void) throw () -{ - Ptr::Ref rdsString(new Glib::ustring); - - RdsItemListType::const_iterator it; - for(it = rdsItemList.begin(); it != rdsItemList.end(); ++it) { - Ptr::Ref rdsItem = *it; - rdsString->append(*rdsItem->toString()); - } - - return rdsString; -} - - -/*------------------------------------------------------------------------------ - * Convert the object to XML. - *----------------------------------------------------------------------------*/ -const xmlpp::Element * -RdsContainer :: toXmlElement(void) throw () -{ - if (!touched && xmlDocument) { - return xmlDocument->get_root_node(); - } - - xmlDocument.reset(new xmlpp::Document()); - xmlpp::Element * rootNode = xmlDocument->create_root_node( - configElementName); - RdsItemListType::const_iterator it; - for(it = rdsItemList.begin(); it != rdsItemList.end(); ++it) { - Ptr::Ref rdsItem = *it; - rootNode->import_node(rdsItem->toXmlElement(), true); - } - - touched = false; - return rootNode; -} - diff --git a/src/modules/core/src/RdsContainerTest.cxx b/src/modules/core/src/RdsContainerTest.cxx deleted file mode 100644 index 95002e93f..000000000 --- a/src/modules/core/src/RdsContainerTest.cxx +++ /dev/null @@ -1,144 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - -#include -#include - -#include "RdsContainerTest.h" - - -using namespace LiveSupport::Core; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(RdsContainerTest); - -namespace { - -/** - * The name of the test RDS container config file. - */ -const std::string configFileName = "etc/rdsContainer.xml"; - -} - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -RdsContainerTest :: setUp(void) throw (CPPUNIT_NS::Exception) -{ - std::ifstream ifs; - ifs.open(configFileName.c_str()); - - if (!ifs.is_open() || ifs.bad()) { - ifs.close(); - CPPUNIT_FAIL("could not open RDS container config file " - + configFileName); - } - - rdsContainer.reset(new RdsContainer); - - try { - Ptr::Ref parser(new xmlpp::DomParser()); - parser->parse_stream(ifs); - parser->set_validate(); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - rdsContainer->configure(*root); - - } catch (std::invalid_argument &e) { - ifs.close(); - CPPUNIT_FAIL("semantic error in RDS container configuration file: " - + std::string(e.what())); - } catch (xmlpp::exception &e) { - ifs.close(); - CPPUNIT_FAIL("syntax error in RDS container configuration file: " - + std::string(e.what())); - } - ifs.close(); -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -RdsContainerTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * A simple test. - *----------------------------------------------------------------------------*/ -void -RdsContainerTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref key(new const Glib::ustring("PS")); - - Ptr::Ref value = rdsContainer->getRdsValue(key); - CPPUNIT_ASSERT(value); - CPPUNIT_ASSERT(*value == "BBC Four"); - - bool enabled = rdsContainer->getRdsEnabled(key); - CPPUNIT_ASSERT(enabled); -} - - -/*------------------------------------------------------------------------------ - * Test the toString() method. - *----------------------------------------------------------------------------*/ -void -RdsContainerTest :: toStringTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref string = rdsContainer->toString(); - CPPUNIT_ASSERT(string); - CPPUNIT_ASSERT(*string == "PS=BBC Four\r\n" - "RT=C. Monster - Monsterpiece Theater\r\n"); -} - diff --git a/src/modules/core/src/RdsContainerTest.h b/src/modules/core/src/RdsContainerTest.h deleted file mode 100644 index ca53c3415..000000000 --- a/src/modules/core/src/RdsContainerTest.h +++ /dev/null @@ -1,122 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef RdsContainerTest_h -#define RdsContainerTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" -#include "LiveSupport/Core/BaseTestMethod.h" - -#include "LiveSupport/Core/RdsContainer.h" - - -namespace LiveSupport { -namespace Core { - -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Testing audio playback from the storage. - * - * @see KeyboardShortcutFactory - */ -class RdsContainerTest : public BaseTestMethod -{ - CPPUNIT_TEST_SUITE(RdsContainerTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST(toStringTest); - CPPUNIT_TEST_SUITE_END(); - - private: - - /** - * The RdsContainer object we are testing. - */ - Ptr::Ref rdsContainer; - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the toString() method. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - toStringTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (CPPUNIT_NS::Exception); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // RdsContainerTest_h - diff --git a/src/modules/core/src/RdsItem.cxx b/src/modules/core/src/RdsItem.cxx deleted file mode 100644 index 5469c70a3..000000000 --- a/src/modules/core/src/RdsItem.cxx +++ /dev/null @@ -1,158 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/RdsItem.h" - - -using namespace LiveSupport::Core; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/** - * The name of the config element for this class - */ -const std::string RdsItem::configElementName = "rdsItem"; - -namespace { - -/** - * The name of the "key" attribute. - */ -const std::string keyAttributeName = "key"; - -/** - * The name of the "value" attribute. - */ -const std::string valueAttributeName = "value"; - -/** - * The name of the "enabled" attribute. - */ -const std::string enabledAttributeName = "enabled"; - -} - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create an RDS item object based on an XML element. - *----------------------------------------------------------------------------*/ -void -RdsItem :: configure(const xmlpp::Element & element) - throw (std::invalid_argument) -{ - if (element.get_name() != configElementName) { - throw std::invalid_argument("bad coniguration element " - + element.get_name()); - } - - xmlpp::Attribute * keyAttribute = element.get_attribute( - keyAttributeName); - if (keyAttribute) { - key.reset(new Glib::ustring(keyAttribute->get_value())); - } else { - throw std::invalid_argument("missing " - + keyAttributeName + " attribute"); - } - - xmlpp::Attribute * valueAttribute = element.get_attribute( - valueAttributeName); - if (valueAttribute) { - value.reset(new Glib::ustring(valueAttribute->get_value())); - } else { - throw std::invalid_argument("missing " - + valueAttributeName + " attribute"); - } - - xmlpp::Attribute * enabledAttribute = element.get_attribute( - enabledAttributeName); - if (enabledAttribute) { - Glib::ustring enabledString = enabledAttribute->get_value(); - if (enabledString == "0") { - enabled = false; - } else if (enabledString == "1") { - enabled = true; - } else { - throw std::invalid_argument("bad " - + enabledAttributeName + " attribute"); - } - } else { - throw std::invalid_argument("missing " - + enabledAttributeName + " attribute"); - } -} - - -/*------------------------------------------------------------------------------ - * Convert the object to a string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -RdsItem :: toString(void) throw () -{ - Ptr::Ref rdsString(new Glib::ustring); - - if (enabled) { - rdsString->append(*key); - rdsString->append("="); - rdsString->append(*value); - rdsString->append("\r\n"); - } - - return rdsString; -} - - -/*------------------------------------------------------------------------------ - * Convert the object to XML. - *----------------------------------------------------------------------------*/ -const xmlpp::Element * -RdsItem :: toXmlElement(void) throw () -{ - if (!touched && xmlDocument) { - return xmlDocument->get_root_node(); - } - - xmlDocument.reset(new xmlpp::Document()); - xmlpp::Element * rootNode = xmlDocument->create_root_node( - configElementName); - rootNode->set_attribute(keyAttributeName, *key); - rootNode->set_attribute(valueAttributeName, *value); - rootNode->set_attribute(enabledAttributeName, enabled ? "1" : "0"); - - touched = false; - return rootNode; -} - diff --git a/src/modules/core/src/ScheduleEntry.cxx b/src/modules/core/src/ScheduleEntry.cxx deleted file mode 100644 index b8509ea06..000000000 --- a/src/modules/core/src/ScheduleEntry.cxx +++ /dev/null @@ -1,138 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/ScheduleEntry.h" - -using namespace boost::posix_time; - -using namespace LiveSupport::Core; - - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * The name of the schedule entry element - *----------------------------------------------------------------------------*/ -const std::string ScheduleEntry::scheduleEntryElementName = "scheduleEntry"; - -/*------------------------------------------------------------------------------ - * The name of the id attribute in the schedule entry element - *----------------------------------------------------------------------------*/ -const std::string ScheduleEntry::idAttrName = "id"; - -/*------------------------------------------------------------------------------ - * The name of the playlist attribute in the schedule entry element - *----------------------------------------------------------------------------*/ -const std::string ScheduleEntry::playlistIdAttrName = "playlistId"; - -/*------------------------------------------------------------------------------ - * The name of the startTime attribute in the schedule entry element - *----------------------------------------------------------------------------*/ -const std::string ScheduleEntry::startTimeAttrName = "startTime"; - -/*------------------------------------------------------------------------------ - * The name of the endTime attribute in the schedule entry element - *----------------------------------------------------------------------------*/ -const std::string ScheduleEntry::endTimeAttrName = "endTime"; - -/*------------------------------------------------------------------------------ - * The name of the playlength attribute in the schedule entry element - *----------------------------------------------------------------------------*/ -const std::string ScheduleEntry::playlengthAttrName = "playlength"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Create a schedule entry based on a previously exported DOM element - *----------------------------------------------------------------------------*/ -ScheduleEntry :: ScheduleEntry(xmlpp::Element * element) - throw (std::invalid_argument) -{ - if (element->get_name() != scheduleEntryElementName) { - std::string eMsg = "bad configuration element "; - eMsg += element->get_name(); - throw std::invalid_argument(eMsg); - } - - const xmlpp::Attribute * attribute = 0; - - if (!(attribute = element->get_attribute(idAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - id = UniqueId::fromDecimalString(attribute->get_value()); - - if (!(attribute = element->get_attribute(playlistIdAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - playlistId = UniqueId::fromDecimalString(attribute->get_value().c_str()); - - if (!(attribute = element->get_attribute(startTimeAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - startTime.reset(new ptime(from_iso_string(attribute->get_value()))); - - if (!(attribute = element->get_attribute(endTimeAttrName))) { - std::string eMsg = "missing attribute "; - eMsg += idAttrName; - throw std::invalid_argument(eMsg); - } - endTime.reset(new ptime(from_iso_string(attribute->get_value()))); - - playlength.reset(new time_duration(*endTime - *startTime)); -} - - -/*------------------------------------------------------------------------------ - * Export a schedule entry into a DOM element. - *----------------------------------------------------------------------------*/ -void -ScheduleEntry :: toDom(xmlpp::Element * element) const throw () -{ - xmlpp::Element * node = element->add_child(scheduleEntryElementName); - - node->set_attribute(idAttrName, *(id->toDecimalString())); - node->set_attribute(playlistIdAttrName, *(playlistId->toDecimalString())); - node->set_attribute(startTimeAttrName, to_iso_string(*startTime)); - node->set_attribute(endTimeAttrName, to_iso_string(*endTime)); - node->set_attribute(playlengthAttrName, to_simple_string(*playlength)); -} - diff --git a/src/modules/core/src/ScheduleEntryTest.cxx b/src/modules/core/src/ScheduleEntryTest.cxx deleted file mode 100644 index 08df77430..000000000 --- a/src/modules/core/src/ScheduleEntryTest.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/ScheduleEntry.h" -#include "ScheduleEntryTest.h" - - -using namespace std; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(ScheduleEntryTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -ScheduleEntryTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -ScheduleEntryTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the singleton Hello object is accessible - *----------------------------------------------------------------------------*/ -void -ScheduleEntryTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref id(new UniqueId(1)); - Ptr::Ref playlistId(new UniqueId(2)); - Ptr::Ref startTime(new ptime( - time_from_string("2006-05-10 10:00:00"))); - Ptr::Ref endTime(new ptime( - time_from_string("2006-05-10 11:00:00"))); - - Ptr::Ref se(new ScheduleEntry(id, - playlistId, - startTime, - endTime)); - - xmlpp::Document * document = new xmlpp::Document(); - document->create_root_node("root"); - - se->toDom(document->get_root_node()); - - xmlpp::Node::NodeList::iterator it = document->get_root_node() - ->get_children().begin(); - xmlpp::Node * node = *it; - xmlpp::Element * element = dynamic_cast (node); - Ptr::Ref see(new ScheduleEntry(element)); - - CPPUNIT_ASSERT(*se == *see); -} - diff --git a/src/modules/core/src/ScheduleEntryTest.h b/src/modules/core/src/ScheduleEntryTest.h deleted file mode 100644 index 442443712..000000000 --- a/src/modules/core/src/ScheduleEntryTest.h +++ /dev/null @@ -1,103 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef ScheduleEntryTest_h -#define ScheduleEntryTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include "LiveSupport/Core/ScheduleEntry.h" - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the ScheduleEntry class. - * - * @see ScheduleEntry - */ -class ScheduleEntryTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(ScheduleEntryTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST_SUITE_END(); - - private: - - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // ScheduleEntryTest_h - diff --git a/src/modules/core/src/SearchCriteria.cxx b/src/modules/core/src/SearchCriteria.cxx deleted file mode 100644 index 51020ab9f..000000000 --- a/src/modules/core/src/SearchCriteria.cxx +++ /dev/null @@ -1,270 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/TimeConversion.h" -#include "LiveSupport/Core/SearchCriteria.h" - -using namespace LiveSupport::Core; -using namespace boost::posix_time; -using namespace XmlRpc; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Construct a SearchCriteria object with a single condition. - *----------------------------------------------------------------------------*/ -SearchCriteria :: SearchCriteria(const std::string & type, - const std::string & key, - const std::string & comparisonOperator, - const std::string & value) - throw(std::invalid_argument) - : logicalOperator("and"), limit(0), offset(0) -{ - setType(type); - addCondition(key, comparisonOperator, value); -} - - -/*------------------------------------------------------------------------------ - * Construct a SearchCriteria object from an XmlRpcValue. - *----------------------------------------------------------------------------*/ -SearchCriteria :: SearchCriteria(const XmlRpcValue & xmlRpcValue) - throw(std::invalid_argument) -{ - // make a non-const copy, because XmlRpcValue::operator[](const char *) - // does not work on const objects - XmlRpcValue value(xmlRpcValue); - - if (value.hasMember("filetype") - && value["filetype"].getType() == XmlRpcValue::TypeString) { - type = std::string(value["filetype"]); - } else { - throw std::invalid_argument("missing file type in search criteria"); - } - - if (value.hasMember("operator") - && value["operator"].getType() == XmlRpcValue::TypeString) { - logicalOperator = std::string(value["operator"]); - } else { - logicalOperator = std::string("and"); - } - - if (value.hasMember("limit") - && value["limit"].getType() == XmlRpcValue::TypeInt) { - limit = value["limit"]; - } - - if (value.hasMember("offset") - && value["offset"].getType() == XmlRpcValue::TypeInt) { - offset = value["offset"]; - } - - if (!value.hasMember("conditions") - || value["conditions"].getType() != XmlRpcValue::TypeArray) { - throw std::invalid_argument("missing conditions in search criteria"); - } - - for (int i = 0; i < value["conditions"].size(); ++i) { - addCondition(value["conditions"][i]); - } -} - - -/*------------------------------------------------------------------------------ - * Add a search condition. - *----------------------------------------------------------------------------*/ -void -SearchCriteria :: addCondition(const std::string & key, - const std::string & comparisonOperator, - const std::string & value) - throw(std::invalid_argument) -{ - std::string lowerCaseOp = lowerCase(comparisonOperator); - - if (lowerCaseOp == "=" - || lowerCaseOp == "partial" || lowerCaseOp == "prefix" - || lowerCaseOp == "<" || lowerCaseOp == "<=" - || lowerCaseOp == ">" || lowerCaseOp == ">=") { - SearchConditionType condition(key, lowerCaseOp, value); - searchConditions.push_back(condition); - } else { - throw std::invalid_argument("bad comparison operator argument"); - } -} - - -/*------------------------------------------------------------------------------ - * Add a search condition. - *----------------------------------------------------------------------------*/ -void -SearchCriteria :: addCondition(const XmlRpcValue & xmlRpcValue) - throw(std::invalid_argument) -{ - // make a non-const copy, because XmlRpcValue::operator[](const char *) - // does not work on const objects - XmlRpcValue value(xmlRpcValue); - - if (!value.hasMember("cat") - || value["cat"].getType() != XmlRpcValue::TypeString) { - throw std::invalid_argument("missing metadata name in search criteria"); - } - - if (!value.hasMember("op") - || value["op"].getType() != XmlRpcValue::TypeString) { - throw std::invalid_argument("missing operator name in search criteria"); - } - - if (!value.hasMember("val") - || value["val"].getType() != XmlRpcValue::TypeString) { - throw std::invalid_argument("missing value in search criteria"); - } - - addCondition(std::string(value["cat"]), - std::string(value["op"]), - std::string(value["val"])); -} - - -/*------------------------------------------------------------------------------ - * Add a search condition specifying the mtime (modified-at time). - *----------------------------------------------------------------------------*/ -void -SearchCriteria :: addMtimeCondition(const std::string & comparisonOperator, - Ptr::Ref value) - throw(std::invalid_argument) -{ - std::string lowerCaseOp = lowerCase(comparisonOperator); - - if (lowerCaseOp == "=" - || lowerCaseOp == "partial" || lowerCaseOp == "prefix" - || lowerCaseOp == "<" || lowerCaseOp == "<=" - || lowerCaseOp == ">" || lowerCaseOp == ">=") { - mtimeComparisonOperator = lowerCaseOp; - mtimeValue = value; - } else { - throw std::invalid_argument("bad comparison operator argument"); - } -} - - -/*------------------------------------------------------------------------------ - * Convert to an XmlRpcValue. - *----------------------------------------------------------------------------*/ -SearchCriteria :: operator XmlRpcValue() const - throw() -{ - XmlRpcValue returnValue; - - returnValue["filetype"] = type; - if (searchConditions.size() != 1) { - returnValue["operator"] = logicalOperator; - } - - XmlRpcValue conditionList; - conditionList.setSize(searchConditions.size()); - SearchConditionListType::const_iterator it, end; - it = searchConditions.begin(); - end = searchConditions.end(); - for (int i = 0; it != end; ++i, ++it) { - XmlRpcValue condition; - condition["cat"] = it->key; - condition["op"] = it->comparisonOperator; - condition["val"] = it->value; - conditionList[i] = condition; - } - - if (mtimeValue) { - int i = conditionList.size(); - struct tm mtimeStructTm; - TimeConversion::ptimeToTm(mtimeValue, mtimeStructTm); - - XmlRpcValue condition; - condition["cat"] = "ls:mtime"; - condition["op"] = mtimeComparisonOperator; - condition["val"] = XmlRpcValue(&mtimeStructTm); - conditionList[i] = condition; - } - - returnValue["conditions"] = conditionList; - - if (limit) { - returnValue["limit"] = limit; - } - - if (offset) { - returnValue["offset"] = offset; - } - - return returnValue; -} - - -/*------------------------------------------------------------------------------ - * Check two SearchCriteria objects for equality. - *----------------------------------------------------------------------------*/ -bool -SearchCriteria :: operator ==(const SearchCriteria & other) const - throw() -{ - if (type != other.type - || limit != other.limit - || offset != other.offset - || searchConditions.size() != other.searchConditions.size()) { - return false; - } - - if (searchConditions.size() != 1 - && logicalOperator != other.logicalOperator) { - return false; - } - - SearchConditionListType::const_iterator it, otherIt; - it = searchConditions.begin(); - otherIt = other.searchConditions.begin(); - - for ( ; it != searchConditions.end(); ++it, ++otherIt) { - if (it->key != otherIt->key - || it->comparisonOperator != otherIt->comparisonOperator - || it->value != otherIt->value) { - return false; - } - } - - return true; -} - diff --git a/src/modules/core/src/SearchCriteriaTest.cxx b/src/modules/core/src/SearchCriteriaTest.cxx deleted file mode 100644 index 1814de1e2..000000000 --- a/src/modules/core/src/SearchCriteriaTest.cxx +++ /dev/null @@ -1,189 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#include - -#include "LiveSupport/Core/SearchCriteria.h" -#include "SearchCriteriaTest.h" - -using namespace LiveSupport::Core; - - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(SearchCriteriaTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -SearchCriteriaTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -SearchCriteriaTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if we can do some simple operations - *----------------------------------------------------------------------------*/ -void -SearchCriteriaTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - XmlRpc::XmlRpcValue xmlRpcValue; - - try { - SearchCriteria firstCriteria; - xmlRpcValue = firstCriteria; - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - CPPUNIT_ASSERT(xmlRpcValue.hasMember("filetype")); - CPPUNIT_ASSERT(xmlRpcValue["filetype"] == "all"); - CPPUNIT_ASSERT(xmlRpcValue.hasMember("conditions")); - CPPUNIT_ASSERT(xmlRpcValue["conditions"].getType() - == XmlRpc::XmlRpcValue::TypeArray); - CPPUNIT_ASSERT(xmlRpcValue["conditions"].size() == 0); - - try { - SearchCriteria secondCriteria("playlist", "Or"); - secondCriteria.setLimit(50); - secondCriteria.setOffset(100); - secondCriteria.addCondition("dc:title", "PREFIX", "My "); - secondCriteria.addCondition("DcTerms:Extent", "<", "180"); - xmlRpcValue = secondCriteria; - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - CPPUNIT_ASSERT(xmlRpcValue.hasMember("filetype")); - CPPUNIT_ASSERT(xmlRpcValue["filetype"] == "playlist"); - CPPUNIT_ASSERT(xmlRpcValue.hasMember("operator")); - CPPUNIT_ASSERT(xmlRpcValue["operator"] == "or"); - CPPUNIT_ASSERT(xmlRpcValue.hasMember("conditions")); - XmlRpc::XmlRpcValue conditions = xmlRpcValue["conditions"]; - CPPUNIT_ASSERT(conditions.getType() == XmlRpc::XmlRpcValue::TypeArray); - CPPUNIT_ASSERT(conditions.size() == 2); - - XmlRpc::XmlRpcValue condition0 = conditions[0]; - CPPUNIT_ASSERT(condition0.hasMember("cat")); - CPPUNIT_ASSERT(condition0["cat"] == "dc:title"); - CPPUNIT_ASSERT(condition0.hasMember("op")); - CPPUNIT_ASSERT(condition0["op"] == "prefix"); - CPPUNIT_ASSERT(condition0.hasMember("val")); - CPPUNIT_ASSERT(condition0["val"] == "My "); - - XmlRpc::XmlRpcValue condition1 = conditions[1]; - CPPUNIT_ASSERT(condition1.hasMember("cat")); - CPPUNIT_ASSERT(condition1["cat"] == "DcTerms:Extent"); - CPPUNIT_ASSERT(condition1.hasMember("op")); - CPPUNIT_ASSERT(condition1["op"] == "<"); - CPPUNIT_ASSERT(condition1.hasMember("val")); - CPPUNIT_ASSERT(condition1["val"] == "180"); - - CPPUNIT_ASSERT(xmlRpcValue.hasMember("limit")); - CPPUNIT_ASSERT(xmlRpcValue["limit"].getType() - == XmlRpc::XmlRpcValue::TypeInt); - CPPUNIT_ASSERT(int(xmlRpcValue["limit"]) == 50); - CPPUNIT_ASSERT(xmlRpcValue.hasMember("offset")); - CPPUNIT_ASSERT(xmlRpcValue["offset"].getType() - == XmlRpc::XmlRpcValue::TypeInt); - CPPUNIT_ASSERT(int(xmlRpcValue["offset"]) == 100); - - try { - SearchCriteria thirdCriteria("all", "dc:creator", "partial", "X"); - xmlRpcValue = thirdCriteria; - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - CPPUNIT_ASSERT(xmlRpcValue.hasMember("filetype")); - CPPUNIT_ASSERT(xmlRpcValue["filetype"] == "all"); - CPPUNIT_ASSERT(xmlRpcValue.hasMember("conditions")); - conditions = xmlRpcValue["conditions"]; - CPPUNIT_ASSERT(conditions.getType() == XmlRpc::XmlRpcValue::TypeArray); - CPPUNIT_ASSERT(conditions.size() == 1); - - condition0 = conditions[0]; - CPPUNIT_ASSERT(condition0.hasMember("cat")); - CPPUNIT_ASSERT(condition0["cat"] == "dc:creator"); - CPPUNIT_ASSERT(condition0.hasMember("op")); - CPPUNIT_ASSERT(condition0["op"] == "partial"); - CPPUNIT_ASSERT(condition0.hasMember("val")); - CPPUNIT_ASSERT(condition0["val"] == "X"); -} - - -/*------------------------------------------------------------------------------ - * Test the conversion to/from an XmlRpcValue. - *----------------------------------------------------------------------------*/ -void -SearchCriteriaTest :: marshalingTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref criteria; - CPPUNIT_ASSERT_NO_THROW( - criteria.reset(new SearchCriteria("playlist", "Or")); - criteria->setLimit(50); - criteria->setOffset(100); - criteria->addCondition("dc:title", "PREFIX", "My "); - criteria->addCondition("DcTerms:Extent", "<", "180"); - ); - - XmlRpc::XmlRpcValue xmlRpcValue; - CPPUNIT_ASSERT_NO_THROW( - xmlRpcValue = *criteria; - ); - - Ptr::Ref copyCriteria; - CPPUNIT_ASSERT_NO_THROW( - copyCriteria.reset(new SearchCriteria(xmlRpcValue)); - ); - - CPPUNIT_ASSERT(*criteria == *copyCriteria); - - XmlRpc::XmlRpcValue copyXmlRpcValue; - CPPUNIT_ASSERT_NO_THROW( - copyXmlRpcValue = *copyCriteria; - ); - - CPPUNIT_ASSERT(xmlRpcValue == copyXmlRpcValue); -} - diff --git a/src/modules/core/src/SearchCriteriaTest.h b/src/modules/core/src/SearchCriteriaTest.h deleted file mode 100644 index 9164015a6..000000000 --- a/src/modules/core/src/SearchCriteriaTest.h +++ /dev/null @@ -1,108 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef SearchCriteriaTest_h -#define SearchCriteriaTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the SearchCriteria class. - * - * @see SearchCriteria - */ -class SearchCriteriaTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(SearchCriteriaTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST(marshalingTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the conversion to/from an XmlRpcValue. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - marshalingTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // SearchCriteriaTest_h - diff --git a/src/modules/core/src/TestRunnable.cxx b/src/modules/core/src/TestRunnable.cxx deleted file mode 100644 index a4b013266..000000000 --- a/src/modules/core/src/TestRunnable.cxx +++ /dev/null @@ -1,75 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/TimeConversion.h" - -#include "TestRunnable.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -TestRunnable :: TestRunnable(Ptr::Ref loopTime) - throw () -{ - shouldRun = true; - state = created; - this->loopTime = loopTime; -} - - -/*------------------------------------------------------------------------------ - * The main execution body of the thread. - *----------------------------------------------------------------------------*/ -void -TestRunnable :: run(void) throw () -{ - state = running; - - while (shouldRun) { - // don't do anything in the main loop - TimeConversion::sleep(loopTime); - } - - state = stopped; -} - diff --git a/src/modules/core/src/TestRunnable.h b/src/modules/core/src/TestRunnable.h deleted file mode 100644 index bf7188432..000000000 --- a/src/modules/core/src/TestRunnable.h +++ /dev/null @@ -1,155 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef TestRunnable_h -#define TestRunnable_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/RunnableInterface.h" - - -namespace LiveSupport { -namespace Core { - - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A sample Runnable object, for testing purposes. - */ -class TestRunnable : public virtual RunnableInterface -{ - public: - /** - * An enum signaling the states of the Runnable object. - */ - typedef enum { created, running, stopped } State; - - private: - /** - * The time interval the run() method will check if stop() - * has been called meanwhile. - */ - Ptr::Ref loopTime; - - /** - * Flag that marks if the main execution body should be - * running. - */ - bool shouldRun; - - /** - * The state of the object. - */ - State state; - - /** - * Default constructor. - */ - TestRunnable(void) throw () - { - } - - - public: - /** - * Constructor. - * - * @param loopTime the time at which the run() method checks - * if it still should run. - */ - TestRunnable(Ptr::Ref loopTime) throw (); - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~TestRunnable(void) throw () - { - } - - /** - * The main execution loop for the thread. - */ - virtual void - run(void) throw (); - - /** - * Signal the thread to stop, gracefully. - * This is just a call to signal the execution to stop, eventually. - */ - virtual void - stop(void) throw () - { - shouldRun = false; - } - - /** - * Send a signal to this object. - * This currently simply does nothing. - * - * @param userData the user data for the signal. - */ - virtual void - signal(int userData) throw () - { - } - - /** - * Get the state of the object. - */ - virtual State - getState(void) const throw () - { - return state; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - - -#endif // TestRunnable_h - diff --git a/src/modules/core/src/TestRunner.cxx b/src/modules/core/src/TestRunner.cxx deleted file mode 100644 index 8ce1c29bb..000000000 --- a/src/modules/core/src/TestRunner.cxx +++ /dev/null @@ -1,275 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - -#if HAVE_GETOPT_H -#include -#else -#error "Need getopt.h" -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/** - * Our copyright notice, should be at most 80 columns - */ -static const char copyrightNotice[] = - "Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL"; - -/** - * String describing the short options. - */ -static const char options[] = "ho:s:v"; - -/** - * Structure describing the long options - */ -static const struct option longOptions[] = { - { "help", no_argument, 0, 'h' }, - { "output", required_argument, 0, 'o' }, - { "stylesheet", required_argument, 0, 's' }, - { "version", no_argument, 0, 'v' }, - { 0, 0, 0, 0 } -}; - -/** - * The encoding to use for the output file. - */ -static const std::string encoding = "utf-8"; - -/** - * The output XML file name. - */ -static Ptr::Ref xmlOutFileName; - -/** - * The XSLT attached to the output file. - */ -static Ptr::Ref xsltFileName; - - -/* =============================================== local function prototypes */ - -/** - * Print program version. - * - * @param os the std::ostream to print to. - */ -static void -printVersion ( std::ostream & os ); - -/** - * Print program usage information. - * - * @param invocation the command line command used to invoke this program. - * @param os the std::ostream to print to. - */ -static void -printUsage ( const char invocation[], - std::ostream & os ); - -/** - * Process command line arguments. - * - * @param argc the number of arguments. - * @param argv the arguments themselves. - * @return true of all went well, false in case the program should exit - * after this call. - */ -static bool -processArguments(int argc, char *argv[]); - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Run all tests - *----------------------------------------------------------------------------*/ -int -main( int argc, - char * argv[] ) throw () -{ - if (!processArguments(argc, argv)) { - return 0; - } - - // Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // Add a listener that colllects test result - CPPUNIT_NS::TestResultCollector result; - controller.addListener( &result ); - - // Add a listener that print dots as test run. - CPPUNIT_NS::BriefTestProgressListener progress; - controller.addListener( &progress ); - - // Add the top suite to the test runner - CPPUNIT_NS::TestRunner runner; - runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); - runner.run( controller ); - - // Print test in a compiler compatible format. - CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); - outputter.setLocationFormat("%p:%l:"); - outputter.write(); - - // also generate an XML document as an output - std::ofstream xmlOutFile(xmlOutFileName->c_str()); - CPPUNIT_NS::XmlOutputter xmlOutputter(&result, xmlOutFile, encoding); - xmlOutputter.setStandalone(false); - if (xsltFileName) { - xmlOutputter.setStyleSheet(*xsltFileName); - } - xmlOutputter.write(); - xmlOutFile.flush(); - xmlOutFile.close(); - - return result.wasSuccessful() ? 0 : 1; -} - - -/*------------------------------------------------------------------------------ - * Process command line arguments. - *----------------------------------------------------------------------------*/ -static bool -processArguments(int argc, char *argv[]) -{ - int i; - - while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) { - switch (i) { - case 'h': - printUsage(argv[0], std::cout); - return false; - - case 'o': - xmlOutFileName.reset(new std::string(optarg)); - break; - - case 's': - xsltFileName.reset(new std::string(optarg)); - break; - - case 'v': - printVersion(std::cout); - return false; - - default: - printUsage(argv[0], std::cout); - return false; - } - } - - if (optind < argc) { - std::cerr << "error processing command line arguments" << std::endl; - printUsage(argv[0], std::cout); - return false; - } - - if (!xmlOutFileName) { - std::cerr << "mandatory option output file name not specified" - << std::endl; - printUsage(argv[0], std::cout); - return false; - } - - std::cerr << "writing output to '" << *xmlOutFileName << '\'' << std::endl; - if (xsltFileName) { - std::cerr << "using XSLT file '" << *xsltFileName << '\'' << std::endl; - } - - return true; -} - - -/*------------------------------------------------------------------------------ - * Print program version. - *----------------------------------------------------------------------------*/ -static void -printVersion ( std::ostream & os ) -{ - os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl - << "Unit test runner" << std::endl - << copyrightNotice << std::endl; -} - - -/*------------------------------------------------------------------------------ - * Print program usage. - *----------------------------------------------------------------------------*/ -static void -printUsage ( const char invocation[], - std::ostream & os ) -{ - os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl - << "Unit test runner" << std::endl - << std::endl - << "Usage: " << invocation << " [OPTION]" - << std::endl - << " mandatory options:" << std::endl - << " -o, --output=file.name write test results into this XML file" - << std::endl - << " optional options:" << std::endl - << " -s, --stylesheet specify this XSLT for the output file" - << std::endl - << " this is either an absolute URI, or a" - << std::endl - << " relative path for the output document" - << std::endl - << " -h, --help display this help and exit" << std::endl - << " -v, --version display version information and exit" - << std::endl - << std::endl - << "Report bugs to " << PACKAGE_BUGREPORT << std::endl; -} - diff --git a/src/modules/core/src/Thread.cxx b/src/modules/core/src/Thread.cxx deleted file mode 100644 index 1fbb67ad3..000000000 --- a/src/modules/core/src/Thread.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_UNISTD_H -#include -#else -#error need unistd.h -#endif - - -#include "LiveSupport/Core/Thread.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -Thread :: Thread(Ptr::Ref runnable) throw () -{ - this->runnable = runnable; -} - - -/*------------------------------------------------------------------------------ - * The POSIX thread function for this thread. - *----------------------------------------------------------------------------*/ -void * -Thread :: posixThreadFunction(void * thread) throw () -{ - Thread * pThread = (Thread *) thread; - - pThread->runnable->run(); - - return 0; -} - - -/*------------------------------------------------------------------------------ - * Start the thread. - *----------------------------------------------------------------------------*/ -void -Thread :: start(void) throw (std::exception) -{ - int ret; - pthread_attr_t attr; - - pthread_attr_init(&attr); - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); - ret = pthread_create(&thread, &attr, posixThreadFunction, this); - pthread_attr_destroy(&attr); - - yield(); - - if (ret) { - // TODO: signal return code - throw std::exception(); - } -} - - -/*------------------------------------------------------------------------------ - * Join the thread. - *----------------------------------------------------------------------------*/ -void -Thread :: join(void) throw () -{ - int ret; - if ((ret = pthread_join(thread, 0))) { - // TODO: signal return code - } -} - diff --git a/src/modules/core/src/ThreadTest.cxx b/src/modules/core/src/ThreadTest.cxx deleted file mode 100644 index 5f6d8038f..000000000 --- a/src/modules/core/src/ThreadTest.cxx +++ /dev/null @@ -1,122 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include - -#include "LiveSupport/Core/TimeConversion.h" -#include "LiveSupport/Core/Thread.h" -#include "TestRunnable.h" -#include "ThreadTest.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(ThreadTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -ThreadTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -ThreadTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * A simple thread test. - *----------------------------------------------------------------------------*/ -void -ThreadTest :: simpleTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref cycle(new time_duration(seconds(1))); - Ptr::Ref runnable(new TestRunnable(cycle)); - Ptr::Ref thread(new Thread(runnable)); - Ptr::Ref sleepTime(new time_duration(seconds(1))); - - CPPUNIT_ASSERT(runnable->getState() == TestRunnable::created); - thread->start(); - Thread::yield(); - TimeConversion::sleep(sleepTime); - CPPUNIT_ASSERT(runnable->getState() == TestRunnable::running); - TimeConversion::sleep(sleepTime); - CPPUNIT_ASSERT(runnable->getState() == TestRunnable::running); - thread->stop(); - TimeConversion::sleep(sleepTime); - CPPUNIT_ASSERT(runnable->getState() == TestRunnable::stopped); - thread->join(); -} - - -/*------------------------------------------------------------------------------ - * A test to see if a thread respoding slowly for a stop() - * call is joined correctly. - *----------------------------------------------------------------------------*/ -void -ThreadTest :: slowThreadTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref cycle(new time_duration(seconds(10))); - Ptr::Ref runnable(new TestRunnable(cycle)); - Ptr::Ref thread(new Thread(runnable)); - Ptr::Ref sleepTime(new time_duration(seconds(1))); - - CPPUNIT_ASSERT(runnable->getState() == TestRunnable::created); - thread->start(); - Thread::yield(); - CPPUNIT_ASSERT(runnable->getState() == TestRunnable::running); - TimeConversion::sleep(sleepTime); - CPPUNIT_ASSERT(runnable->getState() == TestRunnable::running); - thread->stop(); - TimeConversion::sleep(sleepTime); - thread->join(); - CPPUNIT_ASSERT(runnable->getState() == TestRunnable::stopped); -} - diff --git a/src/modules/core/src/ThreadTest.h b/src/modules/core/src/ThreadTest.h deleted file mode 100644 index f42c42e54..000000000 --- a/src/modules/core/src/ThreadTest.h +++ /dev/null @@ -1,108 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef ThreadTest_h -#define ThreadTest_H - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the Thread class. - * - * @see Thread - */ -class ThreadTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(ThreadTest); - CPPUNIT_TEST(simpleTest); - CPPUNIT_TEST(slowThreadTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple thread test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - simpleTest(void) throw (CPPUNIT_NS::Exception); - - /** - * A test to see if a thread respoding slowly for a stop() - * call is joined correctly. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - slowThreadTest(void) throw (CPPUNIT_NS::Exception); - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // ThreadTest_h - diff --git a/src/modules/core/src/TimeConversion.cxx b/src/modules/core/src/TimeConversion.cxx deleted file mode 100644 index 9db4d4bb7..000000000 --- a/src/modules/core/src/TimeConversion.cxx +++ /dev/null @@ -1,408 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/TimeConversion.h" - - -using namespace boost::posix_time; -using namespace boost::gregorian; - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/** - * The number of digits used for fractional seconds in time durations. - */ -static const int numberOfDigitsPrecision = 6; - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Convert a struct timeval to a boost::ptime - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: timevalToPtime(const struct timeval *timeval) - throw (std::out_of_range) -{ - // don't convert through the boost::posix_time::from_time_t() function - // as probably because of timezone settings it ruins the actual value - struct tm tm; - localtime_r(&timeval->tv_sec, &tm); - Ptr::Ref time(new ptime(date(1900 + tm.tm_year, - 1 + tm.tm_mon, - tm.tm_mday), - time_duration(tm.tm_hour, - tm.tm_min, - tm.tm_sec) - + microseconds(timeval->tv_usec))); - - return time; -} - - -/*------------------------------------------------------------------------------ - * Convert a struct tm to a boost::ptime - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: tmToPtime(const struct tm *time) - throw (std::out_of_range) -{ - // don't convert through the boost::posix_time::from_time_t() function - // as probably because of timezone settings it ruins the actual value - Ptr::Ref pTime(new ptime(date(1900 + time->tm_year, - 1 + time->tm_mon, - time->tm_mday), - time_duration(time->tm_hour, - time->tm_min, - time->tm_sec))); - - return pTime; -} - - -/*------------------------------------------------------------------------------ - * Convert a boost::ptime to a struct tm - *----------------------------------------------------------------------------*/ -void -TimeConversion :: ptimeToTm(Ptr::Ref convertFrom, - struct tm & convertTo) - throw () -{ - date date = convertFrom->date(); - time_duration time = convertFrom->time_of_day(); - - convertTo.tm_year = date.year() - 1900; - convertTo.tm_mon = date.month() - 1; - convertTo.tm_mday = date.day(); - convertTo.tm_hour = time.hours(); - convertTo.tm_min = time.minutes(); - convertTo.tm_sec = time.seconds(); -} - - -/*------------------------------------------------------------------------------ - * Return the current time. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: now(void) - throw () -{ - struct timeval timeval; - - // TODO: check for -1 return value, to see if there are errors - gettimeofday(&timeval, 0); - return timevalToPtime(&timeval); -} - - -/*------------------------------------------------------------------------------ - * Return the current time, as a string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: nowString(void) - throw () -{ - ptime now = second_clock::local_time(); - Ptr::Ref timeString(new std::string(to_simple_string(now))); - - return timeString; -} - - -/*------------------------------------------------------------------------------ - * Sleep for the specified duration. - *----------------------------------------------------------------------------*/ -void -TimeConversion :: sleep(Ptr::Ref duration) - throw () -{ - int ret; - struct timespec tv; - - tv.tv_sec = duration->total_seconds(); - tv.tv_nsec = duration->fractional_seconds(); - - // if fractional digits is in microseconds, convert it to nanoseconds - if (time_duration::num_fractional_digits() == 6) { - tv.tv_nsec *= 1000L; - } - - if ((ret = nanosleep(&tv, 0))) { - // TODO: signal error - } -} - - -/*------------------------------------------------------------------------------ - * Convert a time_duration to a format used in SMILs. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: timeDurationToSmilString( - Ptr::Ref duration) - throw () -{ - std::stringstream stringStream; - stringStream << std::dec - << duration->total_seconds(); - - int microseconds = duration->fractional_seconds(); - stringStream << "." - << std::setw(3) - << std::setfill('0') - << (microseconds + 500) / 1000 - << 's'; - Ptr::Ref result(new std::string(stringStream.str())); - return result; -} - - -/*------------------------------------------------------------------------------ - * Convert a time_duration to a rounded format used on the screen. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: timeDurationToHhMmSsString( - Ptr::Ref duration) - throw () -{ - Ptr::Ref roundedDuration = roundToNearestSecond( - duration); - std::stringstream stringStream; - stringStream << std::dec - << std::setw(2) - << std::setfill('0') - << roundedDuration->hours() - << ":" - << std::setw(2) - << std::setfill('0') - << roundedDuration->minutes() - << ":" - << std::setw(2) - << std::setfill('0') - << roundedDuration->seconds(); - - Ptr::Ref result(new std::string(stringStream.str())); - return result; -} - - -/*------------------------------------------------------------------------------ - * Convert a time_duration to a format used for fade info. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: timeDurationToShortString( - Ptr::Ref duration) - throw () -{ - std::stringstream stringStream; - - if (duration->hours()) { - stringStream << duration->hours() - << ":" - << std::setw(2) - << std::setfill('0') - << duration->minutes() - << ":" - << std::setw(2) - << std::setfill('0'); - - } else if (duration->minutes()) { - stringStream << duration->minutes() - << ":" - << std::setw(2) - << std::setfill('0'); - } - - stringStream << duration->seconds(); - - std::stringstream fractionsStream; - fractionsStream << std::setw(getNumberOfDigitsPrecision()) - << std::setfill('0') - << duration->fractional_seconds(); - std::string fractionsString(fractionsStream.str()); - unsigned int lastNonZero = fractionsString.find_last_not_of('0'); - if (lastNonZero != std::string::npos) { - stringStream << "." - << fractionsString.substr(0, lastNonZero+1); - } - - Ptr::Ref result(new std::string(stringStream.str())); - return result; -} - - -/*------------------------------------------------------------------------------ - * Parse a string to a time_duration. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: parseTimeDuration(Ptr::Ref durationString) - throw () -{ - int micros = 0; - int seconds = 0; - int minutes = 0; - int hours = 0; - - Ptr::Ref temp(new std::string(*durationString)); - - if (temp->length() > 0) { - Ptr::Ref secondsString = nextNumberFromEnd(temp, ':'); - Ptr::Ref fractionsString = nextNumberFromStart( - secondsString, '.'); - if (fractionsString->length() > 0) { - std::stringstream fractionsStream; - fractionsStream << std::left - << std::setw( - TimeConversion::getNumberOfDigitsPrecision() ) - << std::setfill('0') - << *fractionsString; - fractionsStream >> micros; - } - if (secondsString->length() > 0) { - std::stringstream secondsStream(*secondsString); - secondsStream >> seconds; - } - } - - if (temp->length() > 0) { - Ptr::Ref minutesString = nextNumberFromEnd(temp, ':'); - std::stringstream minutesStream(*minutesString); - minutesStream >> minutes; - } - - if (temp->length() > 0) { - std::stringstream hoursStream(*temp); - hoursStream >> hours; - } - - Ptr::Ref result(new time_duration( - hours, minutes, seconds, micros )); - return result; -} - - -/*------------------------------------------------------------------------------ - * Parse a time string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: nextNumberFromEnd(Ptr::Ref timeString, - char separator) - throw () -{ - Ptr::Ref result; - unsigned int pos = timeString->find_last_of(separator); - - if (pos != std::string::npos) { - if (pos != timeString->length()-1) { - result.reset(new std::string(*timeString, pos+1)); - } else { - result.reset(new std::string); - } - *timeString = timeString->substr(0, pos); - } else { - result.reset(new std::string(*timeString)); - *timeString = std::string(""); - } - - return result; -} - - -/*------------------------------------------------------------------------------ - * Parse a decimal string. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: nextNumberFromStart(Ptr::Ref timeString, - char separator) - throw () -{ - Ptr::Ref result; - unsigned int pos = timeString->find(separator); - - if (pos != std::string::npos) { - if (pos != timeString->length()-1) { - result.reset(new std::string(*timeString, pos+1)); - } else { - result.reset(new std::string); - } - *timeString = timeString->substr(0, pos); - } else { - result.reset(new std::string("")); - } - - return result; -} - - -/*------------------------------------------------------------------------------ - * Get the number of digits used for fractional seconds in time durations. - *----------------------------------------------------------------------------*/ -int -TimeConversion :: getNumberOfDigitsPrecision(void) throw () -{ - return numberOfDigitsPrecision; -} - - -/*------------------------------------------------------------------------------ - * Round the time duration to the nearest second. - *----------------------------------------------------------------------------*/ -Ptr::Ref -TimeConversion :: roundToNearestSecond(Ptr::Ref duration) - throw () -{ - int hours = duration->hours(); - int minutes = duration->minutes(); - int seconds = duration->seconds(); - - if (duration->fractional_seconds() >= 500000) { - ++seconds; - } - if (seconds == 60) { - seconds = 0; - ++minutes; - } - if (minutes == 60) { - minutes = 0; - ++hours; - } - - Ptr::Ref roundedDuration(new time_duration( - hours, minutes, seconds, 0)); - return roundedDuration; -} - diff --git a/src/modules/core/src/TimeConversionTest.cxx b/src/modules/core/src/TimeConversionTest.cxx deleted file mode 100644 index 74a46a35d..000000000 --- a/src/modules/core/src/TimeConversionTest.cxx +++ /dev/null @@ -1,300 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include -#include - -#include "LiveSupport/Core/TimeConversion.h" -#include "TimeConversionTest.h" - - -using namespace boost::posix_time; - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(TimeConversionTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test the timevalToPtime function - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: timevalToPtimeTest(void) - throw (CPPUNIT_NS::Exception) -{ - struct tm tm; - time_t time; - struct timeval timeval; - Ptr::Ref pTime; - - // first create a time_t with the time for 2004-11-04 12:58:30 - tm.tm_year = 104; // number of years since 1900, 104 means 2004 - tm.tm_mon = 10; // number of months since January, 10 means November - tm.tm_mday = 4; - tm.tm_hour = 12; - tm.tm_min = 58; - tm.tm_sec = 30; - tm.tm_isdst = 0; - time = mktime(&tm); - - // now fill the timeval with timet, and 1234 useconds - timeval.tv_sec = time; - timeval.tv_usec = 1234; - - // and now convert, and see if it is correct - pTime = TimeConversion::timevalToPtime(&timeval); - CPPUNIT_ASSERT(pTime->date().year() == 2004); - CPPUNIT_ASSERT(pTime->date().month() == 11); - CPPUNIT_ASSERT(pTime->date().day() == 4); - CPPUNIT_ASSERT(pTime->time_of_day().hours() == 12); - CPPUNIT_ASSERT(pTime->time_of_day().minutes() == 58); - CPPUNIT_ASSERT(pTime->time_of_day().seconds() == 30); - CPPUNIT_ASSERT((pTime->time_of_day().total_microseconds() - - ((uint64_t) (pTime->time_of_day().total_seconds()) * 1000000UL)) - == 1234); -} - - -/*------------------------------------------------------------------------------ - * Test the tmToPtime function - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: tmToPtimeTest(void) - throw (CPPUNIT_NS::Exception) -{ - struct tm tm; - Ptr::Ref pTime; - - // first create a time_t with the time for 2004-11-04 12:58:30 - tm.tm_year = 104; // number of years since 1900, 104 means 2004 - tm.tm_mon = 10; // number of months since January, 10 means November - tm.tm_mday = 4; - tm.tm_hour = 12; - tm.tm_min = 58; - tm.tm_sec = 30; - tm.tm_isdst = 0; - - // and now convert, and see if it is correct - pTime = TimeConversion::tmToPtime(&tm); - CPPUNIT_ASSERT(pTime->date().year() == 2004); - CPPUNIT_ASSERT(pTime->date().month() == 11); - CPPUNIT_ASSERT(pTime->date().day() == 4); - CPPUNIT_ASSERT(pTime->time_of_day().hours() == 12); - CPPUNIT_ASSERT(pTime->time_of_day().minutes() == 58); - CPPUNIT_ASSERT(pTime->time_of_day().seconds() == 30); -} - - -/*------------------------------------------------------------------------------ - * Test the ptimeToTm function - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: ptimeToTmTest(void) - throw (CPPUNIT_NS::Exception) -{ - struct tm tm; - Ptr::Ref pTime(new ptime(time_from_string("1770-12-17 10:20:30"))); - - TimeConversion::ptimeToTm(pTime, tm); - CPPUNIT_ASSERT(tm.tm_year + 1900 == 1770); - CPPUNIT_ASSERT(tm.tm_mon + 1 == 12); - CPPUNIT_ASSERT(tm.tm_mday == 17); - CPPUNIT_ASSERT(tm.tm_hour == 10); - CPPUNIT_ASSERT(tm.tm_min == 20); - CPPUNIT_ASSERT(tm.tm_sec == 30); -} - - -/*------------------------------------------------------------------------------ - * Test the now function - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: nowTest(void) - throw (CPPUNIT_NS::Exception) -{ - struct tm tm; - time_t tTime; - Ptr::Ref pTime; - - tTime = time(0); - pTime = TimeConversion::now(); - - localtime_r(&tTime, &tm); - - // the below checking is a bit phone, what if the two times actually - // spill over the second barrier (or, for that instance, the year - // barrier?) - CPPUNIT_ASSERT(pTime->date().year() == (1900 + tm.tm_year)); - CPPUNIT_ASSERT(pTime->date().month() == (1 + tm.tm_mon)); - CPPUNIT_ASSERT(pTime->date().day() == tm.tm_mday); - CPPUNIT_ASSERT(pTime->time_of_day().hours() == tm.tm_hour); - CPPUNIT_ASSERT(pTime->time_of_day().minutes() == tm.tm_min); - CPPUNIT_ASSERT(pTime->time_of_day().seconds() == tm.tm_sec); -} - - -/*------------------------------------------------------------------------------ - * Test the sleep function - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: sleepTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref start; - Ptr::Ref end; - Ptr::Ref duration; - - duration.reset(new time_duration(seconds(2))); - - start = TimeConversion::now(); - TimeConversion::sleep(duration); - end = TimeConversion::now(); - - CPPUNIT_ASSERT((*end - *start) >= *duration); -} - - -/*------------------------------------------------------------------------------ - * Test the time_duration to string conversions - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: durationToStringTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref duration; - Ptr::Ref smilString; - Ptr::Ref hhMmSsString; - Ptr::Ref shortString; - - - duration.reset(new time_duration(duration_from_string("01:02:03.503700"))); - smilString = TimeConversion::timeDurationToSmilString(duration); - CPPUNIT_ASSERT_EQUAL(std::string("3723.504s"), *smilString); - - hhMmSsString = TimeConversion::timeDurationToHhMmSsString(duration); - CPPUNIT_ASSERT_EQUAL(std::string("01:02:04"), *hhMmSsString); - - shortString = TimeConversion::timeDurationToShortString(duration); - CPPUNIT_ASSERT_EQUAL(std::string("1:02:03.5037"), *shortString); - - duration.reset(new time_duration(duration_from_string("111:22:33"))); - hhMmSsString = TimeConversion::timeDurationToHhMmSsString(duration); - CPPUNIT_ASSERT_EQUAL(std::string("111:22:33"), *hhMmSsString); - shortString = TimeConversion::timeDurationToShortString(duration); - CPPUNIT_ASSERT_EQUAL(std::string("111:22:33"), *shortString); - - duration.reset(new time_duration(duration_from_string("00:01:02.500000"))); - shortString = TimeConversion::timeDurationToShortString(duration); - CPPUNIT_ASSERT_EQUAL(std::string("1:02.5"), *shortString); - - duration.reset(new time_duration(duration_from_string("00:00:02.001000"))); - shortString = TimeConversion::timeDurationToShortString(duration); - CPPUNIT_ASSERT_EQUAL(std::string("2.001"), *shortString); -} - - -/*------------------------------------------------------------------------------ - * Test the parseTimeDuration() function. - *----------------------------------------------------------------------------*/ -void -TimeConversionTest :: parseTimeDurationTest(void) - throw (CPPUNIT_NS::Exception) -{ - // legal arguments - Ptr::Ref timeString(new std::string("01:02:03.503700")); - Ptr::Ref duration; - CPPUNIT_ASSERT_NO_THROW( - duration = TimeConversion::parseTimeDuration(timeString) - ); - CPPUNIT_ASSERT(duration); - CPPUNIT_ASSERT_EQUAL(std::string("01:02:03.503700"), - to_simple_string(*duration)); - - timeString.reset(new std::string("02:03.5")); - CPPUNIT_ASSERT_NO_THROW( - duration = TimeConversion::parseTimeDuration(timeString) - ); - CPPUNIT_ASSERT(duration); - CPPUNIT_ASSERT_EQUAL(std::string("00:02:03.500000"), - to_simple_string(*duration)); - - timeString.reset(new std::string("77")); - CPPUNIT_ASSERT_NO_THROW( - duration = TimeConversion::parseTimeDuration(timeString) - ); - CPPUNIT_ASSERT(duration); - CPPUNIT_ASSERT_EQUAL(std::string("00:01:17"), - to_simple_string(*duration)); - - // illegal arguments - timeString.reset(new std::string("5 minutes and 2 seconds")); - CPPUNIT_ASSERT_NO_THROW( - duration = TimeConversion::parseTimeDuration(timeString) - ); - CPPUNIT_ASSERT(duration); - CPPUNIT_ASSERT_EQUAL(std::string("00:00:05"), // bad! - to_simple_string(*duration)); - - timeString.reset(new std::string("1.2.3")); - CPPUNIT_ASSERT_NO_THROW( - duration = TimeConversion::parseTimeDuration(timeString) - ); - CPPUNIT_ASSERT(duration); - CPPUNIT_ASSERT_EQUAL(std::string("00:00:01.000002"), // bad! - to_simple_string(*duration)); -} - diff --git a/src/modules/core/src/TimeConversionTest.h b/src/modules/core/src/TimeConversionTest.h deleted file mode 100644 index 0c1491334..000000000 --- a/src/modules/core/src/TimeConversionTest.h +++ /dev/null @@ -1,154 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef TimeConversionTest_h -#define TimeConversionTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the TimeConversion class. - * - * @see TimeConversion - */ -class TimeConversionTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(TimeConversionTest); - CPPUNIT_TEST(timevalToPtimeTest); - CPPUNIT_TEST(tmToPtimeTest); - CPPUNIT_TEST(ptimeToTmTest); - CPPUNIT_TEST(nowTest); - CPPUNIT_TEST(sleepTest); - CPPUNIT_TEST(durationToStringTest); - CPPUNIT_TEST(parseTimeDurationTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * Test conversion from struct timeval to ptime - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - timevalToPtimeTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test conversion from struct tm to ptime - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - tmToPtimeTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test conversion from ptime to struct tm - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - ptimeToTmTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the now function. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - nowTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the sleep function. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - sleepTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the time_duration to string conversions - * functions. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - durationToStringTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Test the parseTimeDuration() function. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - parseTimeDurationTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // TimeConversionTest_h - diff --git a/src/modules/core/src/UniqueId.cxx b/src/modules/core/src/UniqueId.cxx deleted file mode 100644 index 5d54d432b..000000000 --- a/src/modules/core/src/UniqueId.cxx +++ /dev/null @@ -1,73 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Uuid.h" -#include "LiveSupport/Core/Md5.h" -#include "LiveSupport/Core/UniqueId.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Generate a globally unique id. - *----------------------------------------------------------------------------*/ -Ptr::Ref -UniqueId :: generateId(void) throw () -{ - Ptr::Ref uuid = Uuid::generateId(); - // as uuid is 128 bits, but we have only 63 bits, create an md5 hash - // (which is still 128 bits), and use its values to create a 63 value - // hopefully this is unique enough - Md5 md5((std::string)*uuid); - uint64_t idValue; - - idValue = md5.high64bits(); - idValue += md5.low64bits(); - // make sure it's 63 bits only, so that signed 64 bit containers can - // also accept it - idValue &= 0x7fffffffffffffffLL; - - Ptr::Ref id(new UniqueId(idValue)); - - return id; -} - diff --git a/src/modules/core/src/UniqueIdTest.cxx b/src/modules/core/src/UniqueIdTest.cxx deleted file mode 100644 index c2f6ecfb8..000000000 --- a/src/modules/core/src/UniqueIdTest.cxx +++ /dev/null @@ -1,129 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/UniqueId.h" -#include "UniqueIdTest.h" - - -using namespace std; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(UniqueIdTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -UniqueIdTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -UniqueIdTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the singleton Hello object is accessible - *----------------------------------------------------------------------------*/ -void -UniqueIdTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - UniqueId::IdType idNumeric = 51966; - std::string idAsString = "000000000000cafe"; - Ptr::Ref id; - - id.reset(new UniqueId(idNumeric)); - CPPUNIT_ASSERT(id->getId() == idNumeric); - CPPUNIT_ASSERT(UniqueId::IdType(*id) == idNumeric); - CPPUNIT_ASSERT(std::string(*id) == idAsString); - - id.reset(new UniqueId(idAsString)); - CPPUNIT_ASSERT(id->getId() == idNumeric); - CPPUNIT_ASSERT(UniqueId::IdType(*id) == idNumeric); - CPPUNIT_ASSERT(std::string(*id) == idAsString); - - id = UniqueId::generateId(); - idNumeric = UniqueId::IdType(*id); - idAsString = std::string(*id); - std::stringstream idReader(idAsString); - UniqueId::IdType idNumericCheck; - idReader >> std::hex >> idNumericCheck; - CPPUNIT_ASSERT(idNumeric == idNumericCheck); - - // OK if initialized with bad strings, but the integral value is bogus - std::string idAsVeryLongString = "123456789abcdef0123456789abcdef0"; - id.reset(new UniqueId(idAsVeryLongString)); - CPPUNIT_ASSERT(std::string(*id) == idAsVeryLongString); - - std::string idAsSillyString = "this is not a number"; - id.reset(new UniqueId(idAsSillyString)); - CPPUNIT_ASSERT(std::string(*id) == idAsSillyString); - -/* // this works fine, but please don't use - UniqueId::IdType idSillyNumeric = -3; - id.reset(new UniqueId(idSillyNumeric)); - CPPUNIT_ASSERT(UniqueId::IdType(*id) == idSillyNumeric); - CPPUNIT_ASSERT(std::string(*id) == "fffffffffffffffd"); */ - - // this is used in Postgresql classes, because Long does not get properly - // typedef'd to long long -- can be removed after this bug is fixed - std::string idAsDecimalString = "65546"; - id = UniqueId::fromDecimalString(idAsDecimalString); - CPPUNIT_ASSERT(id->getId() == 65546); - CPPUNIT_ASSERT(*id->toDecimalString() == idAsDecimalString); -} - diff --git a/src/modules/core/src/UniqueIdTest.h b/src/modules/core/src/UniqueIdTest.h deleted file mode 100644 index 27810190d..000000000 --- a/src/modules/core/src/UniqueIdTest.h +++ /dev/null @@ -1,99 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef UniqueIdTest_h -#define UniqueIdTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the UniqueId class. - * - * @see UniqueId - */ -class UniqueIdTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(UniqueIdTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // UniqueIdTest_h - diff --git a/src/modules/core/src/Uuid.cxx b/src/modules/core/src/Uuid.cxx deleted file mode 100644 index 8bf938300..000000000 --- a/src/modules/core/src/Uuid.cxx +++ /dev/null @@ -1,312 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_SYS_TIME_H -#include -#else -#error need sys/time.h -#endif - -#ifdef HAVE_UNISTD_H -#include -#else -#error need unistd.h -#endif - - -#include -#include -#include -#include -#include "LiveSupport/Core/Uuid.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/*------------------------------------------------------------------------------ - * Set the following to the number of 100ns ticks of the actual - * resolution of your system's clock - *----------------------------------------------------------------------------*/ -#define UUIDS_PER_TICK 1024 - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Generate a globally unique id. - *----------------------------------------------------------------------------*/ -Ptr::Ref -Uuid :: generateId(void) throw () -{ - Ptr::Ref id(new Uuid()); - - UuidTime timestamp; - UuidTime lastTime; - uint16_t clockseq; - UuidNode node; - UuidNode lastNode; - int f; - - /* acquire system wide lock so we're alone */ - //LOCK; - - /* get current time */ - getCurrentTime(×tamp); - - /* get node ID */ - getIeeeNodeIdentifier(&node); - - /* get saved state from NV storage */ - f = id->readState(&clockseq, &lastTime, &lastNode); - - /* if no NV state, or if clock went backwards, or node ID changed - (e.g., net card swap) change clockseq */ - if (!f || memcmp(&node, &lastNode, sizeof(UuidNode))) { - clockseq = trueRandom(); - } else if (timestamp < lastTime) { - clockseq++; - } - - /* stuff fields into the UUID */ - id->format(clockseq, timestamp, node); - id->representAsString(); - - /* save the state for next time */ - id->writeState(clockseq, timestamp, node); - - //UNLOCK; - - return id; -} - - -/*------------------------------------------------------------------------------ - * Format the UUID - *----------------------------------------------------------------------------*/ -void -Uuid :: format(uint16_t clockSeq, - UuidTime timestamp, - UuidNode node) throw () -{ - /* Construct a version 1 uuid with the information we've gathered - * plus a few constants. */ - timeLow = (unsigned long)(timestamp & 0xFFFFFFFF); - timeMid = (unsigned short)((timestamp >> 32) & 0xFFFF); - timeHiAndVersion = (unsigned short)((timestamp >> 48) & 0x0FFF); - timeHiAndVersion |= (1 << 12); - clockSeqLow = clockSeq & 0xFF; - clockSeqHiAndReserved = (clockSeq & 0x3F00) >> 8; - clockSeqHiAndReserved |= 0x80; - - for (int i = 0; i < 6; ++i) { - this->node[i] = node.nodeId[i]; - } -} - - -/*------------------------------------------------------------------------------ - * Create a string representation of the UUID - *----------------------------------------------------------------------------*/ -void -Uuid :: representAsString(void) throw () -{ - std::stringstream sstr; - - sstr << std::hex << std::setw(8) << std::setfill('0') << timeLow << '-' - << std::hex << std::setw(4) << std::setfill('0') << timeMid << '-' - << std::hex << std::setw(4) << std::setfill('0') - << timeHiAndVersion << '-' - << std::hex << std::setw(2) << std::setfill('0') - << (unsigned short) clockSeqHiAndReserved << '-' - << std::hex << std::setw(2) << std::setfill('0') - << (unsigned short) clockSeqLow << '-'; - for (int i = 0; i < 6; ++i) { - sstr << std::hex << std::setw(2) << std::setfill('0') - << (unsigned short) this->node[i]; - } - - idAsString = sstr.str(); -} - - -/*------------------------------------------------------------------------------ - * Read the current state from non-volatile storage - *----------------------------------------------------------------------------*/ -int -Uuid :: readState(uint16_t * clockSeq, - UuidTime * timestamp, - UuidNode * node) throw () -{ - // TODO: read the state from non-volatile storage - - return 0; -} - - -/*------------------------------------------------------------------------------ - * Write the current state to non-volatile storage - *----------------------------------------------------------------------------*/ -void -Uuid :: writeState(uint16_t clockSeq, - UuidTime timestamp, - UuidNode node) throw () -{ - // TODO: write the current state to non-volatile storage -} - - -/*------------------------------------------------------------------------------ - * Get the current time into a timestamp - *----------------------------------------------------------------------------*/ -void -Uuid :: getCurrentTime(UuidTime *timestamp) throw () -{ - UuidTime timeNow; - static UuidTime timeLast; - static uint16_t uuidsThisTick; - static bool inited = false; - - if (!inited) { - getSystemTime(&timeNow); - uuidsThisTick = UUIDS_PER_TICK; - inited = true; - }; - - while (true) { - getSystemTime(&timeNow); - - /* if clock reading changed since last UUID generated... */ - if (timeLast != timeNow) { - /* reset count of uuids gen'd with this clock reading */ - uuidsThisTick = 0; - break; - }; - if (uuidsThisTick < UUIDS_PER_TICK) { - uuidsThisTick++; - break; - }; - /* going too fast for our clock; spin */ - }; - - /* add the count of uuids to low order bits of the clock reading */ - *timestamp = timeNow + uuidsThisTick; -} - - -/*------------------------------------------------------------------------------ - * Get the system time in the UUID UTC base time, which is October 15, 1582 - *----------------------------------------------------------------------------*/ -void -Uuid :: getSystemTime(UuidTime * uuidTime) throw () -{ - struct timeval tp; - - gettimeofday(&tp, (struct timezone *)0); - - /* Offset between UUID formatted times and Unix formatted times. - UUID UTC base time is October 15, 1582. - Unix base time is January 1, 1970. - */ - *uuidTime = (tp.tv_sec * 10000000) - + (tp.tv_usec * 10) - + 0x01B21DD213814000LL; -} - - -/*------------------------------------------------------------------------------ - * Get the IEEE node identifier - *----------------------------------------------------------------------------*/ -void -Uuid :: getIeeeNodeIdentifier(UuidNode * node) throw () -{ - long hostId = gethostid(); - - node->nodeId[5] = (char) (hostId & 0x0000000000ffL); - node->nodeId[4] = (char) ((hostId & 0x00000000ff00L) >> 8); - node->nodeId[3] = (char) ((hostId & 0x000000ff0000L) >> 16); - node->nodeId[2] = (char) ((hostId & 0x0000ff000000L) >> 24); - // these will be 0, as the returned node is only 32 bits - node->nodeId[1] = 0; - node->nodeId[0] = 0; -} - - -/*------------------------------------------------------------------------------ - * Generate a random number - *----------------------------------------------------------------------------*/ -uint16_t -Uuid :: trueRandom(void) throw () -{ - static bool inited = false; - UuidTime timeNow; - - if (!inited) { - getSystemTime(&timeNow); - timeNow = timeNow/UUIDS_PER_TICK; - srand((unsigned int)(((timeNow >> 32) ^ timeNow)&0xffffffff)); - inited = true; - }; - - return rand(); -} - - -/*------------------------------------------------------------------------------ - * Compare two ids. - *----------------------------------------------------------------------------*/ -bool -Uuid :: compare(const Uuid & id1, - const Uuid & id2) throw () -{ - if (!(id1.timeLow == id2.timeLow - && id1.timeMid == id2.timeMid - && id1.timeHiAndVersion == id2.timeHiAndVersion - && id1.clockSeqHiAndReserved == id2.clockSeqHiAndReserved - && id1.clockSeqLow == id2.clockSeqLow)) { - - return false; - } - - for (int i = 0; i < 6; ++i) { - if (id1.node[i] != id2.node[i]) { - return false; - } - } - - return true; -} - diff --git a/src/modules/core/src/UuidTest.cxx b/src/modules/core/src/UuidTest.cxx deleted file mode 100644 index cf1b60182..000000000 --- a/src/modules/core/src/UuidTest.cxx +++ /dev/null @@ -1,93 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/Uuid.h" -#include "UuidTest.h" - - -using namespace std; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(UuidTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -UuidTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -UuidTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Test to see if the singleton Hello object is accessible - *----------------------------------------------------------------------------*/ -void -UuidTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref id1; - Ptr::Ref id2; - - id1 = Uuid::generateId(); - id2 = Uuid::generateId(); - - CPPUNIT_ASSERT(*id1 != *id2); -} - diff --git a/src/modules/core/src/UuidTest.h b/src/modules/core/src/UuidTest.h deleted file mode 100644 index 8469b4b19..000000000 --- a/src/modules/core/src/UuidTest.h +++ /dev/null @@ -1,99 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef UuidTest_h -#define UuidTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the Uuid class. - * - * @see Uuid - */ -class UuidTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(UuidTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST_SUITE_END(); - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Core -} // namespace LiveSupport - -#endif // UuidTest_h - diff --git a/src/modules/core/src/XmlRpcException.cxx b/src/modules/core/src/XmlRpcException.cxx deleted file mode 100644 index cd8ce781f..000000000 --- a/src/modules/core/src/XmlRpcException.cxx +++ /dev/null @@ -1,59 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/XmlRpcException.h" - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -XmlRpcException :: XmlRpcException(const std::string & msg, - const std::exception & parent) - throw () - : parent(parent) -{ - message.reset(new std::string(msg)); - message->append("\nparent exception:\n"); - message->append(parent.what()); -} - diff --git a/src/modules/core/src/XmlRpcTools.cxx b/src/modules/core/src/XmlRpcTools.cxx deleted file mode 100644 index 891d863bb..000000000 --- a/src/modules/core/src/XmlRpcTools.cxx +++ /dev/null @@ -1,1161 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_TIME_H -#include -#else -#error need time.h -#endif - - -#include -#include "LiveSupport/Core/TimeConversion.h" - -#include "LiveSupport/Core/XmlRpcTools.h" - - -using namespace boost; -using namespace boost::posix_time; - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - -namespace { - -/*------------------------------------------------------------------------------ - * The name of the generic ID member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string idName = "id"; - -/*------------------------------------------------------------------------------ - * The name of the playlist ID member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string playlistIdName = "playlistId"; - -/*------------------------------------------------------------------------------ - * The name of the audio clip ID member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string audioClipIdName = "audioClipId"; - -/*------------------------------------------------------------------------------ - * The name of the playlist element ID member in the XML-RPC param structure - *----------------------------------------------------------------------------*/ -const std::string playlistElementIdName = "playlistElementId"; - -/*------------------------------------------------------------------------------ - * The name of the relative offset member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string relativeOffsetName = "relativeOffset"; - -/*------------------------------------------------------------------------------ - * The name of the relative offset member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string clipStartName = "clipStart"; - -/*------------------------------------------------------------------------------ - * The name of the relative offset member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string clipEndName = "clipEnd"; - -/*------------------------------------------------------------------------------ - * The name of the relative offset member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string clipLengthName = "clipLength"; - -/*------------------------------------------------------------------------------ - * The name of the from member in the XML-RPC parameter structure. - *----------------------------------------------------------------------------*/ -const std::string fromTimeName = "from"; - -/*------------------------------------------------------------------------------ - * The name of the to member in the XML-RPC parameter structure. - *----------------------------------------------------------------------------*/ -const std::string toTimeName = "to"; - -/*------------------------------------------------------------------------------ - * The name of the start member in the XML-RPC parameter structure. - *----------------------------------------------------------------------------*/ -const std::string startTimeName = "start"; - -/*------------------------------------------------------------------------------ - * The name of the end member in the XML-RPC parameter structure. - *----------------------------------------------------------------------------*/ -const std::string endTimeName = "end"; - -/*------------------------------------------------------------------------------ - * The name of the schedule entry id member in the XML-RPC parameter structure. - *----------------------------------------------------------------------------*/ -const std::string scheduleEntryIdName = "scheduleEntryId"; - -/*------------------------------------------------------------------------------ - * The name of the playtime member in the XML-RPC parameter structure. - *----------------------------------------------------------------------------*/ -const std::string playtimeName = "playtime"; - -/*------------------------------------------------------------------------------ - * The name of the fade in member in the XML-RPC parameter structure. - *----------------------------------------------------------------------------*/ -const std::string fadeInName = "fadeIn"; - -/*------------------------------------------------------------------------------ - * The name of the fade out member in the XML-RPC parameter structure. - *----------------------------------------------------------------------------*/ -const std::string fadeOutName = "fadeOut"; - -/*------------------------------------------------------------------------------ - * The name of the session ID member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string sessionIdName = "sessionId"; - -/*------------------------------------------------------------------------------ - * The name of the login name member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string loginName = "login"; - -/*------------------------------------------------------------------------------ - * The name of the password member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string passwordName = "password"; - -/*------------------------------------------------------------------------------ - * The name of the search criteria member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string searchCriteriaName = "criteria"; - -/*------------------------------------------------------------------------------ - * The name of the token member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string tokenName = "token"; - -/*------------------------------------------------------------------------------ - * The name of the backup status member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string backupStatusName = "status"; - -/*------------------------------------------------------------------------------ - * The name of the URL member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string urlName = "url"; - -/*------------------------------------------------------------------------------ - * The name of the path member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string pathName = "path"; - -/*------------------------------------------------------------------------------ - * The name of the fault string member in the XML-RPC parameter structure - *----------------------------------------------------------------------------*/ -const std::string faultStringName = "faultString"; - -} - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Extract the schedule entry ID from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractScheduleEntryId( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(scheduleEntryIdName) - || xmlRpcValue[scheduleEntryIdName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad schedule entry ID " - "argument"); - } - - Ptr::Ref id(new UniqueId(std::string( - xmlRpcValue[scheduleEntryIdName] ))); - return id; -} - - -/*------------------------------------------------------------------------------ - * Extract the generic ID from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(idName) - || xmlRpcValue[idName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad ID argument"); - } - - Ptr::Ref id(new UniqueId(std::string(xmlRpcValue[idName]))); - return id; -} - - -/*------------------------------------------------------------------------------ - * Extract the playlist ID from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractPlaylistId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(playlistIdName) - || xmlRpcValue[playlistIdName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad playlist ID argument"); - } - - Ptr::Ref id(new UniqueId(std::string( - xmlRpcValue[playlistIdName] ))); - return id; -} - - -/*------------------------------------------------------------------------------ - * Extract the playlist element ID from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractPlaylistElementId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(playlistElementIdName) - || xmlRpcValue[playlistElementIdName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad playlist element ID " - "argument"); - } - - Ptr::Ref id(new UniqueId(std::string( - xmlRpcValue[playlistElementIdName] ))); - return id; -} - - -/*------------------------------------------------------------------------------ - * Extract the audio clip ID from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractAudioClipId(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(audioClipIdName) - || xmlRpcValue[audioClipIdName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad audio clip ID argument"); - } - - Ptr::Ref id(new UniqueId(std::string( - xmlRpcValue[audioClipIdName] ))); - return id; -} - -/*------------------------------------------------------------------------------ - * Extract the relative offset from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractClipStart(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(clipStartName) - || xmlRpcValue[clipStartName].getType() - != XmlRpc::XmlRpcValue::TypeInt) { - throw std::invalid_argument("missing clip start argument"); - } - - Ptr::Ref clipStart(new time_duration(0,0, - int(xmlRpcValue[clipStartName]), 0)); - return clipStart; -} - -/*------------------------------------------------------------------------------ - * Extract the relative offset from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractClipEnd(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(clipEndName) - || xmlRpcValue[clipEndName].getType() - != XmlRpc::XmlRpcValue::TypeInt) { - throw std::invalid_argument("missing clip end argument"); - } - - Ptr::Ref clipEnd(new time_duration(0,0, - int(xmlRpcValue[clipEndName]), 0)); - return clipEnd; -} - -/*------------------------------------------------------------------------------ - * Extract the relative offset from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractClipLength(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(clipLengthName) - || xmlRpcValue[clipLengthName].getType() - != XmlRpc::XmlRpcValue::TypeInt) { - throw std::invalid_argument("missing clip length argument"); - } - - Ptr::Ref clipLength(new time_duration(0,0, - int(xmlRpcValue[clipLengthName]), 0)); - return clipLength; -} - -/*------------------------------------------------------------------------------ - * Extract the relative offset from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractRelativeOffset(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(relativeOffsetName) - || xmlRpcValue[relativeOffsetName].getType() - != XmlRpc::XmlRpcValue::TypeInt) { - throw std::invalid_argument("missing relative offset argument"); - } - - Ptr::Ref relativeOffset(new time_duration(0,0, - int(xmlRpcValue[relativeOffsetName]), 0)); - return relativeOffset; -} - - -/*------------------------------------------------------------------------------ - * Convert a Playlist to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: playlistToXmlRpcValue( - Ptr::Ref playlist, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw () -{ - xmlRpcValue["playlist"] = std::string(*playlist->getXmlDocumentString()); -} - - -/*------------------------------------------------------------------------------ - * Convert a vector of Playlists into an XML-RPC value. - * This function returns an XML-RPC array of XML-RPC structures. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: playlistVectorToXmlRpcValue( - const Ptr::Ref> >::Ref playlistVector, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue.setSize(playlistVector->size()); - // a call to setSize() makes sure it's an XML-RPC - // array - - std::vector::Ref>::const_iterator it = - playlistVector->begin(); - int arraySize = 0; - while (it != playlistVector->end()) { - Ptr::Ref playlist = *it; - XmlRpc::XmlRpcValue returnStruct; - playlistToXmlRpcValue(playlist, returnStruct); - returnValue[arraySize++] = returnStruct; - ++it; - } -} - - -/*------------------------------------------------------------------------------ - * Convert an AudioClip to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: audioClipToXmlRpcValue( - Ptr::Ref audioClip, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw () -{ - xmlRpcValue["audioClip"] = std::string(*audioClip->getXmlDocumentString()); -} - - -/*------------------------------------------------------------------------------ - * Convert a vector of AudioClips into an XML-RPC value. - * This function returns an XML-RPC array of XML-RPC structures. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: audioClipVectorToXmlRpcValue( - const Ptr::Ref> >::Ref audioClipVector, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue.setSize(audioClipVector->size()); - // a call to setSize() makes sure it's an XML-RPC - // array - - std::vector::Ref>::const_iterator it = - audioClipVector->begin(); - int arraySize = 0; - while (it != audioClipVector->end()) { - Ptr::Ref audioClip = *it; - XmlRpc::XmlRpcValue returnStruct; - audioClipToXmlRpcValue(audioClip, returnStruct); - returnValue[arraySize++] = returnStruct; - ++it; - } -} - - -/*------------------------------------------------------------------------------ - * Extract a Playlist from an XML-RPC parameter. - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractPlaylist(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - Ptr::Ref playlist(new Playlist(xmlRpcValue)); - // may throw std::invalid_argument - return playlist; -} - - -/*------------------------------------------------------------------------------ - * Extract a vector of Playlists from an XML-RPC parameter. - *----------------------------------------------------------------------------*/ -Ptr::Ref> >::Ref -XmlRpcTools :: extractPlaylistVector(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (xmlRpcValue.getType() != XmlRpc::XmlRpcValue::TypeArray) { - throw std::invalid_argument("argument to extractPlaylistVector " - "is not an array"); - } - - Ptr::Ref> >::Ref playlistVector; - for (int i=0; i < xmlRpcValue.size(); i++) { - Ptr::Ref playlist(new Playlist(xmlRpcValue[i])); - // may throw std::invalid_argument - playlistVector->push_back(playlist); - } - return playlistVector; -} - - -/*------------------------------------------------------------------------------ - * Extract an AudioClip from an XML-RPC parameter. - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractAudioClip(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - Ptr::Ref audioClip(new AudioClip(xmlRpcValue)); - // may throw std::invalid_argument - return audioClip; -} - - -/*------------------------------------------------------------------------------ - * Extract a vector of AudioClips from an XML-RPC parameter. - *----------------------------------------------------------------------------*/ -Ptr::Ref> >::Ref -XmlRpcTools :: extractAudioClipVector(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (xmlRpcValue.getType() != XmlRpc::XmlRpcValue::TypeArray) { - throw std::invalid_argument("argument to extractAudioClipVector " - "is not an array"); - } - - Ptr::Ref> >::Ref audioClipVector; - for (int i=0; i < xmlRpcValue.size(); i++) { - Ptr::Ref audioClip(new AudioClip(xmlRpcValue[i])); - // may throw std::invalid_argument - audioClipVector->push_back(audioClip); - } - return audioClipVector; -} - - -/*------------------------------------------------------------------------------ - * Convert an error code, error message pair to an XML-RPC fault response - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: markError(int errorCode, const std::string errorMessage, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (XmlRpc::XmlRpcException) -{ - throw XmlRpc::XmlRpcException(errorMessage, errorCode); -} - - -/*------------------------------------------------------------------------------ - * Convert the valid status of a playlist to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: validStatusToXmlRpcValue( - bool validStatus, - XmlRpc::XmlRpcValue & xmlRpcValue) - throw () -{ - xmlRpcValue["valid"] = XmlRpc::XmlRpcValue(validStatus); -} - - -/*------------------------------------------------------------------------------ - * Extract the 'from' time from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractFromTime( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(fromTimeName) - || xmlRpcValue[fromTimeName].getType() - != XmlRpc::XmlRpcValue::TypeDateTime) { - throw std::invalid_argument("missing or bad 'from' time in " - "parameter structure"); - } - - struct tm time = (struct tm) xmlRpcValue[fromTimeName]; - return TimeConversion::tmToPtime(&time); -} - - -/*------------------------------------------------------------------------------ - * Extract the 'to' time from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractToTime( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(toTimeName) - || xmlRpcValue[toTimeName].getType() - != XmlRpc::XmlRpcValue::TypeDateTime) { - throw std::invalid_argument("missing or bad 'to' time in " - "parameter structure"); - } - - struct tm time = (struct tm) xmlRpcValue[toTimeName]; - return TimeConversion::tmToPtime(&time); -} - - -/*------------------------------------------------------------------------------ - * Extract the 'start' time from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractStartTime( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(startTimeName) - || xmlRpcValue[startTimeName].getType() - != XmlRpc::XmlRpcValue::TypeDateTime) { - throw std::invalid_argument("missing or bad 'start' time in " - "parameter structure"); - } - - struct tm time = (struct tm) xmlRpcValue[startTimeName]; - return TimeConversion::tmToPtime(&time); -} - - -/*------------------------------------------------------------------------------ - * Extract the 'end' time from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractEndTime( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(endTimeName) - || xmlRpcValue[endTimeName].getType() - != XmlRpc::XmlRpcValue::TypeDateTime) { - throw std::invalid_argument("missing or bad 'end' time in " - "parameter structure"); - } - - struct tm time = (struct tm) xmlRpcValue[endTimeName]; - return TimeConversion::tmToPtime(&time); -} - - -/*------------------------------------------------------------------------------ - * Convert a boost::posix_time::ptime to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: ptimeToXmlRpcValue( - Ptr::Ref ptimeParam, - XmlRpc::XmlRpcValue& xmlRpcValue) - throw () -{ - struct tm time; - Ptr::Ref myPtime(new ptime(*ptimeParam)); // get rid of const - - TimeConversion::ptimeToTm(myPtime, time); - xmlRpcValue = XmlRpc::XmlRpcValue(&time); -} - - -/*------------------------------------------------------------------------------ - * Convert a vector of ScheduleEntries into an XML-RPC value. - * This function returns an XML-RPC array of XML-RPC structures. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: scheduleEntriesToXmlRpcValue( - Ptr::Ref> >::Ref scheduleEntries, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue.setSize(scheduleEntries->size()); - // a call to setSize() makes sure it's an XML-RPC - // array - - std::vector::Ref>::iterator it - = scheduleEntries->begin(); - int arraySize = 0; - while (it != scheduleEntries->end()) { - Ptr::Ref entry = *it; - XmlRpc::XmlRpcValue returnStruct; - returnStruct[idName] = std::string(*entry->getId()); - returnStruct[playlistIdName] = std::string(*entry->getPlaylistId()); - - XmlRpc::XmlRpcValue time; - ptimeToXmlRpcValue(entry->getStartTime(), time); - returnStruct[startTimeName] = time; - - ptimeToXmlRpcValue(entry->getEndTime(), time); - returnStruct[endTimeName] = time; - - returnValue[arraySize++] = returnStruct; - ++it; - } -} - - -/*------------------------------------------------------------------------------ - * Convert an XML-RPC value, holding an array of schedule entries - * to a vector holding the same ScheduleEntry object. - *----------------------------------------------------------------------------*/ -Ptr::Ref> >::Ref -XmlRpcTools :: extractScheduleEntries( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw () -{ - Ptr::Ref> >::Ref entries; - entries.reset(new std::vector::Ref>()); - - int nEntries = xmlRpcValue.size(); - for (int i = 0; i < nEntries; ++i) { - XmlRpc::XmlRpcValue & entryValue = xmlRpcValue[i]; - - Ptr::Ref entryId = extractId(entryValue); - Ptr::Ref playlistId = extractPlaylistId(entryValue); - Ptr::Ref start = extractStartTime(entryValue); - Ptr::Ref end = extractEndTime(entryValue); - - Ptr::Ref entry(new ScheduleEntry(entryId, - playlistId, - start, - end)); - - entries->push_back(entry); - } - - return entries; -} - - -/*------------------------------------------------------------------------------ - * Extract the playtime from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractPlayschedule( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(playtimeName) - || xmlRpcValue[playtimeName].getType() - != XmlRpc::XmlRpcValue::TypeDateTime) { - throw std::invalid_argument("missing or bad playtime in " - "parameter structure"); - } - - struct tm time = (struct tm) xmlRpcValue[playtimeName]; - return TimeConversion::tmToPtime(&time); -} - - -/*------------------------------------------------------------------------------ - * Extract the fade in time from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractFadeIn(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(fadeInName) - || xmlRpcValue[fadeInName].getType() - != XmlRpc::XmlRpcValue::TypeInt) { - throw std::invalid_argument("missing or bad 'fade in' argument"); - } - - Ptr::Ref fadeIn(new time_duration(0,0, - int(xmlRpcValue[fadeInName]), 0)); - return fadeIn; -} - - -/*------------------------------------------------------------------------------ - * Extract the fade out time from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractFadeOut(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(fadeOutName) - || xmlRpcValue[fadeOutName].getType() - != XmlRpc::XmlRpcValue::TypeInt) { - throw std::invalid_argument("missing or bad 'fade out' argument"); - } - - Ptr::Ref fadeOut(new time_duration(0,0, - int(xmlRpcValue[fadeOutName]), 0)); - return fadeOut; -} - - -/*------------------------------------------------------------------------------ - * Convert a schedule entry ID (a UniqueId) to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: scheduleEntryIdToXmlRpcValue( - Ptr::Ref scheduleEntryId, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[scheduleEntryIdName] = std::string(*scheduleEntryId); -} - - -/*------------------------------------------------------------------------------ - * Add a session ID to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: sessionIdToXmlRpcValue( - Ptr::Ref sessionId, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[sessionIdName] = sessionId->getId(); -} - - -/*------------------------------------------------------------------------------ - * Add a playlist ID to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: playlistIdToXmlRpcValue( - Ptr::Ref playlistId, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[playlistIdName] = std::string(*playlistId); -} - - -/*------------------------------------------------------------------------------ - * Add an audio clip ID to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: audioClipIdToXmlRpcValue( - Ptr::Ref audioClipId, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[audioClipIdName] = std::string(*audioClipId); -} - - -/*------------------------------------------------------------------------------ - * Add a playlist element ID to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: playlistElementIdToXmlRpcValue( - Ptr::Ref playlistElementId, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[playlistElementIdName] = std::string(*playlistElementId); -} - - -/*------------------------------------------------------------------------------ - * Add a playtime value to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: playtimeToXmlRpcValue( - Ptr::Ref playtime, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - XmlRpc::XmlRpcValue timestamp; - ptimeToXmlRpcValue(playtime, timestamp); - returnValue[playtimeName] = timestamp; -} - - -/*------------------------------------------------------------------------------ - * Add a 'from' time value to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: fromTimeToXmlRpcValue( - Ptr::Ref from, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - XmlRpc::XmlRpcValue timestamp; - ptimeToXmlRpcValue(from, timestamp); - returnValue[fromTimeName] = timestamp; -} - - -/*------------------------------------------------------------------------------ - * Add a 'to' time value to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: toTimeToXmlRpcValue( - Ptr::Ref to, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - XmlRpc::XmlRpcValue timestamp; - ptimeToXmlRpcValue(to, timestamp); - returnValue[toTimeName] = timestamp; -} - - -/*------------------------------------------------------------------------------ - * Convert a PlayLogEntry to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: playLogEntryToXmlRpcValue( - Ptr::Ref playLogEntry, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue["audioClipId"] = std::string(*playLogEntry->getAudioClipId()); - - XmlRpc::XmlRpcValue timestamp; - ptimeToXmlRpcValue(playLogEntry->getTimestamp(), timestamp); - returnValue["timestamp"] = timestamp; -} - - -/*------------------------------------------------------------------------------ - * Convert a vector of PlayLogEntries into an XML-RPC value. - * This function returns an XML-RPC array of XML-RPC structures. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: playLogVectorToXmlRpcValue( - Ptr::Ref> >::Ref playLogVector, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue.setSize(playLogVector->size()); - // a call to setSize() makes sure it's an XML-RPC - // array - - std::vector::Ref>::const_iterator it = - playLogVector->begin(); - int arraySize = 0; - while (it != playLogVector->end()) { - Ptr::Ref playLog = *it; - XmlRpc::XmlRpcValue returnStruct; - playLogEntryToXmlRpcValue(playLog, returnStruct); - returnValue[arraySize++] = returnStruct; - ++it; - } -} - - -/*------------------------------------------------------------------------------ - * Extract the session ID from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractSessionId( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(sessionIdName) - || xmlRpcValue[sessionIdName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad session ID argument"); - } - - Ptr::Ref id(new SessionId(std::string( - xmlRpcValue[sessionIdName] ))); - return id; -} - - -/*------------------------------------------------------------------------------ - * Extract the login name from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractLoginName( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(loginName) - || xmlRpcValue[loginName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad login name argument"); - } - - Ptr::Ref login(new std::string(xmlRpcValue[loginName])); - return login; -} - - -/*------------------------------------------------------------------------------ - * Extract the password from an XML-RPC function call parameter - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractPassword( - XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(passwordName) - || xmlRpcValue[passwordName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad password argument"); - } - - Ptr::Ref password(new std::string( - xmlRpcValue[passwordName] )); - return password; -} - - -/*------------------------------------------------------------------------------ - * Extract the search criteria from the XML-RPC parameters. - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractSearchCriteria(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(searchCriteriaName) - || xmlRpcValue[searchCriteriaName].getType() - != XmlRpc::XmlRpcValue::TypeStruct) { - throw std::invalid_argument("missing or bad criteria argument"); - } - XmlRpc::XmlRpcValue xmlCriteria = xmlRpcValue[searchCriteriaName]; - - Ptr::Ref criteria(new SearchCriteria(xmlCriteria)); - - return criteria; -} - - -/*------------------------------------------------------------------------------ - * Convert a SearchCriteria to an XmlRpcValue - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: searchCriteriaToXmlRpcValue( - Ptr::Ref criteria, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[searchCriteriaName] = *criteria; -} - - -/*------------------------------------------------------------------------------ - * Extract a token from the XML-RPC parameters. - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractToken(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(tokenName) - || xmlRpcValue[tokenName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad token argument"); - } - - Ptr::Ref token(new Glib::ustring( - xmlRpcValue[tokenName] )); - return token; -} - - -/*------------------------------------------------------------------------------ - * Convert a string token to an XmlRpcValue. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: tokenToXmlRpcValue( - Ptr::Ref token, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[tokenName] = std::string(*token); -} - - -/*------------------------------------------------------------------------------ - * Extract the backup status from the XML-RPC parameters. - *----------------------------------------------------------------------------*/ -AsyncState -XmlRpcTools :: extractBackupStatus(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(backupStatusName) - || xmlRpcValue[backupStatusName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad status argument"); - } - - AsyncState status = AsyncState::fromBackupString( - xmlRpcValue[backupStatusName]); - return status; -} - - -/*------------------------------------------------------------------------------ - * Convert a StorageClientInterface::AsyncState returned by one - * of the backup methods to an XmlRpcValue. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: backupStatusToXmlRpcValue(AsyncState status, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - Ptr::Ref stringValue = status.toBackupString(); - returnValue[backupStatusName] = *stringValue; -} - - -/*------------------------------------------------------------------------------ - * Extract a URL string from the XML-RPC parameters. - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractUrl(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(urlName) - || xmlRpcValue[urlName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad url argument"); - } - - Ptr::Ref url(new Glib::ustring( - xmlRpcValue[urlName] )); - return url; -} - - -/*------------------------------------------------------------------------------ - * Convert a string token to an XmlRpcValue. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: urlToXmlRpcValue( - Ptr::Ref url, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[urlName] = std::string(*url); -} - - -/*------------------------------------------------------------------------------ - * Extract a path string from the XML-RPC parameters. - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractPath(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(pathName) - || xmlRpcValue[pathName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad path argument"); - } - - Ptr::Ref path(new Glib::ustring( - xmlRpcValue[pathName] )); - return path; -} - - -/*------------------------------------------------------------------------------ - * Convert a string token to an XmlRpcValue. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: pathToXmlRpcValue( - Ptr::Ref path, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[pathName] = std::string(*path); -} - - -/*------------------------------------------------------------------------------ - * Extract a fault string from the XML-RPC parameters. - *----------------------------------------------------------------------------*/ -Ptr::Ref -XmlRpcTools :: extractFaultString(XmlRpc::XmlRpcValue & xmlRpcValue) - throw (std::invalid_argument) -{ - if (!xmlRpcValue.hasMember(faultStringName) - || xmlRpcValue[faultStringName].getType() - != XmlRpc::XmlRpcValue::TypeString) { - throw std::invalid_argument("missing or bad faultString argument"); - } - - Ptr::Ref faultString(new Glib::ustring( - xmlRpcValue[faultStringName] )); - return faultString; -} - - -/*------------------------------------------------------------------------------ - * Convert a fault string to an XmlRpcValue. - *----------------------------------------------------------------------------*/ -void -XmlRpcTools :: faultStringToXmlRpcValue( - Ptr::Ref faultString, - XmlRpc::XmlRpcValue & returnValue) - throw () -{ - returnValue[faultStringName] = std::string(*faultString); -} - diff --git a/src/modules/core/src/XmlRpcToolsTest.cxx b/src/modules/core/src/XmlRpcToolsTest.cxx deleted file mode 100644 index 0398fcf1c..000000000 --- a/src/modules/core/src/XmlRpcToolsTest.cxx +++ /dev/null @@ -1,321 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include -#include - -#include "LiveSupport/Core/XmlRpcTools.h" -#include "XmlRpcToolsTest.h" - - -using namespace LiveSupport::Core; - -using namespace std; -using namespace XmlRpc; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(XmlRpcToolsTest); - -/** - * The name of the configuration file for the playlist. - */ -const std::string configFileName = "etc/playlist.xml"; - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Configure a Configurable with an XML file. - *----------------------------------------------------------------------------*/ -void -XmlRpcToolsTest :: configure( - Ptr::Ref configurable, - const std::string fileName) - throw (CPPUNIT_NS::Exception) -{ - try { - Ptr::Ref parser( - new xmlpp::DomParser(configFileName, true)); - const xmlpp::Document * document = parser->get_document(); - const xmlpp::Element * root = document->get_root_node(); - - configurable->configure(*root); - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL("semantic error in configuration file"); - } catch (xmlpp::exception &e) { - CPPUNIT_FAIL("error parsing configuration file"); - } -} - - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -XmlRpcToolsTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -XmlRpcToolsTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Just a very simple smoke test - *----------------------------------------------------------------------------*/ -void -XmlRpcToolsTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - XmlRpcValue xmlRpcPlaylist; - XmlRpcValue xmlRpcAudioClip; - Ptr::Ref playlist = Ptr::Ref(new Playlist()); - Ptr::Ref audioClip; - - // set up a playlist instance - configure(playlist, configFileName); - audioClip = playlist->begin()->second->getAudioClip(); - - // run the packing methods - XmlRpcTools :: playlistToXmlRpcValue(playlist, xmlRpcPlaylist); - XmlRpcTools :: audioClipToXmlRpcValue(audioClip, xmlRpcAudioClip); - - CPPUNIT_ASSERT(xmlRpcPlaylist.hasMember("playlist")); - CPPUNIT_ASSERT(xmlRpcPlaylist["playlist"].getType() - == XmlRpcValue::TypeString); - - CPPUNIT_ASSERT(xmlRpcAudioClip.hasMember("audioClip")); - CPPUNIT_ASSERT(xmlRpcAudioClip["audioClip"].getType() - == XmlRpcValue::TypeString); - - XmlRpcValue xmlRpcPlaylistId; - Ptr::Ref playlistId(new UniqueId(rand())); - Ptr::Ref audioClipId(new UniqueId(rand())); - Ptr::Ref relativeOffset(new time_duration(0,0,rand(),0)); - - xmlRpcPlaylistId["playlistId"] = std::string(*playlistId); - xmlRpcPlaylistId["audioClipId"] = std::string(*audioClipId); - xmlRpcPlaylistId["relativeOffset"] = relativeOffset->total_seconds(); - - // run the unpacking methods - Ptr::Ref newPlaylistId; - Ptr::Ref newAudioClipId; - Ptr::Ref newRelativeOffset; - Ptr::Ref newPlaylist; - Ptr::Ref newAudioClip; - try { - newPlaylistId = XmlRpcTools::extractPlaylistId(xmlRpcPlaylistId); - newAudioClipId = XmlRpcTools::extractAudioClipId(xmlRpcPlaylistId); - newRelativeOffset - = XmlRpcTools::extractRelativeOffset(xmlRpcPlaylistId); - newPlaylist = XmlRpcTools::extractPlaylist(xmlRpcPlaylist); - newAudioClip = XmlRpcTools::extractAudioClip(xmlRpcAudioClip); - - } catch (std::invalid_argument &e) { - CPPUNIT_FAIL(e.what()); - } - - CPPUNIT_ASSERT(*playlistId == *newPlaylistId); - CPPUNIT_ASSERT(*audioClipId == *newAudioClipId); - CPPUNIT_ASSERT(*relativeOffset == *newRelativeOffset); - - CPPUNIT_ASSERT(*playlist->getId() == *newPlaylist->getId()); - CPPUNIT_ASSERT(*playlist->getTitle() == *newPlaylist->getTitle()); - CPPUNIT_ASSERT(*playlist->getPlaylength() - == *newPlaylist->getPlaylength()); - - CPPUNIT_ASSERT(*audioClip->getId() == *newAudioClip->getId()); - CPPUNIT_ASSERT(*audioClip->getTitle() == *newAudioClip->getTitle()); - CPPUNIT_ASSERT(*audioClip->getPlaylength() - == *newAudioClip->getPlaylength()); -} - - -/*------------------------------------------------------------------------------ - * Testing the search criteria marshaling/demarshaling. - *----------------------------------------------------------------------------*/ -void -XmlRpcToolsTest :: secondTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref token(new Glib::ustring("this is a token")); - XmlRpcValue xmlRpcToken; - - CPPUNIT_ASSERT_NO_THROW( - XmlRpcTools::tokenToXmlRpcValue(token, xmlRpcToken) - ); - - Ptr::Ref otherToken; - CPPUNIT_ASSERT_NO_THROW( - otherToken = XmlRpcTools::extractToken(xmlRpcToken) - ); - CPPUNIT_ASSERT(otherToken); - - CPPUNIT_ASSERT(*token == *otherToken); - - XmlRpcValue otherXmlRpcToken; - CPPUNIT_ASSERT_NO_THROW( - XmlRpcTools::tokenToXmlRpcValue(otherToken, otherXmlRpcToken) - ); - - CPPUNIT_ASSERT(xmlRpcToken == otherXmlRpcToken); -} - - -/*------------------------------------------------------------------------------ - * Testing the search criteria marshaling/demarshaling. - *----------------------------------------------------------------------------*/ -void -XmlRpcToolsTest :: searchCriteriaTest(void) - throw (CPPUNIT_NS::Exception) -{ - std::string xmlStringCriteria = -"" -"" -"criteria" -"" -" " -" filetype" -" audioClip" -" " -" " -" operator" -" or" -" " -" " -" limit" -" 5" -" " -" " -" offset" -" 100" -" " -" " -" conditions" -" " -" " -" " -" cat" -" dc:title" -" " -" " -" op" -" partial" -" " -" " -" val" -" abcdef" -" " -" " -" " -" " -" cat" -" dc:creator" -" " -" " -" op" -" =" -" " -" " -" val" -" ABCDEF" -" " -" " -" " -" " -"" -"" -""; - - XmlRpcValue xmlRpcCriteria; - int offset = 0; - xmlRpcCriteria.fromXml(xmlStringCriteria, &offset); - - Ptr::Ref criteria; - CPPUNIT_ASSERT_NO_THROW( - criteria = XmlRpcTools::extractSearchCriteria(xmlRpcCriteria) - ); - CPPUNIT_ASSERT(criteria); - - XmlRpcValue otherXmlRpcCriteria; - CPPUNIT_ASSERT_NO_THROW( - XmlRpcTools::searchCriteriaToXmlRpcValue(criteria, otherXmlRpcCriteria) - ); - - CPPUNIT_ASSERT(xmlRpcCriteria == otherXmlRpcCriteria); - - Ptr::Ref otherCriteria; - CPPUNIT_ASSERT_NO_THROW( - otherCriteria = XmlRpcTools::extractSearchCriteria(otherXmlRpcCriteria) - ); - CPPUNIT_ASSERT(otherCriteria); - - CPPUNIT_ASSERT(*criteria == *otherCriteria); -} - - -/*------------------------------------------------------------------------------ - * Testing markError() - *----------------------------------------------------------------------------*/ -void -XmlRpcToolsTest :: errorTest(void) - throw (CPPUNIT_NS::Exception) -{ - XmlRpcValue xmlRpcValue; - - try { - XmlRpcTools :: markError(42, "this is an error", xmlRpcValue); - CPPUNIT_FAIL("did not throw exception in markError()"); - } catch (XmlRpc::XmlRpcException &e) { - CPPUNIT_ASSERT(e.getCode() == 42); - CPPUNIT_ASSERT(e.getMessage() == "this is an error"); - } -} - diff --git a/src/modules/core/src/XmlRpcToolsTest.h b/src/modules/core/src/XmlRpcToolsTest.h deleted file mode 100644 index 4b2f13d3b..000000000 --- a/src/modules/core/src/XmlRpcToolsTest.h +++ /dev/null @@ -1,143 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef XmlRpcToolsTest_h -#define XmlRpcToolsTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace Core { - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the XmlRpcTools class. - * - * @see XmlRpcTools - */ -class XmlRpcToolsTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(XmlRpcToolsTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST(secondTest); - CPPUNIT_TEST(searchCriteriaTest); - CPPUNIT_TEST(errorTest); - CPPUNIT_TEST_SUITE_END(); - - private: - - /** - * Configure a configurable with an XML file. - * - * @param configurable configure this - * @param fileName the name of the XML file to configure with. - * @exception CPPUNIT_NS::Exception on XML parsing errors. - */ - void - configure(Ptr::Ref configurable, - std::string fileName) - throw (CPPUNIT_NS::Exception); - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Another simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - secondTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing the search criteria marshaling/demarshaling. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - searchCriteriaTest(void) throw (CPPUNIT_NS::Exception); - - /** - * Testing the method for error message packaging. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - errorTest(void) throw (CPPUNIT_NS::Exception); - - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace Scheduler -} // namespace LiveSupport - -#endif // XmlRpcToolsTest_h - diff --git a/src/modules/core/tmp/.keepme b/src/modules/core/tmp/.keepme deleted file mode 100644 index e0808fa16..000000000 --- a/src/modules/core/tmp/.keepme +++ /dev/null @@ -1 +0,0 @@ -keep me diff --git a/src/modules/core/var/.keepme b/src/modules/core/var/.keepme deleted file mode 100644 index e0808fa16..000000000 --- a/src/modules/core/var/.keepme +++ /dev/null @@ -1 +0,0 @@ -keep me diff --git a/src/modules/core/var/en.txt b/src/modules/core/var/en.txt deleted file mode 100644 index a0b0a6d89..000000000 --- a/src/modules/core/var/en.txt +++ /dev/null @@ -1,7 +0,0 @@ -en:table -{ - section1:table - { - foo:string { "fou" } - } -} diff --git a/src/modules/core/var/hello.tar b/src/modules/core/var/hello.tar deleted file mode 100644 index 0d2d65d0a..000000000 Binary files a/src/modules/core/var/hello.tar and /dev/null differ diff --git a/src/modules/core/var/hu.txt b/src/modules/core/var/hu.txt deleted file mode 100644 index 894de6442..000000000 --- a/src/modules/core/var/hu.txt +++ /dev/null @@ -1,14 +0,0 @@ -hu:table -{ - section1:table - { - foo:string { "fú" } - bar:string { "bár" } - } - - metadata:table - { - creator:string { "Előadó" } - } -} - diff --git a/src/modules/core/var/jp.txt b/src/modules/core/var/jp.txt deleted file mode 100644 index df95b8b0c..000000000 --- a/src/modules/core/var/jp.txt +++ /dev/null @@ -1,14 +0,0 @@ -jp:table -{ - section1:table - { - foo:string { "ふ" } - bar:string { "ばる" } - } - - metadata:table - { - creator:string { "クリエーター" } - } -} - diff --git a/src/modules/core/var/md5test.data b/src/modules/core/var/md5test.data deleted file mode 100644 index 8ad1499cd..000000000 --- a/src/modules/core/var/md5test.data +++ /dev/null @@ -1 +0,0 @@ -some sample data for an MD5 test diff --git a/src/modules/core/var/root.txt b/src/modules/core/var/root.txt deleted file mode 100644 index c2a668faf..000000000 --- a/src/modules/core/var/root.txt +++ /dev/null @@ -1,55 +0,0 @@ -root:table -{ - section1:table - { - foo:string { "foo" } - bar:string { "bar" } - } - - messages:table - { - aMessage:string { "parameter 0: {0}, parameter 1: {1}" } - aMessage3Args:string { "p0: {0}, p2: {2}, p1: {1}" } - } - - metadata:table - { - title:string { "Title" } - creator:string { "Creator" } - album:string { "Album" } - year:string { "Year" } - genre:string { "Genre" } - description:string { "Description" } - format:string { "Format" } - length:string { "Length" } - bpm:string { "BPM" } - rating:string { "Rating" } - encoded_by:string { "Encoded by" } - track_number:string { "Track number" } - disc_number:string { "Disc number" } - mood:string { "Mood" } - publishing_label:string { "Publishing label" } - composer:string { "Composer" } - bitrate:string { "Bitrate" } - channels:string { "Channels" } - sample_rate:string { "Sample rate" } - encoding_software:string { "Encoding software" } - checksum:string { "Checksum" } - lyrics:string { "Lyrics" } - orchestra_or_band:string { "Orchestra or band" } - conductor:string { "Conductor" } - lyricist:string { "Lyricist" } - original_lyricist:string { "Original lyricist" } - radio_station_name:string { "Radio station name" } - audio_file_info_url:string { "File info web page" } - artist_url:string { "Artist web page" } - audio_source_url:string { "Source web page" } - radio_station_url:string { "Radio station web page" } - buy_cd_url:string { "Buy CD web page" } - isrc_number:string { "ISRC number" } - catalog_number:string { "Catalog number" } - original_artist:string { "Original artist" } - copyright:string { "Copyright" } - } -} - diff --git a/src/modules/core/var/test10001.mp3 b/src/modules/core/var/test10001.mp3 deleted file mode 100644 index 91f3dae0e..000000000 Binary files a/src/modules/core/var/test10001.mp3 and /dev/null differ diff --git a/src/modules/eventScheduler/bin/autogen.sh b/src/modules/eventScheduler/bin/autogen.sh deleted file mode 100755 index befe0ed10..000000000 --- a/src/modules/eventScheduler/bin/autogen.sh +++ /dev/null @@ -1,90 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.sourcefabric.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Run this to set up the build system: configure, makefiles, etc. -# (based on the version in enlightenment's cvs) -#------------------------------------------------------------------------------- - -package="EventScheduler" - -# assume we're in $basedir/bin -reldir=`dirname $0`/.. -basedir=`cd $reldir; pwd;` -test -z "$basedir" && basedir=. -usrdir=`cd $basedir/../../../usr; pwd;` - -bindir=$basedir/bin -etcdir=$basedir/etc -tmpdir=$basedir/tmp - -cd "$tmpdir" -DIE=0 - -(autoheader --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have autoconf installed to compile $package." - echo "Download the appropriate package for your distribution," - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" - DIE=1 -} - -(autoconf --version) < /dev/null > /dev/null 2>&1 || { - echo - echo "You must have autoconf installed to compile $package." - echo "Download the appropriate package for your distribution," - echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" - DIE=1 -} - -if test "$DIE" -eq 1; then - exit 1 -fi - -if test -z "$*"; then - echo "I am going to run ./configure with no arguments - if you wish " - echo "to pass any to it, please specify them on the $0 command line." -fi - -echo "Generating configuration files for $package, please wait...." - -configure_ac=${etcdir}/configure.ac -configure=${tmpdir}/configure -aclocal_m4=${tmpdir}/aclocal.m4 - -# copy over configure.ac and acinlclude.m4 from etc to tmp, -# as aclocal >= 1.8 is sooo unbelivably stupid that it will simply try to -# look for configure.ac in the current directory, and include acinclude.m4 -# in aclocal.m4 it without a directory path in front -ACLOCAL_FLAGS="-I ${tmpdir} --acdir=${tmpdir} --output=${aclocal_m4}" -echo " aclocal $ACLOCAL_FLAGS" -cp -f ${configure_ac} ${tmpdir} -cp -f ${etcdir}/acinclude.m4 ${tmpdir} -aclocal $ACLOCAL_FLAGS - -echo " autoheader ${configure_ac}" -autoheader ${configure_ac} - -echo " autoconf -I ${tmpdir} -o ${configure} ${configure_ac}" -autoconf -I ${tmpdir} -o ${configure} ${configure_ac} - diff --git a/src/modules/eventScheduler/bin/gen_coverage_data.sh b/src/modules/eventScheduler/bin/gen_coverage_data.sh deleted file mode 100755 index 52ad8fc6f..000000000 --- a/src/modules/eventScheduler/bin/gen_coverage_data.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/bash -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.sourcefabric.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- -#------------------------------------------------------------------------------- -# This script generates code coverage data for the module -#------------------------------------------------------------------------------- -module="Campcaster EventScheduler" - -reldir=`dirname $0`/.. -basedir=`cd $reldir; pwd;` -bindir=$basedir/bin -docdir=$basedir/doc -tmpdir=$basedir/tmp - -usrdir=`cd $basedir/../../../usr; pwd;` - -coverage_report_dir=$docdir/coverage - -raw_coverage_file=$tmpdir/raw_coverage.info -coverage_file=$tmpdir/coverage.info - -lcov=$usrdir/bin/lcov -genhtml=$usrdir/bin/genhtml - - -cd $basedir - -#------------------------------------------------------------------------------- -# Re-configure with covarege collection enabled, compile and run the tests -#------------------------------------------------------------------------------- -$bindir/autogen.sh --enable-coverage -make clean -make check - -#------------------------------------------------------------------------------- -# Generate some symlinks so that the sources are visible from tmpdir -#------------------------------------------------------------------------------- -ln -s $basedir/include $tmpdir/include -ln -s $basedir/src $tmpdir/src - - -#------------------------------------------------------------------------------- -# Use lcov to generate an HTML report on the coverage data -#------------------------------------------------------------------------------- -$lcov -d $tmpdir -c > $raw_coverage_file -$lcov -e $raw_coverage_file "$tmpdir/*" > $coverage_file -rm -rf $coverage_report_dir -mkdir -p $coverage_report_dir -$genhtml -t "$module" -o $coverage_report_dir $coverage_file - - -#------------------------------------------------------------------------------- -# Clean up -#------------------------------------------------------------------------------- -rm -f $tmpdir/include -rm -f $tmpdir/src diff --git a/src/modules/eventScheduler/configure b/src/modules/eventScheduler/configure deleted file mode 100755 index 0c58cc366..000000000 --- a/src/modules/eventScheduler/configure +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.campware.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Run this script to configure the environment. -# -# This script in effect calls the real automake / autoconf configure script -#------------------------------------------------------------------------------- - -# assume we're in $basedir -reldir=`dirname $0` -basedir=`cd $reldir; pwd;` -test -z "$basedir" && basedir=. - -bindir=$basedir/bin -tmpdir=$basedir/tmp - - -autogen=$bindir/autogen.sh -configure=$tmpdir/configure - -if [ ! -x $configure ]; then - (cd $basedir && $autogen "$@") -fi - -(cd $tmpdir && $configure "$@") - diff --git a/src/modules/eventScheduler/doc/.keepme b/src/modules/eventScheduler/doc/.keepme deleted file mode 100644 index e0808fa16..000000000 --- a/src/modules/eventScheduler/doc/.keepme +++ /dev/null @@ -1 +0,0 @@ -keep me diff --git a/src/modules/eventScheduler/etc/Makefile.in b/src/modules/eventScheduler/etc/Makefile.in deleted file mode 100644 index 2d0a8c248..000000000 --- a/src/modules/eventScheduler/etc/Makefile.in +++ /dev/null @@ -1,178 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.sourcefabric.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# @configure_input@ -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# General command definitions -#------------------------------------------------------------------------------- -MKDIR = mkdir -p -RM = rm -f -RMDIR = rm -rf -DOXYGEN = doxygen -CP = cp -f - - -#------------------------------------------------------------------------------- -# Basic directory and file definitions -#------------------------------------------------------------------------------- -BASE_DIR = @builddir@ -DOC_DIR = ${BASE_DIR}/doc -DOXYGEN_DIR = ${DOC_DIR}/doxygen -COVERAGE_DIR = ${DOC_DIR}/coverage -ETC_DIR = ${BASE_DIR}/etc -INCLUDE_DIR = ${BASE_DIR}/include -LIB_DIR = ${BASE_DIR}/lib -SRC_DIR = ${BASE_DIR}/src -TMP_DIR = ${BASE_DIR}/tmp - -prefix = @prefix@ - -USR_DIR = ${prefix} -USR_INCLUDE_DIR = ${USR_DIR}/include -USR_LIB_DIR = ${USR_DIR}/lib - -MODULES_DIR = ${BASE_DIR}/.. - -CORE_DIR = ${MODULES_DIR}/core -CORE_INCLUDE_DIR = ${CORE_DIR}/include -CORE_LIB_DIR = ${CORE_DIR}/lib -CORE_LIB = livesupport_core -CORE_LIB_FILE = ${CORE_LIB_DIR}/lib${CORE_LIB}.a - -VPATH = ${SRC_DIR} - -BOOST_CFLAGS=@BOOST_CPPFLAGS@ -BOOST_LIBS=@BOOST_LDFLAGS@ -BOOST_DATE_TIME_LIB=@BOOST_DATE_TIME_LIB@ - -LIBXMLPP_CFLAGS=@LIBXMLPP_CFLAGS@ -LIBXMLPP_LIBS=@LIBXMLPP_LIBS@ - -TEST_RESULTS = ${DOC_DIR}/testResults.xml -# the text result XSLT has to be relative to the test result file, e.g. TMP_DIR -TEST_XSLT = ../etc/testResultToHtml.xsl - -EVENT_SCHEDULER_LIB = livesupport_event_scheduler -EVENT_SCHEDULER_LIB_FILE = ${LIB_DIR}/lib${EVENT_SCHEDULER_LIB}.a -TEST_RUNNER = ${TMP_DIR}/testRunner - -DOXYGEN_CONFIG = ${ETC_DIR}/doxygen.config - -export LD_LIBRARY_PATH:=${USR_LIB_DIR}:${LD_LIBRARY_PATH} - - -#------------------------------------------------------------------------------- -# Configuration parameters -#------------------------------------------------------------------------------- -CPPFLAGS = @CPPFLAGS@ -CXXFLAGS = @CXXFLAGS@ @DEFS@ @COVERAGE_CXXFLAGS@ -pthread \ - -Wall -Wno-long-long \ - ${BOOST_CFLAGS} \ - ${LIBXMLPP_CFLAGS} \ - -I${USR_INCLUDE_DIR} \ - -I${CORE_INCLUDE_DIR} \ - -I${INCLUDE_DIR} -I${TMP_DIR} -LDFLAGS = @LDFLAGS@ -pthread \ - ${BOOST_LIBS} \ - ${LIBXMLPP_LIBS} \ - -L${USR_LIB_DIR} \ - -L${CORE_LIB_DIR} \ - -L${LIB_DIR} - - -#------------------------------------------------------------------------------- -# Dependencies -#------------------------------------------------------------------------------- -EVENT_SCHEDULER_LIB_OBJS = ${TMP_DIR}/SchedulerThread.o \ - ${TMP_DIR}/EventScheduler.o -TEST_RUNNER_OBJS = ${TMP_DIR}/TestScheduledEvent.o \ - ${TMP_DIR}/TestEventContainer.o \ - ${TMP_DIR}/SchedulerThreadTest.o \ - ${TMP_DIR}/EventSchedulerTest.o \ - ${TMP_DIR}/TestRunner.o -TEST_RUNNER_LIBS = -l${EVENT_SCHEDULER_LIB} -l${CORE_LIB} \ - ${BOOST_DATE_TIME_LIB} \ - -lcppunit -ldl - - -#------------------------------------------------------------------------------- -# Targets -#------------------------------------------------------------------------------- -.PHONY: all dir_setup doc clean docclean depclean distclean check install - -all: dir_setup ${EVENT_SCHEDULER_LIB_FILE} - -dir_setup: ${TMP_DIR} ${DOXYGEN_DIR} - -doc: - ${DOXYGEN} ${DOXYGEN_CONFIG} - -clean: - ${RM} ${EVENT_SCHEDULER_LIB_OBJS} ${EVENT_SCHEDULER_LIB_FILE} - ${RM} ${TEST_RUNNER_OBJS} ${TEST_RUNNER} - ${RM} ${TMP_DIR}/*.bb ${TMP_DIR}/*.bbg ${TMP_DIR}/*.da ${TMP_DIR}/*.info - -docclean: - ${RMDIR} ${DOXYGEN_DIR}/html - ${RMDIR} ${COVERAGE_DIR}/* - ${RM} ${TEST_RESULTS} - -depclean: clean - -distclean: clean docclean - ${RMDIR} ${TMP_DIR}/config* ${TMP_DIR}/autom4te* ${TMP_DIR}/ac*.m4 - -check: all ${TEST_RUNNER} - ${TEST_RUNNER} -o ${TEST_RESULTS} -s ${TEST_XSLT} - -install: all - ${MKDIR} ${USR_INCLUDE_DIR}/LiveSupport/EventScheduler - ${CP} ${INCLUDE_DIR}/LiveSupport/EventScheduler/*.h \ - ${USR_INCLUDE_DIR}/LiveSupport/EventScheduler - ${CP} ${EVENT_SCHEDULER_LIB_FILE} ${USR_LIB_DIR} - - -#------------------------------------------------------------------------------- -# Specific targets -#------------------------------------------------------------------------------- -${EVENT_SCHEDULER_LIB_FILE}: ${EVENT_SCHEDULER_LIB_OBJS} - ${AR} crus $@ $^ - -${TMP_DIR}: - ${MKDIR} ${TMP_DIR} - -${DOXYGEN_DIR}: - ${MKDIR} ${DOXYGEN_DIR} - -${TEST_RUNNER}: ${CORE_LIB_FILE} ${TEST_RUNNER_OBJS} ${EVENT_SCHEDULER_LIB_FILE} - ${CXX} ${LDFLAGS} -o $@ ${TEST_RUNNER_OBJS} ${TEST_RUNNER_LIBS} - -${CORE_LIB_FILE}: - ${MAKE} -C ${CORE_DIR} - - -#------------------------------------------------------------------------------- -# Pattern rules -#------------------------------------------------------------------------------- -${TMP_DIR}/%.o : ${SRC_DIR}/%.cxx - ${CXX} ${CPPFLAGS} ${CXXFLAGS} -c -o $@ $< - diff --git a/src/modules/eventScheduler/etc/acinclude.m4 b/src/modules/eventScheduler/etc/acinclude.m4 deleted file mode 100644 index 314a5a258..000000000 --- a/src/modules/eventScheduler/etc/acinclude.m4 +++ /dev/null @@ -1,403 +0,0 @@ -dnl----------------------------------------------------------------------------- -dnl Copyright (c) 2010 Sourcefabric O.P.S. -dnl -dnl This file is part of the Campcaster project. -dnl http://campcaster.sourcefabric.org/ -dnl -dnl Campcaster is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2 of the License, or -dnl (at your option) any later version. -dnl -dnl Campcaster is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with Campcaster; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -dnl -dnl----------------------------------------------------------------------------- - -dnl----------------------------------------------------------------------------- -dnl Macro to check for available modules using pkg-conf -dnl -dnl usage: -dnl PKG_CHECK_MODULES(GSTUFF,[gtk+-2.0 >= 1.3], action-if, action-not) -dnl -dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page -dnl also defines GSTUFF_PKG_ERRORS on error -dnl -dnl This function was taken from the glade-- project -dnl----------------------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_MODULES], [ - succeeded=no - - if test -z "$PKG_CONFIG"; then - AC_PATH_PROG(PKG_CONFIG, pkg-config, no) - fi - - if test "$PKG_CONFIG" = "no" ; then - echo "*** The pkg-config script could not be found. Make sure it is" - echo "*** in your path, or set the PKG_CONFIG environment variable" - echo "*** to the full path to pkg-config." - echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config." - else - PKG_CONFIG_MIN_VERSION=0.9.0 - if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then - AC_MSG_CHECKING(for $2) - - if $PKG_CONFIG --exists "$2" ; then - AC_MSG_RESULT(yes) - succeeded=yes - - AC_MSG_CHECKING($1_CFLAGS) - $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` - AC_MSG_RESULT($$1_CFLAGS) - - AC_MSG_CHECKING($1_LIBS) - $1_LIBS=`$PKG_CONFIG --libs "$2"` - AC_MSG_RESULT($$1_LIBS) - else - $1_CFLAGS="" - $1_LIBS="" - ## If we have a custom action on failure, don't print errors, but - ## do set a variable so people can do so. - $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` - ifelse([$4], ,echo $$1_PKG_ERRORS,) - fi - - AC_SUBST($1_CFLAGS) - AC_SUBST($1_LIBS) - else - echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." - echo "*** See http://www.freedesktop.org/software/pkgconfig" - fi - fi - - if test $succeeded = yes; then - ifelse([$3], , :, [$3]) - else - ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4]) - fi -]) - - - -dnl----------------------------------------------------------------------------- -dnl Macro to check for C++ namespaces -dnl for more information on this macro, see -dnl http://autoconf-archive.cryp.to/ac_cxx_namespaces.html -dnl -dnl usage: -dnl If the compiler can prevent names clashes using namespaces, -dnl define HAVE_NAMESPACES. -dnl----------------------------------------------------------------------------- -AC_DEFUN([AC_CXX_NAMESPACES], -[AC_CACHE_CHECK(whether the compiler implements namespaces, -ac_cv_cxx_namespaces, -[AC_LANG_SAVE - AC_LANG_CPLUSPLUS - AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], - [using namespace Outer::Inner; return i;], - ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) - AC_LANG_RESTORE -]) -if test "$ac_cv_cxx_namespaces" = yes; then - AC_DEFINE(HAVE_NAMESPACES,,[define if the compiler implements namespaces]) -fi -]) - - -dnl----------------------------------------------------------------------------- -dnl Test for the Boost C++ libraries of a particular version (or newer). -dnl for more information on boost, see http://www.boost.org/ -dnl for more information on this macro, see -dnl http://autoconf-archive.cryp.to/ax_boost_base.html -dnl -dnl usage: -dnl If no path to the installed boost library is given the macro searches -dnl under ${prefix}, /usr, /usr/local, and /opt, and evaluates the $BOOST_ROOT -dnl environment variable. Further documentation is available at -dnl http://randspringer.de/boost/index.html -dnl -dnl This macro calls: AC_SUBST(BOOST_CPPFLAGS) and AC_SUBST(BOOST_LDFLAGS) -dnl and sets: HAVE_BOOST -dnl -dnl Modified for Campcaster: -dnl * --with-boost default changed to Yes; -dnl * if the library is not found, it does not die, just prints "no", leaves -dnl HAVE_BOOST undefined, and sets the BOOST_CPPFLAGS and BOOST_LDFLAGS -dnl variables to ""; -dnl * ${prefix} is prepended to the search path. -dnl -dnl Author: Thomas Porschberg -dnl -dnl License: -dnl Copyright © 2006 Thomas Porschberg -dnl Copying and distribution of this file, with or without modification, -dnl are permitted in any medium without royalty provided the copyright notice -dnl and this notice are preserved. -dnl----------------------------------------------------------------------------- -AC_DEFUN([AX_BOOST_BASE], -[ -AC_ARG_WITH([boost], - AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is Yes) - it is possible to specify the root directory for boost (optional)]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ac_boost_path="" - else - want_boost="yes" - ac_boost_path="$withval" - fi - ], - [want_boost="yes"]) - -if test "x$want_boost" = "xyes"; then - boost_lib_version_req=ifelse([$1], ,1.20.0,$1) - boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` - boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` - boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` - boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` - if test "x$boost_lib_version_req_sub_minor" = "x" ; then - boost_lib_version_req_sub_minor="0" - fi - WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` - AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) - succeeded=no - - dnl first we check the system location for boost libraries - dnl this location ist chosen if boost libraries are installed with the --layout=system option - dnl or if you install boost with RPM - if test "$ac_boost_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_path/lib" - BOOST_CPPFLAGS="-I$ac_boost_path/include" - else - for ac_boost_path_tmp in ${prefix} /usr /usr/local /opt ; do - if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then - BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib" - BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" - break; - fi - done - fi - - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - - - - dnl if we found no boost with system layout we search for boost libraries - dnl built and installed without the --layout=system option or for a staged(not installed) version - if test "x$succeeded" != "xyes"; then - _version=0 - if test "$ac_boost_path" != ""; then - BOOST_LDFLAGS="-L$ac_boost_path/lib" - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - fi - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" - done - fi - else - for ac_boost_path in /usr /usr/local /opt ; do - if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then - for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do - _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` - V_CHECK=`expr $_version_tmp \> $_version` - if test "$V_CHECK" = "1" ; then - _version=$_version_tmp - best_path=$ac_boost_path - fi - done - fi - done - - VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` - BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" - BOOST_LDFLAGS="-L$best_path/lib" - - if test "x$BOOST_ROOT" != "x"; then - if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then - version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` - stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` - stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` - V_CHECK=`expr $stage_version_shorten \>\= $_version` - if test "$V_CHECK" = "1" ; then - AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) - BOOST_CPPFLAGS="-I$BOOST_ROOT" - BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib" - fi - fi - fi - fi - - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_LANG_PUSH(C++) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ - @%:@include - ]], [[ - #if BOOST_VERSION >= $WANT_BOOST_VERSION - // Everything is okay - #else - # error Boost version is too old - #endif - ]])],[ - AC_MSG_RESULT(yes) - succeeded=yes - found_system=yes - ],[ - ]) - AC_LANG_POP([C++]) - fi - - if test "$succeeded" != "yes" ; then - BOOST_CPPFLAGS="" - BOOST_LDFLAGS="" - AC_MSG_RESULT(no) - else - AC_SUBST(BOOST_CPPFLAGS) - AC_SUBST(BOOST_LDFLAGS) - AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" -fi - -]) - - -dnl----------------------------------------------------------------------------- -dnl Test for Date_Time library from the Boost C++ libraries. -dnl for more information on boost, see http://www.boost.org/ -dnl for more information on this macro, see -dnl http://autoconf-archive.cryp.to/ax_boost_date_time.html -dnl -dnl usage: -dnl The macro requires a preceding call to AX_BOOST_BASE. -dnl Further documentation is available at -dnl . -dnl -dnl This macro calls: AC_SUBST(BOOST_DATE_TIME_LIB) -dnl and sets: HAVE_BOOST_DATE_TIME -dnl -dnl Modified for Campcaster: -dnl * --with-boost-date-time default changed to Yes. -dnl * added some more recognized suffixes to the library's name, incl. "-st". -dnl -dnl Authors: -dnl Thomas Porschberg -dnl Michael Tindal -dnl -dnl License: -dnl Copyright © 2006 Thomas Porschberg -dnl Copying and distribution of this file, with or without modification, -dnl are permitted in any medium without royalty provided the copyright notice -dnl and this notice are preserved. -dnl----------------------------------------------------------------------------- -AC_DEFUN([AX_BOOST_DATE_TIME], -[ - AC_ARG_WITH([boost-date-time], - AS_HELP_STRING([--with-boost-date-time@<:@=special-lib@:>@], - [use the Date_Time library from boost - it is possible to specify a certain library for the linker - e.g. --with-boost-date-time=boost_date_time-gcc-mt-d-1_33_1 ]), - [ - if test "$withval" = "no"; then - want_boost="no" - elif test "$withval" = "yes"; then - want_boost="yes" - ax_boost_user_date_time_lib="" - else - want_boost="yes" - ax_boost_user_date_time_lib="$withval" - fi - ], - [want_boost="yes"] - ) - - if test "x$want_boost" = "xyes"; then - AC_REQUIRE([AC_PROG_CC]) - CPPFLAGS_SAVED="$CPPFLAGS" - CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" - export CPPFLAGS - - LDFLAGS_SAVED="$LDFLAGS" - LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" - export LDFLAGS - - AC_CACHE_CHECK(whether the Boost::Date_Time library is available, - ax_cv_boost_date_time, - [AC_LANG_PUSH([C++]) - AC_COMPILE_IFELSE(AC_LANG_PROGRAM([[@%:@include ]], - [[using namespace boost::gregorian; date d(2002,Jan,10); - return 0; - ]]), - ax_cv_boost_date_time=yes, ax_cv_boost_date_time=no) - AC_LANG_POP([C++]) - ]) - if test "x$ax_cv_boost_date_time" = "xyes"; then - AC_DEFINE(HAVE_BOOST_DATE_TIME,,[define if the Boost::Date_Time library is available]) - BN=boost_date_time - if test "x$ax_boost_user_date_time_lib" = "x"; then - for ax_lib in $BN $BN-st $BN-mt $BN-mt-s $BN-s \ - $BN-$CC $BN-$CC-st $BN-$CC-mt $BN-$CC-mt-s $BN-$CC-s \ - lib$BN lib$BN-st lib$BN-mt lib$BN-mt-s lib$BN-s \ - lib$BN-$CC lib$BN-$CC-st lib$BN-$CC-mt lib$BN-$CC-mt-s lib$BN-$CC-s \ - $BN-mgw $BN-mgw $BN-mgw-st $BN-mgw-mt $BN-mgw-mt-s $BN-mgw-s ; do - AC_CHECK_LIB($ax_lib, main, [BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break], - [link_date_time="no"]) - done - else - for ax_lib in $ax_boost_user_date_time_lib $BN-$ax_boost_user_date_time_lib; do - AC_CHECK_LIB($ax_lib, main, - [BOOST_DATE_TIME_LIB="-l$ax_lib" AC_SUBST(BOOST_DATE_TIME_LIB) link_date_time="yes" break], - [link_date_time="no"]) - done - - fi - if test "x$link_date_time" = "xno"; then - AC_MSG_ERROR(Could not link against $ax_lib !) - fi - fi - - CPPFLAGS="$CPPFLAGS_SAVED" - LDFLAGS="$LDFLAGS_SAVED" - fi -]) - diff --git a/src/modules/eventScheduler/etc/configure.ac b/src/modules/eventScheduler/etc/configure.ac deleted file mode 100644 index 7d81cff76..000000000 --- a/src/modules/eventScheduler/etc/configure.ac +++ /dev/null @@ -1,114 +0,0 @@ -dnl----------------------------------------------------------------------------- -dnl Copyright (c) 2010 Sourcefabric O.P.S. -dnl -dnl This file is part of the Campcaster project. -dnl http://campcaster.sourcefabric.org/ -dnl -dnl Campcaster is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 2 of the License, or -dnl (at your option) any later version. -dnl -dnl Campcaster is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with Campcaster; if not, write to the Free Software -dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -dnl -dnl----------------------------------------------------------------------------- - -dnl----------------------------------------------------------------------------- -dnl NOTE: Run all configure related scripts from the tmp directory of the -dnl project. -dnl This is due to the fact that configure spreads a lot of trash around, -dnl like atom4te cache directories, config.* files, etc. into the directory -dnl it is being run from. We clearly don't want these in our base directory. -dnl----------------------------------------------------------------------------- -AC_INIT(EventScheduler, 0.0, bugs@campware.org) -AC_PREREQ(2.59) -AC_COPYRIGHT([Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL]) -AC_REVISION($Revision$) - -AC_CONFIG_SRCDIR(../src/SchedulerThread.cxx) - -AC_CONFIG_HEADERS(configure.h) -AC_PROG_CXX() - -AC_CHECK_HEADERS(getopt.h unistd.h sys/time.h) - - -dnl----------------------------------------------------------------------------- -dnl specify whether debug info should be compiled into the executable -dnl----------------------------------------------------------------------------- -AC_SUBST(CXXFLAGS) - -AC_ARG_ENABLE([debug], - AC_HELP_STRING([--enable-debug], [compile with debug info (no)]), - [], - [enable_debug=no]) - -if test "x${enable_debug}" = "xyes"; then - CXXFLAGS="-g -O0" - AC_DEFINE( YDEBUG, 1, [Debug is on] ) -else - CXXFLAGS="-O3" -fi - - -AC_MSG_RESULT([using compiler options: ${CXXFLAGS}]) - - -dnl----------------------------------------------------------------------------- -dnl specify the pkg-config path -dnl----------------------------------------------------------------------------- -AC_ARG_WITH([pkg-config-path], - AC_HELP_STRING([--with-pkg-config-path], - [use the pkg-config path (prefix/lib/pkgconfig)]), - [PKG_CONFIG_PATH=${withval}], - [PKG_CONFIG_PATH=${prefix}/lib/pkgconfig:$PKG_CONFIG_PATH]) - -AC_MSG_RESULT([using pkg-config path: ${PKG_CONFIG_PATH}]) - -export PKG_CONFIG_PATH - -export PATH=${prefix}/bin:${PATH} - - -AX_BOOST_BASE([1.33.1]) -if test "x${BOOST_CPPFLAGS}" != "x"; then - AX_BOOST_DATE_TIME - if test "x${BOOST_DATE_TIME_LIB}" = "x"; then - AC_MSG_ERROR([Boost date-time library not found]) - fi -else - AC_MSG_ERROR([Boost library >= 1.33.1 not found]) -fi - -PKG_CHECK_MODULES(LIBXMLPP,[libxml++-2.6 >= 2.8.1]) -AC_SUBST(LIBXMLPP_CFLAGS) -AC_SUBST(LIBXMLPP_LIBS) - - -dnl----------------------------------------------------------------------------- -dnl enable compilaton for code coverage data -dnl----------------------------------------------------------------------------- -AC_SUBST(COVERAGE_CXXFLAGS) - -AC_ARG_ENABLE( coverage, -[ --enable-coverage enable code coverage data generaton (no) ], - ENABLE_COVERAGE=${enableval}, ENABLE_COVERAGE="no" ) - -if test "x${ENABLE_COVERAGE}" == "xyes" ; then - COVERAGE_CXXFLAGS="-fprofile-arcs -ftest-coverage" - AC_MSG_RESULT([compiling in code coverage mode]) -else - AC_MSG_RESULT([not compiling in code coverage mode]) -fi - - -AC_CONFIG_FILES(../Makefile:../etc/Makefile.in) - -AC_OUTPUT() diff --git a/src/modules/eventScheduler/etc/doxygen.config b/src/modules/eventScheduler/etc/doxygen.config deleted file mode 100644 index f03486e9f..000000000 --- a/src/modules/eventScheduler/etc/doxygen.config +++ /dev/null @@ -1,1139 +0,0 @@ -#------------------------------------------------------------------------------- -# Copyright (c) 2010 Sourcefabric O.P.S. -# -# This file is part of the Campcaster project. -# http://campcaster.sourcefabric.org/ -# -# Campcaster 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 of the License, or -# (at your option) any later version. -# -# Campcaster 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 Campcaster; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -#------------------------------------------------------------------------------- - -# Doxyfile 1.3.6 - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = Campcaster - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = 0.0 - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = doc/doxygen - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, Dutch, -# Finnish, French, German, Greek, Hungarian, Italian, Japanese, Japanese-en -# (Japanese with English messages), Korean, Korean-en, Norwegian, Polish, Portuguese, -# Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is used -# as the annotated text. Otherwise, the brief description is used as-is. If left -# blank, the following values are used ("$name" is automatically replaced with the -# name of the entity): "The $name class" "The $name widget" "The $name file" -# "is" "provides" "specifies" "contains" "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all inherited -# members of a class in the documentation of that class as if those members were -# ordinary class members. Constructors, destructors and assignment operators of -# the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = NO - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. It is allowed to use relative paths in the argument list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = YES - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C sources -# only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = YES - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# users are advised to set this option to NO. - -CASE_SENSE_NAMES = YES - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = include src - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx *.hpp -# *.h++ *.idl *.odl *.cs *.php *.php3 *.inc - -FILE_PATTERNS = - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or directories -# that are symbolic links (a Unix filesystem feature) are excluded from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. - -INPUT_FILTER = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = YES - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = YES - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = include - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. - -PREDEFINED = - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse the -# parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base or -# super classes. Setting the tag to NO turns the diagrams off. Note that this -# option is superseded by the HAVE_DOT option below. This is only a fallback. It is -# recommended to install and use dot, since it yields more powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found on the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes that -# lay further from the root node will be omitted. Note that setting this option to -# 1 or 2 may greatly reduce the computation time needed for large code bases. Also -# note that a graph may be further truncated if the graph's image dimensions are -# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). -# If 0 is used for the depth value (the default), the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/src/modules/eventScheduler/etc/testResultToHtml.xsl b/src/modules/eventScheduler/etc/testResultToHtml.xsl deleted file mode 100644 index f9e893521..000000000 --- a/src/modules/eventScheduler/etc/testResultToHtml.xsl +++ /dev/null @@ -1,63 +0,0 @@ - - - - - - - Campcaster unit test results - - -

Preface

-This document is part of the -Campcaster -project, Copyright © 2004 Media -Development Loan Fund, under the GNU -GPL. -
-This is an automatically generated document. -

Scope

-This document contains the generated unit test results for the -Campcaster project. -

Summary

- - - - - - - - - - - - - - - - - - -
Total number of tests:
Tests passed:
Tests failed:
Test errors:
-
-

Tests

- - - - - - - - - - - - - -
test nametest status
failedpassed
- - -
- -
- diff --git a/src/modules/eventScheduler/include/LiveSupport/EventScheduler/EventContainerInterface.h b/src/modules/eventScheduler/include/LiveSupport/EventScheduler/EventContainerInterface.h deleted file mode 100644 index 5cb320345..000000000 --- a/src/modules/eventScheduler/include/LiveSupport/EventScheduler/EventContainerInterface.h +++ /dev/null @@ -1,108 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_EventScheduler_EventContainerInterface_h -#define LiveSupport_EventScheduler_EventContainerInterface_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/EventScheduler/ScheduledEventInterface.h" - - -namespace LiveSupport { -namespace EventScheduler { - -using namespace boost::posix_time; - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Base interface for providing the events to get schedulerd by the - * EventScheduler. - */ -class EventContainerInterface -{ - public: - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~EventContainerInterface(void) throw () - { - } - - /** - * Return the first event after the specified timepoint. - * - * @param when return the first event after this timepoint, - * @return the first event to schedule after the specified - * timepoint. may be a reference to 0, if currently - * there are no known events after the specified time. - */ - virtual Ptr::Ref - getNextEvent(Ptr::Ref when) throw () = 0; - - - /** - * Return current event - * - * @param - * @return the first event to schedule at this point in time - * may be a reference to 0, if there are no known events at this time - */ - virtual Ptr::Ref - getCurrentEvent() throw () = 0; -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace EventScheduler -} // namespace LiveSupport - - -#endif // LiveSupport_EventScheduler_EventContainerInterface_h - diff --git a/src/modules/eventScheduler/include/LiveSupport/EventScheduler/EventScheduler.h b/src/modules/eventScheduler/include/LiveSupport/EventScheduler/EventScheduler.h deleted file mode 100644 index c26c0de9b..000000000 --- a/src/modules/eventScheduler/include/LiveSupport/EventScheduler/EventScheduler.h +++ /dev/null @@ -1,133 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_EventScheduler_EventScheduler_h -#define LiveSupport_EventScheduler_EventScheduler_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Thread.h" -#include "LiveSupport/Core/RunnableInterface.h" -#include "LiveSupport/EventScheduler/EventContainerInterface.h" - - -namespace LiveSupport { -namespace EventScheduler { - -using namespace boost::posix_time; - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A generic event scheduler, for non-everlapping subsequent events. - */ -class EventScheduler -{ - private: - /** - * The thread of the scheduler. - */ - Ptr::Ref thread; - - /** - * The scheduler thread runnable object. - */ - Ptr::Ref runnable; - - - public: - /** - * Constructor. - * - * @param eventContainer the container this thread will get its - * events to schedule from. - * @param granularity the granularity of the thread: the time the - * thread will sleep between checking up on things. - */ - EventScheduler(Ptr::Ref eventContainer, - Ptr::Ref granularity) - throw (); - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~EventScheduler(void) throw () - { - } - - /** - * Start the event scheduler. - * This function starts the event scheduler in the background, - * and returns immediately. - */ - virtual void - start(void) throw (); - - /** - * Forces the scheduler to re-read its event container. - * Call this if the events held in the event container have - * changed. - */ - virtual void - update(void) throw (); - - /** - * Stop the event scheduler. - */ - virtual void - stop(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace EventScheduler -} // namespace LiveSupport - - -#endif // LiveSupport_EventScheduler_EventScheduler_h - diff --git a/src/modules/eventScheduler/include/LiveSupport/EventScheduler/ScheduledEventInterface.h b/src/modules/eventScheduler/include/LiveSupport/EventScheduler/ScheduledEventInterface.h deleted file mode 100644 index 3d38341f7..000000000 --- a/src/modules/eventScheduler/include/LiveSupport/EventScheduler/ScheduledEventInterface.h +++ /dev/null @@ -1,162 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef LiveSupport_EventScheduler_ScheduledEventInterface_h -#define LiveSupport_EventScheduler_ScheduledEventInterface_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/Ptr.h" - - -namespace LiveSupport { -namespace EventScheduler { - -using namespace boost::posix_time; - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * The base class for all events scheduled by the EventScheduler. - * Subclass this one, and implement the necessary functions to have - * a class that can be scheduled. - * - * The lifetime of the scheduled event is as follows, if it is scheduled - * to start at time S and end at time E, where E = S + event.eventLength(): - *
    - *
  • latest at S - event.maxTimeToInitialize(): event.initialize()
  • - *
  • at S: event.start()
  • - *
  • at E: event.stop()
  • - *
  • after E: event.deInitialize()
  • - *
- */ -class ScheduledEventInterface -{ - public: - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~ScheduledEventInterface(void) throw () - { - } - - /** - * Tell the time this event is scheduled for. - * - * @return the time this event is scheduled for. - */ - virtual Ptr::Ref - getScheduledTime(void) throw () = 0; - - /** - * Initialize the event object. - * This should finishin at most maxTimeToInitialize() time. - * Use this call to allocate any resources that will be needed - * by the event itself. - * - * @exception std::exception on initialization problems. - * a raised exception will result in the cancellation - * of the event. - * @see #maxTimeToInitialize - */ - virtual void - initialize(void) throw (std::exception) = 0; - - /** - * The maximum time for the initalize() function to complete. - * It is the responsibility of the ScheduledEventInterface object to - * complete the initialization in that time. - * - * @return the maximum time for the initialize() function to complete. - * @see #initialize - */ - virtual Ptr::Ref - maxTimeToInitialize(void) throw () = 0; - - /** - * De-initialize the event object. - */ - virtual void - deInitialize(void) throw () = 0; - - /** - * Start the event. - * This function call should start the execution of the event in - * a separate thread, and return immediately. - */ - virtual void - start(Ptr::Ref offset) throw () = 0; - - /** - * The length of the event. - * The scheduler will call stop() when this much time has passed - * after calling start(). - * - * @return the length of the event, in time. - */ - virtual Ptr::Ref - eventLength(void) throw () = 0; - - /** - * Stop the event. - * This function call should result in the event stopping, if - * this has not happened yet. The event execution should be stopped - * and ready to be de-initialized after this call returns. - */ - virtual void - stop(void) throw () = 0; -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace EventScheduler -} // namespace LiveSupport - - -#endif // LiveSupport_EventScheduler_ScheduledEventInterface_h - diff --git a/src/modules/eventScheduler/lib/.keepme b/src/modules/eventScheduler/lib/.keepme deleted file mode 100644 index e0808fa16..000000000 --- a/src/modules/eventScheduler/lib/.keepme +++ /dev/null @@ -1 +0,0 @@ -keep me diff --git a/src/modules/eventScheduler/src/EventScheduler.cxx b/src/modules/eventScheduler/src/EventScheduler.cxx deleted file mode 100644 index 11d8b747a..000000000 --- a/src/modules/eventScheduler/src/EventScheduler.cxx +++ /dev/null @@ -1,92 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/Core/TimeConversion.h" -#include "LiveSupport/EventScheduler/EventScheduler.h" - -#include "SchedulerThread.h" - - -using namespace LiveSupport::Core; -using namespace LiveSupport::EventScheduler; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -LiveSupport::EventScheduler::EventScheduler :: EventScheduler( - Ptr::Ref eventContainer, - Ptr::Ref granularity) - throw () -{ - runnable.reset(new SchedulerThread(eventContainer, granularity)); - thread.reset(new Thread(runnable)); -} - - -/*------------------------------------------------------------------------------ - * Start the event scheduler. - *----------------------------------------------------------------------------*/ -void -LiveSupport::EventScheduler::EventScheduler :: start(void) throw () -{ - thread->start(); -} - - -/*------------------------------------------------------------------------------ - * Update the events. - *----------------------------------------------------------------------------*/ -void -LiveSupport::EventScheduler::EventScheduler :: update(void) throw () -{ - thread->signal(SchedulerThread::UpdateSignal); -} - - -/*------------------------------------------------------------------------------ - * Stop the event scheduler. - *----------------------------------------------------------------------------*/ -void -LiveSupport::EventScheduler::EventScheduler :: stop(void) throw () -{ - thread->stop(); - thread->join(); -} - diff --git a/src/modules/eventScheduler/src/EventSchedulerTest.cxx b/src/modules/eventScheduler/src/EventSchedulerTest.cxx deleted file mode 100644 index d5dbc6512..000000000 --- a/src/modules/eventScheduler/src/EventSchedulerTest.cxx +++ /dev/null @@ -1,230 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/TimeConversion.h" - -#include "LiveSupport/EventScheduler/EventScheduler.h" -#include "TestScheduledEvent.h" -#include "TestEventContainer.h" -#include "EventSchedulerTest.h" - - -using namespace boost::posix_time; - -using namespace LiveSupport::Core; -using namespace LiveSupport::EventScheduler; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(EventSchedulerTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -EventSchedulerTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -EventSchedulerTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * A simple test for the event scheduler thread - *----------------------------------------------------------------------------*/ -void -EventSchedulerTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref event; - Ptr::Ref container; - Ptr::Ref eventScheduler; - Ptr::Ref now; - Ptr::Ref when; - Ptr::Ref initTime; - Ptr::Ref eventLength; - Ptr::Ref granularity; - TestScheduledEvent::State state; - - /* time timeline for this test is: - initialize - 1sec, sometime before start - start - now + 5sec - stop - start + 3 sec - */ - - now = TimeConversion::now(); - when.reset(new ptime(*now + seconds(5))); - initTime.reset(new time_duration(seconds(1))); - eventLength.reset(new time_duration(seconds(3))); - granularity.reset(new time_duration(seconds(1))); - - event.reset(new TestScheduledEvent(when, initTime, eventLength)); - container.reset(new TestEventContainer(event)); - - eventScheduler.reset(new EventScheduler(container, granularity)); - - eventScheduler->start(); - - CPPUNIT_ASSERT(event->getState() == TestScheduledEvent::created); - state = event->getState(); - - for (bool running = true; running; ) { - // check for each state, and see if they are entered into in a correct - // order - now = TimeConversion::now(); - switch (event->getState()) { - case TestScheduledEvent::created: - CPPUNIT_ASSERT(state == TestScheduledEvent::created); - break; - - case TestScheduledEvent::initializing: - // as the init time is same as granularity, we will only - // see initializing once, and can assume that the previous - // state was 'created' - CPPUNIT_ASSERT(state == TestScheduledEvent::created); - break; - - case TestScheduledEvent::initialized: - CPPUNIT_ASSERT(state == TestScheduledEvent::initializing - || state == TestScheduledEvent::initialized); - break; - - case TestScheduledEvent::running: - CPPUNIT_ASSERT(state == TestScheduledEvent::initialized - || state == TestScheduledEvent::running); - // see if the state changed from initialized to running - // at the appropriate time - if (state == TestScheduledEvent::initialized) { - CPPUNIT_ASSERT(*when <= *now - && *now <= *when + *granularity); - } - break; - - case TestScheduledEvent::stopped: - CPPUNIT_ASSERT(state == TestScheduledEvent::running - || state == TestScheduledEvent::stopped); - break; - - case TestScheduledEvent::deInitialized: - // accept running as a possible previous state, as we might - // not catch the stopped state at all - CPPUNIT_ASSERT(state == TestScheduledEvent::running - || state == TestScheduledEvent::stopped); - running = false; - break; - - default: - CPPUNIT_FAIL("unrecognized event state"); - } - state = event->getState(); - TimeConversion::sleep(granularity); - } - - eventScheduler->stop(); -} - - -/*------------------------------------------------------------------------------ - * A test to see what happens, when an event is scheduled after it should - * have been initialized, but not to be started yet. - * See http://bugs.campware.org/view.php?id=757 for details. - *----------------------------------------------------------------------------*/ -void -EventSchedulerTest :: postInitTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref event; - Ptr::Ref container; - Ptr::Ref eventScheduler; - Ptr::Ref now; - Ptr::Ref when; - Ptr::Ref initTime; - Ptr::Ref eventLength; - Ptr::Ref granularity; - TestScheduledEvent::State state; - - /* time timeline for this test is: - initialize - 10 sec - start - now + 5sec - stop - start + 3 sec - */ - - now = TimeConversion::now(); - when.reset(new ptime(*now + seconds(5))); - initTime.reset(new time_duration(seconds(10))); - eventLength.reset(new time_duration(seconds(3))); - granularity.reset(new time_duration(seconds(1))); - - event.reset(new TestScheduledEvent(when, initTime, eventLength)); - container.reset(new TestEventContainer(event)); - - eventScheduler.reset(new EventScheduler(container, granularity)); - - eventScheduler->start(); - - CPPUNIT_ASSERT(event->getState() == TestScheduledEvent::created); - state = event->getState(); - - Ptr::Ref end(new ptime(*when + seconds(10))); - while (*TimeConversion::now() < *end) { - // nothing should happen here, just wait for some to see that - // indeed it doesn't - CPPUNIT_ASSERT(event->getState() == TestScheduledEvent::created); - TimeConversion::sleep(granularity); - } - - eventScheduler->stop(); -} - diff --git a/src/modules/eventScheduler/src/EventSchedulerTest.h b/src/modules/eventScheduler/src/EventSchedulerTest.h deleted file mode 100644 index ecc06031e..000000000 --- a/src/modules/eventScheduler/src/EventSchedulerTest.h +++ /dev/null @@ -1,111 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef EventSchedulerTest_h -#define EventSchedulerTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace EventScheduler { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the EventScheduler class. - * - * @see EventScheduler - */ -class EventSchedulerTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(EventSchedulerTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST(postInitTest); - CPPUNIT_TEST_SUITE_END(); - - private: - - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - /** - * A test to see if an event is scheduled after it should have - * been initialized (see http://bugs.campware.org/view.php?id=757) - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - postInitTest(void) throw (CPPUNIT_NS::Exception); - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace EventScheduler -} // namespace LiveSupport - -#endif // EventSchedulerTest_h - diff --git a/src/modules/eventScheduler/src/SchedulerThread.cxx b/src/modules/eventScheduler/src/SchedulerThread.cxx deleted file mode 100644 index 972c8e666..000000000 --- a/src/modules/eventScheduler/src/SchedulerThread.cxx +++ /dev/null @@ -1,235 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#define DEBUG_PREFIX "SchedulerThread" -#include "LiveSupport/Core/Debug.h" - -#include "LiveSupport/Core/TimeConversion.h" - -#include "SchedulerThread.h" - - -using namespace LiveSupport::Core; -using namespace LiveSupport::EventScheduler; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -SchedulerThread :: SchedulerThread( - Ptr::Ref eventContainer, - Ptr::Ref granularity) - throw () - : eventContainer(eventContainer), - granularity(granularity), - shouldRun(false) -{ - //DEBUG_FUNC_INFO -} - - -/*------------------------------------------------------------------------------ - * Get the next event from the eventContainer - *----------------------------------------------------------------------------*/ -void -SchedulerThread :: getNextEvent(Ptr::Ref when) throw () -{ - //DEBUG_FUNC_INFO - - nextEvent = eventContainer->getNextEvent(when); - if (nextEvent.get()) { - nextEventTime = nextEvent->getScheduledTime(); - nextInitTime.reset(new ptime(*nextEventTime - - *granularity - - *nextEvent->maxTimeToInitialize())); - nextEventEnd.reset(new ptime(*nextEventTime - + *nextEvent->eventLength())); - debug() << "::getNextEvent() - nextInitTime: " - << to_simple_string(*nextInitTime) << endl; - debug() << " - nextEventTime: " - << to_simple_string(*nextEventTime) << endl; - debug() << " - nextEventEnd: " - << to_simple_string(*nextEventEnd) << endl; - } -} - -/*------------------------------------------------------------------------------ - * Get the next event from the eventContainer - *----------------------------------------------------------------------------*/ -void -SchedulerThread :: getCurrentEvent() throw () -{ - //DEBUG_FUNC_INFO - - nextEvent = eventContainer->getCurrentEvent(); - if (nextEvent.get()) { - //fake these events here so we can preload - nextInitTime.reset(new ptime(*TimeConversion::now() + *granularity)); - nextEventTime.reset(new ptime(*nextInitTime + *nextEvent->maxTimeToInitialize())); - nextEventEnd.reset(new ptime(*nextEvent->getScheduledTime() - + *nextEvent->eventLength())); - debug() << "::getCurrentEvent() - nextInitTime: " - << to_simple_string(*nextInitTime) << endl; - debug() << " - nextEventTime: " - << to_simple_string(*nextEventTime) << endl; - debug() << " - nextEventEnd: " - << to_simple_string(*nextEventEnd) << endl; - } -} - - -/*------------------------------------------------------------------------------ - * The main execution body of the thread. - *----------------------------------------------------------------------------*/ -void -SchedulerThread :: nextStep(Ptr::Ref now) throw () -{ - nextEventMutex.lock(); - - if (nextEvent) { - if (imminent(now, nextInitTime)) { - preloadMutex.lock(); - debug() << "::nextStep() - Init [" << *TimeConversion::now() - << "]" << endl; - try { - nextEvent->initialize(); - } catch (std::exception &e) { - preloadMutex.unlock(); - // cancel event by getting the next event after this was - // supposed to finish - getNextEvent(nextEventEnd); - // TODO: log error - std::cerr << "event initialization error: " << e.what() - << std::endl; - } - } else if (imminent(now, nextEventTime)) { - Ptr::Ref timePassed(new time_duration(*now - - *nextEvent->getScheduledTime())); - Ptr::Ref timeNull(new time_duration(0, 0, 0, 0)); - if(*timePassed > *timeNull) { - debug() << "::nextStep() with offset - Start [" << *TimeConversion::now() - << "]" << endl; - nextEvent->start(timePassed); - } else { - Ptr::Ref timeLeft(new time_duration(*nextEventTime - - *now)); - TimeConversion::sleep(timeLeft); - debug() << "::nextStep() - Start [" << *TimeConversion::now() - << "]" << endl; - nextEvent->start(timeNull); - } - currentEvent = nextEvent; - currentEventEnd = nextEventEnd; - getNextEvent(TimeConversion::now()); - preloadMutex.unlock(); - } - } - - nextEventMutex.unlock(); - - if (currentEvent && imminent(now, currentEventEnd)) { - Ptr::Ref timeLeft(new time_duration(*currentEventEnd - - *now)); - TimeConversion::sleep(timeLeft); - currentEvent->stop(); - currentEvent->deInitialize(); - currentEvent.reset(); - debug() << "::nextStep() - End [" << *TimeConversion::now() - << "]" << endl; - } -} - - -/*------------------------------------------------------------------------------ - * The main execution body of the thread. - *----------------------------------------------------------------------------*/ -void -SchedulerThread :: run(void) throw () -{ - //DEBUG_FUNC_INFO - - shouldRun = true; - getCurrentEvent();//implements scheduler autostart -// getNextEvent(TimeConversion::now());//use if you do not want autostart - - while (shouldRun) { - Ptr::Ref start = TimeConversion::now(); - - nextStep(start); - - // sleep until the next granularity - Ptr::Ref end = TimeConversion::now(); - Ptr::Ref diff(new time_duration(*end - *start)); - if (*diff <= *granularity) { - Ptr::Ref sleepTime(new time_duration(*granularity - - *diff)); - TimeConversion::sleep(sleepTime); - } - } -} - - -/*------------------------------------------------------------------------------ - * Accept a signal. - *----------------------------------------------------------------------------*/ -void -SchedulerThread :: signal(int signalId) throw () -{ - //DEBUG_FUNC_INFO - debug() << "::signal() - [" << *TimeConversion::now() << "]" << endl; - - switch (signalId) { - case UpdateSignal: - if (nextEventMutex.tryLock()) { - if (preloadMutex.tryLock()) { - getNextEvent(TimeConversion::now()); - preloadMutex.unlock(); - nextEventMutex.unlock(); - } else { - nextEventMutex.unlock(); - } - } - break; - - default: - break; - } -} - - diff --git a/src/modules/eventScheduler/src/SchedulerThread.h b/src/modules/eventScheduler/src/SchedulerThread.h deleted file mode 100644 index 9f3e09a8b..000000000 --- a/src/modules/eventScheduler/src/SchedulerThread.h +++ /dev/null @@ -1,244 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef SchedulerThread_h -#define SchedulerThread_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - -#include "LiveSupport/Core/RunnableInterface.h" -#include "LiveSupport/Core/Mutex.h" -#include "LiveSupport/EventScheduler/ScheduledEventInterface.h" -#include "LiveSupport/EventScheduler/EventContainerInterface.h" - - -namespace LiveSupport { -namespace EventScheduler { - -using namespace boost::posix_time; - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * The main, executing thread of the scheduler. - */ -class SchedulerThread : public virtual RunnableInterface -{ - public: - /** - * Enumerated type for the signals accepted by this object. - * - * @see #signal - */ - typedef enum { UpdateSignal } SignalTypes; - - private: - /** - * The event container, to get the events from. - */ - Ptr::Ref eventContainer; - - /** - * The event which is being running now. - */ - Ptr::Ref currentEvent; - - /** - * The next event to execute. - */ - Ptr::Ref nextEvent; - - /** - * The execution time of the next event. - */ - Ptr::Ref nextEventTime; - - /** - * The time to start the initialization of the next event. - */ - Ptr::Ref nextInitTime; - - /** - * The ending time of the current event. - */ - Ptr::Ref currentEventEnd; - - /** - * The ending time of the next event. - */ - Ptr::Ref nextEventEnd; - - /** - * The granularity of the scheduler: the time it will sleep - * between checking up on the state of things. - */ - Ptr::Ref granularity; - - /** - * Flag indicating whether the thread should still run, or - * actually terminate. - */ - bool shouldRun; - - /** - * A mutex for getting the next event. - */ - Mutex nextEventMutex; - - /** - * A mutex for the preload. - */ - Mutex preloadMutex; - - /** - * Default constructor. - */ - SchedulerThread(void) throw () - { - } - - /** - * Get the next event. - * - * @param when get the first event after this specified time. - */ - void - getNextEvent(Ptr::Ref when) throw (); - - /** - * Get the current event. - * - * @param - */ - void - getCurrentEvent() throw (); - - /** - * Tell if the specified time falls within now and the next - * waking up. Basically tells if it is within now and - * now + granularity. - * - * @param now the current time. - * @param time check this time if it is imminent. - * @return true if the specified time falls within now and - * now + granularity, false otherwise. - */ - bool - imminent(Ptr::Ref now, - Ptr::Ref when) const throw () - { - return *when >= *now && (*now + *granularity) > *when; - } - - /** - * Execute the next step on the active event, if any is imminent. - * - * @param now the current time. - */ - void - nextStep(Ptr::Ref now) throw (); - - - public: - /** - * Constructor. - * - * @param eventContainer the container this thread will get its - * events to schedule from. - * @param granularity the granularity of the thread: the time the - * thread will sleep between checking up on things. - */ - SchedulerThread(Ptr::Ref eventContainer, - Ptr::Ref granularity) - throw (); - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~SchedulerThread(void) throw () - { - } - - /** - * The main execution loop for the thread. - */ - virtual void - run(void) throw (); - - /** - * Accept a signal. - * Currently supported signal values are: - *
    - *
  • UpdateSignal - re-read the event container
  • - *
- * - * @param signalId a value from SignalTypes. - * @see #SignalTypes - */ - virtual void - signal(int signalId) throw (); - - - /** - * Signal the thread to stop, gracefully. - */ - virtual void - stop(void) throw () - { - shouldRun = false; - } -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace EventScheduler -} // namespace LiveSupport - - -#endif // SchedulerThread_h - diff --git a/src/modules/eventScheduler/src/SchedulerThreadTest.cxx b/src/modules/eventScheduler/src/SchedulerThreadTest.cxx deleted file mode 100644 index 05c71cd75..000000000 --- a/src/modules/eventScheduler/src/SchedulerThreadTest.cxx +++ /dev/null @@ -1,181 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - - -#include -#include - -#include "LiveSupport/Core/TimeConversion.h" -#include "LiveSupport/Core/Thread.h" - -#include "SchedulerThread.h" -#include "TestScheduledEvent.h" -#include "TestEventContainer.h" -#include "SchedulerThreadTest.h" - - -using namespace boost::posix_time; - -using namespace LiveSupport::Core; -using namespace LiveSupport::EventScheduler; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -CPPUNIT_TEST_SUITE_REGISTRATION(SchedulerThreadTest); - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Set up the test environment - *----------------------------------------------------------------------------*/ -void -SchedulerThreadTest :: setUp(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * Clean up the test environment - *----------------------------------------------------------------------------*/ -void -SchedulerThreadTest :: tearDown(void) throw () -{ -} - - -/*------------------------------------------------------------------------------ - * A simple test for the event scheduler thread - *----------------------------------------------------------------------------*/ -void -SchedulerThreadTest :: firstTest(void) - throw (CPPUNIT_NS::Exception) -{ - Ptr::Ref event; - Ptr::Ref container; - Ptr::Ref thread; - Ptr::Ref schedulerThread; - Ptr::Ref now; - Ptr::Ref when; - Ptr::Ref initTime; - Ptr::Ref eventLength; - Ptr::Ref granularity; - TestScheduledEvent::State state; - - /* time timeline for this test is: - initialize - 1sec, sometime before start - start - now + 5sec - stop - start + 3 sec - */ - - now = TimeConversion::now(); - when.reset(new ptime(*now + seconds(5))); - initTime.reset(new time_duration(seconds(1))); - eventLength.reset(new time_duration(seconds(3))); - granularity.reset(new time_duration(seconds(1))); - - event.reset(new TestScheduledEvent(when, initTime, eventLength)); - container.reset(new TestEventContainer(event)); - - schedulerThread.reset(new SchedulerThread(container, granularity)); - thread.reset(new Thread(schedulerThread)); - - thread->start(); - - CPPUNIT_ASSERT(event->getState() == TestScheduledEvent::created); - state = event->getState(); - - for (bool running = true; running; ) { - // check for each state, and see if they are entered into in a correct - // order - now = TimeConversion::now(); - switch (event->getState()) { - case TestScheduledEvent::created: - CPPUNIT_ASSERT(state == TestScheduledEvent::created); - break; - - case TestScheduledEvent::initializing: - // as the init time is same as granularity, we will only - // see initializing once, and can assume that the previous - // state was 'created' - CPPUNIT_ASSERT(state == TestScheduledEvent::created); - break; - - case TestScheduledEvent::initialized: - CPPUNIT_ASSERT(state == TestScheduledEvent::initializing - || state == TestScheduledEvent::initialized); - break; - - case TestScheduledEvent::running: - CPPUNIT_ASSERT(state == TestScheduledEvent::initialized - || state == TestScheduledEvent::running); - // see if the state changed from initialized to running - // at the appropriate time - if (state == TestScheduledEvent::initialized) { - CPPUNIT_ASSERT(*when <= *now - && *now <= *when + *granularity); - } - break; - - case TestScheduledEvent::stopped: - CPPUNIT_ASSERT(state == TestScheduledEvent::running - || state == TestScheduledEvent::stopped); - break; - - case TestScheduledEvent::deInitialized: - // accept running as a possible previous state, as we might - // not catch the stopped state at all - CPPUNIT_ASSERT(state == TestScheduledEvent::running - || state == TestScheduledEvent::stopped); - running = false; - break; - - default: - CPPUNIT_FAIL("unrecognized event state"); - } - state = event->getState(); - TimeConversion::sleep(granularity); - } - - thread->stop(); - thread->join(); -} - diff --git a/src/modules/eventScheduler/src/SchedulerThreadTest.h b/src/modules/eventScheduler/src/SchedulerThreadTest.h deleted file mode 100644 index 609eb7563..000000000 --- a/src/modules/eventScheduler/src/SchedulerThreadTest.h +++ /dev/null @@ -1,101 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef SchedulerThreadTest_h -#define SchedulerThreadTest_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include - - -namespace LiveSupport { -namespace EventScheduler { - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * Unit test for the SchedulerThread class. - * - * @see EventScheduler - */ -class SchedulerThreadTest : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE(SchedulerThreadTest); - CPPUNIT_TEST(firstTest); - CPPUNIT_TEST_SUITE_END(); - - private: - - - protected: - - /** - * A simple test. - * - * @exception CPPUNIT_NS::Exception on test failures. - */ - void - firstTest(void) throw (CPPUNIT_NS::Exception); - - public: - - /** - * Set up the environment for the test case. - */ - void - setUp(void) throw (); - - /** - * Clean up the environment after the test case. - */ - void - tearDown(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace EventScheduler -} // namespace LiveSupport - -#endif // SchedulerThreadTest_h - diff --git a/src/modules/eventScheduler/src/TestEventContainer.cxx b/src/modules/eventScheduler/src/TestEventContainer.cxx deleted file mode 100644 index 6909b4d05..000000000 --- a/src/modules/eventScheduler/src/TestEventContainer.cxx +++ /dev/null @@ -1,79 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_UNISTD_H -#include -#else -#error need unistd.h -#endif - - -#include "TestEventContainer.h" - - -using namespace LiveSupport::Core; -using namespace LiveSupport::EventScheduler; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -TestEventContainer :: TestEventContainer( - Ptr::Ref event) - throw () -{ - this->event = event; -} - - -/*------------------------------------------------------------------------------ - * Return the first scheduled event after the specified timepoint - *----------------------------------------------------------------------------*/ -Ptr::Ref -TestEventContainer :: getNextEvent(Ptr::Ref when) throw () -{ - if (*when < (*event->getScheduledTime() - *event->maxTimeToInitialize())) { - return event; - } else { - // return an empty reference - Ptr::Ref empty; - return empty; - } -} - diff --git a/src/modules/eventScheduler/src/TestEventContainer.h b/src/modules/eventScheduler/src/TestEventContainer.h deleted file mode 100644 index b07e14610..000000000 --- a/src/modules/eventScheduler/src/TestEventContainer.h +++ /dev/null @@ -1,109 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef TestEventContainer_h -#define TestEventContainer_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/EventScheduler/EventContainerInterface.h" - - -namespace LiveSupport { -namespace EventScheduler { - -using namespace boost::posix_time; - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * An event container for testing purposes. - */ -class TestEventContainer : public virtual EventContainerInterface -{ - private: - /** - * The only event that this container holds. - */ - Ptr::Ref event; - - - public: - /** - * Constructor. - * - * @param event the only event this container will hold. - */ - TestEventContainer(Ptr::Ref event) - throw (); - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~TestEventContainer(void) throw () - { - } - - /** - * Return the first event after the specified timepoint. - * - * @param when return the first event after this timepoint, - * @return the first event to schedule after the specified - * timepoint. may be a reference to 0, if currently - * there are no known events after the specified time. - */ - virtual Ptr::Ref - getNextEvent(Ptr::Ref when) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace EventScheduler -} // namespace LiveSupport - - -#endif // TestEventContainer_h - diff --git a/src/modules/eventScheduler/src/TestRunner.cxx b/src/modules/eventScheduler/src/TestRunner.cxx deleted file mode 100644 index 8ce1c29bb..000000000 --- a/src/modules/eventScheduler/src/TestRunner.cxx +++ /dev/null @@ -1,275 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#if HAVE_UNISTD_H -#include -#else -#error "Need unistd.h" -#endif - -#if HAVE_GETOPT_H -#include -#else -#error "Need getopt.h" -#endif - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "LiveSupport/Core/Ptr.h" - - -using namespace LiveSupport::Core; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - -/** - * Our copyright notice, should be at most 80 columns - */ -static const char copyrightNotice[] = - "Copyright (c) 2010 Sourcefabric O.P.S. under the GNU GPL"; - -/** - * String describing the short options. - */ -static const char options[] = "ho:s:v"; - -/** - * Structure describing the long options - */ -static const struct option longOptions[] = { - { "help", no_argument, 0, 'h' }, - { "output", required_argument, 0, 'o' }, - { "stylesheet", required_argument, 0, 's' }, - { "version", no_argument, 0, 'v' }, - { 0, 0, 0, 0 } -}; - -/** - * The encoding to use for the output file. - */ -static const std::string encoding = "utf-8"; - -/** - * The output XML file name. - */ -static Ptr::Ref xmlOutFileName; - -/** - * The XSLT attached to the output file. - */ -static Ptr::Ref xsltFileName; - - -/* =============================================== local function prototypes */ - -/** - * Print program version. - * - * @param os the std::ostream to print to. - */ -static void -printVersion ( std::ostream & os ); - -/** - * Print program usage information. - * - * @param invocation the command line command used to invoke this program. - * @param os the std::ostream to print to. - */ -static void -printUsage ( const char invocation[], - std::ostream & os ); - -/** - * Process command line arguments. - * - * @param argc the number of arguments. - * @param argv the arguments themselves. - * @return true of all went well, false in case the program should exit - * after this call. - */ -static bool -processArguments(int argc, char *argv[]); - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Run all tests - *----------------------------------------------------------------------------*/ -int -main( int argc, - char * argv[] ) throw () -{ - if (!processArguments(argc, argv)) { - return 0; - } - - // Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // Add a listener that colllects test result - CPPUNIT_NS::TestResultCollector result; - controller.addListener( &result ); - - // Add a listener that print dots as test run. - CPPUNIT_NS::BriefTestProgressListener progress; - controller.addListener( &progress ); - - // Add the top suite to the test runner - CPPUNIT_NS::TestRunner runner; - runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); - runner.run( controller ); - - // Print test in a compiler compatible format. - CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr ); - outputter.setLocationFormat("%p:%l:"); - outputter.write(); - - // also generate an XML document as an output - std::ofstream xmlOutFile(xmlOutFileName->c_str()); - CPPUNIT_NS::XmlOutputter xmlOutputter(&result, xmlOutFile, encoding); - xmlOutputter.setStandalone(false); - if (xsltFileName) { - xmlOutputter.setStyleSheet(*xsltFileName); - } - xmlOutputter.write(); - xmlOutFile.flush(); - xmlOutFile.close(); - - return result.wasSuccessful() ? 0 : 1; -} - - -/*------------------------------------------------------------------------------ - * Process command line arguments. - *----------------------------------------------------------------------------*/ -static bool -processArguments(int argc, char *argv[]) -{ - int i; - - while ((i = getopt_long(argc, argv, options, longOptions, 0)) != -1) { - switch (i) { - case 'h': - printUsage(argv[0], std::cout); - return false; - - case 'o': - xmlOutFileName.reset(new std::string(optarg)); - break; - - case 's': - xsltFileName.reset(new std::string(optarg)); - break; - - case 'v': - printVersion(std::cout); - return false; - - default: - printUsage(argv[0], std::cout); - return false; - } - } - - if (optind < argc) { - std::cerr << "error processing command line arguments" << std::endl; - printUsage(argv[0], std::cout); - return false; - } - - if (!xmlOutFileName) { - std::cerr << "mandatory option output file name not specified" - << std::endl; - printUsage(argv[0], std::cout); - return false; - } - - std::cerr << "writing output to '" << *xmlOutFileName << '\'' << std::endl; - if (xsltFileName) { - std::cerr << "using XSLT file '" << *xsltFileName << '\'' << std::endl; - } - - return true; -} - - -/*------------------------------------------------------------------------------ - * Print program version. - *----------------------------------------------------------------------------*/ -static void -printVersion ( std::ostream & os ) -{ - os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl - << "Unit test runner" << std::endl - << copyrightNotice << std::endl; -} - - -/*------------------------------------------------------------------------------ - * Print program usage. - *----------------------------------------------------------------------------*/ -static void -printUsage ( const char invocation[], - std::ostream & os ) -{ - os << PACKAGE_NAME << ' ' << PACKAGE_VERSION << std::endl - << "Unit test runner" << std::endl - << std::endl - << "Usage: " << invocation << " [OPTION]" - << std::endl - << " mandatory options:" << std::endl - << " -o, --output=file.name write test results into this XML file" - << std::endl - << " optional options:" << std::endl - << " -s, --stylesheet specify this XSLT for the output file" - << std::endl - << " this is either an absolute URI, or a" - << std::endl - << " relative path for the output document" - << std::endl - << " -h, --help display this help and exit" << std::endl - << " -v, --version display version information and exit" - << std::endl - << std::endl - << "Report bugs to " << PACKAGE_BUGREPORT << std::endl; -} - diff --git a/src/modules/eventScheduler/src/TestScheduledEvent.cxx b/src/modules/eventScheduler/src/TestScheduledEvent.cxx deleted file mode 100644 index b94c12db4..000000000 --- a/src/modules/eventScheduler/src/TestScheduledEvent.cxx +++ /dev/null @@ -1,111 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#ifdef HAVE_UNISTD_H -#include -#else -#error need unistd.h -#endif - -#include "LiveSupport/Core/TimeConversion.h" - -#include "TestScheduledEvent.h" - - -using namespace LiveSupport::Core; -using namespace LiveSupport::EventScheduler; - -/* =================================================== local data structures */ - - -/* ================================================ local constants & macros */ - - -/* =============================================== local function prototypes */ - - -/* ============================================================= module code */ - -/*------------------------------------------------------------------------------ - * Constructor. - *----------------------------------------------------------------------------*/ -TestScheduledEvent :: TestScheduledEvent( - Ptr::Ref when, - Ptr::Ref maxTimeToInitialize, - Ptr::Ref eventLength) - throw () -{ - this->when = when; - this->initTime = maxTimeToInitialize; - this->length = eventLength; - state = created; -} - - -/*------------------------------------------------------------------------------ - * Initialize the event object. - *----------------------------------------------------------------------------*/ -void -TestScheduledEvent :: initialize(void) throw (std::exception) -{ - state = initializing; - TimeConversion::sleep(initTime); - state = initialized; -} - - -/*------------------------------------------------------------------------------ - * Initialize the event object. - *----------------------------------------------------------------------------*/ -void -TestScheduledEvent :: deInitialize(void) throw () -{ - state = deInitialized; -} - - -/*------------------------------------------------------------------------------ - * Initialize the event object. - *----------------------------------------------------------------------------*/ -void -TestScheduledEvent :: start(void) throw () -{ - state = running; -} - - -/*------------------------------------------------------------------------------ - * Initialize the event object. - *----------------------------------------------------------------------------*/ -void -TestScheduledEvent :: stop(void) throw () -{ - state = stopped; -} - diff --git a/src/modules/eventScheduler/src/TestScheduledEvent.h b/src/modules/eventScheduler/src/TestScheduledEvent.h deleted file mode 100644 index fbf31e4ff..000000000 --- a/src/modules/eventScheduler/src/TestScheduledEvent.h +++ /dev/null @@ -1,213 +0,0 @@ -/*------------------------------------------------------------------------------ - - Copyright (c) 2010 Sourcefabric O.P.S. - - This file is part of the Campcaster project. - http://campcaster.sourcefabric.org/ - - Campcaster 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 of the License, or - (at your option) any later version. - - Campcaster 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 Campcaster; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -------------------------------------------------------------------------------*/ -#ifndef TestScheduledEvent_h -#define TestScheduledEvent_h - -#ifndef __cplusplus -#error This is a C++ include file -#endif - - -/* ============================================================ include files */ - -#ifdef HAVE_CONFIG_H -#include "configure.h" -#endif - -#include "LiveSupport/EventScheduler/ScheduledEventInterface.h" - - -namespace LiveSupport { -namespace EventScheduler { - -using namespace boost::posix_time; - -using namespace LiveSupport; -using namespace LiveSupport::Core; - -/* ================================================================ constants */ - - -/* =================================================================== macros */ - - -/* =============================================================== data types */ - -/** - * A scheduled event for testing purposes. - */ -class TestScheduledEvent : public virtual ScheduledEventInterface -{ - public: - /** - * Enumeration describing the possible states of the event. - */ - typedef enum { created, - initializing, - initialized, - running, - stopped, - deInitialized } State; - - private: - /** - * The time this event is scheduled for. - */ - Ptr::Ref when; - - /** - * The maximum time this event should get initialized. - */ - Ptr::Ref initTime; - - /** - * The length of the event. - */ - Ptr::Ref length; - - /** - * The current state of the event. - */ - State state; - - public: - /** - * Constructor. - * - * @param when the time this event is scheduled for. - * @param maxTimeToInitialize the maximum time for this event - * to initialize. - * @param eventLength the length of the event. - */ - TestScheduledEvent(Ptr::Ref when, - Ptr::Ref maxTimeToInitialize, - Ptr::Ref eventLength) - throw (); - - /** - * A virtual destructor, as this class has virtual functions. - */ - virtual - ~TestScheduledEvent(void) throw () - { - } - - /** - * Return the current state of the event. - */ - virtual State - getState(void) const throw () - { - return state; - } - - /** - * Tell the time this event is scheduled for. - * - * @return the time this event is scheduled for. - */ - virtual Ptr::Ref - getScheduledTime(void) throw () - { - return when; - } - - /** - * Initialize the event object. - * This should finishin at most maxTimeToInitialize() time. - * Use this call to allocate any resources that will be needed - * by the event itself. - * - * @exception std::exception on initialization problems. - * a raised exception will result in the cancellation - * of the event. - * @see #maxTimeToInitialize - */ - virtual void - initialize(void) throw (std::exception); - - /** - * The maximum time for the initalize() function to complete. - * It is the responsibility of the ScheduledEventInterface object to - * complete the initialization in that time. - * - * @return the maximum time for the initialize() function to complete. - * @see #initialize - */ - virtual Ptr::Ref - maxTimeToInitialize(void) throw () - { - return initTime; - } - - /** - * De-initialize the event object. - */ - virtual void - deInitialize(void) throw (); - - /** - * Start the event. - * This function call should start the execution of the event in - * a separate thread, and return immediately. - */ - virtual void - start(void) throw (); - - /** - * The length of the event. - * The scheduler will call stop() when this much time has passed - * after calling start(). - * - * @return the length of the event, in time. - */ - virtual Ptr::Ref - eventLength(void) throw () - { - return length; - } - - /** - * Stop the event. - * This function call should result in the event stopping, if - * this has not happened yet. The processing of this event should - * persue in a seperate thread, and the function itself should - * return immediately. - */ - virtual void - stop(void) throw (); -}; - - -/* ================================================= external data structures */ - - -/* ====================================================== function prototypes */ - - -} // namespace EventScheduler -} // namespace LiveSupport - - -#endif // TestScheduledEvent_h - diff --git a/src/modules/eventScheduler/tmp/.keepme b/src/modules/eventScheduler/tmp/.keepme deleted file mode 100644 index e0808fa16..000000000 --- a/src/modules/eventScheduler/tmp/.keepme +++ /dev/null @@ -1 +0,0 @@ -keep me