Do delete userbouquets when they are renamed
authorLittlesat <Littlesat99@yahoo.com>
Wed, 21 Jan 2015 18:10:41 +0000 (19:10 +0100)
committerLittlesat <Littlesat99@yahoo.com>
Wed, 21 Jan 2015 18:10:41 +0000 (19:10 +0100)
This solves the issue on http://forums.openpli.org/topic/36676-rename-bouquet/

When a bouquet was rename actually in the list it was removed and than pushed
back with the renamed name. Removing the bouquet actually add a '.del' to the
actual bouquet file on your box. Due to this this bouquet was not readed again
after an enigma2/box restart. By adding an option to removeService for not
adding the '.del' to the bouquet file and putting this default to true and
call it with False in ChannelSelection.py it can be avoided to add the '.del'
when we are renaming bouquets.

lib/dvb/db.cpp
lib/dvb/idvb.h
lib/python/Screens/ChannelSelection.py
lib/service/iservice.h
lib/service/servicedvb.cpp
lib/service/servicedvb.h

index 87764b2..a299580 100644 (file)
@@ -35,13 +35,13 @@ RESULT eBouquet::addService(const eServiceReference &ref, eServiceReference befo
        return 0;
 }
 
-RESULT eBouquet::removeService(const eServiceReference &ref)
+RESULT eBouquet::removeService(const eServiceReference &ref, bool renameBouquet)
 {
        list::iterator it =
                std::find(m_services.begin(), m_services.end(), ref);
        if ( it == m_services.end() )
                return -1;
-       if (ref.flags & eServiceReference::canDescent)
+       if (renameBouquet && (ref.flags & eServiceReference::canDescent))
        {
                std::string filename = ref.toString();
                size_t pos = filename.find("FROM BOUQUET ");
index dcb64c6..4f2cfe0 100644 (file)
@@ -66,7 +66,7 @@ struct eBouquet
 // the following five methods are implemented in db.cpp
        RESULT flushChanges();
        RESULT addService(const eServiceReference &, eServiceReference before=eServiceReference());
-       RESULT removeService(const eServiceReference &);
+       RESULT removeService(const eServiceReference &, bool renameBouquet=true);
        RESULT moveService(const eServiceReference &, unsigned int);
        RESULT setListName(const std::string &name);
 };
index b53d1df..7217ece 100644 (file)
@@ -756,7 +756,7 @@ class ChannelSelectionEdit:
                                current = self.servicelist.getCurrent()
                                current.setName(name)
                                index = self.servicelist.getCurrentIndex()
-                               mutableList.removeService(current)
+                               mutableList.removeService(current, False)
                                mutableList.addService(current)
                                mutableList.moveService(current, index)
                                mutableList.flushChanges()
index d9516cd..0983175 100644 (file)
@@ -727,7 +727,7 @@ public:
                /* adds a service to a list */
        virtual RESULT addService(eServiceReference &ref, eServiceReference before=eServiceReference())=0;
                /* removes a service from a list */
-       virtual RESULT removeService(eServiceReference &ref)=0;
+       virtual RESULT removeService(eServiceReference &ref, bool renameBouquet=true)=0;
                /* 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;
index 9533f7c..af23ba1 100644 (file)
@@ -880,11 +880,11 @@ RESULT eDVBServiceList::addService(eServiceReference &ref, eServiceReference bef
        return m_bouquet->addService(ref, before);
 }
 
-RESULT eDVBServiceList::removeService(eServiceReference &ref)
+RESULT eDVBServiceList::removeService(eServiceReference &ref, bool renameBouquet)
 {
        if (!m_bouquet)
                return -1;
-       return m_bouquet->removeService(ref);
+       return m_bouquet->removeService(ref, renameBouquet);
 }
 
 RESULT eDVBServiceList::moveService(eServiceReference &ref, int pos)
index 641a251..253c346 100644 (file)
@@ -49,7 +49,7 @@ public:
        RESULT startEdit(ePtr<iMutableServiceList> &);
        RESULT flushChanges();
        RESULT addService(eServiceReference &ref, eServiceReference before);
-       RESULT removeService(eServiceReference &ref);
+       RESULT removeService(eServiceReference &ref, bool renameBouquet=true);
        RESULT moveService(eServiceReference &ref, int pos);
        RESULT setListName(const std::string &name);
 private: