diff options
author | LarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b> | 2004-02-12 09:15:07 +0000 |
---|---|---|
committer | LarsAC <LarsAC@e10066b5-e1e2-0310-b819-94efdf66514b> | 2004-02-12 09:15:07 +0000 |
commit | 368bacb21c6d0c57c0066ae67c88810b6a79b58d (patch) | |
tree | 789cfb6855f86309856abd8c4825cbe55c652c8e | |
parent | 13414776db3ca8457acef6b3466720507c191946 (diff) | |
download | vdr-plugin-muggle-368bacb21c6d0c57c0066ae67c88810b6a79b58d.tar.gz vdr-plugin-muggle-368bacb21c6d0c57c0066ae67c88810b6a79b58d.tar.bz2 |
Moved filter classes into separate files
git-svn-id: https://vdr-muggle.svn.sourceforge.net/svnroot/vdr-muggle/trunk/muggle-plugin@40 e10066b5-e1e2-0310-b819-94efdf66514b
-rw-r--r-- | Makefile | 14 | ||||
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | gd_content_interface.c | 11 | ||||
-rw-r--r-- | gd_content_interface.h | 11 | ||||
-rw-r--r-- | mg_filters.c | 296 | ||||
-rw-r--r-- | mg_filters.h | 164 | ||||
-rw-r--r-- | mg_media.c | 298 | ||||
-rw-r--r-- | mg_media.h | 240 | ||||
-rw-r--r-- | sh_console_osd.c | 212 | ||||
-rw-r--r-- | sh_console_osd.h | 191 | ||||
-rw-r--r-- | sh_console_osd_menuitems.c | 530 | ||||
-rw-r--r-- | sh_console_osd_menuitems.h | 130 | ||||
-rw-r--r-- | sh_dummy_content.c | 596 | ||||
-rw-r--r-- | sh_dummy_content.h | 188 | ||||
-rw-r--r-- | sh_muggle.c | 366 | ||||
-rw-r--r-- | sh_muggle2.c | 66 | ||||
-rw-r--r-- | sh_plugin.c | 77 | ||||
-rw-r--r-- | sh_plugin.h | 46 |
18 files changed, 538 insertions, 2899 deletions
@@ -1,7 +1,7 @@ # # Makefile for a Video Disk Recorder plugin # -# $Id: Makefile,v 1.6 2004/02/09 22:07:44 RaK Exp $ +# $Id: Makefile,v 1.7 2004/02/12 09:15:07 LarsAC Exp $ # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. @@ -46,10 +46,8 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' ### The object files (add further files here): -OBJS = $(PLUGIN).o vdr_menu.o mg_database.o mg_content_interface.o gd_content_interface.o mg_tools.o mg_media.o - -BINOBJS = mg_database.o mg_content_interface.o gd_content_interface.o mg_tools.o mg_media.o -#BINOBJS = sh_console_osd.o muggle.o vdr_menu.o content_interface.o gd_content_interface.o muggle_tools.o mgmedia.o +OBJS = $(PLUGIN).o vdr_menu.o mg_database.o mg_content_interface.o gd_content_interface.o mg_tools.o mg_media.o mg_filters.o +BINOBJS = mg_database.o mg_content_interface.o gd_content_interface.o mg_tools.o mg_media.o mg_filters.o ### Targets: @@ -73,12 +71,6 @@ libvdr-$(PLUGIN).so: $(OBJS) $(CXX) $(CXXFLAGS) -shared $(OBJS) -lmysqlclient -o $@ @cp $@ $(LIBDIR)/$@.$(VDRVERSION) -sh_muggle : sh_muggle.c $(BINOBJS) - $(CXX) $(CXXFLAGS) $(BINOBJS) sh_muggle.c -lmysqlclient -o $@ - -sh_muggle2 : sh_muggle2.c $(BINOBJS) - $(CXX) $(CXXFLAGS) sh_muggle2.c $(BINOBJS) -lmysqlclient -o $@ - dist: clean @-rm -rf $(TMPDIR)/$(ARCHIVE) @mkdir $(TMPDIR)/$(ARCHIVE) @@ -17,6 +17,7 @@ OSD - handle filters: - create tracklist from filter - create tree from filter +- i18n Content ------- diff --git a/gd_content_interface.c b/gd_content_interface.c index c916e6a..bcaf500 100644 --- a/gd_content_interface.c +++ b/gd_content_interface.c @@ -3,10 +3,10 @@ * \brief Data Objects for content (e.g. mp3 files, movies) * for the vdr muggle plugindatabase ******************************************************************** - * \version $Revision: 1.14 $ - * \date $Date: 2004/02/12 07:56:46 $ + * \version $Revision: 1.15 $ + * \date $Date: 2004/02/12 09:15:07 $ * \author Ralf Klueber, Lars von Wedel, Andreas Kellner - * \author file owner: $Author: RaK $ + * \author file owner: $Author: LarsAC $ * * DUMMY * Implements main classes of for content items and interfaces to SQL databases @@ -40,7 +40,7 @@ int GdInitDatabase(MYSQL *db) } if(mysql_real_connect(db,"localhost","root","", - "GiantDisc",0,NULL,0) == NULL) + "GiantDisc2",0,NULL,0) == NULL) { return -2; } @@ -1438,6 +1438,9 @@ mgContentItem* GdTreeNode::getSingleTrack() /* -------------------- begin CVS log --------------------------------- * $Log: gd_content_interface.c,v $ + * Revision 1.15 2004/02/12 09:15:07 LarsAC + * Moved filter classes into separate files + * * Revision 1.14 2004/02/12 07:56:46 RaK * - SQL Fehler bei der Playlist Search korrigiert * diff --git a/gd_content_interface.h b/gd_content_interface.h index fecca7c..ce86163 100644 --- a/gd_content_interface.h +++ b/gd_content_interface.h @@ -3,10 +3,10 @@ * \brief Data Objects for content (e.g. mp3 files, movies) * for the vdr muggle plugindatabase ******************************************************************** - * \version $Revision: 1.4 $ - * \date $Date: 2004/02/09 19:27:52 $ + * \version $Revision: 1.5 $ + * \date $Date: 2004/02/12 09:15:07 $ * \author Ralf Klueber, Lars von Wedel, Andreas Kellner - * \author file owner: $Author: MountainMan $ + * \author file owner: $Author: LarsAC $ * * Declares main classes of for content items and interfaces to SQL databases * @@ -29,12 +29,12 @@ #include "mg_content_interface.h" #include "mg_media.h" +#include "mg_filters.h" // non-member function int GdInitDatabase(MYSQL *db); std::vector<std::string> *GdGetStoredPlaylists(MYSQL db); - class gdFilterSets : public mgFilterSets { @@ -219,6 +219,9 @@ public: /* -------------------- begin CVS log --------------------------------- * $Log: gd_content_interface.h,v $ + * Revision 1.5 2004/02/12 09:15:07 LarsAC + * Moved filter classes into separate files + * * Revision 1.4 2004/02/09 19:27:52 MountainMan * filter set implemented * diff --git a/mg_filters.c b/mg_filters.c new file mode 100644 index 0000000..bd19178 --- /dev/null +++ b/mg_filters.c @@ -0,0 +1,296 @@ +/*******************************************************************/ +/*! \file mg_filters.c + * \brief + ******************************************************************** + * \version $Revision: 1.1 $ + * \date $Date: 2004/02/12 09:15:07 $ + * \author Ralf Klueber, Lars von Wedel, Andreas Kellner + * \author file owner: $Author: LarsAC $ + */ +/*******************************************************************/ + +/* makes sure we dont parse the same declarations twice */ +#include "mg_filters.h" +#include "mg_tools.h" + +using namespace std; + +//------------------------------------------------------------------- +// mgFilter +//------------------------------------------------------------------- +mgFilter::mgFilter(const char* name) +{ + m_name = strdup(name); +} +mgFilter::~mgFilter() +{ + free(m_name); +} + +const char* mgFilter::getName() +{ + return m_name; +} + +mgFilter::filterType mgFilter::getType() +{ + return m_type; +} + +//------------------------------------------------------------------- +// mgFilterInt +//------------------------------------------------------------------- +mgFilterInt::mgFilterInt(const char *name, int value, int min, int max) + : mgFilter(name) +{ + m_type = INT; + m_intval = value; + m_default_val = value; + m_stored_val = value; + m_max = max; + m_min = min; +} +mgFilterInt::~mgFilterInt() +{ +} + +string mgFilterInt::getStrVal() +{ + char buffer[20]; + sprintf(buffer, "%d", m_intval); + + return (string)buffer; +} + +int mgFilterInt::getIntVal() +{ + return (int) m_intval; +} + +int mgFilterInt::getVal() +{ + return m_intval; +} + +int mgFilterInt::getMin() +{ + return m_min; +} + +int mgFilterInt::getMax() +{ + return m_max; +} + +void mgFilterInt::store() +{ + m_stored_val = m_intval; +} +void mgFilterInt::restore() +{ + m_intval = m_stored_val; +} +void mgFilterInt::clear() +{ + m_stored_val = m_default_val; + m_intval = m_default_val; +} + +bool mgFilterInt::isSet() +{ + if(m_stored_val == m_default_val) + { + return false; + } + return true; +} + +//------------------------------------------------------------------- +// mgFilterString +//------------------------------------------------------------------- +mgFilterString::mgFilterString(const char *name, const char* value, + int maxlen, string allowedchar) + : mgFilter(name) +{ + m_type = STRING; + m_strval = strdup(value); + m_default_val = strdup(value); + m_stored_val = strdup(value); + m_allowedchar = allowedchar; + m_maxlen = maxlen; +} +mgFilterString::~mgFilterString() +{ + if(m_strval) + { + free(m_strval); + } +} + +int mgFilterString::getMaxLength() +{ + return m_maxlen; +} + +string mgFilterString::getAllowedChars() +{ + return m_allowedchar; +} +string mgFilterString::getStrVal() +{ + + return (string) m_strval; +} +void mgFilterString::store() +{ + if(m_stored_val) free(m_stored_val); + m_stored_val = strdup(m_strval); +} +void mgFilterString::restore() +{ + if(m_strval) free(m_strval); + m_strval = strdup(m_stored_val); +} +void mgFilterString::clear() +{ + if(m_stored_val) free(m_stored_val); + if(m_strval) free(m_strval); + + m_stored_val = strdup(m_default_val); + m_strval = strdup(m_default_val); +} + +bool mgFilterString::isSet() +{ + if(strlen(m_stored_val) == 0) + { + return false; + } + return true; +} +//------------------------------------------------------------------- +// mgFilterBool +//------------------------------------------------------------------- +mgFilterBool::mgFilterBool(const char *name, bool value, + string truestr, string falsestr) + : mgFilter(name) +{ + m_type = BOOL; + m_bval = (int) value; + m_default_val = value; + m_stored_val = value; + m_truestr = truestr; + m_falsestr = falsestr; + +} + +mgFilterBool::~mgFilterBool() +{ +} + +string mgFilterBool::getStrVal() +{ + if(m_bval) + return "true"; + else + return "false"; +} + +int mgFilterBool::getIntVal() +{ + return (int) m_bval; +} + +string mgFilterBool::getTrueString() +{ + return m_truestr; +} + +string mgFilterBool::getFalseString() +{ + return m_falsestr; +} + +bool mgFilterBool::getVal() +{ + return (bool) m_bval; +} + +void mgFilterBool::store() +{ + m_stored_val = (bool) m_bval; +} + +void mgFilterBool::restore() +{ + m_bval = (int) m_stored_val; +} + +void mgFilterBool::clear() +{ + m_stored_val = (int) m_default_val; + m_bval = (int) m_default_val; +} + +bool mgFilterBool::isSet() +{ + if(m_stored_val == m_default_val ) + { + return false; + } + return true; +} +//------------------------------------------------------------------- +// mgFilterChoice +//------------------------------------------------------------------- +mgFilterChoice::mgFilterChoice(const char *name, int value, vector<string> *choices) + : mgFilter(name) +{ + m_choices = *choices; + m_selval = value; + m_default_val = value; + if( m_selval < 0 || m_selval >= (int) m_choices.size() ) + { + mgError("mgFilterChoice::mgFilterChoice(..): Illegal index %d", m_selval); + } +} +mgFilterChoice::~mgFilterChoice() +{ + m_choices.clear(); +} + +string mgFilterChoice::getStrVal() +{ + if( m_selval < 0 || m_selval >= (int) m_choices.size() ) + { + mgError("mgFilterChoice::getStrVal(): Illegal index %d", m_selval); + } + return m_choices[m_selval]; +} +vector<string> &mgFilterChoice::getChoices() +{ + return m_choices; +} +void mgFilterChoice::store() +{ + m_stored_val = m_selval; + +} +void mgFilterChoice::restore() +{ + m_selval = m_stored_val; +} +void mgFilterChoice::clear() +{ + m_stored_val = m_default_val; + m_selval = m_default_val; +} + +bool mgFilterChoice::isSet() +{ + if(m_stored_val == m_default_val) + { + return false; + } + return true; +} diff --git a/mg_filters.h b/mg_filters.h new file mode 100644 index 0000000..8a983f7 --- /dev/null +++ b/mg_filters.h @@ -0,0 +1,164 @@ +/*******************************************************************/ +/*! \file mg_filters.h + * \brief Top level access to media in vdr plugin muggle + * for the vdr muggle plugindatabase + ******************************************************************** + * \version $Revision: 1.1 $ + * \date $Date: 2004/02/12 09:15:07 $ + * \author Ralf Klueber, Lars von Wedel, Andreas Kellner + * \author file owner: $Author: LarsAC $ + */ +/*******************************************************************/ + +#ifndef _MG_FILTERS_H +#define _MG_FILTERS_H + +#include <string> +#include <vector> + +/*! + ******************************************************************* + * \class mgFilter + * + * Abstract base class for representation of filter values with boundaries + ********************************************************************/ +class mgFilter +{ + public: + typedef enum filterType + { + UNDEF=0, INT, STRING, BOOL, CHOICE + } filterType; + + protected: + filterType m_type; + char* m_name; + + public: + mgFilter(const char* name); + virtual ~mgFilter(); + filterType getType(); + const char* getName(); + virtual std::string getStrVal()=0; + virtual int getIntVal(){return 0;} + virtual void store()=0; + virtual void restore()=0; + virtual void clear()=0; + virtual bool isSet()=0; +}; + +/*! + ******************************************************************* + * \class mgFilterInt + ********************************************************************/ +class mgFilterInt : public mgFilter +{ + private: + int m_min; + int m_max; + int m_stored_val; + int m_default_val; + + public: + int m_intval; + + mgFilterInt(const char *name, int value, int min = 0, int max = 9999); + virtual ~mgFilterInt(); + + int getVal(); + int getMin(); + int getMax(); + virtual std::string getStrVal(); + virtual int getIntVal(); + virtual void store(); + virtual void restore(); + virtual void clear(); + virtual bool isSet(); +}; + +/*! + ******************************************************************* + * \class mgFilterString + ********************************************************************/ +class mgFilterString : public mgFilter +{ + private: + std::string m_allowedchar; + int m_maxlen; + char* m_stored_val; + char* m_default_val; + + public: + char* m_strval; + + mgFilterString(const char *name, const char* value, int maxlen=255, + std::string allowedchar="abcdefghijklmnopqrstuvwxyz0123456789-"); + + virtual ~mgFilterString(); + + int getMaxLength(); + std::string getAllowedChars(); + virtual std::string getStrVal(); + virtual void store(); + virtual void restore(); + virtual void clear(); + virtual bool isSet(); +}; + +/*! + ******************************************************************* + * \class mgFilterBool + ********************************************************************/ +class mgFilterBool : public mgFilter +{ + private: + std::string m_truestr; + std::string m_falsestr; + bool m_stored_val; + bool m_default_val; + + public: + int m_bval; + + mgFilterBool(const char *name, bool value, + std::string truestr="yes", std::string falsestr="no"); + virtual ~mgFilterBool(); + + virtual std::string getStrVal(); + virtual int getIntVal(); + std::string getTrueString(); + std::string getFalseString(); + bool getVal(); + virtual void store(); + virtual void restore(); + virtual void clear(); + virtual bool isSet(); +}; + +/*! + ******************************************************************* + * \class mgFilterChoice + ********************************************************************/ +class mgFilterChoice : public mgFilter +{ + private: + std::vector<std::string> m_choices; + int m_stored_val; + int m_default_val; + + public: + int m_selval; // index of the currently selected item + + mgFilterChoice(const char *name, int val, std::vector<std::string> *choices); + virtual ~mgFilterChoice(); + + virtual std::string getStrVal(); + virtual std::vector<std::string> &getChoices(); + virtual void store(); + virtual void restore(); + virtual void clear(); + virtual bool isSet(); +}; + + +#endif @@ -3,12 +3,10 @@ * \brief Top level access to media in vdr plugin muggle * for the vdr muggle plugindatabase ******************************************************************** - * \version $Revision: 1.10 $ - * \date $Date: 2004/02/10 23:47:23 $ + * \version $Revision: 1.11 $ + * \date $Date: 2004/02/12 09:15:07 $ * \author Ralf Klueber, Lars von Wedel, Andreas Kellner - * \author file owner: $Author: RaK $ - * - * + * \author file owner: $Author: LarsAC $ */ /*******************************************************************/ @@ -18,290 +16,9 @@ #include "mg_content_interface.h" #include "gd_content_interface.h" - using namespace std; //------------------------------------------------------------------- -// mgFilter -//------------------------------------------------------------------- -mgFilter::mgFilter(const char* name) -{ - m_name = strdup(name); -} -mgFilter::~mgFilter() -{ - free(m_name); -} - -const char* mgFilter::getName() -{ - return m_name; -} - -mgFilter::filterType mgFilter::getType() -{ - return m_type; -} - -//------------------------------------------------------------------- -// mgFilterInt -//------------------------------------------------------------------- -mgFilterInt::mgFilterInt(const char *name, int value, int min, int max) - : mgFilter(name) -{ - m_type = INT; - m_intval = value; - m_default_val = value; - m_stored_val = value; - m_max = max; - m_min = min; -} -mgFilterInt::~mgFilterInt() -{ -} - -string mgFilterInt::getStrVal() -{ - char buffer[20]; - sprintf(buffer, "%d", m_intval); - - return (string)buffer; -} - -int mgFilterInt::getIntVal() -{ - return (int) m_intval; -} - -int mgFilterInt::getVal() -{ - return m_intval; -} - -int mgFilterInt::getMin() -{ - return m_min; -} - -int mgFilterInt::getMax() -{ - return m_max; -} - -void mgFilterInt::store() -{ - m_stored_val = m_intval; -} -void mgFilterInt::restore() -{ - m_intval = m_stored_val; -} -void mgFilterInt::clear() -{ - m_stored_val = m_default_val; - m_intval = m_default_val; -} - -bool mgFilterInt::isSet() -{ - if(m_stored_val == m_default_val) - { - return false; - } - return true; -} - -//------------------------------------------------------------------- -// mgFilterString -//------------------------------------------------------------------- -mgFilterString::mgFilterString(const char *name, const char* value, - int maxlen, string allowedchar) - : mgFilter(name) -{ - m_type = STRING; - m_strval = strdup(value); - m_default_val = strdup(value); - m_stored_val = strdup(value); - m_allowedchar = allowedchar; - m_maxlen = maxlen; -} -mgFilterString::~mgFilterString() -{ - if(m_strval) - { - free(m_strval); - } -} - -int mgFilterString::getMaxLength() -{ - return m_maxlen; -} - -string mgFilterString::getAllowedChars() -{ - return m_allowedchar; -} -string mgFilterString::getStrVal() -{ - - return (string) m_strval; -} -void mgFilterString::store() -{ - if(m_stored_val) free(m_stored_val); - m_stored_val = strdup(m_strval); -} -void mgFilterString::restore() -{ - if(m_strval) free(m_strval); - m_strval = strdup(m_stored_val); -} -void mgFilterString::clear() -{ - if(m_stored_val) free(m_stored_val); - if(m_strval) free(m_strval); - - m_stored_val = strdup(m_default_val); - m_strval = strdup(m_default_val); -} - -bool mgFilterString::isSet() -{ - if(strlen(m_stored_val) == 0) - { - return false; - } - return true; -} -//------------------------------------------------------------------- -// mgFilterBool -//------------------------------------------------------------------- -mgFilterBool::mgFilterBool(const char *name, bool value, - string truestr, string falsestr) - : mgFilter(name) -{ - m_type = BOOL; - m_bval = (int) value; - m_default_val = value; - m_stored_val = value; - m_truestr = truestr; - m_falsestr = falsestr; - -} - -mgFilterBool::~mgFilterBool() -{ -} - -string mgFilterBool::getStrVal() -{ - if(m_bval) - return "true"; - else - return "false"; -} - -int mgFilterBool::getIntVal() -{ - return (int) m_bval; -} - -string mgFilterBool::getTrueString() -{ - return m_truestr; -} - -string mgFilterBool::getFalseString() -{ - return m_falsestr; -} - -bool mgFilterBool::getVal() -{ - return (bool) m_bval; -} - -void mgFilterBool::store() -{ - m_stored_val = (bool) m_bval; -} - -void mgFilterBool::restore() -{ - m_bval = (int) m_stored_val; -} - -void mgFilterBool::clear() -{ - m_stored_val = (int) m_default_val; - m_bval = (int) m_default_val; -} - -bool mgFilterBool::isSet() -{ - if(m_stored_val == m_default_val ) - { - return false; - } - return true; -} -//------------------------------------------------------------------- -// mgFilterChoice -//------------------------------------------------------------------- -mgFilterChoice::mgFilterChoice(const char *name, int value, vector<string> *choices) - : mgFilter(name) -{ - m_choices = *choices; - m_selval = value; - m_default_val = value; - if( m_selval < 0 || m_selval >= (int) m_choices.size() ) - { - mgError("mgFilterChoice::mgFilterChoice(..): Illegal index %d", m_selval); - } -} -mgFilterChoice::~mgFilterChoice() -{ - m_choices.clear(); -} - -string mgFilterChoice::getStrVal() -{ - if( m_selval < 0 || m_selval >= (int) m_choices.size() ) - { - mgError("mgFilterChoice::getStrVal(): Illegal index %d", m_selval); - } - return m_choices[m_selval]; -} -vector<string> &mgFilterChoice::getChoices() -{ - return m_choices; -} -void mgFilterChoice::store() -{ - m_stored_val = m_selval; - -} -void mgFilterChoice::restore() -{ - m_selval = m_stored_val; -} -void mgFilterChoice::clear() -{ - m_stored_val = m_default_val; - m_selval = m_default_val; -} - -bool mgFilterChoice::isSet() -{ - if(m_stored_val == m_default_val) - { - return false; - } - return true; -} - -//------------------------------------------------------------------- // mgFilterSets //------------------------------------------------------------------- /*! @@ -463,7 +180,7 @@ mgMedia::mgMedia(contentType mediatype) case GD_MP3: { errval = GdInitDatabase(&m_db); - mgDebug(3, "Successfully conntected to sql database 'GiantDisc'"); + mgDebug(3, "Successfully conntected to sql database 'GiantDisc2'"); } } if(errval < 0) @@ -477,7 +194,7 @@ mgMedia::mgMedia(contentType mediatype) case GD_MP3: { errval = GdInitDatabase(&m_db); - mgDebug(3, "Successfully conntected to sql database 'GiantDisc'"); + mgDebug(3, "Successfully conntected to sql database 'GiantDisc2'"); } } } @@ -503,7 +220,7 @@ string mgMedia::getMediaTypeName() switch(m_mediatype) { case GD_MP3: - return "GiantDisc-mp3"; + return "GiantDisc2"; } mgError("implementation Error"); // we should never get here return ""; @@ -712,6 +429,9 @@ mgSelectionTreeNode *mgMedia::applyActiveFilter() /* -------------------- begin CVS log --------------------------------- * $Log: mg_media.c,v $ + * Revision 1.11 2004/02/12 09:15:07 LarsAC + * Moved filter classes into separate files + * * Revision 1.10 2004/02/10 23:47:23 RaK * - views konsitent gemacht. siehe FROMJOIN * - isLeafNode angepasst fuer neue views 4,5,100,101 @@ -3,12 +3,10 @@ * \brief Top level access to media in vdr plugin muggle * for the vdr muggle plugindatabase ******************************************************************** - * \version $Revision: 1.9 $ - * \date $Date: 2004/02/09 22:07:44 $ + * \version $Revision: 1.10 $ + * \date $Date: 2004/02/12 09:15:07 $ * \author Ralf Klueber, Lars von Wedel, Andreas Kellner - * \author file owner: $Author: RaK $ - * - * + * \author file owner: $Author: LarsAC $ */ /*******************************************************************/ /* makes sure we dont use parse the same declarations twice */ @@ -23,147 +21,8 @@ class mgPlaylist; class mgTracklist; class mgSelectionTreeNode; - -/*! - ******************************************************************* - * \class mgFilter - * - * Abstract base class for representation of filter values with boundaries - ********************************************************************/ -class mgFilter -{ - public: - typedef enum filterType { UNDEF=0, INT, STRING, BOOL }filterType; - protected: - filterType m_type; - char* m_name; - - public: - mgFilter(const char* name); - virtual ~mgFilter(); - filterType getType(); - const char* getName(); - virtual std::string getStrVal()=0; - virtual int getIntVal(){return 0;} - virtual void store()=0; - virtual void restore()=0; - virtual void clear()=0; - virtual bool isSet()=0; -}; - -/*! - ******************************************************************* - * \class mgFilterInt - ********************************************************************/ -class mgFilterInt : public mgFilter -{ - private: - int m_min; - int m_max; - int m_stored_val; - int m_default_val; - - public: - int m_intval; - - mgFilterInt(const char *name, int value, int min = 0, int max = 9999); - virtual ~mgFilterInt(); - - int getVal(); - int getMin(); - int getMax(); - virtual std::string getStrVal(); - virtual int getIntVal(); - virtual void store(); - virtual void restore(); - virtual void clear(); - virtual bool isSet(); -}; - -/*! - ******************************************************************* - * \class mgFilterString - ********************************************************************/ -class mgFilterString : public mgFilter -{ - private: - std::string m_allowedchar; - int m_maxlen; - char* m_stored_val; - char* m_default_val; - - public: - char* m_strval; - - mgFilterString(const char *name, const char* value, int maxlen=255, - std::string allowedchar="abcdefghijklmnopqrstuvwxyz0123456789-"); - - virtual ~mgFilterString(); - - int getMaxLength(); - std::string getAllowedChars(); - virtual std::string getStrVal(); - virtual void store(); - virtual void restore(); - virtual void clear(); - virtual bool isSet(); -}; - -/*! - ******************************************************************* - * \class mgFilterBool - ********************************************************************/ -class mgFilterBool : public mgFilter -{ - private: - std::string m_truestr; - std::string m_falsestr; - bool m_stored_val; - bool m_default_val; - - public: - int m_bval; - - mgFilterBool(const char *name, bool value, - std::string truestr="yes", std::string falsestr="no"); - virtual ~mgFilterBool(); - - virtual std::string getStrVal(); - virtual int getIntVal(); - std::string getTrueString(); - std::string getFalseString(); - bool getVal(); - virtual void store(); - virtual void restore(); - virtual void clear(); - virtual bool isSet(); -}; - -/*! - ******************************************************************* - * \class mgFilterChoices - ********************************************************************/ -class mgFilterChoice : public mgFilter -{ - private: - std::vector<std::string> m_choices; - int m_stored_val; - int m_default_val; - - public: - int m_selval; // index of the currently selected item - - mgFilterChoice(const char *name, int val, std::vector<std::string> *choices); - virtual ~mgFilterChoice(); - - virtual std::string getStrVal(); - virtual std::vector<std::string> &getChoices(); - virtual void store(); - virtual void restore(); - virtual void clear(); - virtual bool isSet(); -}; - +class mgFilter; +class mgFilterSets; /*! ******************************************************************* @@ -220,6 +79,7 @@ class mgFilterSets { // returns title of active filter set }; + /*! ******************************************************************* * \class mgMedia @@ -235,61 +95,63 @@ class mgMedia { public: - typedef enum contentType{ - GD_MP3 - } contentType; - + typedef enum contentType + { + GD_MP3 + } contentType; + private: MYSQL m_db; contentType m_mediatype; std::string m_sql_filter; int m_defaultView; - mgFilterSets *m_filters; + mgFilterSets *m_filters; public: - mgMedia(contentType mediatype); - ~mgMedia(); - - std::string getMediaTypeName(); - - mgSelectionTreeNode* getSelectionRoot(); - - // playlist management - mgPlaylist* createTemporaryPlaylist(); - mgPlaylist* loadPlaylist( std::string name ); - std::vector<std::string> *getStoredPlaylists(); - - std::vector<int> getDefaultCols(); - mgTracklist* getTracks(); - - // filter management - - void initFilterSet(int num=0); - // creates FiliterSetObject for the selected media type - // and activates set n (if available) - - - std::vector<mgFilter*> *getActiveFilters(); - // returns pointer to the activen filter set to be modified by the osd - // Note: Modifications become only active by calling applyActiveFilter() - - std::string getActiveFilterTitle(); - - void nextFilterSet(); - // proceeds to the next filter set in a cirlucar fashion - - void clearActiveFilter(); - // clears the current filter values and restores defaults - - - mgSelectionTreeNode *applyActiveFilter(); - // Applies the active filter set and returns a root node for the - // selection in the default view for this filter set + mgMedia(contentType mediatype); + ~mgMedia(); + + std::string getMediaTypeName(); + + mgSelectionTreeNode* getSelectionRoot(); + + // playlist management + mgPlaylist* createTemporaryPlaylist(); + mgPlaylist* loadPlaylist( std::string name ); + std::vector<std::string> *getStoredPlaylists(); + + std::vector<int> getDefaultCols(); + mgTracklist* getTracks(); + + // filter management + + void initFilterSet(int num=0); + // creates FiliterSetObject for the selected media type + // and activates set n (if available) + + std::vector<mgFilter*> *getActiveFilters(); + // returns pointer to the activen filter set to be modified by the osd + // Note: Modifications become only active by calling applyActiveFilter() + + std::string getActiveFilterTitle(); + + void nextFilterSet(); + // proceeds to the next filter set in a cirlucar fashion + + void clearActiveFilter(); + // clears the current filter values and restores defaults + + mgSelectionTreeNode *applyActiveFilter(); + // Applies the active filter set and returns a root node for the + // selection in the default view for this filter set }; /* -------------------- begin CVS log --------------------------------- * $Log: mg_media.h,v $ + * Revision 1.10 2004/02/12 09:15:07 LarsAC + * Moved filter classes into separate files + * * Revision 1.9 2004/02/09 22:07:44 RaK * secound filter set (album search incl. special view #101 * diff --git a/sh_console_osd.c b/sh_console_osd.c deleted file mode 100644 index ebb4702..0000000 --- a/sh_console_osd.c +++ /dev/null @@ -1,212 +0,0 @@ -/* - * osd.c: Abstract On Screen Display layer - * - * See the main source file 'vdr.c' for copyright information and - * how to reach the author. - * - * $Id: sh_console_osd.c,v 1.1 2004/02/01 18:22:53 LarsAC Exp $ - */ - -#include "myosd.h" -#include <string.h> -//#include "device.h" -// #include "i18n.h" -//#include "status.h" - -// --- cOsdItem -------------------------------------------------------------- - -cOsdItem::cOsdItem(eOSState State) -{ - text = NULL; -} - -cOsdItem::cOsdItem(const char *Text, eOSState State) -{ - text = NULL; - SetText(Text,true); -} - -cOsdItem::~cOsdItem() -{ - free(text); -} - -void cOsdItem::SetText(const char *Text, bool Copy) -{ - free(text); - text = Copy ? strdup(Text) : (char *)Text; // text assumes ownership! -} - -const char* cOsdItem::Get() -{ - return text; -} -void cOsdItem::Display() -{ - printf("%s\n", text); -} - -// --- cOsdMenu -------------------------------------------------------------- - -cOsdMenu::cOsdMenu(const char *Title, int c0, int c1, int c2, int c3, int c4) -{ - cols[0] = c0; - cols[1] = c1; - cols[2] = c2; - cols[3] = c3; - cols[4] = c4; - m_first = 0; - m_current = m_marked = -1; - subMenu = NULL; - helpRed = helpGreen = helpYellow = helpBlue = NULL; - status = NULL; -} - -cOsdMenu::~cOsdMenu() -{ - free(title); - delete subMenu; - free(status); -} - - -void cOsdMenu::SetTitle(const char *Title, bool ShowDate) -{ - title = strdup(Title); -} - -void cOsdMenu::Add(cOsdItem *Item) -{ - m_display.push_back(Item); -} - -void cOsdMenu::Display(void) -{ - //Interface->Clear(); - printf("\n\n\n\n"); - printf("----------(start %d, current %d)--------------------\n", - m_first, m_current); - //Interface->SetCols(cols); - //Interface->Title(title); - printf(" Title: %s\n", title); - //Interface->Help(helpRed, helpGreen, helpYellow, helpBlue); - for(int i= m_first; i < (int) m_display.size() && i < m_first+DISPLAY_SIZE; i++) - { - if(i == m_current) - { - printf("==>"); - - } - else - { - printf(" "); - - } - printf("%s\n", m_display[i]->Get()); - } - printf("----------------------------------------------\n"); - if(hasHotkeys) - { - printf("%15s (r) %15s (g) %15s (y) %15s (b)\n", - helpRed? helpRed :"" , - helpGreen? helpGreen :"" , - helpYellow? helpYellow :"" , - helpBlue? helpBlue :"" ); - - } -} - -int cOsdMenu::Index(cOsdItem *Item) -{ - int pos=0; - for(vector<cOsdItem*>::iterator iter = m_display.begin(); - iter != m_display.end(); iter++) - { - if((*iter) == Item) - { - break; - } - pos++; - } - return pos; -} -void cOsdMenu::SetCurrent(cOsdItem *Item) -{ - m_current = Item ? Index(Item) : -1; -} -void cOsdMenu::CursorUp(void) -{ - if(m_current >0) m_current--; - if(m_current < m_first) m_first = m_first - PAGE_JUMP; - Display(); -} -void cOsdMenu::CursorDown(void) -{ - if(m_current < (int)m_display.size()-1) - m_current++; - if(m_current >= m_first+DISPLAY_SIZE) m_first =m_first + PAGE_JUMP; - Display(); -} - -void cOsdMenu::PageUp(void) -{ - if(m_first >= PAGE_JUMP) - { - m_first -= PAGE_JUMP; - m_current -= PAGE_JUMP; - } - Display(); - -} -void cOsdMenu::PageDown(void) -{ - if(m_first+ PAGE_JUMP< (int)m_display.size()) - { - m_first += PAGE_JUMP; - m_current += PAGE_JUMP; - if(m_current < m_first) m_current = m_first; - if(m_current >= (int) m_display.size()) - m_current = (int) m_display.size(); - } - Display(); -} - -void cOsdMenu::Clear(void) -{ - m_first = 0; - m_current = m_marked = -1; - hasHotkeys = false; - for(vector<cOsdItem*>::iterator iter = m_display.begin(); - iter != m_display.end(); iter++) - { - delete *iter; - } - m_display.clear(); -} - -eOSState cOsdMenu::ProcessKey(eKeys Key) -{ - - switch (Key) { - case kUp|k_Repeat: - case kUp: CursorUp(); break; - case kDown|k_Repeat: - case kDown: CursorDown(); break; - case kLeft|k_Repeat: - case kLeft: PageUp(); break; - case kRight|k_Repeat: - case kRight: PageDown(); break; - case kBack: return osBack; - default: if (m_marked < 0) - return osUnknown; - } - return osContinue; -} - -void cOsdMenu::SetHelp(const char *Red, const char *Green, const char *Yellow, const char *Blue) -{ - helpRed = Red; - helpGreen = Green; - helpYellow = Yellow; - helpBlue = Blue; -} diff --git a/sh_console_osd.h b/sh_console_osd.h deleted file mode 100644 index 4a4e413..0000000 --- a/sh_console_osd.h +++ /dev/null @@ -1,191 +0,0 @@ -/* - * osd.h: Abstract On Screen Display layer - * - * See the main source file 'vdr.c' for copyright information and - * how to reach the author. - * - * $Id: sh_console_osd.h,v 1.1 2004/02/01 18:22:53 LarsAC Exp $ - */ -#ifndef __OSD_H -#define __OSD_H -#define DEBUG_OSD -#if defined(DEBUG_OSD) -#include <ncurses.h> -#include <stdlib.h> -#include <vector.h> -#endif -//#include "config.h" -// #include "interface.h" -//#include "osdbase.h" -//#include "tools.h" -#define MaxCols 5 -#define Setup_OSDheight 12 -#define Setup_OSDwidth 40 -#define Setup_Symbol false -#define Setup_MenuScrollPage true -#define MAXOSDITEMS (Setup.OSDheight - 4) -enum eDvbColor { - clrBackground, - clrTransparent = clrBackground, - clrBlack = clrBackground, - clrRed, - clrGreen, - clrYellow, - clrBlue, - clrMagenta, - clrCyan, - clrWhite, - }; - -extern int bgbackground, bgchannelname, bgepgtime, bgtitleline, bgscrolline, - bghelpred, bghelpgreen, bghelpyellow, bghelpblue; - -#define clrBackground ((eDvbColor)bgbackground) -#define clrChannelName ((eDvbColor)bgchannelname) -#define clrEpgTime ((eDvbColor)bgepgtime) -#define clrTitleLine ((eDvbColor)bgtitleline) -#define clrScrolLine ((eDvbColor)bgscrolline) -#define clrHelpRed ((eDvbColor)bghelpred) -#define clrHelpGreen ((eDvbColor)bghelpgreen) -#define clrHelpYellow ((eDvbColor)bghelpyellow) -#define clrHelpBlue ((eDvbColor)bghelpblue) - -#define DISPLAY_SIZE 12 -#define PAGE_JUMP 11 - -extern int fgchannelname, fgdatetime, fgepgtime, fgtitle, fgsubtitle, fgtitleline, fgscrolline, - fgmenufont, volumebar, timebar1, timebar2, fgsymbolon, fgsymboloff; - -enum eOSState { osUnknown, - osContinue, - osSchedule, - osChannels, - osDirector, - osTimers, - osRecordings, - osPlugin, - osSetup, - osCommands, - osPause, - osRecord, - osReplay, - osStopRecord, - osStopReplay, - osCancelEdit, - osSwitchDvb, - osBack, - osEnd, - os_User, // the following values can be used locally - osUser1, - osUser2, - osUser3, - osUser4, - osUser5, - osUser6, - osUser7, - osUser8, - osUser9, - osUser10, - osUser11, - }; -enum eDvbFont { - fontOsd, - fontOsd2, - fontFix, - fontSym, -/* TODO as soon as we have the font files... - fontTtxSmall, - fontTtxLarge, -*/ - }; -enum eKeys { // "Up" and "Down" must be the first two keys! - kUp, - kDown, - kMenu, - kOk, - kBack, - kLeft, - kRight, - kRed, - kGreen, - kYellow, - kBlue, - k0, k1, k2, k3, k4, k5, k6, k7, k8, k9, - kPlay, - kPause, - kStop, - kRecord, - kFastFwd, - kFastRew, - kPower, - kChanUp, - kChanDn, - kVolUp, - kVolDn, - kMute, - kSchedule, - kChannels, - kTimers, - kRecordings, - kDirector, - kSetup, - kCommands, - kUser1, kUser2, kUser3, kUser4, kUser5, kUser6, kUser7, kUser8, kUser9, - kNone, - kKbd, - // The following codes are used internally: - k_Plugin, - k_Setup, - // The following flags are OR'd with the above codes: - k_Repeat = 0x8000, - k_Release = 0x4000, - k_Flags = k_Repeat | k_Release, - }; - -class cOsdItem { -private: - char *text; - public: - cOsdItem(eOSState State = osUnknown); - cOsdItem(const char *Text, eOSState State = osUnknown); - void SetText(const char *Text, bool Copy); - virtual ~cOsdItem(); - int Index(); - const char* Get(); - void Display(); -}; - -class cOsdMenu { -private: - char *title; - int cols[MaxCols]; - int m_first, m_current, m_marked; - cOsdMenu *subMenu; - const char *helpRed, *helpGreen, *helpYellow, *helpBlue; - char *status; - int digit; - bool hasHotkeys; - vector<cOsdItem*> m_display; -protected: - bool visible; - void CursorUp(void); - void CursorDown(void); - void PageUp(void); - void PageDown(void); - int Index(cOsdItem *Item); -public: - cOsdMenu(const char *Title, int c0 = 0, int c1 = 0, int c2 = 0, int c3 = 0, int c4 = 0); - virtual ~cOsdMenu(); - void SetTitle(const char *Title, bool ShowDate=false); - int Current(void) { return m_current; } - void Add(cOsdItem *Item); -// void Ins(cOsdItem *Item, bool Current = false, cOsdItem *Before = NULL); - virtual void Display(void); - virtual void SetCurrent(cOsdItem *Item); - virtual eOSState ProcessKey(eKeys Key); - virtual void Clear(void); - virtual void SetHasHotkeys(){ hasHotkeys = true; } - virtual void SetHelp(const char *Red, const char *Green = NULL, const char *Yellow = NULL, const char *Blue = NULL); -}; - -#endif //__OSD_H diff --git a/sh_console_osd_menuitems.c b/sh_console_osd_menuitems.c deleted file mode 100644 index 48b5d3a..0000000 --- a/sh_console_osd_menuitems.c +++ /dev/null @@ -1,530 +0,0 @@ -/* - * menuitems.c: General purpose menu items - * - * See the main source file 'vdr.c' for copyright information and - * how to reach the author. - * - * $Id: sh_console_osd_menuitems.c,v 1.1 2004/02/01 18:22:53 LarsAC Exp $ - */ - -#include "mymenuitems.h" - -const char *FileNameChars = " abcdefghijklmnopqrstuvwxyz0123456789-.#~"; - -// --- cMenuEditItem --------------------------------------------------------- - -cMenuEditItem::cMenuEditItem(const char *Name) -{ - name = strdup(Name); - value = NULL; -} - -cMenuEditItem::~cMenuEditItem() -{ - free(name); - free(value); -} - -void cMenuEditItem::SetValue(const char *Value) -{ - free(value); - value = strdup(Value); - char *buffer = NULL; - asprintf(&buffer, "%s:\t%s", name, value); - SetText(buffer, false); - Display(); -} - -// --- cMenuEditIntItem ------------------------------------------------------ - -cMenuEditIntItem::cMenuEditIntItem(const char *Name, int *Value, int Min, int Max) -:cMenuEditItem(Name) -{ - value = Value; - min = Min; - max = Max; - Set(); -} - -void cMenuEditIntItem::Set(void) -{ - char buf[16]; - snprintf(buf, sizeof(buf), "%d", *value); - SetValue(buf); -} - -eOSState cMenuEditIntItem::ProcessKey(eKeys Key) -{ - return osContinue; -} - -// --- cMenuEditBoolItem ----------------------------------------------------- - -cMenuEditBoolItem::cMenuEditBoolItem(const char *Name, int *Value, const char *FalseString, const char *TrueString) -:cMenuEditIntItem(Name, Value, 0, 1) -{ - falseString = FalseString ? FalseString : "no"; - trueString = TrueString ? TrueString : "yes"; - Set(); -} - -void cMenuEditBoolItem::Set(void) -{ - char buf[16]; - snprintf(buf, sizeof(buf), "%s", *value ? trueString : falseString); - SetValue(buf); -} - -// --- cMenuEditNumItem ------------------------------------------------------ - -cMenuEditNumItem::cMenuEditNumItem(const char *Name, char *Value, int Length, bool Blind) -:cMenuEditItem(Name) -{ - value = Value; - length = Length; - blind = Blind; - Set(); -} - -void cMenuEditNumItem::Set(void) -{ - if (blind) { - char buf[length + 1]; - int i; - for (i = 0; i < length && value[i]; i++) - buf[i] = '*'; - buf[i] = 0; - SetValue(buf); - } - else - SetValue(value); -} - -eOSState cMenuEditNumItem::ProcessKey(eKeys Key) -{ - return osContinue; -} - -// --- cMenuEditChrItem ------------------------------------------------------ - -cMenuEditChrItem::cMenuEditChrItem(const char *Name, char *Value, const char *Allowed) -:cMenuEditItem(Name) -{ - value = Value; - allowed = strdup(Allowed); - current = strchr(allowed, *Value); - if (!current) - current = allowed; - Set(); -} - -cMenuEditChrItem::~cMenuEditChrItem() -{ - free(allowed); -} - -void cMenuEditChrItem::Set(void) -{ - char buf[2]; - snprintf(buf, sizeof(buf), "%c", *value); - SetValue(buf); -} - -eOSState cMenuEditChrItem::ProcessKey(eKeys Key) -{ - return osContinue; -} - -// --- cMenuEditStrItem ------------------------------------------------------ - -cMenuEditStrItem::cMenuEditStrItem(const char *Name, char *Value, int Length, const char *Allowed) -:cMenuEditItem(Name) -{ - value = Value; - length = Length; - allowed = strdup(Allowed); - pos = -1; - insert = uppercase = false; - newchar = true; - ieCurChr = 0; - lastKey = kNone; - Set(); -} - -cMenuEditStrItem::~cMenuEditStrItem() -{ - free(allowed); -} - -void cMenuEditStrItem::SetHelpKeys(void) -{ -} - -void cMenuEditStrItem::Set(void) -{ -} - -eOSState cMenuEditStrItem::ProcessKey(eKeys Key) -{ -#if 0 - const char c1[] = "-.#~,/_@1"; - const char c2[] = "abcäåá2"; - const char c3[] = "defé3"; - const char c4[] = "ghi4"; - const char c5[] = "jkl5"; - const char c6[] = "mnoöñó6"; - const char c7[] = "pqrs7"; - const char c8[] = "tuvüú8"; - const char c9[] = "wxyz9"; - const char c0[] = " 0"; - - switch (Key) { - case kRed: // Switch between upper- and lowercase characters - if (pos >= 0 && (!insert || !newchar)) { - uppercase = !uppercase; - value[pos] = uppercase ? toupper(value[pos]) : tolower(value[pos]); - } - break; - case kGreen: // Toggle insert/overwrite modes - if (pos >= 0) { - insert = !insert; - newchar = true; - } - SetHelpKeys(); - lastKey = Key; - break; - case kYellow|k_Repeat: - case kYellow: // Remove the character at current position; in insert mode it is the character to the right of cursor - if (pos >= 0) { - if (strlen(value) > 1) { - if (!insert || pos < int(strlen(value)) - 1) - memmove(value + pos, value + pos + 1, strlen(value) - pos); - // reduce position, if we removed the last character - if (pos == int(strlen(value))) - pos--; - } - else if (strlen(value) == 1) - value[0] = ' '; // This is the last character in the string, replace it with a blank - if (isalpha(value[pos])) - uppercase = isupper(value[pos]); - newchar = true; - } - lastKey = Key; - break; - case kLeft|k_Repeat: - case kLeft: if (pos > 0) { - if (!insert || newchar) - pos--; - newchar = true; - } - if (!insert && isalpha(value[pos])) - uppercase = isupper(value[pos]); - lastKey = Key; - break; - case kRight|k_Repeat: - case kRight: if (pos < length - 2 && pos < int(strlen(value)) ) { - if (++pos >= int(strlen(value))) { - if (pos >= 2 && value[pos - 1] == ' ' && value[pos - 2] == ' ') - pos--; // allow only two blanks at the end - else { - value[pos] = ' '; - value[pos + 1] = 0; - } - } - } - newchar = true; - if (!insert && isalpha(value[pos])) - uppercase = isupper(value[pos]); - if (pos == 0) - SetHelpKeys(); - lastKey = Key; - break; - case kUp|k_Repeat: - case kUp: - case kDown|k_Repeat: - case kDown: if (pos >= 0) { - if (insert && newchar) { - // create a new character in insert mode - if (int(strlen(value)) < length - 1) { - memmove(value + pos + 1, value + pos, strlen(value) - pos + 1); - value[pos] = ' '; - } - } - if (uppercase) - value[pos] = toupper(Inc(tolower(value[pos]), NORMALKEY(Key) == kUp)); - else - value[pos] = Inc( value[pos], NORMALKEY(Key) == kUp); - newchar = false; - } - else - return cMenuEditItem::ProcessKey(Key); - lastKey = Key; - break; - case k0|k_Repeat ... k9|k_Repeat: - case k0 ... k9: if (Key != lastKey) { - ieCurChr = 0; - if (!newchar) { - // kRight - if (pos < length - 2 && pos < int(strlen(value)) ) { - if (++pos >= int(strlen(value))) { - if (pos >= 2 && value[pos - 1] == ' ' && value[pos - 2] == ' ') - pos--; // allow only two blanks at the end - else { - value[pos] = ' '; - value[pos + 1] = 0; - } - } - } - newchar = true; - if (!insert && isalpha(value[pos])) - uppercase = isupper(value[pos]); - } - } - // kUp/kDown - if (pos >= 0) { - if (insert && newchar) { - // create a new character in insert mode - if (int(strlen(value)) < length - 1) { - memmove(value + pos + 1, value + pos, strlen(value) - pos + 1); - value[pos] = ' '; - } - } - } - else - return cMenuEditItem::ProcessKey(Key); - switch (Key) { - case k1: - if (uppercase) - value[pos] = toupper(c1[ieCurChr]); - else - value[pos] = c1[ieCurChr]; - if (c1[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k2: - if (uppercase) - value[pos] = toupper(c2[ieCurChr]); - else - value[pos] = c2[ieCurChr]; - if (c2[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k3: - if (uppercase) - value[pos] = toupper(c3[ieCurChr]); - else - value[pos] = c3[ieCurChr]; - if (c3[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k4: - if (uppercase) - value[pos] = toupper(c4[ieCurChr]); - else - value[pos] = c4[ieCurChr]; - if (c4[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k5: - if (uppercase) - value[pos] = toupper(c5[ieCurChr]); - else - value[pos] = c5[ieCurChr]; - if (c5[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k6: - if (uppercase) - value[pos] = toupper(c6[ieCurChr]); - else - value[pos] = c6[ieCurChr]; - if (c6[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k7: - if (uppercase) - value[pos] = toupper(c7[ieCurChr]); - else - value[pos] = c7[ieCurChr]; - if (c7[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k8: - if (uppercase) - value[pos] = toupper(c8[ieCurChr]); - else - value[pos] = c8[ieCurChr]; - if (c8[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k9: - if (uppercase) - value[pos] = toupper(c9[ieCurChr]); - else - value[pos] = c9[ieCurChr]; - if (c9[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - case k0: - if (uppercase) - value[pos] = toupper(c0[ieCurChr]); - else - value[pos] = c0[ieCurChr]; - if (c0[ieCurChr+1] == 0) - ieCurChr = 0; - else - ieCurChr++; - break; - default: - break; - } - lastKey = Key; - newchar = false; - break; - case kOk: if (pos >= 0) { - pos = -1; - lastKey = Key; - newchar = true; - stripspace(value); - SetHelpKeys(); - break; - } - // run into default - default: if (pos >= 0 && BASICKEY(Key) == kKbd) { - int c = KEYKBD(Key); - if (c <= 0xFF) { - const char *p = strchr(allowed, tolower(c)); - if (p) { - int l = strlen(value); - if (insert && l < length - 1) - memmove(value + pos + 1, value + pos, l - pos + 1); - value[pos] = c; - if (pos < length - 2) - pos++; - if (pos >= l) { - value[pos] = ' '; - value[pos + 1] = 0; - } - } - else { - switch (c) { - case 0x7F: // backspace - if (pos > 0) { - pos--; - return ProcessKey(kYellow); - } - break; - } - } - } - else { - switch (c) { - case kfHome: pos = 0; break; - case kfEnd: pos = strlen(value) - 1; break; - case kfIns: return ProcessKey(kGreen); - case kfDel: return ProcessKey(kYellow); - } - } - } - else - return cMenuEditItem::ProcessKey(Key); - } - Set(); -#endif - return osContinue; -} - -// --- cMenuEditStraItem ----------------------------------------------------- - -cMenuEditStraItem::cMenuEditStraItem(const char *Name, int *Value, int NumStrings, const char * const *Strings) -:cMenuEditIntItem(Name, Value, 0, NumStrings - 1) -{ - strings = Strings; - Set(); -} - -void cMenuEditStraItem::Set(void) -{ - SetValue(strings[*value]); -} - -// --- cMenuTextItem --------------------------------------------------------- - -cMenuTextItem::cMenuTextItem(const char *Text, int X, int Y, int W, int H, eDvbColor FgColor, eDvbColor BgColor, eDvbFont Font) -{ - - text = strdup(Text); -} - -cMenuTextItem::~cMenuTextItem() -{ - free(text); -} - -void cMenuTextItem::Clear(void) -{ -} - -void cMenuTextItem::Display(int Offset, eDvbColor FgColor, eDvbColor BgColor) -{ -} - -void cMenuTextItem::ScrollUp(bool Page) -{ -} - -void cMenuTextItem::ScrollDown(bool Page) -{ -} - -eOSState cMenuTextItem::ProcessKey(eKeys Key) -{ - return osContinue; -} - -// --- cMenuSetupPage -------------------------------------------------------- - -cMenuSetupPage::cMenuSetupPage(void) -:cOsdMenu("", 33) -{ - plugin = NULL; -} - -void cMenuSetupPage::SetSection(const char *Section) -{ -} - -eOSState cMenuSetupPage::ProcessKey(eKeys Key) -{ - return osContinue; -} - -void cMenuSetupPage::SetPlugin(cPlugin *Plugin) -{ -} - -void cMenuSetupPage::SetupStore(const char *Name, const char *Value) -{ -} - -void cMenuSetupPage::SetupStore(const char *Name, int Value) -{ -} diff --git a/sh_console_osd_menuitems.h b/sh_console_osd_menuitems.h deleted file mode 100644 index 8812862..0000000 --- a/sh_console_osd_menuitems.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * menuitems.h: General purpose menu items - * - * See the main source file 'vdr.c' for copyright information and - * how to reach the author. - * - * $Id: sh_console_osd_menuitems.h,v 1.1 2004/02/01 18:22:53 LarsAC Exp $ - */ - -#ifndef __MENUITEMS_H -#define __MENUITEMS_H - -#include "myosd.h" - -extern const char *FileNameChars; - -class cMenuEditItem : public cOsdItem { -private: - char *name; - char *value; -public: - cMenuEditItem(const char *Name); - ~cMenuEditItem(); - void SetValue(const char *Value); - }; - -class cMenuEditIntItem : public cMenuEditItem { -protected: - int *value; - int min, max; - virtual void Set(void); -public: - cMenuEditIntItem(const char *Name, int *Value, int Min = 0, int Max = INT_MAX); - virtual eOSState ProcessKey(eKeys Key); - }; - -class cMenuEditBoolItem : public cMenuEditIntItem { -protected: - const char *falseString, *trueString; - virtual void Set(void); -public: - cMenuEditBoolItem(const char *Name, int *Value, const char *FalseString = NULL, const char *TrueString = NULL); - }; - -class cMenuEditNumItem : public cMenuEditItem { -protected: - char *value; - int length; - bool blind; - virtual void Set(void); -public: - cMenuEditNumItem(const char *Name, char *Value, int Length, bool Blind = false); - virtual eOSState ProcessKey(eKeys Key); - }; - -class cMenuEditChrItem : public cMenuEditItem { -private: - char *value; - char *allowed; - const char *current; - virtual void Set(void); -public: - cMenuEditChrItem(const char *Name, char *Value, const char *Allowed); - ~cMenuEditChrItem(); - virtual eOSState ProcessKey(eKeys Key); - }; - -class cMenuEditStrItem : public cMenuEditItem { -private: - char *value; - int length; - char *allowed; - int pos; - bool insert, newchar, uppercase; - void SetHelpKeys(void); - virtual void Set(void); - char Inc(char c, bool Up); - int ieCurChr; - eKeys lastKey; -public: - cMenuEditStrItem(const char *Name, char *Value, int Length, const char *Allowed); - ~cMenuEditStrItem(); - virtual eOSState ProcessKey(eKeys Key); - }; - -class cMenuEditStraItem : public cMenuEditIntItem { -private: - const char * const *strings; -protected: - virtual void Set(void); -public: - cMenuEditStraItem(const char *Name, int *Value, int NumStrings, const char * const *Strings); - }; - -class cMenuTextItem : public cOsdItem { -private: - char *text; - int x, y, w, h, lines, offset; - eDvbColor fgColor, bgColor; - eDvbFont font; -public: - cMenuTextItem(const char *Text, int X, int Y, int W, int H = -1, eDvbColor FgColor = clrWhite, eDvbColor BgColor = clrBackground, eDvbFont Font = fontOsd); - ~cMenuTextItem(); - int Height(void) { return h; } - void Clear(void); - virtual void Display(int Offset = -1, eDvbColor FgColor = clrWhite, eDvbColor BgColor = clrBackground); - bool CanScrollUp(void) { return offset > 0; } - bool CanScrollDown(void) { return h + offset < lines; } - void ScrollUp(bool Page); - void ScrollDown(bool Page); - virtual eOSState ProcessKey(eKeys Key); - }; - -class cPlugin; - -class cMenuSetupPage : public cOsdMenu { -private: - cPlugin *plugin; -protected: - void SetSection(const char *Section); - virtual void Store(void) = 0; - void SetupStore(const char *Name, const char *Value = NULL); - void SetupStore(const char *Name, int Value); -public: - cMenuSetupPage(void); - virtual eOSState ProcessKey(eKeys Key); - void SetPlugin(cPlugin *Plugin); - }; - -#endif //__MENUITEMS_H diff --git a/sh_dummy_content.c b/sh_dummy_content.c deleted file mode 100644 index 1ccfe9e..0000000 --- a/sh_dummy_content.c +++ /dev/null @@ -1,596 +0,0 @@ -/*******************************************************************/ -/*! \file content_interface.cpp - * \brief Data Objects for content (e.g. mp3 files, movies) - * for the vdr muggle plugindatabase - ******************************************************************** - * \version $Revision: 1.3 $ - * \date $Date: 2004/02/02 22:48:04 $ - * \author Ralf Klueber, Lars von Wedel, Andreas Kellner - * \author file owner: $Author: MountainMan $ - * - * DUMMY - * - * - * Dummy artists: Artist_1, Artist_2, Artist_3 - * Dummy albums by ArtistX: Album_X1, .... AlbumX3 - * Dummy Tracks On Album_XY: Track_XY1,... Track_XY5 - * - */ -/*******************************************************************/ -#define DEBUG - -#include "sh_dummy_content.h" -#include "mg_tools.h" - -#include <strstream> -#include <string> -#define GD_PLAYLIST_TYPE 0 // listtype for giant disc db - -// some dummies to keep the compiler happy -#define DUMMY_CONDITION true // we use that as dummy condition to satisfy C++ syntax -#define DUMMY -#define NUM_ARTISTS 5 -#define NUM_ALBUMS_PER_ARTIST 3 -#define NUM_TRACKS_PER_ALBUM 9 - -int DummyInitDatabase(MYSQL *db){return 0;} -vector<string> *DummyGetStoredPlaylists(MYSQL db){ return new vector<string>();} - -/*******************************************************************/ -/* class mgTack */ -/********************************************************************/ -DummyTrack DummyTrack::UNDEFINED = DummyTrack(); - -/*! - ***************************************************************************** - * \brief Constructor: creates a DummyTrack obect - * - * \param sqlIdentifier identifies a unique row in the track database - * \param dbase database which stores the track table - * - * On creation, the object contains only the idea. The actual data fields - * are filled when readData() is called for the first time. - ****************************************************************************/ -DummyTrack::DummyTrack(int sqlIdentifier, MYSQL dbase) -{ - m_uniqID = sqlIdentifier; - char buf[255]; - - mgDebug(9, "Creating dumy track %d", sqlIdentifier); - // create dummy value based on the id - sprintf(buf, "ArtistName_%d", (int) m_uniqID / 100); - m_artist = buf; - sprintf(buf,"Album_%d", (int) m_uniqID / 10); - m_album = buf; - sprintf(buf,"Track_%d",m_uniqID); - m_title = buf; - sprintf(buf,"sourcefile_%d", m_uniqID); - m_mp3file = buf; - m_genre = "unknown_genre"; - m_year = 1970 + (m_uniqID%35); - m_rating = 2; - m_length = 180; -} - -/*! - ***************************************************************************** - * \brief copy constructor - * - ****************************************************************************/ -DummyTrack::DummyTrack(const DummyTrack& org) -{ - m_uniqID = org.m_uniqID; - m_db = org.m_db; - - mgDebug(9, - "Creating a TrackCopy for track '%s' (is this really necessary?", - org.m_title.c_str()); - - m_artist = org.m_artist; - m_title = org.m_title; - m_mp3file = org.m_mp3file; - m_album = org.m_album; - m_genre = org.m_genre; - m_year = org.m_year; - m_rating = org.m_rating; - -} - - -/*! - ***************************************************************************** - * \brief destructor - * - ****************************************************************************/ -DummyTrack::~DummyTrack() -{ - // nothing to be done -} - -/*! - ***************************************************************************** - * \brief returns value for _mp3file - ****************************************************************************/ -string DummyTrack::getSourceFile() -{ - return m_mp3file; -} - -/*! - ***************************************************************************** - * \brief returns value for m_title - ****************************************************************************/ -string DummyTrack::getTitle() -{ - return m_title; -} - -/*! - ***************************************************************************** - * \brief returns value for m_artist - ****************************************************************************/ -string DummyTrack::getArtist() -{ - return m_artist; -} -string DummyTrack::getLabel(int col) -{ - switch(col) - { - case 0: - return m_artist; - break; - case 1: - return m_title; - break; - default: - return ""; - } -} -string DummyTrack::getDescription() -{ - return m_artist + " - " + m_title; -} - -/*! - ***************************************************************************** - * \brief returns value for m_album - ****************************************************************************/ -string DummyTrack::getAlbum() -{ - return m_album; -} - -/*! - ***************************************************************************** - * \brief returns value for m_genre - ****************************************************************************/ -string DummyTrack::getGenre() -{ - return m_genre; -} - -/*! - ***************************************************************************** - * \brief returns value for m_year - ****************************************************************************/ -int DummyTrack::getYear() -{ - return m_year; -} - -/*! - ***************************************************************************** - * \brief returns value for m_rating - * - * If value has not been retrieved from the database, radData() is called first - ****************************************************************************/ -int DummyTrack::getRating() -{ - return m_rating; -} - -int DummyTrack::getDuration() -{ - return m_rating; -} - -/*! - ***************************************************************************** - * \brief sets the field for m_title to the specified value - * - * Note: The new value is not stored in the database. - * This is only done, when writeData() is called - ****************************************************************************/ -void DummyTrack::setTitle(string new_title) -{ - m_title = new_title; -} - -/*! - ***************************************************************************** - * \brief sets the field for m_artist to the specified value - * - * Note: The new value is not stored in the database. - * This is only done, when writeData() is called - ****************************************************************************/ -void DummyTrack::setArtist(string new_artist) -{ - m_artist = new_artist; -} - - -/*! - ***************************************************************************** - * \brief sets the field for m_album to the specified value - * - * Note: The new value is not stored in the database. - * This is only done, when writeData() is called - ****************************************************************************/ -void DummyTrack::setAlbum(string new_album) -{ - m_album = new_album; -} - - -/*! - ***************************************************************************** - * \brief sets the field for m_genre to the specified value - * - * Note: The new value is not stored in the database. - * This is only done, when writeData() is called - ****************************************************************************/ -void DummyTrack::setGenre(string new_genre) -{ - m_genre = new_genre; -} - - -/*! - ***************************************************************************** - * \brief sets the field for m_year to the specified value - * - * Note: The new value is not stored in the database. - * This is only done, when writeData() is called - ****************************************************************************/ -void DummyTrack::setYear(int new_year) -{ - m_year = new_year; -} - - -/*! - ***************************************************************************** - * \brief sets the field for m_rating to the specified value - * - * Note: The new value is not stored in the database. - * This is only done, when writeData() is called - ****************************************************************************/ -void DummyTrack::setRating(int new_rating) -{ - m_rating = new_rating; -} - - -/*! - ***************************************************************************** - * \brief stores current values in the sql database - * - * Note: At the moment, only the values stored directly in the 'tracks' - * database are updated - ****************************************************************************/ -bool DummyTrack::writeData() -{ - return true; -} - -DummyTracklist::DummyTracklist(MYSQL db_handle, string restrictions) -{ -} - -/*******************************************************************/ -/* class DummyPlaylist */ -/********************************************************************/ - -/*! - ***************************************************************************** - * \brief Constructor: opens playlist by name - * - * \param listname user-readable identifier of the paylist - * \param db_handl database which stores the playlist - * - * If the playlist does not yet exist, an empty playlist is created - ****************************************************************************/ -DummyPlaylist::DummyPlaylist(string listname, MYSQL db_handle) -{ - m_db = db_handle; - - // - // check, if the database really exists - // - if(listname =="EXISTS") - { - - m_author = "DUMMY_author"; - m_listname = listname; - createDummyPlaylist(1); - } - else - { - // new Playlist - m_author = "VDR"; - m_listname = listname; - - } - -} - -/*! - ***************************************************************************** - * \brief Constructor: construct playlist object from existing sql playlist - * - * \param sql_identifier: sql internal identifier for the playlist - * \param db_handl database which stores the playlist - * - * This constructor is typically used when a playlist is selected from an - * internal list of playlists - ****************************************************************************/ -DummyPlaylist::DummyPlaylist(unsigned int sql_identifier, MYSQL db_handle) -{ - m_db = db_handle; - char buf[256]; - - m_author = "DUMMY_author"; - sprintf(buf, "Dummylist_%d", sql_identifier); - m_listname = buf; - createDummyPlaylist(sql_identifier); -} - -void DummyPlaylist::createDummyPlaylist(int start) -{ - DummyTrack* trackptr; - for(int id=start; id < start+20; id++) - { - trackptr = new DummyTrack(id, m_db); - m_list.push_back(trackptr); - } -} - -/*! - ***************************************************************************** - * \brief empty destructor - * - * Nothing to be done. The actual data is stored in the sql db - ****************************************************************************/ -DummyPlaylist::~DummyPlaylist() -{ - // nothing to be done -} - -bool DummyPlaylist::storePlaylist() -{ - mgDebug(1, "Storing Playlist #%s'", m_listname.c_str()); - return true; -} -/*! - ***************************************************************************** - * \brief returns the total duration of all songs in the list in seconds - * - ****************************************************************************/ -int DummyPlaylist::getPlayTime() -{ - return m_list.size()* 180; -} - -/*! - ***************************************************************************** - * \brief returns the duration of all remaining songs in the list in seconds - * - ****************************************************************************/ -int DummyPlaylist::getPlayTimeRemaining() -{ - return 0; // dummy -} - -/*******************************************************************/ -/* class DummyTreeNode */ -/*******************************************************************/ - -DummyTreeNode::DummyTreeNode(MYSQL db, int view) - : mgSelectionTreeNode(db, view) -{ - // create a root node - // everything is done in the parent class - m_restriction ="1"; -} - -DummyTreeNode::DummyTreeNode(mgSelectionTreeNode* parent, - string id, string label, string restriction) - : mgSelectionTreeNode(parent, id, label) -{ - m_restriction = restriction; - // everything else is done in the parent class -} - - -/*! - ***************************************************************************** - * \brief destructor - * - ****************************************************************************/ -DummyTreeNode::~DummyTreeNode() -{ - m_children.clear(); -} - -/*! - ***************************************************************************** - * \brief checks if this node can be further expandded or not - * \true, if node ia leaf node, false if node can be expanded - * - ****************************************************************************/ -bool DummyTreeNode::isLeafNode() -{ - switch(m_view) - { - case 1: // artist -> album -> title - if( m_level <= 3 ) - { - return true; - } - break; - default: - mgError("View '%d' not yet implemented", m_view); - } - return false; -} - - -/*! - ***************************************************************************** - * \brief compute children on the fly - * - ****************************************************************************/ -bool DummyTreeNode::expand() -{ - char buf[20]; - if (m_expanded) - { - mgWarning("Node already expanded\n"); - return true; - } - m_expanded = true; - - mgDebug(5, "Expanding level %d\n", m_level); - switch(m_view) - { - case 1: // artist -> album -> title - if(m_level == 0) // root, expand artist - { - for(int artnum=1; artnum <= NUM_ARTISTS; artnum++) - { - sprintf(buf, "%d", artnum); - m_children.push_back(new DummyTreeNode(this, m_id+ (string) buf, - "Artist "+ (string)buf, - m_restriction + " AND album.artist='Artist "+(string) buf+"'")); - } - - } - else if(m_level == 1) // artist, expand album - { - // create album names in the form Album_x1, ... Album_x3 - // where x is the artist ID - // for normal usage: _restrictions should now hold: - // album.artist = XYZ - for(int albnum=1; albnum <= NUM_ALBUMS_PER_ARTIST; albnum++) - { - sprintf(buf, "%d", albnum); - - m_children.push_back(new DummyTreeNode(this, m_id+ (string) buf, - "Album_"+ m_id + (string) buf, - m_restriction + " AND track.sourceid='0x00"+ m_id + (string) buf +"'")); - } - break; - } - else if(m_level == 2) // artist -> album, expand title - { - // create track names in the form Track_xy1, ... Track_xy5 - // where x is the artist ID and y is the album id - // for normal usage: _restrictions should now hold: - // album.artist = ... AND track.sourceid='0x00XY - for(int tracknum=1; tracknum <= NUM_TRACKS_PER_ALBUM; tracknum++) - { - sprintf(buf, "%d", tracknum); - m_children.push_back(new DummyTreeNode(this, m_id+ (string) buf, - "Track_"+m_id+ (string) buf, - m_restriction + " AND track.id=tr"+ m_id + (string) buf + "'" )); - } - break; - } - else - { - mgWarning("View #%d level %d' not yet implemented", m_view, m_level); - m_expanded = false; - return false; - } - break; - default: - mgError("View '%d' not yet implemented", m_view); - } - mgDebug(5, "%d children expanded\n", m_children.size()); - return true; -} - -/*! - ***************************************************************************** - * \brief go over all children recursively to find the tracks - * - ****************************************************************************/ -vector<mgContentItem*>* DummyTreeNode::getTracks() -{ - vector<mgContentItem*>* dummy; - string sql; - - int artistnum; - int albumnum; - int tracknum; - dummy = new vector<mgContentItem*>(); - - sql = m_restriction; - mgDebug(5, "QUERY:\n%s\n", sql.c_str()); - - artistnum = 0; - do // artist_loop - { - if(m_level >=1) - artistnum = m_id[0]-'0'; // we have a unique artist - else - artistnum++; // we are in a loop - - albumnum = 0; - do // album_loop - { - if(m_level >=2) - albumnum = m_id[1]-'0'; // we have a unique album - else - albumnum++; // we are in a loop - - tracknum =0; - do // track_loop - { - if(m_level ==3) - tracknum = m_id[2]-'0'; // we have a unique track - else - tracknum++; // we are in a loop - dummy->push_back(new DummyTrack(artistnum*100+albumnum*10+tracknum, m_db)); - }while ((m_level < 3) && (tracknum< NUM_TRACKS_PER_ALBUM)); - }while ((m_level < 2) && (albumnum < NUM_ALBUMS_PER_ARTIST)); - }while ((m_level < 1) && (artistnum < NUM_ARTISTS )); - - return dummy; -} - -/*! - ***************************************************************************** - * \brief returns the first track matchin the restrictions of this node - * assuming we are in a leaf node, this returns the track represented by the - * the leaf - ****************************************************************************/ -mgContentItem* DummyTreeNode::getSingleTrack() -{ - // get all tracks satisying the restrictions of this node - mgDebug(5, "getTracks(): query '%s'", m_restriction.c_str()); - - mgContentItem* track = new DummyTrack(atoi(m_id.c_str()), m_db); - - return track; -} - -/* -------------------- begin CVS log --------------------------------- - * $Log: sh_dummy_content.c,v $ - * Revision 1.3 2004/02/02 22:48:04 MountainMan - * added CVS $Log - * - * - * --------------------- end CVS log ---------------------------------- - */ diff --git a/sh_dummy_content.h b/sh_dummy_content.h deleted file mode 100644 index 7f79498..0000000 --- a/sh_dummy_content.h +++ /dev/null @@ -1,188 +0,0 @@ -/*******************************************************************/ -/*! \file dummy_content.h - * \brief Dummy Data Objects for testing Muggle - ******************************************************************** - * \version $Revision: 1.3 $ - * \date $Date: 2004/02/02 22:48:04 $ - * \author Ralf Klueber, Lars von Wedel, Andreas Kellner - * \author file owner: $Author: MountainMan $ - * - * Declares main classes of for content items and interfaces to SQL databases - * - *******************************************************************/ -/* makes sur we dont use parse the same declarations twice */ -#ifndef _DUMMY_CONTENT_H -#define _DUMMY_CONTENT_H -using namespace std; -#include <string> -#include <list> -#include <vector> - -#include "mg_content_interface.h" - -// non-member function -int DummyInitDatabase(MYSQL *db); -vector<string> *DummyGetStoredPlaylists(MYSQL db); -/*! - ******************************************************************* - * \class DummyTrack - * - * \brief represents a a single track - * DUMMY - ********************************************************************/ -class DummyTrack : public mgContentItem -{ - -private: - MYSQL m_db; - - // content fields - string m_artist; - string m_title; - string m_mp3file; - string m_album; - string m_genre; - int m_year; - int m_rating; - int m_length; - - - public: - - /* constructor */ - DummyTrack(){ m_uniqID = -1;} // creates invalid item - DummyTrack(int sqlIdentifier, MYSQL dbase); - - DummyTrack(const DummyTrack&); - - /* destructor */ - ~DummyTrack(); - - virtual mgContentItem::contentType getContentType() - {return mgContentItem::GD_AUDIO;} - virtual mgMediaPlayer getPlayer(){return mgMediaPlayer();} - - /* data acess */ - //virtual functions of the base class - virtual string getSourceFile(); - virtual string getTitle(); - virtual string getLabel(int col); - virtual string getDescription(); - virtual string getGenre(); - virtual int getRating(); - - // additional class-specific functions - string getArtist(); - string getAlbum(); - int getYear(); - int getDuration(); - - /* data manipulation */ - void setTitle(string new_title); - void setArtist(string new_artist); - void setAlbum(string new_album); - void setGenre(string new_genre); - void setYear(int new_rating); - void setRating(int new_rating); - - bool writeData(); - static DummyTrack UNDEFINED; - -}; - -class DummyTracklist : public mgTracklist -{ - public: - DummyTracklist(MYSQL db_handle, string restrictions); -}; - -/*! - ******************************************************************* - * \class GdTracklist - * - * \brief represents a playlist, i.e. an ordered collection of tracks - ********************************************************************/ -class DummyPlaylist : public mgPlaylist -{ - private: - int m_sqlId; /* -1 means: not valid */ - string m_author; - MYSQL m_db; - private: - void createDummyPlaylist(int strt); - public: - - - /*==== constructors ====*/ - DummyPlaylist(string listname, MYSQL db_handle); - /* opens existing or creates empty playlist */ - - DummyPlaylist(unsigned int sql_identifier, MYSQL db_handle); - /* construct from the db by internal id*/ - - /*==== destructor ====*/ - ~DummyPlaylist(); - - int getPlayTime(); - /* returns the total duration of all songs in the list in seconds */ - - int getPlayTimeRemaining(); - /* returns the duration of all remaining songs in the list in seconds */ - - bool storePlaylist(); -}; -/*! - ******************************************************************* - * \class mgSelectionTreeNode - ********************************************************************/ -class DummyTreeNode : public mgSelectionTreeNode { - -private: - MYSQL m_db; // underlying db - -public: - - /*==== constructors ====*/ - DummyTreeNode(MYSQL db, int view); - DummyTreeNode(mgSelectionTreeNode* parent, - string id, string label, string restriction); - - /*==== destructor ====*/ - ~DummyTreeNode(); - - // compute children o^xn the fly - virtual bool isLeafNode(); - virtual bool expand(); - - virtual vector<mgContentItem*>* getTracks(); - virtual mgContentItem* getSingleTrack(); -}; - -/* -------------------- begin CVS log --------------------------------- - * $Log: sh_dummy_content.h,v $ - * Revision 1.3 2004/02/02 22:48:04 MountainMan - * added CVS $Log - * - * - * --------------------- end CVS log ---------------------------------- - */ - -#endif /* END _CONTENT_INTERFACE_H */ - - - - - - - - - - - - - - - - - - diff --git a/sh_muggle.c b/sh_muggle.c deleted file mode 100644 index 485905e..0000000 --- a/sh_muggle.c +++ /dev/null @@ -1,366 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include "mysql/mysql.h" - -#include "mg_content_interface.h" -#include "mg_media.h" -#include "mg_tools.h" -#include <unistd.h> - -#define DISPLAY_SIZE 20 -#define PAGE_JUMP 18 - - -#define EXIT 0 -#define TREE_VIEW 1 -#define LIST_VIEW 2 -#define PLAYLIST_VIEW 3 -#define FILTER_VIEW 4 - -using namespace std; - -const char playlist_command_str[] = -" s : shuffle\n" -" 8 : up\n" -" 2 : down\n" -" 9 : page-up\n" -" 3 : page-down\n" -" p : go to top\n" -" t : switch to tree view\n" -" q : quit"; - -const char tree_command_str[] = -" 6 : expand\n" -" 4 : collapse\n" -" 8 : up\n" -" 2 : down\n" -" 9 : page-up\n" -" 3 : page-down\n" -" 5 : add selection to playlist\n" -" p : switch to playlist view\n" -" t : go to root node\n" -" q : quit"; - -mgSelectionTreeNode* GV_currentNode; -vector<mgSelectionTreeNode*> GV_treeDisplay; - -mgPlaylist *GV_currentPlaylist; - -void print_tree(mgSelectionTreeNode* node, string tab) -{ - vector<mgSelectionTreeNode*> children; - vector<mgSelectionTreeNode*>::iterator iter; - - tab = tab + " "; - printf("%2d %c %s-- Id: '%s', level %d '%s' \n", - GV_treeDisplay.size(), (node->isExpanded()?'x':'-'), tab.c_str(), - node->getID().c_str(), node->getLevel(), - node->getLabel().c_str()); -// printf(" %sRestrictions: '%s'\n", tab.c_str(), node->getRestrictions().c_str()); - GV_treeDisplay.push_back(node); - if(node->isExpanded()) - { - children = node->getChildren(); - for(iter = children.begin(); iter != children.end(); iter++) - { - print_tree(*iter, tab); - } - } -} -void print_node(mgSelectionTreeNode* node, unsigned int selected, unsigned int start) -{ - vector<mgSelectionTreeNode*> children; - vector<mgSelectionTreeNode*>::iterator iter; - mgSelectionTreeNode* child; - unsigned int i; - - GV_treeDisplay.clear(); - printf("--%s---\n", node->getLabel().c_str()); - children = node->getChildren(); - // first, add al nodes to the storage - for(iter = children.begin(); iter != children.end(); iter++) - { - GV_treeDisplay.push_back(*iter); - } - - // now display the ones in question - printf("Displaying %d-%d of %d (%s)\n", start+1, start+DISPLAY_SIZE+1, - GV_treeDisplay.size(), node->getRestrictions().c_str()); - if(start >0) - printf(".......\n"); - for (i = start; i < start+DISPLAY_SIZE && i< GV_treeDisplay.size(); i++) - { - child = GV_treeDisplay[i]; - if(i == selected) - printf ("==>"); - else - printf(" "); - printf ("%s\n",child->getLabel().c_str()); - } - if(i==start+DISPLAY_SIZE) - printf(".......\n"); -} - -void print_tracks(vector<mgContentItem*>* tracks, string restriction) -{ - vector<mgContentItem*>::iterator iter; - - printf("======BEGIN_TRACKS=====(restriction:'%s'======\n", restriction.c_str()); - for(iter = tracks->begin(); iter != tracks->end(); iter++) - { - printf(" Track: (%d): '%s' \n",(*iter)->getId(), (*iter)->getTitle().c_str()); - } - printf("======END_TRACKS===========\n"); - printf("press key t continue\n"); - getchar(); -} - -void PrintPlaylist(mgPlaylist *pl, unsigned int selected, unsigned int start) -{ - vector<mgContentItem*>::iterator iter; - unsigned int i; - - // now display the ones in question - printf("Playlist '%s' (%d entries)\n", pl->getListname().c_str(), - pl->getNumItems()); - if(start >0) - printf(".......\n"); - for (i = start; i<start+DISPLAY_SIZE && i< pl->getNumItems(); i++) - { - if(i == selected) - printf ("==>"); - else - printf(" "); - printf ("%s\n",pl->getLabel(i, "\t").c_str()); - } - if(i==start+DISPLAY_SIZE) - printf(".......\n"); -} -int PlaylistView() -{ - char cmd; - bool loop = true; - unsigned int selected = 0; - unsigned int start=0; - - while(loop) - { - printf("\n\n\n\n\n\n"); - PrintPlaylist(GV_currentPlaylist, selected, start); - printf("------- enter command ('h' for help) -----------\n"); - cmd = getchar(); - switch (cmd) - { - case 'h': // shuffle - printf("%s\n", playlist_command_str); - break; - case 's': // shuffle - GV_currentPlaylist->shuffle(); - break; - case '8': // up - if(selected >0) selected--; - if(selected < start) start = start - PAGE_JUMP; - break; - case '2': // down - if(selected < (GV_currentPlaylist->getNumItems()-1)) - selected++; - if(selected >= start+DISPLAY_SIZE) start = start + PAGE_JUMP; - break; - case '9': // pgup - if(start >= PAGE_JUMP) - { - start -= PAGE_JUMP; - selected -= PAGE_JUMP; - } - else - mgDebug(6,"Can not go up %d %d", start, selected); - break; - case '3': // pgdown - mgDebug(6,"pgdown %d %d", start, selected); - if(start+ PAGE_JUMP< (GV_currentNode->getChildren()).size()) - { - start += PAGE_JUMP; - selected += PAGE_JUMP; - if(selected >= ((GV_currentNode->getChildren()).size())) - selected = (GV_currentNode->getChildren()).size(); - } - - break; - case 'p': // go to top of playlist view - selected=0; - start=0; - break; - case 't': // tree view (on root node) - cmd = getchar(); - return TREE_VIEW; - break; - case 'q': // tree view (on root node) - cmd = getchar(); - return EXIT; - break; - default: - mgWarning("Invalid Command '%c'",cmd); - - } - cmd = getchar(); - - }// end nodeview loop - return EXIT; -} -// displays one node (and all its children) -int NodeView() -{ - vector<mgContentItem*>* tracks; - char cmd; - bool loop = true; - unsigned int selected = 0; - unsigned int start=0; - while(loop) - { - printf("\n\n\n\n\n\n"); - if(!GV_currentNode->isExpanded()) - { - GV_currentNode->expand(); - } - print_node(GV_currentNode,selected, start); - printf("------- enter command ('h' for help) -----------\n"); - - cmd = getchar(); - switch (cmd) - { - case 'h': // shuffle - printf("%s\n", tree_command_str); - break; - case 'e': - case '6':// expand - GV_currentNode = GV_treeDisplay[selected]; - if(GV_currentNode->expand()) - { - selected = 0; - start=0; - } - else - { - GV_currentNode = GV_currentNode ->getParent(); - } - break; - case 'c' : - case '4': - if(GV_currentNode->getParent() != NULL) - { - GV_currentNode->collapse(); - GV_currentNode = GV_currentNode->getParent(); - selected = 0; - start=0; - } - else - { - mgWarning("Already at top level"); - } - break; - case '8': // up - if(selected >0) selected--; - if(selected < start) start = start - PAGE_JUMP; - break; - case '2': // down - if(selected < ((GV_currentNode->getChildren()).size()-1)) - selected++; - if(selected >= start+DISPLAY_SIZE) start = start + PAGE_JUMP; - break; - case '9': // pgup - if(start >= PAGE_JUMP) - { - start -= PAGE_JUMP; - selected -= PAGE_JUMP; - } - else - mgDebug(6,"Can not go up %d %d", start, selected); - break; - case '3': // pgdown - mgDebug(6,"pgdown %d %d", start, selected); - if(start+ PAGE_JUMP< (GV_currentNode->getChildren()).size()) - { - start += PAGE_JUMP; - selected += PAGE_JUMP; - if(selected >= ((GV_currentNode->getChildren()).size())) - selected = (GV_currentNode->getChildren()).size(); - } - - break; - case '5': // OK ,add to playlist - tracks = GV_treeDisplay[selected]->getTracks(); - GV_currentPlaylist->appendList(tracks); - tracks = NULL; - break; - case 'p': // go to playlist view - cmd = getchar(); - return PLAYLIST_VIEW; - break; - case 't': // tree view (on root node) - while(GV_currentNode->getParent() != NULL) - { - GV_currentNode->collapse(); - GV_currentNode = GV_currentNode->getParent(); - } - selected = 0; - start=0; - break; - case 'q': // go to playlist view - cmd = getchar(); - return EXIT; - break; - default: - mgWarning("Invalid Command '%c'",cmd); - - } - cmd = getchar(); - - }// end nodeview loop - return EXIT; -} -int main (int argc, char **argv) -{ - mgMedia* media; - string tab; - bool loop = true; - /* now to connect to the database */ - mgSelectionTreeNode *root; - int activeScreen; - - vector<int> listcols; - mgSetDebugLevel(8); - media = new mgMedia(mgMedia::GD_MP3); - - mgDebug(3," Staring sh_muggle"); - // create initial tree node in view '1' - activeScreen = TREE_VIEW; - root = media->getSelectionRoot(); - root->expand(); - GV_currentNode = root->getChildren()[0]; - GV_currentPlaylist = media->createTemporaryPlaylist(); - listcols.push_back(1); - listcols.push_back(0); - GV_currentPlaylist->setDisplayColumns(listcols); - mgDebug(3," Entering sh_muggle main loop"); - - // now switch to the initial view; - while(loop) - { - switch(activeScreen) - { - case TREE_VIEW: - activeScreen = NodeView(); - break; - case PLAYLIST_VIEW: - activeScreen = PlaylistView(); - break; - case EXIT: - exit(0); - break; - default: - mgError("Invalid screen %d"); - } - } - mgError("leavingNodeView"); - -} diff --git a/sh_muggle2.c b/sh_muggle2.c deleted file mode 100644 index 4c98da6..0000000 --- a/sh_muggle2.c +++ /dev/null @@ -1,66 +0,0 @@ -#include <stdio.h> -#include <stdlib.h> -#include "mysql/mysql.h" - -#include "myosd.h" -#include "muggle.h" -#include "mg_media.h" -#include "mg_tools.h" -#include <unistd.h> - -eKeys waitForKey() -{ - char buf[2]; - read(0, buf, 2); - mgDebug(9, "Key '%c' read\n",buf[0]); - switch(buf[0]) - { - case '8': - return kUp; - case '2': - return kDown; - case '1': - return kMenu; - case '5': - return kOk; - case '3': - return kBack; - case '4': - return kLeft; - case '6': - return kRight; - case 'r': - return kRed; - case 'g': - return kGreen; - case 'y': - return kYellow; - case 'b': - return kBlue; - default: - return kNone; - - } -} -int main (int argc, char **argv) -{ - - cOsdObject *mainMenu; - eKeys key; - eOSState state; - bool loop=true; - mgMuggle muggle; - muggle.Initialize(); - muggle.Start(); - mgSetDebugLevel(8); - - mainMenu = muggle.MainMenuAction(); - - while(loop) - { - key = waitForKey(); - state = mainMenu->ProcessKey(key); - if(state == osEnd) - loop = false; - } -} diff --git a/sh_plugin.c b/sh_plugin.c deleted file mode 100644 index eff5cff..0000000 --- a/sh_plugin.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - * plugin.c: The VDR plugin interface - * - * See the main source file 'vdr.c' for copyright information and - * how to reach the author. - * - * $Id: sh_plugin.c,v 1.1 2004/02/01 18:22:53 LarsAC Exp $ - */ - -#include "shell_plugin.h" - -#define LIBVDR_PREFIX "libvdr-" -#define SO_INDICATOR ".so." - -#define MAXPLUGINARGS 1024 -#define HOUSEKEEPINGDELTA 10 // seconds - -// --- cPlugin --------------------------------------------------------------- - -char *cPlugin::configDirectory = NULL; - -cPlugin::cPlugin(void) -{ - name = NULL; -} - -cPlugin::~cPlugin() -{ - // I18nRegister(NULL, Name()); -} - -void cPlugin::SetName(const char *s) -{ - name = s; -} - -const char *cPlugin::CommandLineHelp(void) -{ - return NULL; -} - -bool cPlugin::ProcessArgs(int argc, char *argv[]) -{ - return true; -} - -bool cPlugin::Initialize(void) -{ - return true; -} - -bool cPlugin::Start(void) -{ - return true; -} - -void cPlugin::Housekeeping(void) -{ -} - -const char *cPlugin::MainMenuEntry(void) -{ - return NULL; -} - -cOsdObject *cPlugin::MainMenuAction(void) -{ - return NULL; -} -bool cPlugin::SetupParse(const char *Name, const char *Value) -{ - return false; -} -cMenuSetupPage *cPlugin::SetupMenu(void) -{ - return NULL; -} diff --git a/sh_plugin.h b/sh_plugin.h deleted file mode 100644 index 2bf7bcb..0000000 --- a/sh_plugin.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * plugin.h: The VDR plugin interface - * - * See the main source file 'vdr.c' for copyright information and - * how to reach the author. - * - * $Id: sh_plugin.h,v 1.1 2004/02/01 18:22:53 LarsAC Exp $ - */ - -#ifndef __PLUGIN_H -#define __PLUGIN_H - -#include "myosd.h" -#include "mymenuitems.h" -typedef cOsdMenu cOsdObject; -#define VDRPLUGINCREATOR(PluginClass) extern "C" void *VDRPluginCreator(void) { return new PluginClass; } - -class cPlugin { -private: - static char *configDirectory; - const char *name; - void SetName(const char *s); -public: - cPlugin(void); - virtual ~cPlugin(); - - const char *Name(void) { return name; } - virtual const char *Version(void) = 0; - virtual const char *Description(void) = 0; - virtual const char *CommandLineHelp(void); - - virtual bool ProcessArgs(int argc, char *argv[]); - virtual bool Initialize(void); - virtual bool Start(void); - virtual void Housekeeping(void); - - virtual const char *MainMenuEntry(void); - virtual cOsdObject *MainMenuAction(void); - - virtual cMenuSetupPage *SetupMenu(void); - - virtual bool SetupParse(const char *Name, const char *Value); - - }; - -#endif //__PLUGIN_H |