From 39fbfd5eb7e45d73d38e8a2ce9437a3d7e1b8e91 Mon Sep 17 00:00:00 2001 From: pohly Date: Thu, 05 May 2005 14:39:33 +0000 Subject: new opie-reader sources with support for ArriereGo, Reb input and flite output plugins --- (limited to 'noncore/apps/opie-reader/outputcodec.h') diff --git a/noncore/apps/opie-reader/outputcodec.h b/noncore/apps/opie-reader/outputcodec.h new file mode 100644 index 0000000..727575c --- a/dev/null +++ b/noncore/apps/opie-reader/outputcodec.h @@ -0,0 +1,84 @@ +#include +#include +#include + +#ifdef USEQPE +#include +#endif + +class COutput +{ + public: + virtual ~COutput() {} + virtual void output(const QString&) = 0; + virtual QString about() = 0; +}; + +#ifndef __STATIC +#include +class outputcodec : public COutput +{ + COutput *codec; + void *handle; + int status; + public: + void output(const QString& q) { codec->output(q); } + QString about() + { + return QString("Plug-in output codec interface (c) Tim Wentford\n")+codec->about(); + } + outputcodec(const QString& _s) : codec(NULL), handle(NULL), status(-1) + { +#ifdef USEQPE +#ifdef OPIE + QString codecpath(getenv("OPIEDIR")); +#else + QString codecpath(getenv("QTDIR")); +#endif + codecpath += "/plugins/reader/outcodecs/lib"; +#else + QString codecpath(getenv("READERDIR")); + codecpath += "/outcodecs/lib"; +#endif + codecpath += _s; + codecpath += ".so"; + if (QFile::exists(codecpath)) + { + qDebug("Codec:%s", (const char*)codecpath); + handle = dlopen(codecpath, RTLD_LAZY); + if (handle == 0) + { + qDebug("Can't find codec:%s", dlerror()); + status = -10; + return; + } + COutput* (*newcodec)(); + newcodec = (COutput* (*)())dlsym(handle, "newcodec"); + if (newcodec == NULL) + { + qDebug("Can't find newcodec"); + status = -20; + return; + } + codec = (*newcodec)(); + status = 0; + } + else + { + qDebug("Can't find codec:%s", (const char*)codecpath); + } + if (codec == NULL) + { + qDebug("Can't do newcodec"); + status = -30; + return; + } + } + virtual ~outputcodec() + { + if (codec != NULL) delete codec; + if (handle != NULL) dlclose(handle); + } + int getStatus() { return status; } +}; +#endif -- cgit v0.9.0.2