diff --git a/configure.ac b/configure.ac index eacab6cba..58fd9cd63 100644 --- a/configure.ac +++ b/configure.ac @@ -299,6 +299,7 @@ src/gui/Makefile src/gui/bedit/Makefile src/gui/components/Makefile src/gui/lua/Makefile +src/gui/moviebrowser/Makefile src/gui/widget/Makefile src/system/Makefile src/system/mtdutils/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 36725b473..a0a03a075 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -83,6 +83,7 @@ neutrino_LDADD = \ driver/pictureviewer/libneutrino_pictureviewer.a \ $(MTDUTILSLIBS) \ gui/movieinfo.o \ + gui/moviebrowser/mb.o \ gui/libneutrino_gui2.a \ gui/components/libneutrino_gui_components.a \ $(LUALIBS) \ diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 3126b8156..049423f30 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -15,7 +15,7 @@ version.h: noinst_HEADERS = version.h .PHONY: version.h -SUBDIRS = bedit components widget +SUBDIRS = bedit components moviebrowser widget if ENABLE_LUA SUBDIRS += lua @@ -72,7 +72,6 @@ libneutrino_gui_a_SOURCES = \ mediaplayer.cpp \ mediaplayer_setup.cpp \ miscsettings_menu.cpp \ - moviebrowser.cpp \ movieinfo.cpp \ movieplayer.cpp \ network_service.cpp \ diff --git a/src/gui/epgplus.cpp b/src/gui/epgplus.cpp index 94ab4af35..c3d9981fa 100644 --- a/src/gui/epgplus.cpp +++ b/src/gui/epgplus.cpp @@ -35,7 +35,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/gui/epgview.cpp b/src/gui/epgview.cpp index e50d93ae3..25c1cd57c 100644 --- a/src/gui/epgview.cpp +++ b/src/gui/epgview.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/gui/eventlist.cpp b/src/gui/eventlist.cpp index 429cc8c71..90f76aa7a 100644 --- a/src/gui/eventlist.cpp +++ b/src/gui/eventlist.cpp @@ -34,7 +34,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/gui/mediaplayer_setup.cpp b/src/gui/mediaplayer_setup.cpp index c2894739d..bb18e8333 100644 --- a/src/gui/mediaplayer_setup.cpp +++ b/src/gui/mediaplayer_setup.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include diff --git a/src/gui/moviebrowser/Makefile.am b/src/gui/moviebrowser/Makefile.am new file mode 100644 index 000000000..46379f2ca --- /dev/null +++ b/src/gui/moviebrowser/Makefile.am @@ -0,0 +1,20 @@ +AM_CPPFLAGS = -fno-rtti -fno-exceptions -D__STDC_FORMAT_MACROS + +AM_CPPFLAGS += \ + -I$(top_builddir) \ + -I$(top_srcdir) \ + -I$(top_srcdir)/src \ + -I$(top_srcdir)/src/zapit/include \ + -I$(top_srcdir)/lib \ + -I$(top_srcdir)/lib/libeventserver \ + -I$(top_srcdir)/lib/libconfigfile \ + -I$(top_srcdir)/lib/xmltree \ + @SIGC_CFLAGS@ \ + @FREETYPE_CFLAGS@ \ + @HWLIB_CFLAGS@ + +noinst_LIBRARIES = libneutrino_gui_moviebrowser.a + + +libneutrino_gui_moviebrowser_a_SOURCES = \ + mb.cpp diff --git a/src/gui/moviebrowser.cpp b/src/gui/moviebrowser/mb.cpp similarity index 97% rename from src/gui/moviebrowser.cpp rename to src/gui/moviebrowser/mb.cpp index 23a32c0cc..9b2212365 100644 --- a/src/gui/moviebrowser.cpp +++ b/src/gui/moviebrowser/mb.cpp @@ -27,7 +27,7 @@ Date: Nov 2005 - Author: Günther@tuxbox.berlios.org + Author: Günther@tuxbox.berlios.org based on code of Steffen Hehn 'McClean' (C) 2009-2014 Stefan Seyfried @@ -42,9 +42,10 @@ #include #include -#include -#include "moviebrowser.h" -#include "filebrowser.h" +//#include +#include "mb.h" +#include "mb_functions.h" +#include #include #include #include @@ -62,12 +63,12 @@ #include // for statfs #include #include -#include +//#include #include #include #include #include -#include +//#include #include #include #include @@ -234,122 +235,7 @@ static MI_MOVIE_INFO* playing_info; //------------------------------------------------------------------------ #define FILEBROWSER_NUMBER_OF_SORT_VARIANTS 5 -bool sortDirection = 0; -bool compare_to_lower(const char a, const char b) -{ - return tolower(a) < tolower(b); -} - -// sort operators -bool sortByTitle(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (std::lexicographical_compare(a->epgTitle.begin(), a->epgTitle.end(), b->epgTitle.begin(), b->epgTitle.end(), compare_to_lower)) - return true; - if (std::lexicographical_compare(b->epgTitle.begin(), b->epgTitle.end(), a->epgTitle.begin(), a->epgTitle.end(), compare_to_lower)) - return false; - return a->file.Time < b->file.Time; -} -bool sortByGenre(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (std::lexicographical_compare(a->epgInfo1.begin(), a->epgInfo1.end(), b->epgInfo1.begin(), b->epgInfo1.end(), compare_to_lower)) - return true; - if (std::lexicographical_compare(b->epgInfo1.begin(), b->epgInfo1.end(), a->epgInfo1.begin(), a->epgInfo1.end(), compare_to_lower)) - return false; - return sortByTitle(a,b); -} -bool sortByChannel(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (std::lexicographical_compare(a->epgChannel.begin(), a->epgChannel.end(), b->epgChannel.begin(), b->epgChannel.end(), compare_to_lower)) - return true; - if (std::lexicographical_compare(b->epgChannel.begin(), b->epgChannel.end(), a->epgChannel.begin(), a->epgChannel.end(), compare_to_lower)) - return false; - return sortByTitle(a,b); -} -bool sortByFileName(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (std::lexicographical_compare(a->file.getFileName().begin(), a->file.getFileName().end(), b->file.getFileName().begin(), b->file.getFileName().end(), compare_to_lower)) - return true; - if (std::lexicographical_compare(b->file.getFileName().begin(), b->file.getFileName().end(), a->file.getFileName().begin(), a->file.getFileName().end(), compare_to_lower)) - return false; - return a->file.Time < b->file.Time; -} -bool sortByRecordDate(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (sortDirection) - return a->file.Time > b->file.Time ; - else - return a->file.Time < b->file.Time ; -} -bool sortBySize(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (sortDirection) - return a->file.Size > b->file.Size; - else - return a->file.Size < b->file.Size; -} -bool sortByAge(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (sortDirection) - return a->parentalLockAge > b->parentalLockAge; - else - return a->parentalLockAge < b->parentalLockAge; -} -bool sortByRating(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (sortDirection) - return a->rating > b->rating; - else - return a->rating < b->rating; -} -bool sortByQuality(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (sortDirection) - return a->quality > b->quality; - else - return a->quality < b->quality; -} -bool sortByDir(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (sortDirection) - return a->dirItNr > b->dirItNr; - else - return a->dirItNr < b->dirItNr; -} - -bool sortByLastPlay(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) -{ - if (sortDirection) - return a->dateOfLastPlay > b->dateOfLastPlay; - else - return a->dateOfLastPlay < b->dateOfLastPlay; -} - -bool (* const sortBy[MB_INFO_MAX_NUMBER+1])(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) = -{ - &sortByFileName, //MB_INFO_FILENAME = 0, - &sortByDir, //MB_INFO_FILEPATH = 1, - &sortByTitle, //MB_INFO_TITLE = 2, - NULL, //MB_INFO_SERIE = 3, - &sortByGenre, //MB_INFO_INFO1 = 4, - NULL, //MB_INFO_MAJOR_GENRE = 5, - NULL, //MB_INFO_MINOR_GENRE = 6, - NULL, //MB_INFO_INFO2 = 7, - &sortByAge, //MB_INFO_PARENTAL_LOCKAGE = 8, - &sortByChannel, //MB_INFO_CHANNEL = 9, - NULL, //MB_INFO_BOOKMARK = 10, - &sortByQuality, //MB_INFO_QUALITY = 11, - &sortByLastPlay, //MB_INFO_PREVPLAYDATE = 12, - &sortByRecordDate, //MB_INFO_RECORDDATE = 13, - NULL, //MB_INFO_PRODDATE = 14, - NULL, //MB_INFO_COUNTRY = 15, - NULL, //MB_INFO_GEOMETRIE = 16, - NULL, //MB_INFO_AUDIO = 17, - NULL, //MB_INFO_LENGTH = 18, - &sortBySize, //MB_INFO_SIZE = 19, - &sortByRating, //MB_INFO_RATING = 20, - NULL //MB_INFO_MAX_NUMBER = 21 -}; CMovieBrowser::CMovieBrowser(): configfile ('\t') { @@ -1502,7 +1388,7 @@ void CMovieBrowser::refreshMovieInfo(void) int w_logo = ratio*CChannelLogo->getWidth()/100; CChannelLogo->setWidth(min(w_logo, logo_w_max)); } - + lx = m_cBoxFrame.iX+m_cBoxFrameTitleRel.iX+m_cBoxFrameTitleRel.iWidth-CChannelLogo->getWidth()-10; ly = m_cBoxFrameTitleRel.iY+m_cBoxFrame.iY+ (m_cBoxFrameTitleRel.iHeight-CChannelLogo->getHeight())/2; CChannelLogo->setXPos(lx - pb_hdd_offset); @@ -3090,10 +2976,7 @@ void CMovieBrowser::showHelp(void) help.exec(NULL,NULL); } -static std::string rateFormat(int i) -{ - return to_string(i/10) + "," + to_string(i%10); -} + #define MAX_STRING 30 int CMovieBrowser::showMovieInfoMenu(MI_MOVIE_INFO* movie_info) diff --git a/src/gui/moviebrowser.h b/src/gui/moviebrowser/mb.h similarity index 73% rename from src/gui/moviebrowser.h rename to src/gui/moviebrowser/mb.h index 4f502ded9..1eaaf819f 100644 --- a/src/gui/moviebrowser.h +++ b/src/gui/moviebrowser/mb.h @@ -1,7 +1,7 @@ /*************************************************************************** Neutrino-GUI - DBoxII-Project - Homepage: http://dbox.cyberphoria.org/ + Homepage: http://dbox.cyberphoria.org/ $Id: moviebrowser.h,v 1.5 2006/09/11 21:11:35 guenther Exp $ @@ -37,7 +37,7 @@ Date: Nov 2005 - Author: Günther@tuxbox.berlios.org + Author: Günther@tuxbox.berlios.org based on code of Steffen Hehn 'McClean' $Log: moviebrowser.h,v $ @@ -69,14 +69,16 @@ #include #endif +#include "mb_types.h" + #include -#include +//#include #include #include -#include -#include + #include +#include #include #include #include @@ -92,105 +94,9 @@ #define MAX_BROWSER_FRAME_HEIGHT 80 void strReplace(std::string& orig, const char* fstr, const std::string &rstr); -/* !!!! Do NOT change the order of the enum, just add items at the end !!!! */ -typedef enum -{ - MB_INFO_FILENAME = 0, - MB_INFO_FILEPATH = 1, - MB_INFO_TITLE = 2, - MB_INFO_SERIE = 3, - MB_INFO_INFO1 = 4, - MB_INFO_MAJOR_GENRE = 5, - MB_INFO_MINOR_GENRE = 6, - MB_INFO_INFO2 = 7, - MB_INFO_PARENTAL_LOCKAGE = 8, - MB_INFO_CHANNEL = 9, - MB_INFO_BOOKMARK = 10, - MB_INFO_QUALITY = 11, - MB_INFO_PREVPLAYDATE = 12, - MB_INFO_RECORDDATE = 13, - MB_INFO_PRODDATE = 14, - MB_INFO_COUNTRY = 15, - MB_INFO_GEOMETRIE = 16, - MB_INFO_AUDIO = 17, - MB_INFO_LENGTH = 18, - MB_INFO_SIZE = 19, - MB_INFO_RATING = 20, - MB_INFO_MAX_NUMBER = 21 // MUST be allways the last item in the list -}MB_INFO_ITEM; -typedef enum -{ - MB_DIRECTION_AUTO = 0, - MB_DIRECTION_UP = 1, - MB_DIRECTION_DOWN = 2, - MB_DIRECTION_MAX_NUMBER = 3 // MUST be allways the last item in the list -}MB_DIRECTION; - -typedef struct -{ - MB_INFO_ITEM item; - MB_DIRECTION direction; -}MB_SORTING; - -typedef enum -{ - MB_STORAGE_TYPE_UNDEFINED = 0, - MB_STORAGE_TYPE_NFS = 1, - MB_STORAGE_TYPE_VLC = 2, - MB_STORAGE_MAX_NUMBER = 3 // MUST be allways the last item in the list -}MB_STORAGE_TYPE; - -typedef struct -{ - MB_INFO_ITEM item; - std::string optionString; - int optionVar; -}MB_FILTER; - -typedef enum -{ - MB_FOCUS_BROWSER = 0, - MB_FOCUS_LAST_PLAY = 1, - MB_FOCUS_LAST_RECORD = 2, - MB_FOCUS_MOVIE_INFO = 3, - MB_FOCUS_FILTER = 4, - MB_FOCUS_MAX_NUMBER = 5 // MUST be allways the last item in the list -}MB_FOCUS; - -typedef enum -{ - MB_GUI_BROWSER_ONLY = 0, - MB_GUI_MOVIE_INFO = 1, - MB_GUI_LAST_PLAY = 2, - MB_GUI_LAST_RECORD = 3, - MB_GUI_FILTER = 4, - MB_GUI_MAX_NUMBER = 5 // MUST be allways the last item in the list -}MB_GUI; - - -typedef enum -{ - MB_PARENTAL_LOCK_OFF = 0, - MB_PARENTAL_LOCK_ACTIVE = 1, - MB_PARENTAL_LOCK_OFF_TMP = 2, // use this to activate the lock temporarily until next dbox start up - MB_PARENTAL_LOCK_MAX_NUMBER = 3 // MUST be allways the last item in the list -}MB_PARENTAL_LOCK; - -typedef struct -{ - std::string name; - int* used; -}MB_DIR; - -typedef enum -{ - MB_SHOW_RECORDS, - MB_SHOW_FILES, - MB_SHOW_YT -} MB_SHOW_MODE; #define MB_MAX_ROWS LF_MAX_ROWS #define MB_MAX_DIRS NETWORK_NFS_NR_OF_ENTRIES @@ -387,7 +293,7 @@ class CMovieBrowser : public CMenuTarget void setMode(int mode) { if (show_mode != mode) m_file_info_stale = true; - show_mode = mode; + show_mode = mode; } bool gotMovie(const char *rec_title); @@ -543,14 +449,7 @@ class CFileChooser : public CMenuWidget int exec(CMenuTarget* parent, const std::string & actionKey); }; -typedef enum -{ - DIR_STATE_UNKNOWN = 0, - DIR_STATE_SERVER_DOWN = 1, - DIR_STATE_NOT_MOUNTED = 2, - DIR_STATE_MOUNTED = 3, - DIR_STATE_DISABLED = 4 -} DIR_STATE; + class CDirMenu : public CMenuWidget { @@ -571,90 +470,6 @@ class CDirMenu : public CMenuWidget }; -// EPG Genre, taken from epgview, TODO: might be splitted in major/minor to increase handling -#define GENRE_ALL_COUNT 76 -const CMenuOptionChooser::keyval GENRE_ALL[GENRE_ALL_COUNT] = -{ - { 0x00, LOCALE_GENRE_UNKNOWN }, - { 0x10, LOCALE_GENRE_MOVIE_0 }, - { 0x11, LOCALE_GENRE_MOVIE_1 }, - { 0x12, LOCALE_GENRE_MOVIE_2 }, - { 0x13, LOCALE_GENRE_MOVIE_3 }, - { 0x14, LOCALE_GENRE_MOVIE_4 }, - { 0x15, LOCALE_GENRE_MOVIE_5 }, - { 0x16, LOCALE_GENRE_MOVIE_6 }, - { 0x17, LOCALE_GENRE_MOVIE_7 }, - { 0x18, LOCALE_GENRE_MOVIE_8 }, - { 0x20, LOCALE_GENRE_NEWS_0 }, - { 0x21, LOCALE_GENRE_NEWS_1 }, - { 0x22, LOCALE_GENRE_NEWS_2 }, - { 0x23, LOCALE_GENRE_NEWS_3 }, - { 0x24, LOCALE_GENRE_NEWS_4 }, - { 0x30, LOCALE_GENRE_SHOW_0 }, - { 0x31, LOCALE_GENRE_SHOW_1 }, - { 0x32, LOCALE_GENRE_SHOW_2 }, - { 0x33, LOCALE_GENRE_SHOW_3 }, - { 0x40, LOCALE_GENRE_SPORTS_0 }, - { 0x41, LOCALE_GENRE_SPORTS_1 }, - { 0x42, LOCALE_GENRE_SPORTS_2 }, - { 0x43, LOCALE_GENRE_SPORTS_3 }, - { 0x44, LOCALE_GENRE_SPORTS_4 }, - { 0x45, LOCALE_GENRE_SPORTS_5 }, - { 0x46, LOCALE_GENRE_SPORTS_6 }, - { 0x47, LOCALE_GENRE_SPORTS_7 }, - { 0x48, LOCALE_GENRE_SPORTS_8 }, - { 0x49, LOCALE_GENRE_SPORTS_9 }, - { 0x4A, LOCALE_GENRE_SPORTS_10 }, - { 0x4B, LOCALE_GENRE_SPORTS_11 }, - { 0x50, LOCALE_GENRE_CHILDRENS_PROGRAMMES_0 }, - { 0x51, LOCALE_GENRE_CHILDRENS_PROGRAMMES_1 }, - { 0x52, LOCALE_GENRE_CHILDRENS_PROGRAMMES_2 }, - { 0x53, LOCALE_GENRE_CHILDRENS_PROGRAMMES_3 }, - { 0x54, LOCALE_GENRE_CHILDRENS_PROGRAMMES_4 }, - { 0x55, LOCALE_GENRE_CHILDRENS_PROGRAMMES_5 }, - { 0x60, LOCALE_GENRE_MUSIC_DANCE_0 }, - { 0x61, LOCALE_GENRE_MUSIC_DANCE_1 }, - { 0x62, LOCALE_GENRE_MUSIC_DANCE_2 }, - { 0x63, LOCALE_GENRE_MUSIC_DANCE_3 }, - { 0x64, LOCALE_GENRE_MUSIC_DANCE_4 }, - { 0x65, LOCALE_GENRE_MUSIC_DANCE_5 }, - { 0x66, LOCALE_GENRE_MUSIC_DANCE_6 }, - { 0x70, LOCALE_GENRE_ARTS_0 }, - { 0x71, LOCALE_GENRE_ARTS_1 }, - { 0x72, LOCALE_GENRE_ARTS_2 }, - { 0x73, LOCALE_GENRE_ARTS_3 }, - { 0x74, LOCALE_GENRE_ARTS_4 }, - { 0x75, LOCALE_GENRE_ARTS_5 }, - { 0x76, LOCALE_GENRE_ARTS_6 }, - { 0x77, LOCALE_GENRE_ARTS_7 }, - { 0x78, LOCALE_GENRE_ARTS_8 }, - { 0x79, LOCALE_GENRE_ARTS_9 }, - { 0x7A, LOCALE_GENRE_ARTS_10 }, - { 0x7B, LOCALE_GENRE_ARTS_11 }, - { 0x80, LOCALE_GENRE_SOCIAL_POLITICAL_0 }, - { 0x81, LOCALE_GENRE_SOCIAL_POLITICAL_1 }, - { 0x82, LOCALE_GENRE_SOCIAL_POLITICAL_2 }, - { 0x83, LOCALE_GENRE_SOCIAL_POLITICAL_3 }, - { 0x90, LOCALE_GENRE_DOCUS_MAGAZINES_0 }, - { 0x91, LOCALE_GENRE_DOCUS_MAGAZINES_1 }, - { 0x92, LOCALE_GENRE_DOCUS_MAGAZINES_2 }, - { 0x93, LOCALE_GENRE_DOCUS_MAGAZINES_3 }, - { 0x94, LOCALE_GENRE_DOCUS_MAGAZINES_4 }, - { 0x95, LOCALE_GENRE_DOCUS_MAGAZINES_5 }, - { 0x96, LOCALE_GENRE_DOCUS_MAGAZINES_6 }, - { 0x97, LOCALE_GENRE_DOCUS_MAGAZINES_7 }, - { 0xA0, LOCALE_GENRE_TRAVEL_HOBBIES_0 }, - { 0xA1, LOCALE_GENRE_TRAVEL_HOBBIES_1 }, - { 0xA2, LOCALE_GENRE_TRAVEL_HOBBIES_2 }, - { 0xA3, LOCALE_GENRE_TRAVEL_HOBBIES_3 }, - { 0xA4, LOCALE_GENRE_TRAVEL_HOBBIES_4 }, - { 0xA5, LOCALE_GENRE_TRAVEL_HOBBIES_5 }, - { 0xA6, LOCALE_GENRE_TRAVEL_HOBBIES_6 }, - { 0xA7, LOCALE_GENRE_TRAVEL_HOBBIES_7 } -}; + #endif /*MOVIEBROWSER_H_*/ - - - - diff --git a/src/gui/moviebrowser/mb_functions.h b/src/gui/moviebrowser/mb_functions.h new file mode 100644 index 000000000..4b0002ddc --- /dev/null +++ b/src/gui/moviebrowser/mb_functions.h @@ -0,0 +1,138 @@ + +#ifndef __MB_FUNCTIONS__ +#define __MB_FUNCTIONS__ + + +#include "mb_types.h" +#include + + + + +void strReplace(std::string& orig, const char* fstr, const std::string &rstr); + +static std::string rateFormat(int i) +{ + return to_string(i/10) + "," + to_string(i%10); +} + +bool sortDirection = 0; + +bool compare_to_lower(const char a, const char b) +{ + return tolower(a) < tolower(b); +} + +// sort operators +bool sortByTitle(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (std::lexicographical_compare(a->epgTitle.begin(), a->epgTitle.end(), b->epgTitle.begin(), b->epgTitle.end(), compare_to_lower)) + return true; + if (std::lexicographical_compare(b->epgTitle.begin(), b->epgTitle.end(), a->epgTitle.begin(), a->epgTitle.end(), compare_to_lower)) + return false; + return a->file.Time < b->file.Time; +} +bool sortByGenre(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (std::lexicographical_compare(a->epgInfo1.begin(), a->epgInfo1.end(), b->epgInfo1.begin(), b->epgInfo1.end(), compare_to_lower)) + return true; + if (std::lexicographical_compare(b->epgInfo1.begin(), b->epgInfo1.end(), a->epgInfo1.begin(), a->epgInfo1.end(), compare_to_lower)) + return false; + return sortByTitle(a,b); +} +bool sortByChannel(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (std::lexicographical_compare(a->epgChannel.begin(), a->epgChannel.end(), b->epgChannel.begin(), b->epgChannel.end(), compare_to_lower)) + return true; + if (std::lexicographical_compare(b->epgChannel.begin(), b->epgChannel.end(), a->epgChannel.begin(), a->epgChannel.end(), compare_to_lower)) + return false; + return sortByTitle(a,b); +} +bool sortByFileName(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (std::lexicographical_compare(a->file.getFileName().begin(), a->file.getFileName().end(), b->file.getFileName().begin(), b->file.getFileName().end(), compare_to_lower)) + return true; + if (std::lexicographical_compare(b->file.getFileName().begin(), b->file.getFileName().end(), a->file.getFileName().begin(), a->file.getFileName().end(), compare_to_lower)) + return false; + return a->file.Time < b->file.Time; +} +bool sortByRecordDate(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (sortDirection) + return a->file.Time > b->file.Time ; + else + return a->file.Time < b->file.Time ; +} +bool sortBySize(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (sortDirection) + return a->file.Size > b->file.Size; + else + return a->file.Size < b->file.Size; +} +bool sortByAge(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (sortDirection) + return a->parentalLockAge > b->parentalLockAge; + else + return a->parentalLockAge < b->parentalLockAge; +} +bool sortByRating(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (sortDirection) + return a->rating > b->rating; + else + return a->rating < b->rating; +} +bool sortByQuality(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (sortDirection) + return a->quality > b->quality; + else + return a->quality < b->quality; +} +bool sortByDir(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (sortDirection) + return a->dirItNr > b->dirItNr; + else + return a->dirItNr < b->dirItNr; +} + +bool sortByLastPlay(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) +{ + if (sortDirection) + return a->dateOfLastPlay > b->dateOfLastPlay; + else + return a->dateOfLastPlay < b->dateOfLastPlay; +} + +bool (* const sortBy[MB_INFO_MAX_NUMBER+1])(const MI_MOVIE_INFO* a, const MI_MOVIE_INFO* b) = +{ + &sortByFileName, //MB_INFO_FILENAME = 0, + &sortByDir, //MB_INFO_FILEPATH = 1, + &sortByTitle, //MB_INFO_TITLE = 2, + NULL, //MB_INFO_SERIE = 3, + &sortByGenre, //MB_INFO_INFO1 = 4, + NULL, //MB_INFO_MAJOR_GENRE = 5, + NULL, //MB_INFO_MINOR_GENRE = 6, + NULL, //MB_INFO_INFO2 = 7, + &sortByAge, //MB_INFO_PARENTAL_LOCKAGE = 8, + &sortByChannel, //MB_INFO_CHANNEL = 9, + NULL, //MB_INFO_BOOKMARK = 10, + &sortByQuality, //MB_INFO_QUALITY = 11, + &sortByLastPlay, //MB_INFO_PREVPLAYDATE = 12, + &sortByRecordDate, //MB_INFO_RECORDDATE = 13, + NULL, //MB_INFO_PRODDATE = 14, + NULL, //MB_INFO_COUNTRY = 15, + NULL, //MB_INFO_GEOMETRIE = 16, + NULL, //MB_INFO_AUDIO = 17, + NULL, //MB_INFO_LENGTH = 18, + &sortBySize, //MB_INFO_SIZE = 19, + &sortByRating, //MB_INFO_RATING = 20, + NULL //MB_INFO_MAX_NUMBER = 21 +}; + + + +#endif /*__MB_FUNCTIONS__*/ diff --git a/src/gui/moviebrowser/mb_types.h b/src/gui/moviebrowser/mb_types.h new file mode 100644 index 000000000..82a36e385 --- /dev/null +++ b/src/gui/moviebrowser/mb_types.h @@ -0,0 +1,198 @@ +#include + +#ifndef __MB_TYPES__ +#define __MB_TYPES__ + + + +/* !!!! Do NOT change the order of the enum, just add items at the end !!!! */ +typedef enum +{ + MB_INFO_FILENAME = 0, + MB_INFO_FILEPATH = 1, + MB_INFO_TITLE = 2, + MB_INFO_SERIE = 3, + MB_INFO_INFO1 = 4, + MB_INFO_MAJOR_GENRE = 5, + MB_INFO_MINOR_GENRE = 6, + MB_INFO_INFO2 = 7, + MB_INFO_PARENTAL_LOCKAGE = 8, + MB_INFO_CHANNEL = 9, + MB_INFO_BOOKMARK = 10, + MB_INFO_QUALITY = 11, + MB_INFO_PREVPLAYDATE = 12, + MB_INFO_RECORDDATE = 13, + MB_INFO_PRODDATE = 14, + MB_INFO_COUNTRY = 15, + MB_INFO_GEOMETRIE = 16, + MB_INFO_AUDIO = 17, + MB_INFO_LENGTH = 18, + MB_INFO_SIZE = 19, + MB_INFO_RATING = 20, + MB_INFO_MAX_NUMBER = 21 // MUST be allways the last item in the list +}MB_INFO_ITEM; + + +typedef enum +{ + MB_DIRECTION_AUTO = 0, + MB_DIRECTION_UP = 1, + MB_DIRECTION_DOWN = 2, + MB_DIRECTION_MAX_NUMBER = 3 // MUST be allways the last item in the list +}MB_DIRECTION; + +typedef struct +{ + MB_INFO_ITEM item; + MB_DIRECTION direction; +}MB_SORTING; + +typedef enum +{ + MB_STORAGE_TYPE_UNDEFINED = 0, + MB_STORAGE_TYPE_NFS = 1, + MB_STORAGE_TYPE_VLC = 2, + MB_STORAGE_MAX_NUMBER = 3 // MUST be allways the last item in the list +}MB_STORAGE_TYPE; + +typedef struct +{ + MB_INFO_ITEM item; + std::string optionString; + int optionVar; +}MB_FILTER; + +typedef enum +{ + MB_FOCUS_BROWSER = 0, + MB_FOCUS_LAST_PLAY = 1, + MB_FOCUS_LAST_RECORD = 2, + MB_FOCUS_MOVIE_INFO = 3, + MB_FOCUS_FILTER = 4, + MB_FOCUS_MAX_NUMBER = 5 // MUST be allways the last item in the list +}MB_FOCUS; + +typedef enum +{ + MB_GUI_BROWSER_ONLY = 0, + MB_GUI_MOVIE_INFO = 1, + MB_GUI_LAST_PLAY = 2, + MB_GUI_LAST_RECORD = 3, + MB_GUI_FILTER = 4, + MB_GUI_MAX_NUMBER = 5 // MUST be allways the last item in the list +}MB_GUI; + + +typedef enum +{ + MB_PARENTAL_LOCK_OFF = 0, + MB_PARENTAL_LOCK_ACTIVE = 1, + MB_PARENTAL_LOCK_OFF_TMP = 2, // use this to activate the lock temporarily until next dbox start up + MB_PARENTAL_LOCK_MAX_NUMBER = 3 // MUST be allways the last item in the list +}MB_PARENTAL_LOCK; + +typedef struct +{ + std::string name; + int* used; +}MB_DIR; + +typedef enum +{ + MB_SHOW_RECORDS, + MB_SHOW_FILES, + MB_SHOW_YT +} MB_SHOW_MODE; + +typedef enum +{ + DIR_STATE_UNKNOWN = 0, + DIR_STATE_SERVER_DOWN = 1, + DIR_STATE_NOT_MOUNTED = 2, + DIR_STATE_MOUNTED = 3, + DIR_STATE_DISABLED = 4 +} DIR_STATE; + +// EPG Genre, taken from epgview, TODO: might be splitted in major/minor to increase handling +#define GENRE_ALL_COUNT 76 +const CMenuOptionChooser::keyval GENRE_ALL[GENRE_ALL_COUNT] = +{ + { 0x00, LOCALE_GENRE_UNKNOWN }, + { 0x10, LOCALE_GENRE_MOVIE_0 }, + { 0x11, LOCALE_GENRE_MOVIE_1 }, + { 0x12, LOCALE_GENRE_MOVIE_2 }, + { 0x13, LOCALE_GENRE_MOVIE_3 }, + { 0x14, LOCALE_GENRE_MOVIE_4 }, + { 0x15, LOCALE_GENRE_MOVIE_5 }, + { 0x16, LOCALE_GENRE_MOVIE_6 }, + { 0x17, LOCALE_GENRE_MOVIE_7 }, + { 0x18, LOCALE_GENRE_MOVIE_8 }, + { 0x20, LOCALE_GENRE_NEWS_0 }, + { 0x21, LOCALE_GENRE_NEWS_1 }, + { 0x22, LOCALE_GENRE_NEWS_2 }, + { 0x23, LOCALE_GENRE_NEWS_3 }, + { 0x24, LOCALE_GENRE_NEWS_4 }, + { 0x30, LOCALE_GENRE_SHOW_0 }, + { 0x31, LOCALE_GENRE_SHOW_1 }, + { 0x32, LOCALE_GENRE_SHOW_2 }, + { 0x33, LOCALE_GENRE_SHOW_3 }, + { 0x40, LOCALE_GENRE_SPORTS_0 }, + { 0x41, LOCALE_GENRE_SPORTS_1 }, + { 0x42, LOCALE_GENRE_SPORTS_2 }, + { 0x43, LOCALE_GENRE_SPORTS_3 }, + { 0x44, LOCALE_GENRE_SPORTS_4 }, + { 0x45, LOCALE_GENRE_SPORTS_5 }, + { 0x46, LOCALE_GENRE_SPORTS_6 }, + { 0x47, LOCALE_GENRE_SPORTS_7 }, + { 0x48, LOCALE_GENRE_SPORTS_8 }, + { 0x49, LOCALE_GENRE_SPORTS_9 }, + { 0x4A, LOCALE_GENRE_SPORTS_10 }, + { 0x4B, LOCALE_GENRE_SPORTS_11 }, + { 0x50, LOCALE_GENRE_CHILDRENS_PROGRAMMES_0 }, + { 0x51, LOCALE_GENRE_CHILDRENS_PROGRAMMES_1 }, + { 0x52, LOCALE_GENRE_CHILDRENS_PROGRAMMES_2 }, + { 0x53, LOCALE_GENRE_CHILDRENS_PROGRAMMES_3 }, + { 0x54, LOCALE_GENRE_CHILDRENS_PROGRAMMES_4 }, + { 0x55, LOCALE_GENRE_CHILDRENS_PROGRAMMES_5 }, + { 0x60, LOCALE_GENRE_MUSIC_DANCE_0 }, + { 0x61, LOCALE_GENRE_MUSIC_DANCE_1 }, + { 0x62, LOCALE_GENRE_MUSIC_DANCE_2 }, + { 0x63, LOCALE_GENRE_MUSIC_DANCE_3 }, + { 0x64, LOCALE_GENRE_MUSIC_DANCE_4 }, + { 0x65, LOCALE_GENRE_MUSIC_DANCE_5 }, + { 0x66, LOCALE_GENRE_MUSIC_DANCE_6 }, + { 0x70, LOCALE_GENRE_ARTS_0 }, + { 0x71, LOCALE_GENRE_ARTS_1 }, + { 0x72, LOCALE_GENRE_ARTS_2 }, + { 0x73, LOCALE_GENRE_ARTS_3 }, + { 0x74, LOCALE_GENRE_ARTS_4 }, + { 0x75, LOCALE_GENRE_ARTS_5 }, + { 0x76, LOCALE_GENRE_ARTS_6 }, + { 0x77, LOCALE_GENRE_ARTS_7 }, + { 0x78, LOCALE_GENRE_ARTS_8 }, + { 0x79, LOCALE_GENRE_ARTS_9 }, + { 0x7A, LOCALE_GENRE_ARTS_10 }, + { 0x7B, LOCALE_GENRE_ARTS_11 }, + { 0x80, LOCALE_GENRE_SOCIAL_POLITICAL_0 }, + { 0x81, LOCALE_GENRE_SOCIAL_POLITICAL_1 }, + { 0x82, LOCALE_GENRE_SOCIAL_POLITICAL_2 }, + { 0x83, LOCALE_GENRE_SOCIAL_POLITICAL_3 }, + { 0x90, LOCALE_GENRE_DOCUS_MAGAZINES_0 }, + { 0x91, LOCALE_GENRE_DOCUS_MAGAZINES_1 }, + { 0x92, LOCALE_GENRE_DOCUS_MAGAZINES_2 }, + { 0x93, LOCALE_GENRE_DOCUS_MAGAZINES_3 }, + { 0x94, LOCALE_GENRE_DOCUS_MAGAZINES_4 }, + { 0x95, LOCALE_GENRE_DOCUS_MAGAZINES_5 }, + { 0x96, LOCALE_GENRE_DOCUS_MAGAZINES_6 }, + { 0x97, LOCALE_GENRE_DOCUS_MAGAZINES_7 }, + { 0xA0, LOCALE_GENRE_TRAVEL_HOBBIES_0 }, + { 0xA1, LOCALE_GENRE_TRAVEL_HOBBIES_1 }, + { 0xA2, LOCALE_GENRE_TRAVEL_HOBBIES_2 }, + { 0xA3, LOCALE_GENRE_TRAVEL_HOBBIES_3 }, + { 0xA4, LOCALE_GENRE_TRAVEL_HOBBIES_4 }, + { 0xA5, LOCALE_GENRE_TRAVEL_HOBBIES_5 }, + { 0xA6, LOCALE_GENRE_TRAVEL_HOBBIES_6 }, + { 0xA7, LOCALE_GENRE_TRAVEL_HOBBIES_7 } +}; + +#endif /*__MB_TYPES__*/ \ No newline at end of file diff --git a/src/gui/movieplayer.h b/src/gui/movieplayer.h index cce01eac0..818b1054f 100644 --- a/src/gui/movieplayer.h +++ b/src/gui/movieplayer.h @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/system/helpers.cpp b/src/system/helpers.cpp index c9d736c85..109c264d5 100644 --- a/src/system/helpers.cpp +++ b/src/system/helpers.cpp @@ -664,8 +664,7 @@ std::string& htmlEntityDecode(std::string& text) CFileHelpers::CFileHelpers() { - FileBufSize = 0xFFFF; - FileBuf = new char[FileBufSize]; + FileBufMaxSize = 0xFFFF; doCopyFlag = true; ConsoleQuiet = false; clearDebugInfo(); @@ -673,8 +672,21 @@ CFileHelpers::CFileHelpers() CFileHelpers::~CFileHelpers() { - if (FileBuf != NULL) - delete [] FileBuf; +} + +char* CFileHelpers::initFileBuf(char* buf, uint32_t size) +{ + if (buf == NULL) + buf = new char[size]; + return buf; +} + +char* CFileHelpers::deleteFileBuf(char* buf) +{ + if (buf != NULL) + delete [] buf; + buf = NULL; + return buf; } CFileHelpers* CFileHelpers::getInstance() @@ -872,10 +884,13 @@ bool CFileHelpers::copyFile(const char *Src, const char *Dst, mode_t forceMode/* return false; } + char* FileBuf = NULL; uint32_t block; off64_t fsizeSrc64 = lseek64(fd1, 0, SEEK_END); lseek64(fd1, 0, SEEK_SET); if (fsizeSrc64 > 0x7FFFFFF0) { // > 2GB + uint32_t FileBufSize = FileBufMaxSize; + FileBuf = initFileBuf(FileBuf, FileBufSize); off64_t fsize64 = fsizeSrc64; block = FileBufSize; //printf("#####[%s] fsizeSrc64: %lld 0x%010llX - large file\n", __FUNCTION__, fsizeSrc64, fsizeSrc64); @@ -894,12 +909,15 @@ bool CFileHelpers::copyFile(const char *Src, const char *Dst, mode_t forceMode/* if (fsizeSrc64 != fsizeDst64){ close(fd1); close(fd2); + FileBuf = deleteFileBuf(FileBuf); return false; } } } else { // < 2GB off_t fsizeSrc = lseek(fd1, 0, SEEK_END); + uint32_t FileBufSize = (fsizeSrc < (off_t)FileBufMaxSize) ? fsizeSrc : FileBufMaxSize; + FileBuf = initFileBuf(FileBuf, FileBufSize); lseek(fd1, 0, SEEK_SET); off_t fsize = fsizeSrc; block = FileBufSize; @@ -919,6 +937,7 @@ bool CFileHelpers::copyFile(const char *Src, const char *Dst, mode_t forceMode/* if (fsizeSrc != fsizeDst){ close(fd1); close(fd2); + FileBuf = deleteFileBuf(FileBuf); return false; } } @@ -929,9 +948,11 @@ bool CFileHelpers::copyFile(const char *Src, const char *Dst, mode_t forceMode/* if (!doCopyFlag) { sync(); unlink(Dst); + FileBuf = deleteFileBuf(FileBuf); return false; } + FileBuf = deleteFileBuf(FileBuf); return true; } @@ -1054,8 +1075,14 @@ bool CFileHelpers::removeDir(const char *Dir) dir = opendir(Dir); if (dir == NULL) { - fh->setDebugInfo("Error opendir().", __path_file__, __func__, __LINE__); - fh->printDebugInfo(); + if (errno == ENOENT) + return true; + if (!fh->getConsoleQuiet()) + dprintf(DEBUG_NORMAL, "[CFileHelpers %s] remove directory %s: %s\n", __func__, Dir, strerror(errno)); + char buf[1024]; + memset(buf, '\0', sizeof(buf)); + snprintf(buf, sizeof(buf)-1, "remove directory %s: %s", Dir, strerror(errno)); + fh->setDebugInfo(buf, __path_file__, __func__, __LINE__); return false; } while ((entry = readdir(dir)) != NULL) { diff --git a/src/system/helpers.h b/src/system/helpers.h index 5fd773953..0508aeb26 100644 --- a/src/system/helpers.h +++ b/src/system/helpers.h @@ -86,10 +86,11 @@ struct helpersDebugInfo { class CFileHelpers { private: - unsigned long FileBufSize; - char *FileBuf; + uint32_t FileBufMaxSize; int fd1, fd2; + char* initFileBuf(char* buf, uint32_t size); + char* deleteFileBuf(char* buf); bool ConsoleQuiet; helpersDebugInfo DebugInfo; void setDebugInfo(const char* msg, const char* file, const char* func, int line);