return -1;
}
+RESULT eBouquet::setListName(const std::string &name)
+{
+ m_bouquet_name = name;
+ return 0;
+}
+
eDVBService::eDVBService()
{
}
std::string m_filename; // without path.. just name
typedef std::list<eServiceReference> list;
list m_services;
-// the following four methods are implemented in db.cpp
+// the following five methods are implemented in db.cpp
RESULT flushChanges();
RESULT addService(const eServiceReference &);
RESULT removeService(const eServiceReference &);
RESULT moveService(const eServiceReference &, unsigned int);
+ RESULT setListName(const std::string &name);
};
/* these structures have by intention no operator int() defined.
from Components.ServiceList import ServiceList
from Components.ActionMap import NumberActionMap, ActionMap
from EpgSelection import EPGSelection
-from enigma import eServiceReference, eEPGCache, eEPGCachePtr, eServiceCenter, eServiceCenterPtr, iMutableServiceListPtr, iStaticServiceInformationPtr, eTimer
+from enigma import eServiceReference, eEPGCache, eEPGCachePtr, eServiceCenter, eServiceCenterPtr, iMutableServiceListPtr, iStaticServiceInformationPtr, eTimer, eDVBDB
from Components.config import config, configElement, ConfigSubsection, configText, currentConfigSelectionElement
from Screens.FixedMenu import FixedMenu
from Tools.NumericalTextInput import NumericalTextInput
from Components.ServiceName import ServiceName
from Components.Clock import Clock
from Components.EventInfo import EventInfo
+from ServiceReference import ServiceReference
from re import *
+from os import remove
import xml.dom.minidom
inBouquet = csel.getMutableList() is not None
haveBouquets = csel.bouquet_root.getPath().find('FROM BOUQUET "bouquets.') != -1
- if not csel.bouquet_mark_edit and not csel.movemode and not inBouquetRootList:
- if (csel.getCurrentSelection().flags & eServiceReference.flagDirectory) != eServiceReference.flagDirectory:
- if haveBouquets:
- menu.append((_("add service to bouquet"), self.addServiceToBouquetSelected))
- else:
- menu.append((_("add service to favourites"), self.addServiceToBouquetSelected))
- if inBouquet:
- menu.append((_("remove service"), self.removeCurrentService))
+ if not csel.bouquet_mark_edit and not csel.movemode:
+ if not inBouquetRootList:
+ if (csel.getCurrentSelection().flags & eServiceReference.flagDirectory) != eServiceReference.flagDirectory:
+ if haveBouquets:
+ menu.append((_("add service to bouquet"), self.addServiceToBouquetSelected))
+ else:
+ menu.append((_("add service to favourites"), self.addServiceToBouquetSelected))
+ elif haveBouquets:
+ if not inBouquet and csel.getCurrentSelection().getPath().find("PROVIDERS") == -1:
+ menu.append((_("copy to favourites"), csel.copyCurrentToBouquetList))
+ if inBouquet:
+ menu.append((_("remove service"), self.removeCurrentService))
+ elif haveBouquets:
+ menu.append((_("remove bouquet"), csel.removeBouquet))
if inBouquet: # current list is editable?
if not csel.bouquet_mark_edit:
else: #no bouquets in root.. so assume only one favourite list is used
self.addCurrentServiceToBouquet(self.csel.bouquet_root)
+ def copyCurrentToBouquetList(self):
+ self.csel.copyCurrentToBouquetList()
+ self.close()
+
+ def removeBouquet(self):
+ self.csel.removeBouquet()
+ self.close()
+
def addCurrentServiceToBouquet(self, dest):
self.csel.addCurrentServiceToBouquet(dest)
self.close()
return list.startEdit()
return None
+ def buildBouquetID(self, str):
+ tmp = str.lower()
+ name = ''
+ for c in tmp:
+ if (c >= 'a' and c <= 'z') or (c >= '0' and c <= '9'):
+ name += c
+ else:
+ name += '_'
+ return name
+
+ def copyCurrentToBouquetList(self):
+ provider = ServiceReference(self.getCurrentSelection())
+ serviceHandler = eServiceCenter.getInstance()
+ mutableBouquetList = serviceHandler.list(self.bouquet_root).startEdit()
+ if mutableBouquetList:
+ providerName = provider.getServiceName()
+ if self.mode == MODE_TV:
+ str = '1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET \"userbouquet.%s.tv\" ORDER BY bouquet'%(self.buildBouquetID(providerName))
+ else:
+ str = '1:7:2:0:0:0:0:0:0:0:(type == 2) FROM BOUQUET \"userbouquet.%s.radio\" ORDER BY bouquet'%(self.buildBouquetID(providerName))
+ new_bouquet_ref = eServiceReference(str)
+ if not mutableBouquetList.addService(new_bouquet_ref):
+ mutableBouquetList.flushChanges()
+ eDVBDB.getInstance().reloadBouquets()
+ mutableBouquet = serviceHandler.list(new_bouquet_ref).startEdit()
+ if mutableBouquet:
+ mutableBouquet.setListName(providerName)
+ list = [ ]
+ services = serviceHandler.list(provider.ref)
+ if not services is None:
+ if not services.getContent(list, True):
+ for service in list:
+ if mutableBouquet.addService(service):
+ print "add", service.toString(), "to new bouquet failed"
+ mutableBouquet.flushChanges()
+ else:
+ print "getContent failed"
+ else:
+ print "list provider", providerName, "failed"
+ else:
+ print "get mutable list for new created bouquet failed"
+ else:
+ print "add", str, "to bouquets failed"
+ else:
+ print "bouquetlist is not editable"
+
+ def removeBouquet(self):
+ refstr = self.getCurrentSelection().toString()
+ pos = refstr.find('FROM BOUQUET "')
+ if pos != -1:
+ refstr = refstr[pos+14:]
+ print refstr
+ pos = refstr.find('"')
+ if pos != -1:
+ filename = '/etc/enigma2/' + refstr[:pos] # FIXMEEE !!! HARDCODED /etc/enigma2
+ self.removeCurrentService()
+ remove(filename)
+ eDVBDB.getInstance().reloadBouquets()
+
# multiple marked entry stuff ( edit mode, later multiepg selection )
def startMarkedEdit(self):
self.mutableList = self.getMutableList()
# this makes it much simple to implement a selectable radio or tv mode :)
self.service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17)'
- self.service_types_radio = '1:7:1:0:0:0:0:0:0:0:(type == 2)'
+ self.service_types_radio = '1:7:2:0:0:0:0:0:0:0:(type == 2)'
self["key_red"] = Button(_("All"))
self["key_green"] = Button(_("Satellites"))
TestObj *result = (TestObj *)new TestObj();
return SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_TestObj, 1);
}
+PyObject *New_eServiceReference(const eServiceReference &ref)
+{
+ eServiceReference *result = new eServiceReference(ref);
+ return SWIG_NewPointerObj((void*)(result), SWIGTYPE_p_eServiceReference, 1);
+}
%}
#define __lib_dvb_iservice_h
#include <lib/python/swig.h>
+#include <lib/python/python.h>
#include <lib/base/object.h>
#include <string>
#include <connection.h>
SWIG_ALLOW_OUTPUT_SIMPLE(eServiceReference);
+extern PyObject *New_eServiceReference(const eServiceReference &ref); // defined in enigma_python.i
+
typedef long long pts_t;
/* the reason we have the servicereference as additional argument is
/* moves a service in a list, only if list suppports a specific sort method. */
/* pos is the new, absolute position from 0..size-1 */
virtual RESULT moveService(eServiceReference &ref, int pos)=0;
+ /* set name of list, for bouquets this is the visible bouquet name */
+ virtual RESULT setListName(const std::string &name)=0;
};
TEMPLATE_TYPEDEF(ePtr<iMutableServiceList>, iMutableServiceListPtr);
#endif
public:
/* legacy interface: get a list */
- virtual RESULT getContent(std::list<eServiceReference> &list)=0;
-
+ virtual RESULT getContent(std::list<eServiceReference> &list, bool sorted=false)=0;
+ virtual RESULT getContent(PyObject *list, bool sorted=false)=0;
+
/* new, shiny interface: streaming. */
virtual SWIG_VOID(RESULT) getNext(eServiceReference &SWIG_OUTPUT)=0;
#include <lib/service/servicedvbrecord.h>
#include <lib/dvb/metaparser.h>
#include <lib/dvb/tstools.h>
+#include <lib/python/python.h>
class eStaticServiceDVBInformation: public iStaticServiceInformation
{
return 0;
}
-RESULT eDVBServiceList::getContent(std::list<eServiceReference> &list)
+RESULT eDVBServiceList::getContent(PyObject *list, bool sorted)
+{
+ eServiceReferenceDVB ref;
+
+ if (!m_query || !list || !PyList_Check(list))
+ return -1;
+
+ std::list<eServiceReferenceDVB> tmplist;
+
+ while (!m_query->getNextResult(ref))
+ tmplist.push_back(ref);
+
+ if (sorted)
+ tmplist.sort(iListableServiceCompare(this));
+
+ for (std::list<eServiceReferenceDVB>::iterator it(tmplist.begin());
+ it != tmplist.end(); ++it)
+ {
+ PyObject *refobj = New_eServiceReference(*it);
+ PyList_Append(list, refobj);
+ Py_DECREF(refobj);
+ }
+ return 0;
+}
+
+RESULT eDVBServiceList::getContent(std::list<eServiceReference> &list, bool sorted)
{
eServiceReferenceDVB ref;
while (!m_query->getNextResult(ref))
list.push_back(ref);
+
+ if (sorted)
+ list.sort(iListableServiceCompare(this));
+
return 0;
}
return m_bouquet->flushChanges();
}
+RESULT eDVBServiceList::setListName(const std::string &name)
+{
+ if (!m_bouquet)
+ return -1;
+ return m_bouquet->setListName(name);
+}
+
RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
{
ePtr<eDVBService> service;
DECLARE_REF(eDVBServiceList);
public:
virtual ~eDVBServiceList();
- RESULT getContent(std::list<eServiceReference> &list);
+ RESULT getContent(std::list<eServiceReference> &list, bool sorted=false);
+ RESULT getContent(PyObject *list, bool sorted=false);
RESULT getNext(eServiceReference &ptr);
int compareLessEqual(const eServiceReference &a, const eServiceReference &b);
RESULT addService(eServiceReference &ref);
RESULT removeService(eServiceReference &ref);
RESULT moveService(eServiceReference &ref, int pos);
+ RESULT setListName(const std::string &name);
private:
RESULT startQuery();
eServiceReference m_parent;
{
}
-RESULT eServiceFS::getContent(std::list<eServiceReference> &list)
+RESULT eServiceFS::getContent(std::list<eServiceReference> &list, bool sorted)
{
DIR *d=opendir(path.c_str());
if (!d)
}
}
closedir(d);
+
+ if (sorted)
+ list.sort(iListableServiceCompare(this));
+
+ return 0;
+}
+
+RESULT eServiceFS::getContent(PyObject *list, bool sorted)
+{
+ if (!list || !PyList_Check(list))
+ return -1;
+
+ std::list<eServiceReference> tmplist;
+
+ getContent(tmplist, sorted);
+
+ if (sorted)
+ tmplist.sort(iListableServiceCompare(this));
+
+ for (std::list<eServiceReference>::iterator it(tmplist.begin());
+ it != tmplist.end(); ++it)
+ {
+ PyObject *refobj = New_eServiceReference(*it);
+ PyList_Append(list, refobj);
+ Py_DECREF(refobj);
+ }
+
return 0;
}
public:
virtual ~eServiceFS();
- RESULT getContent(std::list<eServiceReference> &list);
+ RESULT getContent(std::list<eServiceReference> &list, bool sorted=false);
+ RESULT getContent(PyObject *list, bool sorted=false);
RESULT getNext(eServiceReference &ptr);
int compareLessEqual(const eServiceReference &, const eServiceReference &);
RESULT startEdit(ePtr<iMutableServiceList> &);