From 6e84bf963413305833c980b2fe070fc690892418 Mon Sep 17 00:00:00 2001 From: methodus Date: Fri, 30 Nov 2012 22:33:50 +0100 Subject: Added the ability to filter the number of channels outputed by the vdrProvider --- plugins/provider/fileProvider/fileProvider.cpp | 3 +- plugins/provider/vdrProvider/vdrProvider.cpp | 44 +++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 5 deletions(-) (limited to 'plugins') diff --git a/plugins/provider/fileProvider/fileProvider.cpp b/plugins/provider/fileProvider/fileProvider.cpp index cbc84c2..a60d772 100644 --- a/plugins/provider/fileProvider/fileProvider.cpp +++ b/plugins/provider/fileProvider/fileProvider.cpp @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -82,7 +83,7 @@ public: : fileFD(NULL) { stringstream file; - file << cPlugin::ConfigDirectory(PLUGIN_NAME_I18N) << "/directories.conf"; + file << cMediaServer::GetInstance()->GetConfigDirectory() << "/directories.conf"; Load(file.str()); } diff --git a/plugins/provider/vdrProvider/vdrProvider.cpp b/plugins/provider/vdrProvider/vdrProvider.cpp index 9a45690..c9b9a95 100644 --- a/plugins/provider/vdrProvider/vdrProvider.cpp +++ b/plugins/provider/vdrProvider/vdrProvider.cpp @@ -6,11 +6,14 @@ */ #include +#include #include #include #include +#include #include #include +#include #include #include #include @@ -22,7 +25,33 @@ namespace upnp { class VdrProvider : public cUPnPResourceProvider { private: - time_t lastModified; + time_t lastModified; + int from; + int to; + + bool Load(const string& filename) + { + if (access(filename.c_str(), F_OK) == 0) { + isyslog("loading %s", filename.c_str()); + ifstream file; + file.open(filename.c_str(), ifstream::in); + if(!file.is_open()) + return false; + string line; int pos; + while(getline(file, line)){ + if(line.length() > 0 && line[0] != '#'){ + if((pos = line.find_first_of('-')) != string::npos){ + from = atoi(line.substr(0, pos).c_str()); + to = atoi(line.substr(pos+1).c_str()); + break; + } + } + } + if(to == 0) to = INT_MAX; + return true; + } + return false; + } bool IsRootContainer(const string& uri){ if(uri.find(GetRootContainer(), 0) != 0){ @@ -51,7 +80,13 @@ public: VdrProvider() : lastModified(0) - {} + , from(0) + , to(INT_MAX) + { + stringstream file; + file << cMediaServer::GetInstance()->GetConfigDirectory() << "/vdrProvider.conf"; + Load(file.str()); + } virtual ~VdrProvider(){ Cancel(2); @@ -69,9 +104,10 @@ public: StringList list; int index; cChannel* channel = NULL; + if(to == 0) to = INT_MAX; // Check if this is the root and we have no groups in the channels.conf: if(uri.compare(GetRootContainer()) == 0 && Channels.GetNextGroup(0) == -1){ - for(index = Channels.GetNextNormal(-1); (channel = Channels.Get(index)); index = Channels.GetNextNormal(index)){ + for(index = Channels.GetNextNormal(from - 1); (channel = Channels.Get(index)) && index < to; index = Channels.GetNextNormal(index)){ list.push_back(*channel->GetChannelID().ToString()); } } else { @@ -87,7 +123,7 @@ public: } } } else { - for(index = Channels.GetNextGroup(-1); (channel = Channels.Get(index)); index = Channels.GetNextGroup(index)){ + for(index = Channels.GetNextGroup(from - 1); (channel = Channels.Get(index)) && index < to; index = Channels.GetNextGroup(index)){ string group = string(channel->Name()) + '/'; list.push_back(group); } -- cgit v1.2.3