#TUXBOX_APPS_LIB_PKGCONFIG(FRIBIDI,fribidi)
TUXBOX_APPS_LIB_PKGCONFIG(ID3TAG,id3tag)
TUXBOX_APPS_LIB_PKGCONFIG(MAD,mad)
-TUXBOX_APPS_LIB_PKGCONFIG(MD5SUM,tuxbox-md5sum)
#TUXBOX_APPS_LIB_PKGCONFIG(PLUGINS,tuxbox-plugins)
TUXBOX_APPS_LIB_PKGCONFIG(PNG,libpng)
TUXBOX_APPS_LIB_PKGCONFIG(SIGC,sigc++-1.2)
TUXBOX_APPS_LIB_PKGCONFIG(XMLTREE,tuxbox-xmltree)
-CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS $FRIBIDI_CFLAGS $ID3TAG_CFLAGS $MAD_CFLAGS $MD5SUM_CFLAGS $PLUGINS_CFLAGS $PNG_CFLAGS $SIGC_CFLAGS $XMLTREE_CFLAGS"
-CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions"
+CPPFLAGS="$CPPFLAGS $FREETYPE_CFLAGS $FRIBIDI_CFLAGS $ID3TAG_CFLAGS $MAD_CFLAGS $PLUGINS_CFLAGS $PNG_CFLAGS $SIGC_CFLAGS $XMLTREE_CFLAGS"
+CXXFLAGS="$CXXFLAGS -fno-rtti -fno-exceptions -Wall"
TUXBOX_APPS_GETTEXT
Makefile
lib/Makefile
lib/base/Makefile
+lib/content/Makefile
lib/driver/Makefile
lib/dvb/Makefile
lib/dvb_si/Makefile
lib/gui/Makefile
lib/nav/Makefile
lib/network/Makefile
+lib/python/Makefile
lib/service/Makefile
main/Makefile
])
-SUBDIRS = base dvb dvb_si gdi network service driver nav content gui
+SUBDIRS = base dvb dvb_si gdi network service driver nav content gui python
noinst_LIBRARIES = libenigma_base.a
libenigma_base_a_SOURCES = \
- buffer.cpp console.cpp ebase.cpp econfig.cpp eerror.cpp elock.cpp \
- estring.cpp init.cpp message.cpp nconfig.cpp nxml.cpp thread.cpp \
- smartptr.cpp
+ buffer.cpp ebase.cpp econfig.cpp eerror.cpp elock.cpp \
+ init.cpp message.cpp thread.cpp \
+ smartptr.cpp estring.cpp
+++ /dev/null
-/*
- * console.cpp
- *
- * Copyright (C) 2002 Felix Domke <tmbinc@tuxbox.org>
- *
- * This program 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.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *
- * $Id: console.cpp,v 1.1 2003-10-17 15:35:47 tmbinc Exp $
- */
-
-#include <lib/base/console.h>
-
-#include <lib/base/estring.h>
-#include <sys/vfs.h> // for statfs
-#include <unistd.h>
-#include <signal.h>
-#include <errno.h>
-
-int bidirpipe(int pfd[], char *cmd , char *argv[])
-{
- int pfdin[2]; /* from child to parent */
- int pfdout[2]; /* from parent to child */
- int pfderr[2]; /* stderr from child to parent */
- int pid; /* child's pid */
-
- if ( pipe(pfdin) == -1 || pipe(pfdout) == -1 || pipe(pfderr) == -1)
- return(-1);
-
- if ( ( pid = fork() ) == -1 )
- return(-1);
- else if (pid == 0) /* child process */
- {
- if ( close(0) == -1 || close(1) == -1 || close(2) == -1 )
- _exit(0);
-
- if (dup(pfdout[0]) != 0 || dup(pfdin[1]) != 1 || dup(pfderr[1]) != 2 )
- _exit(0);
-
- if (close(pfdout[0]) == -1 || close(pfdout[1]) == -1 ||
- close(pfdin[0]) == -1 || close(pfdin[1]) == -1 ||
- close(pfderr[0]) == -1 || close(pfderr[1]) == -1 )
- _exit(0);
-
- execv(cmd,argv);
- _exit(0);
- }
- if (close(pfdout[0]) == -1 || close(pfdin[1]) == -1 || close(pfderr[1]) == -1)
- return(-1);
-
- pfd[0] = pfdin[0];
- pfd[1] = pfdout[1];
- pfd[2] = pfderr[0];
-
- return(pid);
-}
-
-eConsoleAppContainer::eConsoleAppContainer( const eString &cmd )
-:pid(-1), killstate(0), outbuf(0)
-{
-// eDebug("cmd = %s", cmd.c_str() );
- memset(fd, 0, sizeof(fd) );
- int cnt=2; // path to app + terminated 0
- eString str(cmd?cmd:"");
-
- while( str.length() && str[0] == ' ' ) // kill spaces at beginning
- str = str.mid(1);
-
- while( str.length() && str[str.length()-1] == ' ' ) // kill spaces at the end
- str = str.left( str.length() - 1 );
-
- if (!str.length())
- return;
-
- unsigned int idx=0;
- eString path = str.left( (idx = str.find(' ')) != eString::npos ? idx : str.length() );
-// eDebug("path = %s", path.c_str() );
-
- eString cmds = str.mid( path.length()+1 );
-// eDebug("cmds = %s", cmds.c_str() );
-
- idx = 0;
- while ( (idx = cmds.find(' ',idx) ) != eString::npos ) // count args
- {
- cnt++;
- idx++;
- }
-
-// eDebug("idx = %d, %d counted spaces", idx, cnt-2);
-
- if ( cmds.length() )
- {
- cnt++;
-// eDebug("increase cnt");
- }
-
-// eDebug("%d args", cnt-2);
- char **argv = new char*[cnt]; // min two args... path and terminating 0
- argv[0] = new char[ path.length() ];
- strcpy( argv[0], path.c_str() );
- argv[cnt-1] = 0; // set terminating null
-
- if ( cnt > 2 ) // more then default args?
- {
- cnt=1; // do not overwrite path in argv[0]
-
- while ( (idx = cmds.find(' ')) != eString::npos ) // parse all args..
- {
- argv[cnt] = new char[ idx ];
-// eDebug("idx=%d, arg = %s", idx, cmds.left(idx).c_str() );
- strcpy( argv[cnt++], cmds.left( idx ).c_str() );
- cmds = cmds.mid(idx+1);
-// eDebug("str = %s", cmds.c_str() );
- }
- // store the last arg
- argv[cnt] = new char[ cmds.length() ];
- strcpy( argv[cnt], cmds.c_str() );
- }
-
- // get one read ,one write and the err pipe to the prog..
-
- if ( (pid = bidirpipe(fd, argv[0], argv)) == -1 )
- {
- while ( cnt-- > 0 )
- delete [] argv[cnt];
- delete [] argv;
- return;
- }
-
- while ( cnt-- > 0 ) // release heap memory
- delete [] argv[cnt];
- delete [] argv;
-
- eDebug("pipe in = %d, out = %d, err = %d", fd[0], fd[1], fd[2]);
-
- in = new eSocketNotifier(eApp, fd[0], 19 ); // 19 = POLLIN, POLLPRI, POLLHUP
- out = new eSocketNotifier(eApp, fd[1], eSocketNotifier::Write); // POLLOUT
- err = new eSocketNotifier(eApp, fd[2], 19 ); // 19 = POLLIN, POLLPRI, POLLHUP
- CONNECT(in->activated, eConsoleAppContainer::readyRead);
- CONNECT(out->activated, eConsoleAppContainer::readyWrite);
- CONNECT(err->activated, eConsoleAppContainer::readyErrRead);
- signal(SIGCHLD, SIG_IGN); // no zombie when child killed
-}
-
-eConsoleAppContainer::~eConsoleAppContainer()
-{
- if ( running() )
- {
- killstate=-1;
- kill();
- }
- if ( outbuf )
- delete [] outbuf;
-}
-
-void eConsoleAppContainer::kill()
-{
- killstate=-1;
- system( eString().sprintf("kill %d", pid).c_str() );
- eDebug("user kill console App");
-}
-
-void eConsoleAppContainer::closePipes()
-{
- in->stop();
- out->stop();
- err->stop();
- ::close(fd[0]);
- fd[0]=0;
- ::close(fd[1]);
- fd[1]=0;
- ::close(fd[2]);
- fd[2]=0;
- eDebug("pipes closed");
-}
-
-void eConsoleAppContainer::readyRead(int what)
-{
- if (what & POLLPRI|POLLIN)
- {
- eDebug("what = %d");
- char buf[2048];
- int readed = read(fd[0], buf, 2048);
- eDebug("%d bytes read", readed);
- if ( readed != -1 && readed )
- /*emit*/ dataAvail( eString( buf ) );
- else if (readed == -1)
- eDebug("readerror %d", errno);
- }
- if (what & eSocketNotifier::Hungup)
- {
- eDebug("child has terminated");
- closePipes();
- /*emit*/ appClosed(killstate);
- }
-}
-
-void eConsoleAppContainer::readyErrRead(int what)
-{
- if (what & POLLPRI|POLLIN)
- {
- eDebug("what = %d");
- char buf[2048];
- int readed = read(fd[2], buf, 2048);
- eDebug("%d bytes read", readed);
- if ( readed != -1 && readed )
- /*emit*/ dataAvail( eString( buf ) );
- else if (readed == -1)
- eDebug("readerror %d", errno);
- }
-}
-
-void eConsoleAppContainer::write( const eString & str )
-{
- outbuf = new char[ str.length()];
- strcpy( outbuf, str.c_str() );
-}
-
-void eConsoleAppContainer::readyWrite(int what)
-{
- if (what == 4 && outbuf)
- {
- if ( ::write( fd[1], outbuf, strlen(outbuf) ) != (int) strlen(outbuf) )
- {
- /* emit */ dataSent(-1);
- eDebug("writeError");
- }
- else
- {
- /* emit */ dataSent(0);
- eDebug("write ok");
- }
-
- delete outbuf;
- outbuf=0;
- }
-}
-#include <lib/base/eerror.h>
-#include <lib/base/econfig.h>
-#include <lib/base/init.h>
-#include <lib/base/init_num.h>
-#include <sys/stat.h>
-
-eConfig *eConfig::instance;
-
-eConfig::eConfig()
-{
- if (!instance)
- instance=this;
-
- setName(CONFIGDIR "/enigma/registry");
- int e=open();
- if (e == NC_ERR_CORRUPT)
- {
- eWarning("CORRUTPED REGISTRY!");
- ::remove(CONFIGDIR "/enigma/registry");
- }
- if (e)
- {
- if (createNew())
- {
- mkdir(CONFIGDIR "/enigma", 0777);
- if (createNew())
- eFatal("error while opening/creating registry - create " CONFIGDIR "/enigma");
- }
- if (open())
- eFatal("still can't open configfile");
- }
- locked=1;
- ppin=0;
- getKey("/elitedvb/pins/parentallock", ppin );
-}
-
-eConfig::~eConfig()
-{
- if (instance==this)
- instance=0;
-}
-
-eAutoInitP0<eConfig> init_eRCConfig(eAutoInitNumbers::configuration, "Configuration");
-#ifndef __econfig_h
-#define __econfig_h
-
-#include <lib/base/nconfig.h>
-
-class eConfig: public NConfig
-{
- static eConfig *instance;
- int ppin;
-public:
- int locked;
- static eConfig *getInstance() { return instance; }
- void setParentalPin( int pin )
- {
- ppin = pin;
- setKey("/elitedvb/pins/parentallock", ppin );
- }
- int getParentalPin() { return ppin; }
- bool pLockActive()
- {
- return ppin && locked;
- }
- eConfig();
- ~eConfig();
-};
-
-#endif
#include <stdlib.h>
#include <unistd.h>
-#include <lib/base/estring.h>
+#include <string>
// #include <lib/gui/emessage.h>
int infatal=0;
-Signal2<void, int, const eString&> logOutput;
+Signal2<void, int, const std::string&> logOutput;
int logOutputConsole=1;
void eFatal(const char* fmt, ...)
va_start(ap, fmt);
vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
- logOutput(lvlDebug, eString(buf) + "\n");
+ logOutput(lvlDebug, std::string(buf) + "\n");
if (logOutputConsole)
fprintf(stderr, "%s\n", buf);
}
va_start(ap, fmt);
vsnprintf(buf, 1024, fmt, ap);
va_end(ap);
- logOutput(lvlWarning, eString(buf) + "\n");
+ logOutput(lvlWarning, std::string(buf) + "\n");
if (logOutputConsole)
fprintf(stderr, "%s\n", buf);
}
void eFatal(const char* fmt, ...);
-class eString;
-
enum { lvlDebug=1, lvlWarning=2, lvlFatal=4 };
-extern Signal2<void, int, const eString&> logOutput;
+#ifndef SWIG
+extern Signal2<void, int, const std::string&> logOutput;
extern int logOutputConsole;
+#endif
#ifdef ASSERT
#undef ASSERT
void eDebug(const char* fmt, ...);
void eDebugNoNewLine(const char* fmt, ...);
void eWarning(const char* fmt, ...);
+#ifndef SWIG
#define ASSERT(x) { if (!(x)) eFatal("%s:%d ASSERTION %s FAILED!", __FILE__, __LINE__, #x); }
+#endif
#else
inline void eDebug(const char* fmt, ...)
{
-#include <lib/base/estring.h>
+#include <string>
#include <ctype.h>
#include <limits.h>
#include <lib/base/elock.h>
+#include <lib/base/eerror.h>
static pthread_mutex_t lock=PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP;
-///////////////////////////////////////// eString sprintf /////////////////////////////////////////////////
-eString& eString::sprintf(char *fmt, ...)
-{
- singleLock s(lock);
-// Implements the normal sprintf method, to use format strings with eString
-// The max length of the result string is 1024 char.
- static char buf[1024];
- va_list ap;
- va_start(ap, fmt);
- std::vsnprintf(buf, 1024, fmt, ap);
- va_end(ap);
- assign(buf);
- return *this;
-}
-
-///////////////////////////////////////// eString setNum(uint, uint) ///////////////////////////////////////
-eString& eString::setNum(int val, int sys)
+std::string getNum(int val, int sys)
{
// Returns a string that contain the value val as string
// if sys == 16 than hexadezimal if sys == 10 than decimal
else if (sys == 16)
std::snprintf(buf, 12, "%X", val);
- assign(buf);
- return *this;
-}
-
-///////////////////////////////////////// eString replaceChars(char, char) /////////////////////////////
-eString& eString::removeChars(char fchar)
-{
-// Remove all chars that equal to fchar, and returns a reference to itself
- unsigned int index=0;
-
- while ( ( index = find(fchar, index) ) != npos )
- erase(index, 1);
-
- return *this;
-}
-
-/////////////////////////////////////// eString upper() ////////////////////////////////////////////////
-eString& eString::upper()
-{
-// convert all lowercase characters to uppercase, and returns a reference to itself
- for (iterator it = begin(); it != end(); it++)
- switch(*it)
- {
- case 'a' ... 'z' :
- *it -= 32;
- break;
-
- case 'ä' :
- *it = 'Ä';
- break;
-
- case 'ü' :
- *it = 'Ü';
- break;
-
- case 'ö' :
- *it = 'Ö';
- break;
- }
-
- return *this;
-}
-
-eString& eString::strReplace(const char* fstr, const eString& rstr)
-{
-// replace all occurrence of fstr with rstr and, and returns a reference to itself
- unsigned int index=0;
- unsigned int fstrlen = strlen(fstr);
- int rstrlen=rstr.size();
-
- while ( ( index = find(fstr, index) ) != npos )
- {
- replace(index, fstrlen, rstr);
- index+=rstrlen;
- }
-
- return *this;
-}
-
-int strnicmp(const char *s1, const char *s2, int len)
-{
-// makes a case insensitive string compare with len Chars
- while ( *s1 && *s2 && len-- )
- if ( tolower(*s1) != tolower(*s2) )
- return tolower(*s1) < tolower(*s2) ? -1 : 1;
- else
- s1++, s2++;
-
- return 0;
-}
-
-/////////////////////////////////////// eString icompare(const eString&) ////////////////////////////////////////////////
-int eString::icompare(const eString& s)
-{
-// makes a case insensitive string compare
- std::string::const_iterator p = begin(),
- p2 = s.begin();
-
- while ( p != end() && p2 != s.end() )
- if ( tolower(*p) != tolower(*p2) )
- return tolower(*p) < tolower(*p2) ? -1 : 1;
- else
- p++, p2++;
-
- return length() == s.length() ? 0 : length() < s.length() ? -1 : 1;
+ std::string res;
+ res.assign(buf);
+ return res;
}
// 8859-x to dvb coding tables. taken from www.unicode.org/Public/MAPPINGS/ISO8859/
}
}
-eString convertDVBUTF8(unsigned char *data, int len, int table)
+std::string convertDVBUTF8(unsigned char *data, int len, int table)
{
int i;
if (!len)
}
if ( t != bytesneeded)
eFatal("t: %d, bytesneeded: %d", t, bytesneeded);
- return eString().assign((char*)res, t);
+ return std::string().assign((char*)res, t);
}
-eString convertUTF8DVB(const eString &string)
+std::string convertUTF8DVB(const std::string &string)
{
- eString ss=eString();
+ std::string ss=std::string();
int len=string.length();
for(int i=0;i<len;i++){
return ss;
}
-eString convertLatin1UTF8(const eString &string)
+std::string convertLatin1UTF8(const std::string &string)
{
unsigned int bytesneeded=0, t=0, i;
}
if ( t != bytesneeded)
eFatal("t: %d, bytesneeded: %d", t, bytesneeded);
- return eString().assign((char*)res, t);
+ return std::string().assign((char*)res, t);
}
-int isUTF8(const eString &string)
+int isUTF8(const std::string &string)
{
unsigned int len=string.size();
int strnicmp(const char*, const char*, int);
-class eString : public std::string
-{
-public:
-// constructors
- inline eString() {}
- inline eString(const char* p);
- inline eString(const char* p, int cnt);
- inline eString(const std::string &s);
-// methods
- inline eString left(unsigned int len) const;
- inline eString mid(unsigned int index, unsigned int len=(unsigned)-1) const;
- inline eString right(unsigned int len) const;
- bool isNull() const;
-// operators
- inline operator bool() const;
- inline bool operator!() const;
-// methods with implementation in estring.cpp
- eString& sprintf(char *fmt, ...);
- eString& setNum(int val, int sys=10);
- eString& removeChars(const char fchar);
- eString& strReplace(const char* fstr, const eString& rstr);
- eString& upper();
- int icompare(const eString& s);
-};
-
-eString convertDVBUTF8(unsigned char *data, int len, int table=5);
-eString convertUTF8DVB(const eString &string); // with default ISO8859-5
-eString convertLatin1UTF8(const eString &string);
-int isUTF8(const eString &string);
-
-/////////////////////////////////////////////// Copy Constructors ////////////////////////////////////////////////
-inline eString::eString(const std::string &s)
- :std::string(s)
-{
-}
-
-inline eString::eString(const char* p)
- :std::string(p?p:"") // when the char* p is null, than use ""... otherwise crash...
-{
-}
-
-inline eString::eString(const char* p, int cnt)
- :std::string(p, cnt)
-{
-}
-
-///////////////////////////////////////// eString operator bool /////////////////////////////////////////////////
-inline eString::operator bool() const
-{
-// Returns a bool that contains true if the string longer than 0 Character otherwise false;
- return !empty();
-}
-
-///////////////////////////////////////// eString operator! ////////////////////////////////////////////////////
-inline bool eString::operator!() const
-{
-// Returns a bool that contains true if the string ist empty otherwise false;
- return empty();
-}
-
-///////////////////////////////////////// eString left //////////////////////////////////////////////////////////
-inline eString eString::left(unsigned int len) const
-{
-// Returns a substring that contains the len leftmost characters of the string.
-// The whole string is returned if len exceeds the length of the string.
- return len >= length() ? *this : substr(0, len);
-}
-
-//////////////////////////////////////// eString mid ////////////////////////////////////////////////////////////
-inline eString eString::mid(unsigned int index, unsigned int len) const
-{
-// Returns a substring that contains the len characters of this string, starting at position index.
-// Returns a null string if the string is empty or index is out of range. Returns the whole string from index if index+len exceeds the length of the string.
- register unsigned int strlen = length();
-
- if (index >= strlen)
- return eString();
-
- if (len == (unsigned)-1)
- return substr(index);
-
- if (strlen < index + len)
- len = strlen-index;
-
- return substr(index, len);
-}
-
-//////////////////////////////////////// eString right ////////////////////////////////////////////////////////////
-inline eString eString::right(unsigned int len) const
-{
-// Returns a substring that contains the len rightmost characters of the string.
-// The whole string is returned if len exceeds the length of the string.
- register unsigned int strlen = length();
- return len >= strlen ? *this : substr(strlen-len, len);
-}
-
-inline bool eString::isNull() const
-{
-// Returns a bool, that contains true, when the internal char* is null (only when a string ist empty constructed)
- return !c_str();
-}
+std::string getNum(int num, int base=10);
+std::string convertDVBUTF8(unsigned char *data, int len, int table=5);
+std::string convertUTF8DVB(const std::string &string); // with default ISO8859-5
+std::string convertLatin1UTF8(const std::string &string);
+int isUTF8(const std::string &string);
#endif // __E_STRING__
template<class T>
class ePtr
{
- /* read doc/iObject about the ePtrHelper */
- template<class T1>
- class ePtrHelper
- {
- T1 *m_obj;
- public:
- inline ePtrHelper(T1 *obj): m_obj(obj)
- {
- m_obj->AddRef();
- }
- inline ~ePtrHelper()
- {
- m_obj->Release();
- }
- inline T1* operator->() { return m_obj; }
- };
protected:
T *ptr;
public:
T* grabRef() { if (!ptr) return 0; ptr->AddRef(); return ptr; }
T* &ptrref() { assert(!ptr); return ptr; }
+ T* operator->() const { assert(ptr); return ptr; }
+ operator T*() const { return this->ptr; }
+};
+
+
+
+#ifndef SWIG
+template<class T>
+class eMutablePtr: public ePtr<T>
+{
+ /* read doc/iObject about the ePtrHelper */
+ template<class T1>
+ class ePtrHelper
+ {
+ T1 *m_obj;
+ public:
+ inline ePtrHelper(T1 *obj): m_obj(obj)
+ {
+ m_obj->AddRef();
+ }
+ inline ~ePtrHelper()
+ {
+ m_obj->Release();
+ }
+ inline T1* operator->() { return m_obj; }
+ };
+protected:
+ T *ptr;
+public:
+ eMutablePtr(): ePtr<T>(0)
+ {
+ }
+
+ eMutablePtr(T *c): ePtr<T>(c)
+ {
+ }
+
+ eMutablePtr(const eMutablePtr &c): ePtr<T>(c)
+ {
+ }
+
+ eMutablePtr &operator=(T *c)
+ {
+ ePtr<T>::operator=(c);
+ return *this;
+ }
+
+
ePtrHelper<T> operator->() { assert(ptr); return ePtrHelper<T>(ptr); }
/* for const objects, we don't need the helper, as they can't */
/* be changed outside the program flow. at least this is */
/* what the compiler assumes, so in case you're using const */
- /* ePtrs note that they have to be const. */
+ /* eMutablePtrs note that they have to be const. */
const T* operator->() const { assert(ptr); return ptr; }
- operator T*() const { return this->ptr; }
};
-
+#endif
#endif
return -1;
}
-eRCDevice::eRCDevice(eString id, eRCDriver *driver): driver(driver), id(id)
+eRCDevice::eRCDevice(std::string id, eRCDriver *driver): driver(driver), id(id)
{
input=driver->getInput();
driver->addCodeListener(this);
}
}
-eString eRCInputEventDriver::getDeviceName()
+std::string eRCInputEventDriver::getDeviceName()
{
char name[128]="";
if (handle >= 0)
handle=newh;
}
-void eRCInput::addDevice(const eString &id, eRCDevice *dev)
+void eRCInput::addDevice(const std::string &id, eRCDevice *dev)
{
- devices.insert(std::pair<eString,eRCDevice*>(id, dev));
+ devices.insert(std::pair<std::string,eRCDevice*>(id, dev));
}
-void eRCInput::removeDevice(const eString &id)
+void eRCInput::removeDevice(const std::string &id)
{
devices.erase(id);
}
-eRCDevice *eRCInput::getDevice(const eString &id)
+eRCDevice *eRCInput::getDevice(const std::string &id)
{
- std::map<eString,eRCDevice*>::iterator i=devices.find(id);
+ std::map<std::string,eRCDevice*>::iterator i=devices.find(id);
if (i == devices.end())
{
eDebug("failed, possible choices are:");
- for (std::map<eString,eRCDevice*>::iterator i=devices.begin(); i != devices.end(); ++i)
+ for (std::map<std::string,eRCDevice*>::iterator i=devices.begin(); i != devices.end(); ++i)
eDebug("%s", i->first.c_str());
return 0;
}
return i->second;
}
-std::map<eString,eRCDevice*,eRCInput::lstr> &eRCInput::getDevices()
+std::map<std::string,eRCDevice*,eRCInput::lstr> &eRCInput::getDevices()
{
return devices;
}
#include <lib/base/ebase.h>
#include <libsig_comp.h>
-#include <lib/base/estring.h>
+#include <string>
class eRCInput;
class eRCDriver;
protected:
eRCInput *input;
eRCDriver *driver;
- eString id;
+ std::string id;
public:
/**
* \brief Constructs a new remote control.
* \param id The identifier of the RC, for use in settings.
* \param input The \ref eRCDriver where this remote gets its codes from.
*/
- eRCDevice(eString id, eRCDriver *input);
+ eRCDevice(std::string id, eRCDriver *input);
~eRCDevice();
/**
* \brief Handles a device specific code.
* \result The description.
*/
virtual const char *getDescription() const=0;
- const eString getIdentifier() const { return id; }
+ const std::string getIdentifier() const { return id; }
/**
* \brief Get a description for a specific key.
* \param key The key to get the description for.
eSocketNotifier *sn;
void keyPressed(int);
public:
- eString getDeviceName();
+ std::string getDeviceName();
eRCInputEventDriver(const char *filename);
~eRCInputEventDriver();
};
public:
struct lstr
{
- bool operator()(const eString &a, const eString &b) const
+ bool operator()(const std::string &a, const std::string &b) const
{
return a<b;
}
};
protected:
- std::map<eString,eRCDevice*,lstr> devices;
+ std::map<std::string,eRCDevice*,lstr> devices;
public:
Signal1<void, const eRCKey&> keyEvent;
enum
/*emit*/ keyEvent(key);
}
- void addDevice(const eString &id, eRCDevice *dev);
- void removeDevice(const eString &id);
- eRCDevice *getDevice(const eString &id);
- std::map<eString,eRCDevice*,lstr> &getDevices();
+ void addDevice(const std::string &id, eRCDevice *dev);
+ void removeDevice(const std::string &id);
+ eRCDevice *getDevice(const std::string &id);
+ std::map<std::string,eRCDevice*,lstr> &getDevices();
static eRCInput *getInstance() { return instance; }
#include <lib/driver/rcinput.h>
+#include <lib/base/eerror.h>
+
#include <sys/ioctl.h>
#include <linux/input.h>
#include <sys/stat.h>
if (strlen(line))
line[strlen(line)-1]=0;
- eString str=line;
+ std::string str=line;
if (str[1]!=':') // old ... (only service_provider)
{
{
unsigned int c=str.find(',');
char p=str[0];
- eString v;
- if (c == eString::npos)
+ std::string v;
+ if (c == std::string::npos)
{
- v=str.mid(2);
+ v=str.substr(2);
str="";
} else
{
- v=str.mid(2, c-2);
- str=str.mid(c+1);
+ v=str.substr(2, c-2);
+ str=str.substr(c+1);
}
// eDebug("%c ... %s", p, v.c_str());
if (p == 'p')
DECLARE_REF;
public:
eDVBService();
- eString m_service_name;
- eString m_provider_name;
+ std::string m_service_name;
+ std::string m_provider_name;
int m_flags;
std::set<int> m_ca;
+#include <lib/base/eerror.h>
#include <lib/dvb/decoder.h>
#include <linux/dvb/audio.h>
#include <linux/dvb/video.h>
+#include <lib/base/eerror.h>
#include <lib/dvb/pmt.h>
#include <lib/dvb/specs.h>
#include <lib/dvb/dvb.h>
return 0;
}
-FTC_FaceID fontRenderClass::getFaceID(const eString &face)
+FTC_FaceID fontRenderClass::getFaceID(const std::string &face)
{
for (fontListEntry *f=font; f; f=f->next)
{
return res;
}
-eString fontRenderClass::AddFont(const eString &filename, const eString &name, int scale)
+std::string fontRenderClass::AddFont(const std::string &filename, const std::string &name, int scale)
{
eDebugNoNewLine("[FONT] adding font %s...", filename.c_str());
fflush(stdout);
// FT_Done_FreeType(library);
}
-int fontRenderClass::getFont(ePtr<Font> &font, const eString &face, int size, int tabwidth)
+int fontRenderClass::getFont(ePtr<Font> &font, const std::string &face, int size, int tabwidth)
{
FTC_FaceID id=getFaceID(face);
if (!id)
setFont(fnt, replacement);
}
-eString eTextPara::replacement_facename;
+std::string eTextPara::replacement_facename;
void eTextPara::setFont(Font *fnt, Font *replacement)
{
void
shape (std::vector<unsigned long> &string, const std::vector<unsigned long> &text);
-int eTextPara::renderString(const eString &string, int rflags)
+int eTextPara::renderString(const std::string &string, int rflags)
{
singleLock s(ftlock);
std::vector<unsigned long> uc_string, uc_visual;
uc_string.reserve(string.length());
- eString::const_iterator p(string.begin());
+ std::string::const_iterator p(string.begin());
while(p != string.end())
{
use_kerning=FT_HAS_KERNING(current_face);
}
-int eTextPara::renderString(const eString &string, int rflags)
+int eTextPara::renderString(const std::string &string, int rflags)
{
eLocker lock(ftlock);
#include <lib/gdi/esize.h>
#include <lib/gdi/epoint.h>
#include <lib/gdi/erect.h>
-#include <lib/base/estring.h>
+#include <string>
#include <lib/base/object.h>
class FontRenderClass;
fbClass *fb;
struct fontListEntry
{
- eString filename, face;
+ std::string filename, face;
int scale; // 100 is 1:1
fontListEntry *next;
~fontListEntry();
FTC_Image_Cache imageCache; /* the glyph image cache */
FTC_SBit_Cache sbitsCache; /* the glyph small bitmaps cache */
- FTC_FaceID getFaceID(const eString &face);
+ FTC_FaceID getFaceID(const std::string &face);
FT_Error getGlyphBitmap(FTC_Image_Desc *font, FT_ULong glyph_index, FTC_SBit *sbit);
static fontRenderClass *instance;
public:
float getLineHeight(const gFont& font);
- eString AddFont(const eString &filename, const eString &name, int scale);
+ std::string AddFont(const std::string &filename, const std::string &name, int scale);
static fontRenderClass *getInstance();
FT_Error FTC_Face_Requester(FTC_FaceID face_id,
FT_Face* aface);
- int getFont(ePtr<Font> &font, const eString &face, int size, int tabwidth=-1);
+ int getFont(ePtr<Font> &font, const std::string &face, int size, int tabwidth=-1);
fontRenderClass();
~fontRenderClass();
};
FT_Face current_face, replacement_face;
int use_kerning;
int previous;
- static eString replacement_facename;
+ static std::string replacement_facename;
eRect area;
ePoint cursor;
}
virtual ~eTextPara();
- static void setReplacementFont(eString font) { replacement_facename=font; }
+ static void setReplacementFont(std::string font) { replacement_facename=font; }
void setFont(const gFont *font);
- int renderString(const eString &string, int flags=0);
+ int renderString(const std::string &string, int flags=0);
void clear();
#define __gpixmap_h
#include <pthread.h>
-#include <lib/base/estring.h>
+#include <string>
#include <lib/base/object.h>
#include <lib/base/elock.h>
#include <lib/gdi/erect.h>
DECLARE_REF;
public:
- eString family;
+ std::string family;
int pointSize;
/**
* \param family The name of the font, for example "NimbusSansL-Regular Sans L Regular".
* \param pointSize the size of the font in PIXELS.
*/
- gFont(const eString &family, int pointSize):
+ gFont(const std::string &family, int pointSize):
family(family), pointSize(pointSize)
{
}
#include <stack>
#include <list>
-#include <lib/base/estring.h>
+#include <string>
#include <lib/base/ringbuffer.h>
#include <lib/base/elock.h>
#include <lib/gdi/erect.h>
struct prenderText
{
eRect area;
- eString text;
+ std::string text;
int flags;
} *renderText;
--- /dev/null
+#include <lib/gui/ebutton.h>
+
+eButton::eButton(eWidget *parent): eLabel(parent)
+{
+}
+
+void eButton::push()
+{
+ selected();
+}
+
+int eButton::event(int event, void *data, void *data2)
+{
+ switch (event)
+ {
+ default:
+ break;
+ }
+ return eLabel::event(event, data, data2);
+}
--- /dev/null
+#ifndef __lib_gui_ebutton_h
+#define __lib_gui_ebutton_h
+
+#include <lib/gui/elabel.h>
+
+class eButton: public eLabel
+{
+public:
+ eButton(eWidget *parent);
+ Signal0<void> selected;
+
+ void push();
+protected:
+ int event(int event, void *data=0, void *data2=0);
+};
+
+#endif
--- /dev/null
+#include <lib/gui/elabel.h>
+
+eLabel::eLabel(eWidget *parent): eWidget(parent)
+{
+
+}
+
+int eLabel::event(int event, void *data, void *data2)
+{
+ switch (event)
+ {
+ case evtPaint:
+ {
+ gPainter &painter = *(gPainter*)data2;
+ ePtr<gFont> fnt = new gFont("Arial", 70);
+ painter.setFont(fnt);
+ painter.setBackgroundColor(gColor(0x10));
+ painter.setForegroundColor(gColor(0x1f));
+ painter.clear();
+ painter.setBackgroundColor(gColor(0x1f));
+ painter.setForegroundColor(gColor(0x10));
+ painter.renderText(eRect(0, 0, size().width(), size().height()), m_text);
+ return 0;
+ }
+ case evtChangedText:
+ invalidate();
+ return 0;
+ default:
+ return eWidget::event(event, data, data2);
+ }
+}
+
+void eLabel::setText(const std::string &string)
+{
+ if (m_text == string)
+ return;
+ m_text = string;
+ event(evtChangedText);
+}
--- /dev/null
+#ifndef __lib_gui_elabel_h
+#define __lib_gui_elabel_h
+
+#include <lib/gui/ewidget.h>
+
+class eLabel: public eWidget
+{
+public:
+ eLabel(eWidget *parent);
+ void setText(const std::string &string);
+protected:
+ int event(int event, void *data=0, void *data2=0);
+private:
+ enum eLabelEvent
+ {
+ evtChangedText = evtUserWidget
+ };
+ std::string m_text;
+};
+
+#endif
--- /dev/null
+#include <lib/gui/ewidget.h>
+#include <lib/gui/ewidgetdesktop.h>
+
+extern void dumpRegion(const gRegion ®ion);
+
+eWidget::eWidget(eWidget *parent): m_parent(parent)
+{
+ m_vis = 0;
+ m_desktop = 0;
+
+ if (parent)
+ m_vis = wVisShow;
+
+ if (parent)
+ parent->m_childs.push_back(this);
+}
+
+void eWidget::move(ePoint pos)
+{
+ m_position = pos;
+
+ event(evtChangedPosition);
+}
+
+void eWidget::resize(eSize size)
+{
+ event(evtWillChangeSize, &size);
+ event(evtChangedSize);
+}
+
+void eWidget::invalidate(const gRegion ®ion)
+{
+ gRegion res = /* region & */ m_visible_with_childs;
+ if (res.empty())
+ return;
+
+ eWidget *root = this;
+ ePoint abspos = position();
+ while (root && !root->m_desktop)
+ {
+ root = root->m_parent;
+ assert(root);
+ abspos += root->position();
+ }
+
+ res.moveBy(abspos);
+// eDebug("region to invalidate:");
+// dumpRegion(res);
+ root->m_desktop->invalidate(res);
+}
+
+void eWidget::show()
+{
+ if (m_vis & wVisShow)
+ return;
+
+ m_vis |= wVisShow;
+
+ /* TODO: optimize here to only recalc what's required. possibly merge with hide. */
+ eWidget *root = this;
+ ePoint abspos = position();
+ while (root && !root->m_desktop)
+ {
+ root = root->m_parent;
+ assert(root);
+ abspos += root->position();
+ }
+
+ root->m_desktop->recalcClipRegions();
+
+ gRegion abs = m_visible_with_childs;
+ abs.moveBy(abspos);
+ root->m_desktop->invalidate(abs);
+}
+
+void eWidget::hide()
+{
+ m_vis &= ~wVisShow;
+
+ /* TODO: optimize here to only recalc what's required. possibly merge with show. */
+ eWidget *root = this;
+ ePoint abspos = position();
+ while (root && !root->m_desktop)
+ {
+ root = root->m_parent;
+ abspos += root->position();
+ }
+ assert(root->m_desktop);
+
+ gRegion abs = m_visible_with_childs;
+ abs.moveBy(abspos);
+
+ root->m_desktop->recalcClipRegions();
+ root->m_desktop->invalidate(abs);
+}
+
+void eWidget::destruct()
+{
+ if (m_parent)
+ m_parent->m_childs.remove(this);
+ delete this;
+}
+
+eWidget::~eWidget()
+{
+ /* destroy all childs */
+ ePtrList<eWidget>::iterator i(m_childs.begin());
+ while (i != m_childs.end())
+ {
+ delete *i;
+ i = m_childs.erase(i);
+ }
+}
+
+void eWidget::doPaint(gPainter &painter, const gRegion &r)
+{
+ if (m_visible_with_childs.empty())
+ return;
+
+ gRegion region = r;
+ /* we were in parent's space, now we are in local space */
+ region.moveBy(-position());
+
+ painter.moveOffset(position());
+ /* walk all childs */
+ for (ePtrList<eWidget>::iterator i(m_childs.begin()); i != m_childs.end(); ++i)
+ i->doPaint(painter, region);
+
+ /* check if there's anything for us to paint */
+ region &= m_visible_region;
+
+ painter.resetClip(region);
+ event(evtPaint, ®ion, &painter);
+
+ painter.moveOffset(-position());
+}
+
+int eWidget::event(int event, void *data, void *data2)
+{
+ switch (event)
+ {
+ case evtPaint:
+ {
+ static int counter = 0x18;
+ gPainter &painter = *(gPainter*)data2;
+// eDebug("eWidget::evtPaint %d", counter);
+// dumpRegion(*(gRegion*)data);
+ painter.setBackgroundColor(gColor(++counter));
+ painter.clear();
+ break;
+ }
+ case evtKey:
+ break;
+ case evtWillChangeSize:
+ m_size = *static_cast<eSize*>(data);
+ break;
+ case evtChangedSize:
+ {
+ m_clip_region = gRegion(eRect(ePoint(0, 0), m_size));
+ break;
+ }
+ default:
+ return -1;
+ }
+ return 0;
+}
+
--- /dev/null
+#ifndef __lib_gui_ewidget_h
+#define __lib_gui_ewidget_h
+
+#include <lib/gdi/grc.h> /* for gRegion */
+#include <lib/base/eptrlist.h> /* for eSmartPtrList */
+
+class eWidget
+{
+ friend class eWidgetDesktop;
+public:
+ eWidget(eWidget *parent);
+
+ void move(ePoint pos);
+ void resize(eSize size);
+
+ ePoint position() const { return m_position; }
+ eSize size() const { return m_size; }
+
+ void invalidate(const gRegion ®ion = gRegion::invalidRegion());
+
+ void show();
+ void hide();
+
+ void destruct();
+private:
+ eWidgetDesktop *m_desktop;
+
+ enum {
+ wVisShow = 1,
+ wVisTransparent = 2,
+ };
+
+ int m_vis;
+
+ ePtrList<eWidget> m_childs;
+ eWidget *m_parent;
+ ePoint m_position;
+ eSize m_size;
+
+
+ void doPaint(gPainter &painter, const gRegion ®ion);
+protected:
+ virtual ~eWidget();
+public:
+
+ // all in local space!
+ gRegion m_clip_region, m_visible_region, m_visible_with_childs;
+
+ enum eWidgetEvent
+ {
+ evtPaint,
+ evtKey,
+ evtChangedPosition,
+ evtChangedSize,
+
+ evtWillShow,
+ evtWillHide,
+ evtWillChangePosition, /* new size is eRect *data */
+ evtWillChangeSize,
+
+ evtUserWidget,
+ };
+ virtual int event(int event, void *data = 0, void *data2 = 0);
+};
+
+#endif
--- /dev/null
+#include <lib/gui/ewidgetdesktop.h>
+#include <lib/gui/ewidget.h>
+
+void eWidgetDesktop::addRootWidget(eWidget *root, int top)
+{
+ assert(!root->m_desktop);
+ if (!top)
+ m_root.push_back(root);
+ else
+ m_root.push_front(root);
+ root->m_desktop = this;
+}
+
+void eWidgetDesktop::calcWidgetClipRegion(eWidget *widget, gRegion &parent_visible)
+{
+ /* start with our clip region, clipped with the parent's */
+ if (widget->m_vis & eWidget::wVisShow)
+ {
+ widget->m_visible_region = widget->m_clip_region;
+ widget->m_visible_region.moveBy(widget->position());
+ widget->m_visible_region &= parent_visible; // in parent space!
+ /* TODO: check transparency here! */
+ /* remove everything this widget will contain from parent's visible list */
+ parent_visible -= widget->m_visible_region; // will remove child regions too!
+
+ /* now prepare for recursing to childs */
+ widget->m_visible_region.moveBy(-widget->position()); // now in local space
+ } else
+ widget->m_visible_region = gRegion();
+
+ widget->m_visible_with_childs = widget->m_visible_region;
+
+ for (ePtrList<eWidget>::iterator i(widget->m_childs.begin()); i != widget->m_childs.end(); ++i)
+ calcWidgetClipRegion(*i, widget->m_visible_region);
+}
+
+void eWidgetDesktop::recalcClipRegions()
+{
+ gRegion screen = gRegion(eRect(ePoint(0, 0), m_screen_size));
+
+ for (ePtrList<eWidget>::iterator i(m_root.begin()); i != m_root.end(); ++i)
+ calcWidgetClipRegion(*i, screen);
+// dumpRegion(screen);
+}
+
+void eWidgetDesktop::invalidate(const gRegion ®ion)
+{
+ m_dirty_region |= region;
+}
+
+void eWidgetDesktop::paint()
+{
+ gPainter painter(m_dc);
+ /* walk all root windows. */
+ for (ePtrList<eWidget>::iterator i(m_root.begin()); i != m_root.end(); ++i)
+ i->doPaint(painter, m_dirty_region);
+ m_dirty_region = gRegion();
+}
+
+void eWidgetDesktop::setDC(gDC *dc)
+{
+ m_dc = dc;
+}
+
+eWidgetDesktop::eWidgetDesktop(eSize size): m_screen_size(size)
+{
+}
+
+eWidgetDesktop::~eWidgetDesktop()
+{
+}
+
--- /dev/null
+#ifndef __lib_gui_ewidgetdesktop_h
+#define __lib_gui_ewidgetdesktop_h
+
+#include <lib/gdi/grc.h>
+#include <lib/base/eptrlist.h>
+
+class eWidget;
+
+class eWidgetDesktop
+{
+public: // weil debug
+ eSize m_screen_size;
+ gRegion m_dirty_region;
+ ePtr<gDC> m_dc;
+public:
+ eWidgetDesktop(eSize screen);
+ ~eWidgetDesktop();
+ void addRootWidget(eWidget *root, int top);
+ void recalcClipRegions();
+
+ void invalidate(const gRegion ®ion);
+ void paint();
+ void setDC(gDC *dc);
+private:
+ ePtrList<eWidget> m_root;
+ void calcWidgetClipRegion(eWidget *widget, gRegion &parent_visible);
+};
+
+#endif
--- /dev/null
+#include <lib/gui/ewindow.h>
+#include <lib/gui/ewidgetdesktop.h>
+
+#include <lib/gui/ewindowstyle.h>
+
+eWindow::eWindow(eWidgetDesktop *desktop): eWidget(0)
+{
+ m_child = new eWidget(this);
+ desktop->addRootWidget(this, 0);
+
+ m_style = new eWindowStyleSimple();
+}
+
+void eWindow::setTitle(const std::string &string)
+{
+ if (m_title == string)
+ return;
+ m_title = string;
+ event(evtTitleChanged);
+}
+
+int eWindow::event(int event, void *data, void *data2)
+{
+ switch (event)
+ {
+ case evtWillChangeSize:
+ {
+ const eSize &new_size = *static_cast<eSize*>(data);
+ eDebug("eWindow::evtWillChangeSize to %d %d", new_size.width(), new_size.height());
+ if (m_style)
+ m_style->handleNewSize(this, new_size);
+ break;
+ }
+ case evtPaint:
+ {
+ gPainter &painter = *static_cast<gPainter*>(data2);
+ painter.setBackgroundColor(gColor(0x18));
+ painter.clear();
+ break;
+ }
+ default:
+ break;
+ }
+ return eWidget::event(event, data, data2);
+}
+
--- /dev/null
+#ifndef __lib_gui_ewindow_h
+#define __lib_gui_ewindow_h
+
+#include <lib/gui/ewidget.h>
+#include <lib/gui/ewindowstyle.h>
+
+class eWidgetDesktop;
+
+class eWindow: public eWidget
+{
+ friend class eWindowStyle;
+public:
+ eWindow(eWidgetDesktop *desktop);
+ void setTitle(const std::string &string);
+ eWidget *child() { return m_child; }
+protected:
+ enum eWindowEvents
+ {
+ evtTitleChanged = evtUserWidget,
+ };
+ int event(int event, void *data=0, void *data2=0);
+private:
+ std::string m_title;
+ eWidget *m_child;
+ ePtr<eWindowStyle> m_style;
+};
+
+#endif
--- /dev/null
+#include <lib/base/eerror.h>
+#include <lib/gdi/esize.h>
+#include <lib/gui/ewindow.h>
+#include <lib/gui/ewindowstyle.h>
+
+DEFINE_REF(eWindowStyleSimple);
+
+eWindowStyleSimple::eWindowStyleSimple()
+{
+ m_border_left = m_border_right = m_border_top = m_border_bottom = 10;
+}
+
+void eWindowStyleSimple::handleNewSize(eWindow *wnd, const eSize &size)
+{
+ eDebug("handle new size: %d x %d", size.width(), size.height());
+
+ eWidget *child = wnd->child();
+
+ wnd->m_clip_region = eRect(ePoint(0, 0), size);
+
+ child->move(ePoint(m_border_left, m_border_top));
+ child->resize(eSize(size.width() - m_border_left - m_border_right, size.height() - m_border_top - m_border_bottom));
+}
--- /dev/null
+#ifndef __lib_gui_ewindowstyle_h
+#define __lib_gui_ewindowstyle_h
+
+class eWindow;
+class eSize;
+
+#include <lib/base/object.h>
+
+class eWindowStyle: public iObject
+{
+public:
+ virtual void handleNewSize(eWindow *wnd, const eSize &size) = 0;
+};
+
+class eWindowStyleSimple: public eWindowStyle
+{
+ DECLARE_REF;
+public:
+ eWindowStyleSimple();
+ void handleNewSize(eWindow *wnd, const eSize &size);
+ int m_border_top, m_border_left, m_border_right, m_border_bottom;
+};
+
+#endif
#include <lib/nav/core.h>
+#include <lib/base/eerror.h>
void eNavigation::serviceEvent(iPlayableService* service, int event)
{
noinst_LIBRARIES = libenigma_network.a
libenigma_network_a_SOURCES = \
- http_dyn.cpp http_file.cpp httpd.cpp serversocket.cpp socket.cpp xmlrpc.cpp
+ http_dyn.cpp http_file.cpp httpd.cpp serversocket.cpp socket.cpp
+
+# xmlrpc.cpp
#include <lib/network/http_dyn.h>
-eHTTPDyn::eHTTPDyn(eHTTPConnection *c, eString result): eHTTPDataSource(c), result(result)
+eHTTPDyn::eHTTPDyn(eHTTPConnection *c, std::string result): eHTTPDataSource(c), result(result)
{
wptr=0;
char buffer[10];
#warning autodelete removed
}
-void eHTTPDynPathResolver::addDyn(eString request, eString path, eString (*function)(eString, eString, eString, eHTTPConnection*))
+void eHTTPDynPathResolver::addDyn(std::string request, std::string path, std::string (*function)(std::string, std::string, std::string, eHTTPConnection*))
{
dyn.push_back(new eHTTPDynEntry(request, path, function));
}
-eHTTPDataSource *eHTTPDynPathResolver::getDataSource(eString request, eString path, eHTTPConnection *conn)
+eHTTPDataSource *eHTTPDynPathResolver::getDataSource(std::string request, std::string path, eHTTPConnection *conn)
{
- eString p, opt;
- if (path.find('?')!=eString::npos)
+ std::string p, opt;
+ if (path.find('?')!=std::string::npos)
{
- p=path.left(path.find('?'));
- opt=path.mid(path.find('?')+1);
+ p=path.substr(0, path.find('?'));
+ opt=path.substr(path.find('?')+1);
} else
{
p=path;
if ((i->path==p) && (i->request==request))
{
conn->code=-1;
- eString s=i->function(request, path, opt, conn);
+ std::string s=i->function(request, path, opt, conn);
- if (s)
+ if (!s.empty())
return new eHTTPDyn(conn, s);
return new eHTTPError(conn, 500);
class eHTTPDyn: public eHTTPDataSource
{
- eString result;
+ std::string result;
int wptr, size;
public:
- eHTTPDyn(eHTTPConnection *c, eString result);
+ eHTTPDyn(eHTTPConnection *c, std::string result);
~eHTTPDyn();
int doWrite(int);
};
{
struct eHTTPDynEntry
{
- eString request, path;
- eString (*function)(eString request, eString path, eString opt, eHTTPConnection *content);
+ std::string request, path;
+ std::string (*function)(std::string request, std::string path, std::string opt, eHTTPConnection *content);
- eHTTPDynEntry(eString request, eString path, eString (*function)(eString, eString, eString, eHTTPConnection *)): request(request), path(path), function(function)
+ eHTTPDynEntry(std::string request, std::string path, std::string (*function)(std::string, std::string, std::string, eHTTPConnection *)): request(request), path(path), function(function)
{
}
};
ePtrList<eHTTPDynEntry> dyn;
public:
- void addDyn(eString request, eString path, eString (*function)(eString, eString, eString, eHTTPConnection *conn));
+ void addDyn(std::string request, std::string path, std::string (*function)(std::string, std::string, std::string, eHTTPConnection *conn));
eHTTPDynPathResolver();
- eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn);
+ eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn);
};
#endif
static char _base64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
-static int unbase64(eString &dst, const eString string)
+static int unbase64(std::string &dst, const std::string string)
{
dst="";
char c[4];
return !!strcmp(cres, cpwd);
}
-static int checkAuth(const eString cauth)
+static int checkAuth(const std::string cauth)
{
- eString auth;
- if (cauth.left(6) != "Basic ")
+ std::string auth;
+ if (cauth.substr(0, 6) != "Basic ")
return -1;
- if (unbase64(auth, cauth.mid(6)))
+ if (unbase64(auth, cauth.substr(6)))
return -1;
- eString username=auth.left(auth.find(":"));
- eString password=auth.mid(auth.find(":")+1);
+ std::string username=auth.substr(0, auth.find(":"));
+ std::string password=auth.substr(auth.find(":")+1);
if (CheckUnixPassword(username.c_str(), password.c_str()))
return -1;
return 0;
}
-eHTTPDataSource *eHTTPFilePathResolver::getDataSource(eString request, eString path, eHTTPConnection *conn)
+eHTTPDataSource *eHTTPFilePathResolver::getDataSource(std::string request, std::string path, eHTTPConnection *conn)
{
int method;
eDebug("request = %s, path = %s", request.c_str(), path.c_str());
method=eHTTPFile::methodPUT;
else
return new eHTTPError(conn, 405); // method not allowed
- if (path.find("../")!=eString::npos) // evil hax0r
+ if (path.find("../")!=std::string::npos) // evil hax0r
return new eHTTPError(conn, 403);
if (path[0] != '/') // prepend '/'
path.insert(0,"/");
eHTTPDataSource *data=0;
for (ePtrList<eHTTPFilePath>::iterator i(translate); i != translate.end(); ++i)
{
- if (i->root==path.left(i->root.length()))
+ if (i->root==path.substr(0, i->root.length()))
{
- eString newpath=i->path+path.mid(i->root.length());
+ std::string newpath=i->path+path.substr(i->root.length());
if (newpath.find('?'))
- newpath=newpath.left(newpath.find('?'));
+ newpath=newpath.substr(0, newpath.find('?'));
eDebug("translated %s to %s", path.c_str(), newpath.c_str());
if (i->authorized & ((method==eHTTPFile::methodGET)?1:2))
break;
}
- eString ext=path.mid(path.rfind('.'));
+ std::string ext=path.substr(path.rfind('.'));
const char *mime="text/unknown";
if ((ext==".html") || (ext==".htm"))
mime="text/html";
return data;
}
-void eHTTPFilePathResolver::addTranslation(eString path, eString root, int authorized)
+void eHTTPFilePathResolver::addTranslation(std::string path, std::string root, int authorized)
{
if (path[path.length()-1]!='/')
path+='/';
{
struct eHTTPFilePath
{
- eString path;
- eString root;
+ std::string path;
+ std::string root;
int authorized; // must be authorized (1 means read, 2 write)
- eHTTPFilePath(eString path, eString root, int authorized): path(path), root(root), authorized(authorized)
+ eHTTPFilePath(std::string path, std::string root, int authorized): path(path), root(root), authorized(authorized)
{
}
};
ePtrList<eHTTPFilePath> translate;
public:
eHTTPFilePathResolver();
- eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn);
- void addTranslation(eString path, eString root, int auth);
+ eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn);
+ void addTranslation(std::string path, std::string root, int auth);
};
#endif
#include <lib/network/httpd.h>
#include <sys/socket.h>
+#include <lib/base/estring.h>
#include <error.h>
#include <errno.h>
#include <time.h>
eHTTPError::eHTTPError(eHTTPConnection *c, int errcode): eHTTPDataSource(c), errcode(errcode)
{
- eString error="unknown error";
+ std::string error="unknown error";
switch (errcode)
{
case 400: error="Bad Request"; break;
int eHTTPError::doWrite(int w)
{
- eString html;
- html+="<html><head><title>Error "+eString().setNum(connection->code)+"</title></head>"+
- "<body><h1>Error "+eString().setNum(errcode)+": "+connection->code_descr+"</h1></body></html>\n";
+ std::string html;
+ html+="<html><head><title>Error " + getNum(connection->code) + "</title></head>"+
+ "<body><h1>Error " + getNum(errcode) + ": " + connection->code_descr + "</h1></body></html>\n";
connection->writeBlock(html.c_str(), html.length());
return -1;
}
#ifdef DEBUG_HTTPD
eDebug("local request");
#endif
- eString req=request+" "+requestpath+" "+httpversion+"\r\n";
+ std::string req=request+" "+requestpath+" "+httpversion+"\r\n";
writeBlock(req.c_str(), req.length());
localstate=stateHeader;
remotestate=stateResponse;
#ifdef DEBUG_HTTPD
eDebug("local Response");
#endif
- writeString( (httpversion + " " + eString().setNum(code)+" " + code_descr + "\r\n").c_str() );
+ writeString( (httpversion + " " + getNum(code) + " " + code_descr + "\r\n").c_str() );
localstate=stateHeader;
local_header["Connection"]="close";
break;
// move to stateClose
if (remote_header.find("Connection") != remote_header.end())
{
- eString &connection=remote_header["Connection"];
+ std::string &connection=remote_header["Connection"];
if (connection == "keep-alive")
localstate=stateWait;
else
#ifdef DEBUG_HTTPD
eDebug("stateRequest");
#endif
- eString line;
+ std::string line;
if (!getLine(line))
{
done=1;
return -1;
break;
}
- request=line.left(del[0]);
- requestpath=line.mid(del[0]+1, (del[1]==-1)?-1:(del[1]-del[0]-1));
+ request=line.substr(0, del[0]);
+ requestpath=line.substr(del[0]+1, (del[1]==-1)?-1:(del[1]-del[0]-1));
if (del[1]!=-1)
{
is09=0;
- httpversion=line.mid(del[1]+1);
+ httpversion=line.substr(del[1]+1);
} else
is09=1;
- if (is09 || (httpversion.left(7) != "HTTP/1.") || httpversion.size()!=8)
+ if (is09 || (httpversion.substr(0, 7) != "HTTP/1.") || httpversion.size()!=8)
{
remotestate=stateData;
done=0;
#ifdef DEBUG_HTTPD
eDebug("state response..");
#endif
- eString line;
+ std::string line;
if (!getLine(line))
{
done=1;
code=-1;
else
{
- httpversion=line.left(del[0]);
- code=atoi(line.mid(del[0]+1, (del[1]==-1)?-1:(del[1]-del[0]-1)).c_str());
+ httpversion=line.substr(0, del[0]);
+ code=atoi(line.substr(del[0]+1, (del[1]==-1)?-1:(del[1]-del[0]-1)).c_str());
if (del[1] != -1)
- code_descr=line.mid(del[1]+1);
+ code_descr=line.substr(del[1]+1);
else
code_descr="";
}
#ifdef DEBUG_HTTPD
eDebug("remote stateHeader");
#endif
- eString line;
+ std::string line;
if (!getLine(line))
{
done=1;
} else
{
int del=line.find(":");
- eString name=line.left(del), value=line.mid(del+1);
+ std::string name=line.substr(0, del), value=line.substr(del+1);
if (value[0]==' ')
- value=value.mid(1);
+ value=value.substr(1);
remote_header[std::string(name)]=std::string(value);
}
done=1;
writeBlock(data, strlen(data));
}
-int eHTTPConnection::getLine(eString &line)
+int eHTTPConnection::getLine(std::string &line)
{
if (!canReadLine())
return 0;
#include <lib/base/eptrlist.h>
#include <lib/base/ebase.h>
-#include <lib/base/estring.h>
+#include <string>
#include <lib/base/eerror.h>
#include <lib/network/socket.h>
#include <lib/network/serversocket.h>
{
public:
virtual ~eHTTPPathResolver() {};
- virtual eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn)=0;
+ virtual eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn)=0;
};
class eHTTPDataSource
{
void doError(int error);
- int getLine(eString &line);
+ int getLine(std::string &line);
int processLocalState();
int processRemoteState();
~eHTTPConnection();
// stateRequest
- eString request, requestpath, httpversion;
+ std::string request, requestpath, httpversion;
int is09;
// stateResponse
int code;
- eString code_descr;
+ std::string code_descr;
std::map<std::string,std::string> remote_header, local_header;
readyRead_();
}
-eString eSocket::readLine()
+std::string eSocket::readLine()
{
int size=readbuffer.searchchr('\n');
if (size == -1)
- return eString();
+ return std::string();
size++; // ich will auch das \n
char buffer[size+1];
buffer[size]=0;
readbuffer.read(buffer, size);
- return eString(buffer);
+ return std::string(buffer);
}
bool eSocket::canReadLine()
return socketdesc;
}
-int eSocket::connectToHost(eString hostname, int port)
+int eSocket::connectToHost(std::string hostname, int port)
{
struct hostent *server;
int res;
#include <lib/base/ebase.h>
#include <lib/base/eerror.h>
-#include <lib/base/estring.h>
+#include <string>
#include <libsig_comp.h>
#include <lib/base/buffer.h>
eSocket(eMainloop *ml);
eSocket(int socket, int issocket, eMainloop *ml);
~eSocket();
- int connectToHost(eString hostname, int port);
+ int connectToHost(std::string hostname, int port);
int getDescriptor();
int writeBlock(const char *data, unsigned int len);
int setSocket(int socketfd, int issocket, eMainloop *ml);
int readBlock(char *data, unsigned int maxlen);
int bytesAvailable();
bool canReadLine();
- eString readLine();
+ std::string readLine();
void close();
// flow control: start/stop data delivery into read buffer.
void enableRead();
#ifndef DISABLE_NETWORK
#include <lib/network/xmlrpc.h>
+#include <lib/base/estring.h>
-static std::map<eString, int (*)(std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant>&)> rpcproc;
+static std::map<std::string, int (*)(std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant>&)> rpcproc;
void eXMLRPCVariant::zero()
{
// _base64=0;
}
-eXMLRPCVariant::eXMLRPCVariant(std::map<eString,eXMLRPCVariant*> *__struct)
+eXMLRPCVariant::eXMLRPCVariant(std::map<std::string,eXMLRPCVariant*> *__struct)
{
zero();
_struct=__struct;
_boolean=__boolean;
}
-eXMLRPCVariant::eXMLRPCVariant(eString *__string)
+eXMLRPCVariant::eXMLRPCVariant(std::string *__string)
{
zero();
_string=__string;
if (c._boolean)
_boolean=new bool(*c._boolean);
if (c._string)
- _string=new eString(*c._string);
+ _string=new std::string(*c._string);
if (c._double)
_double=new double(*c._double);
// datetime, base64
if (c._struct)
{
- _struct=new std::map<eString,eXMLRPCVariant*>;
- for (std::map<eString,eXMLRPCVariant*>::iterator b(c._struct->begin()); b != c._struct->end(); ++b)
- _struct->insert(std::pair<eString,eXMLRPCVariant*>(b->first, new eXMLRPCVariant(*b->second)));
+ _struct=new std::map<std::string,eXMLRPCVariant*>;
+ for (std::map<std::string,eXMLRPCVariant*>::iterator b(c._struct->begin()); b != c._struct->end(); ++b)
+ _struct->insert(std::pair<std::string,eXMLRPCVariant*>(b->first, new eXMLRPCVariant(*b->second)));
}
if (c._array)
_array = new std::vector<eXMLRPCVariant>(*c._array);
{
if (_struct)
{
- for (std::map<eString,eXMLRPCVariant*>::iterator i(_struct->begin()); i != _struct->end(); ++i)
+ for (std::map<std::string,eXMLRPCVariant*>::iterator i(_struct->begin()); i != _struct->end(); ++i)
delete i->second;
delete _struct;
delete _base64;*/
}
-std::map<eString,eXMLRPCVariant*> *eXMLRPCVariant::getStruct()
+std::map<std::string,eXMLRPCVariant*> *eXMLRPCVariant::getStruct()
{
return _struct;
}
return _boolean;
}
-eString *eXMLRPCVariant::getString()
+std::string *eXMLRPCVariant::getString()
{
return _string;
}
return _base64;
} */
-void eXMLRPCVariant::toXML(eString &result)
+void eXMLRPCVariant::toXML(std::string &result)
{
if (getArray())
{
- static eString s1("<value><array><data>");
+ static std::string s1("<value><array><data>");
result+=s1;
for (unsigned int i=0; i<getArray()->size(); i++)
{
- static eString s(" ");
+ static std::string s(" ");
result+=s;
(*getArray())[i].toXML(result);
- static eString s1("\n");
+ static std::string s1("\n");
result+=s1;
}
- static eString s2("</data></array></value>\n");
+ static std::string s2("</data></array></value>\n");
result+=s2;
} else if (getStruct())
{
- static eString s1("<value><struct>");
+ static std::string s1("<value><struct>");
result+=s1;
- for (std::map<eString,eXMLRPCVariant*>::iterator i(_struct->begin()); i != _struct->end(); ++i)
+ for (std::map<std::string,eXMLRPCVariant*>::iterator i(_struct->begin()); i != _struct->end(); ++i)
{
- static eString s1(" <member><name>");
+ static std::string s1(" <member><name>");
result+=s1;
result+=i->first;
- static eString s2("</name>");
+ static std::string s2("</name>");
result+=s2;
i->second->toXML(result);
- static eString s3("</member>\n");
+ static std::string s3("</member>\n");
result+=s3;
}
- static eString s2("</struct></value>\n");
+ static std::string s2("</struct></value>\n");
result+=s2;
} else if (getI4())
{
- static eString s1("<value><i4>");
+ static std::string s1("<value><i4>");
result+=s1;
- result+=eString().setNum(*getI4());
- static eString s2("</i4></value>");
+ result+=getNum(*getI4());
+ static std::string s2("</i4></value>");
result+=s2;
} else if (getBoolean())
{
- static eString s0("<value><boolean>0</boolean></value>");
- static eString s1("<value><boolean>1</boolean></value>");
+ static std::string s0("<value><boolean>0</boolean></value>");
+ static std::string s1("<value><boolean>1</boolean></value>");
result+=(*getBoolean())?s1:s0;
} else if (getString())
{
- static eString s1("<value><string>");
- static eString s2("</string></value>");
+ static std::string s1("<value><string>");
+ static std::string s2("</string></value>");
result+=s1;
result+=*getString();
result+=s2;
} else if (getDouble())
{
- result+=eString().sprintf("<value><double>%lf</double></value>", *getDouble());
+// result+=std::string().sprintf("<value><double>%lf</double></value>", *getDouble());
+#warning double support removed
} else
eFatal("couldn't append");
}
else if (!strcmp(n->GetType(), "boolean"))
return new eXMLRPCVariant(new bool(atoi(data)));
else if (!strcmp(n->GetType(), "string"))
- return new eXMLRPCVariant(new eString(data));
+ return new eXMLRPCVariant(new std::string(data));
else if (!strcmp(n->GetType(), "double"))
return new eXMLRPCVariant(new double(atof(data)));
else if (!strcmp(n->GetType(), "struct")) {
- std::map<eString,eXMLRPCVariant*> *s=new std::map<eString,eXMLRPCVariant*>;
+ std::map<std::string,eXMLRPCVariant*> *s=new std::map<std::string,eXMLRPCVariant*>;
for (n=n->GetChild(); n; n=n->GetNext())
{
if (strcmp(data, "member"))
delete s;
return 0;
}
- eString name=0;
+ std::string name=0;
eXMLRPCVariant *value;
for (XMLTreeNode *v=n->GetChild(); v; v=v->GetNext())
{
if (!strcmp(v->GetType(), "name"))
- name=eString(v->GetData());
+ name=std::string(v->GetData());
else if (!strcmp(v->GetType(), "value"))
value=fromXML(v);
}
eDebug("doing call");
result="";
// get method name
- eString methodName=0;
+ std::string methodName=0;
if (connection->remote_header["Content-Type"]!="text/xml")
{
for (XMLTreeNode *c=methodCall->GetChild(); c; c=c->GetNext())
{
if (!strcmp(c->GetType(), "methodName"))
- methodName=eString(c->GetData());
+ methodName=std::string(c->GetData());
else if (!strcmp(c->GetType(), "params"))
{
for (XMLTreeNode *p=c->GetChild(); p; p=p->GetNext())
httpd->addResolver(new eHTTPXMLRPCResolver);
}
-void xmlrpc_addMethod(eString methodName, int (*proc)(std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant>&))
+void xmlrpc_addMethod(std::string methodName, int (*proc)(std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant>&))
{
rpcproc[methodName]=proc;
}
-void xmlrpc_fault(ePtrList<eXMLRPCVariant> &res, int faultCode, eString faultString)
+void xmlrpc_fault(ePtrList<eXMLRPCVariant> &res, int faultCode, std::string faultString)
{
- std::map<eString,eXMLRPCVariant*> *s=new std::map<eString,eXMLRPCVariant*>;
+ std::map<std::string,eXMLRPCVariant*> *s=new std::map<std::string,eXMLRPCVariant*>;
s->INSERT("faultCode", new eXMLRPCVariant(new __s32(faultCode)));
- s->INSERT("faultString", new eXMLRPCVariant(new eString(faultString)));
+ s->INSERT("faultString", new eXMLRPCVariant(new std::string(faultString)));
res.push_back(new eXMLRPCVariant(s));
}
-int xmlrpc_checkArgs(eString args, std::vector<eXMLRPCVariant> &parm, ePtrList<eXMLRPCVariant> &res)
+int xmlrpc_checkArgs(std::string args, std::vector<eXMLRPCVariant> &parm, ePtrList<eXMLRPCVariant> &res)
{
if (parm.size() != args.length())
{
- xmlrpc_fault(res, -500, eString().sprintf("parameter count mismatch (found %d, expected %d)", parm.size(), args.length()));
+ xmlrpc_fault(res, -500, std::string().sprintf("parameter count mismatch (found %d, expected %d)", parm.size(), args.length()));
return 1;
}
continue;
break;
}
- xmlrpc_fault(res, -501, eString().sprintf("parameter type mismatch, expected %c as #%d", args[i], i));
+ xmlrpc_fault(res, -501, std::string().sprintf("parameter type mismatch, expected %c as #%d", args[i], i));
return 1;
}
return 0;
{
}
-eHTTPDataSource *eHTTPXMLRPCResolver::getDataSource(eString request, eString path, eHTTPConnection *conn)
+eHTTPDataSource *eHTTPXMLRPCResolver::getDataSource(std::string request, std::string path, eHTTPConnection *conn)
{
if ((path=="/RPC2") && (request=="POST"))
return new eXMLRPCResponse(conn);
#include <vector>
#include <xmltree.h>
-#include <lib/base/estring.h>
+#include <string>
#include <lib/base/eptrlist.h>
#include <lib/network/httpd.h>
-#define INSERT(KEY,VALUE) insert(std::pair<eString, eXMLRPCVariant*>(KEY,VALUE))
+#define INSERT(KEY,VALUE) insert(std::pair<std::string, eXMLRPCVariant*>(KEY,VALUE))
class eXMLRPCVariant
{
- std::map<eString,eXMLRPCVariant*> *_struct;
+ std::map<std::string,eXMLRPCVariant*> *_struct;
std::vector<eXMLRPCVariant> *_array;
__s32 *_i4;
bool *_boolean;
- eString *_string;
+ std::string *_string;
double *_double;
// QDateTime *_datetime;
// QByteArray *_base64;
void zero();
public:
- eXMLRPCVariant(std::map<eString,eXMLRPCVariant*> *_struct);
+ eXMLRPCVariant(std::map<std::string,eXMLRPCVariant*> *_struct);
eXMLRPCVariant(std::vector<eXMLRPCVariant> *_array);
eXMLRPCVariant(__s32 *_i4);
eXMLRPCVariant(bool *_boolean);
- eXMLRPCVariant(eString *_string);
+ eXMLRPCVariant(std::string *_string);
eXMLRPCVariant(double *_double);
// eXMLRPCVariant(QDateTime *_datetime);
// eXMLRPCVariant(QByteArray *_base64);
eXMLRPCVariant(const eXMLRPCVariant &c);
~eXMLRPCVariant();
- std::map<eString,eXMLRPCVariant*> *getStruct();
+ std::map<std::string,eXMLRPCVariant*> *getStruct();
std::vector<eXMLRPCVariant> *getArray();
__s32 *getI4();
bool *getBoolean();
- eString *getString();
+ std::string *getString();
double *getDouble();
// QDateTime *getDatetime();
// QByteArray *getBase64();
- void toXML(eString &);
+ void toXML(std::string &);
};
class eXMLRPCResponse: public eHTTPDataSource
{
XMLTreeParser parser;
- eString result;
+ std::string result;
int size;
int wptr;
int doCall();
};
void xmlrpc_initialize(eHTTPD *httpd);
-void xmlrpc_addMethod(eString methodName, int (*)(std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant>&));
-void xmlrpc_fault(ePtrList<eXMLRPCVariant> &res, int faultCode, eString faultString);
-int xmlrpc_checkArgs(eString args, std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant> &res);
+void xmlrpc_addMethod(std::string methodName, int (*)(std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant>&));
+void xmlrpc_fault(ePtrList<eXMLRPCVariant> &res, int faultCode, std::string faultString);
+int xmlrpc_checkArgs(std::string args, std::vector<eXMLRPCVariant>&, ePtrList<eXMLRPCVariant> &res);
class eHTTPXMLRPCResolver: public eHTTPPathResolver
{
public:
eHTTPXMLRPCResolver();
- eHTTPDataSource *getDataSource(eString request, eString path, eHTTPConnection *conn);
+ eHTTPDataSource *getDataSource(std::string request, std::string path, eHTTPConnection *conn);
};
#endif
--- /dev/null
+INCLUDES = \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/src \
+ -I/usr/include/python2.3
+
+noinst_LIBRARIES = libenigma_python.a
+
+libenigma_python_a_SOURCES = \
+ python.cpp enigma_python_wrap.cxx
+
+enigma_python_wrap.cxx: enigma_python.i
+ swig -I$(top_srcdir)/ -c++ -python enigma_python.i
--- /dev/null
+%module enigma
+%{
+#define SWIG_COMPILE
+#include <lib/base/smartptr.h>
+#include <lib/base/eerror.h>
+#include <lib/base/econfig.h>
+#include <lib/service/iservice.h>
+#include <lib/service/service.h>
+%}
+
+#define DEBUG
+%include "stl.i"
+%include <lib/base/object.h>
+%include <lib/base/eerror.h>
+%include <lib/base/econfig.h>
+%include <lib/base/smartptr.h>
+%include <lib/service/iservice.h>
+%include <lib/service/service.h>
+%template(eServiceCenterPtr) ePtr<eServiceCenter>;
+%template(iPlayableServicePtr) ePtr<iPlayableService>;
+%template(iPauseableServicePtr) ePtr<iPauseableService>;
+%template(iRecordableServicePtr) ePtr<iRecordableService>;
+%template(iListableServicePtr) ePtr<iListableService>;
--- /dev/null
+#include <lib/python/python.h>
+#include <Python.h>
+
+extern "C" void init_enigma();
+
+ePython::ePython()
+{
+ Py_Initialize();
+
+ init_enigma();
+}
+
+ePython::~ePython()
+{
+ Py_Finalize();
+}
+
+int ePython::execute(const std::string &pythonfile, const std::string &funcname)
+{
+ PyObject *pName, *pModule, *pDict, *pFunc, *pArgs, *pValue;
+
+ pName = PyString_FromString(pythonfile.c_str());
+
+ pModule = PyImport_Import(pName);
+ Py_DECREF(pName);
+
+ if (pModule != NULL)
+ {
+ pDict = PyModule_GetDict(pModule);
+
+ pFunc = PyDict_GetItemString(pDict, funcname.c_str());
+
+ if (pFunc && PyCallable_Check(pFunc))
+ {
+ pArgs = PyTuple_New(0);
+ // implement arguments..
+ pValue = PyObject_CallObject(pFunc, pArgs);
+ Py_DECREF(pArgs);
+ if (pValue != NULL)
+ {
+ printf("Result of call: %ld\n", PyInt_AsLong(pValue));
+ Py_DECREF(pValue);
+ } else
+ {
+ Py_DECREF(pModule);
+ PyErr_Print();
+ return 1;
+ }
+ }
+ } else
+ {
+ if (PyErr_Occurred())
+ PyErr_Print();
+ return 1;
+ }
+ return 0;
+}
--- /dev/null
+#ifndef __lib_python_python_h
+#define __lib_python_python_h
+
+#include <string>
+
+class ePython
+{
+public:
+ ePython();
+ ~ePython();
+ int execute(const std::string &pythonfile, const std::string &funcname);
+private:
+
+};
+
+#endif
#define __lib_dvb_iservice_h
#include <lib/base/object.h>
-#include <lib/base/estring.h>
+#include <string>
#include <connection.h>
#include <list>
inline int getSortKey() const { return (flags & hasSortKey) ? data[3] : ((flags & sort1) ? 1 : 0); }
int data[8];
- eString path;
+ std::string path;
eServiceReference()
: type(idInvalid), flags(0)
data[3]=data3;
data[4]=data4;
}
- eServiceReference(int type, int flags, const eString &path)
+ eServiceReference(int type, int flags, const std::string &path)
: type(type), flags(flags), path(path)
{
memset(data, 0, sizeof(data));
}
- eServiceReference(const eString &string);
- eString toString() const;
+ eServiceReference(const std::string &string);
+ std::string toString() const;
bool operator==(const eServiceReference &c) const
{
if (type != c.type)
class iServiceInformation: public iObject
{
public:
- virtual RESULT getName(eString &name)=0;
+ virtual RESULT getName(std::string &name)=0;
};
+typedef ePtr<iServiceInformation> iServiceInformationPtr;
+
class iPauseableService: public iObject
{
public:
virtual RESULT unpause()=0;
};
+typedef ePtr<iPauseableService> iPauseableServicePtr;
+
class iPlayableService: public iObject
{
friend class iServiceHandler;
virtual RESULT getIServiceInformation(ePtr<iServiceInformation> &ptr)=0;
};
+typedef ePtr<iPlayableService> iPlayableServicePtr;
+
class iRecordableService: public iObject
{
public:
virtual RESULT stop()=0;
};
+typedef ePtr<iRecordableService> iRecordableServicePtr;
+
class iListableService: public iObject
{
public:
virtual RESULT getContent(std::list<eServiceReference> &list)=0;
};
+typedef ePtr<iListableService> iListableServicePtr;
+
class iServiceHandler: public iObject
{
public:
virtual RESULT list(const eServiceReference &, ePtr<iListableService> &ptr)=0;
};
+typedef ePtr<iServiceHandler> iServiceHandlerPtr;
+
#endif
+#include <lib/base/eerror.h>
+#include <lib/base/estring.h>
#include <lib/service/service.h>
#include <lib/base/init_num.h>
#include <lib/base/init.h>
-eServiceReference::eServiceReference(const eString &string)
+eServiceReference::eServiceReference(const std::string &string)
{
const char *c=string.c_str();
int pathl=-1;
path=c+pathl;
}
-eString eServiceReference::toString() const
+std::string eServiceReference::toString() const
{
- eString ret;
- ret+=eString().sprintf("%d:", type);
- ret+=eString().sprintf("%d", flags);
+ std::string ret;
+ ret += getNum(type);
+ ret += ":";
+ ret += getNum(flags);
for (unsigned int i=0; i<sizeof(data)/sizeof(*data); ++i)
- ret+=":"+eString().sprintf("%x", data[i]);
+ {
+ ret+=":"+ getNum(data[i], 0x10);
+ }
ret+=":"+path;
return ret;
}
#include <lib/base/object.h>
#include <lib/service/iservice.h>
+class eServiceCenter;
+
+typedef ePtr<eServiceCenter> eServiceCenterPtr;
+
class eServiceCenter: public iServiceHandler
{
DECLARE_REF;
private:
- std::map<int,ePtr<iServiceHandler> > handler;
+ std::map<int,iServiceHandlerPtr> handler;
static eServiceCenter *instance;
public:
eServiceCenter();
virtual ~eServiceCenter();
// iServiceHandler
- RESULT play(const eServiceReference &, ePtr<iPlayableService> &ptr);
- RESULT record(const eServiceReference &, ePtr<iRecordableService> &ptr);
- RESULT list(const eServiceReference &, ePtr<iListableService> &ptr);
+ RESULT play(const eServiceReference &, iPlayableServicePtr &ptr);
+ RESULT record(const eServiceReference &, iRecordableServicePtr &ptr);
+ RESULT list(const eServiceReference &, iListableServicePtr &ptr);
// eServiceCenter
- static RESULT getInstance(ePtr<eServiceCenter> &ptr) { ptr = instance; return 0; }
+ static RESULT getInstance(eServiceCenterPtr &ptr) { ptr = instance; return 0; }
RESULT addServiceFactory(int id, iServiceHandler *hnd);
RESULT removeServiceFactory(int id);
};
return 0;
}
-RESULT eDVBServicePlay::getName(eString &name)
+RESULT eDVBServicePlay::getName(std::string &name)
{
name = "DVB service";
return 0;
RESULT getIServiceInformation(ePtr<iServiceInformation> &ptr);
// iServiceInformation
- RESULT getName(eString &name);
+ RESULT getName(std::string &name);
};
#endif
if (!(strcmp(e->d_name, ".") && strcmp(e->d_name, "..")))
continue;
- eString filename;
+ std::string filename;
filename = path;
filename += e->d_name;
{
DECLARE_REF;
private:
- eString path;
+ std::string path;
friend class eServiceFactoryFS;
eServiceFS(const char *path);
public:
RESULT eServiceMP3::getIServiceInformation(ePtr<iServiceInformation>&i) { i = this; return 0; }
-RESULT eServiceMP3::getName(eString &name)
+RESULT eServiceMP3::getName(std::string &name)
{
name = "MP3 File: " + filename;
return 0;
RESULT getIServiceInformation(ePtr<iServiceInformation>&);
// iServiceInformation
- RESULT getName(eString &name);
+ RESULT getName(std::string &name);
};
#endif
$(top_builddir)/lib/dvb_si/libenigma_dvb_si.a \
$(top_builddir)/lib/gdi/libenigma_gdi.a \
$(top_builddir)/lib/gui/libenigma_gui.a \
+ $(top_builddir)/lib/python/libenigma_python.a \
$(top_builddir)/lib/nav/libenigma_nav.a \
$(top_builddir)/lib/network/libenigma_network.a \
$(top_builddir)/lib/service/libenigma_service.a
@MAD_LIBS@ \
@PNG_LIBS@ \
@SIGC_LIBS@ \
- -ldl -lpthread -lcrypt -lresolv
+ -ldl -lpthread -lcrypt -lresolv -lpython2.3
enigma2$(EXEEXT): $(enigma2_OBJECTS) $(enigma2_DEPENDENCIES) $(enigma2_LDADD_WHOLE)
@rm -f enigma2$(EXEEXT)
eDebug("failed to get iserviceinformation");
break;
}
- eString name;
+ std::string name;
m_serviceInformation->getName(name);
eDebug("NEW running service: %s", name.c_str());
break;
#include <lib/gui/ewindow.h>
+#include <lib/python/python.h>
+
#ifdef OBJECT_DEBUG
int object_total_remaining;
#ifdef OBJECT_DEBUG
atexit(object_dump);
#endif
-
eInit init;
-
+
init.setRunlevel(eAutoInitNumbers::main);
+
+ // gui stuff
+#if 0
ePtr<gFBDC> my_dc;
gFBDC::getInstance(my_dc);
#if 1
// dumpRegion(dsk.m_dirty_region);
dsk.paint();
+
+#endif
+
+ ePython python;
+
+ printf("about to execute TEST :)\n");
+ python.execute("mytest", "test");
+
return 0;
}
--- /dev/null
+from enigma import *
+
+def test():
+ ref = eServiceReference("4097:47:0:0:0:0:0:0:0:0:/sine_60s_100.mp3");
+
+ sc = eServiceCenterPtr()
+ print sc
+
+ if eServiceCenter.getInstance(sc):
+ print "no eServiceCenter instance!"
+ else:
+ print "now trying to play!"
+ i = iPlayableServicePtr();
+ if sc.play(ref, i):
+ print "play failed! :("
+ else:
+ print "play ruled!"
+
+ p = iPauseableServicePtr()
+ if (i.getIPausableService(p)):
+ print "no pause available"
+ else:
+ p.pause()
+ p.unpause()
+
+ return 0