DEFINE_REF(eDVBService);
-// the following three methodes are declared in idvb.h
RESULT eBouquet::addService(const eServiceReference &ref)
{
list::iterator it =
fclose(f);
}
+RESULT eBouquet::flushChanges()
+{
+ FILE *f=fopen(m_path.c_str(), "wt");
+ if (!f)
+ return -1;
+ if ( fprintf(f, "#NAME %s\r\n", m_bouquet_name.c_str()) < 0 )
+ goto err;
+ for (list::iterator i(m_services.begin()); i != m_services.end(); ++i)
+ {
+ eServiceReference tmp = *i;
+ std::string str = tmp.path;
+ if ( (i->flags&eServiceReference::flagDirectory) == eServiceReference::flagDirectory )
+ {
+ unsigned int p1 = str.find("FROM BOUQUET \"");
+ if (p1 == std::string::npos)
+ {
+ eDebug("doof... kaputt");
+ continue;
+ }
+ str.erase(0, p1+14);
+ p1 = str.find("\"");
+ if (p1 == std::string::npos)
+ {
+ eDebug("doof2... kaputt");
+ continue;
+ }
+ str.erase(p1);
+ tmp.path=str;
+ }
+ if ( fprintf(f, "#SERVICE %s\r\n", tmp.toString().c_str()) < 0 )
+ goto err;
+ if ( i->name.length() )
+ if ( fprintf(f, "#DESCRIPTION %s\r\n", i->name.c_str()) < 0 )
+ goto err;
+ }
+ fclose(f);
+ return 0;
+err:
+ fclose(f);
+ eDebug("couldn't write file %s", m_path.c_str());
+ return -1;
+}
+
void eDVBDB::loadBouquet(const char *path)
{
std::string bouquet_name = path;
std::string m_path;
typedef std::list<eServiceReference> list;
list m_services;
-// the following three methods are implemented in db.cpp
+// the following four methods are implemented in db.cpp
+ RESULT flushChanges();
RESULT addService(const eServiceReference &);
RESULT removeService(const eServiceReference &);
RESULT moveService(const eServiceReference &, unsigned int);
self.l.setRoot(root)
self.l.sort()
+ def cursorGet(self):
+ return self.l.cursorGet()
+
+ def cursorSet(self, val):
+ self.l.cursorSet(val)
+
# stuff for multiple marks (edit mode / later multiepg)
def clearMarks(self):
self.l.initMarked()
else:
menu.append(("edit bouquet...", self.bouquetMarkStart))
+ if not csel.bouquet_mark_edit and not csel.movemode:
+ menu.append(("remove service", self.removeCurrentService))
+
FixedMenu.__init__(self, session, "Channel Selection", menu)
self.skinName = "Menu"
+ def removeCurrentService(self):
+ self.close()
+ self.csel.removeCurrentService()
+
def toggleMoveMode(self):
self.csel.toggleMoveMode()
self.close()
def bouquetMarkStart(self):
- self.csel.startMarkedEdit()
self.close()
+ self.csel.startMarkedEdit()
def bouquetMarkEnd(self):
self.csel.endMarkedEdit(abort=False)
if l.movemode: #movemode active?
l.channelSelected() # unmark
l.toggleMoveMode() # disable move mode
+ elif l.bouquet_mark_edit:
+ l.endMarkedEdit(True) # abort edit mode
ActionMap.action(self, contexts, action)
self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions", "ContextMenuActions"],
for x in self.__marked:
l.addMarked(eServiceReference(x))
+ def removeCurrentService(self):
+ l = self["list"]
+ ref=l.getCurrent()
+ if ref.valid() and self.mutableList is not None:
+ self.mutableList.removeService(ref)
+ pos = l.cursorGet()
+ self.mutableList.flushChanges() #FIXME dont flush on each single removed service
+ self.setRoot(l.getRoot())
+# l.cursorSet(pos) #whats going wrong here????
+
def endMarkedEdit(self, abort):
l = self["list"]
if not abort and self.mutableList is not None:
changed = True
self.mutableList.addService(eServiceReference(x))
if changed:
- l.setRoot(self.bouquetRoot)
+ self.mutableList.flushChanges()
+ self.setRoot(self.bouquetRoot)
self.__marked = []
self.clearMarks()
self.bouquet_mark_edit = False
def toggleMoveMode(self):
if self.movemode:
self.movemode = False
+ self.mutableList.flushChanges() # FIXME add check if changes was made
else:
self.movemode = True
class iMutableServiceList: public iObject
{
public:
+ /* flush changes */
+ virtual RESULT flushChanges()=0;
/* adds a service to a list */
virtual RESULT addService(eServiceReference &ref)=0;
/* removes a service from a list */
eListboxServiceContent();
void setRoot(const eServiceReference &ref);
void getCurrent(eServiceReference &ref);
-
+
/* support for marked services */
void initMarked();
void addMarked(const eServiceReference &ref);
void removeMarked(const eServiceReference &ref);
int isMarked(const eServiceReference &ref);
-
+
/* this is NOT thread safe! */
void markedQueryStart();
int markedQueryNext(eServiceReference &ref);
void setElementFont(int element, gFont *font);
void sort();
-
+
int setCurrentMarked(bool);
-
+ int cursorSet(int n);
+ int cursorGet();
protected:
void cursorHome();
void cursorEnd();
int cursorMove(int count=1);
int cursorValid();
- int cursorSet(int n);
- int cursorGet();
-
+
void cursorSave();
void cursorRestore();
int size();
/* support for marked services */
std::set<eServiceReference> m_marked;
-
std::set<eServiceReference>::const_iterator m_marked_iterator;
/* support for movemode */
return m_bouquet->moveService(ref, pos);
}
+RESULT eDVBServiceList::flushChanges()
+{
+ if (!m_bouquet)
+ return -1;
+ return m_bouquet->flushChanges();
+}
+
RESULT eServiceFactoryDVB::play(const eServiceReference &ref, ePtr<iPlayableService> &ptr)
{
ePtr<eDVBService> service;
int compareLessEqual(const eServiceReference &a, const eServiceReference &b);
RESULT startEdit(ePtr<iMutableServiceList> &);
+ RESULT flushChanges();
RESULT addService(eServiceReference &ref);
RESULT removeService(eServiceReference &ref);
RESULT moveService(eServiceReference &ref, int pos);