dont mark found services with newFlags when "remove existing services" was
[enigma2.git] / lib / dvb / scan.cpp
index 3c952b8f90fa9e38da4f69d229406ef605c157e5..e2bf6215884268a339c73e593d00cb31998f9087 100644 (file)
@@ -84,7 +84,7 @@ RESULT eDVBScan::nextChannel()
 {
        ePtr<iDVBFrontend> fe;
 
-       m_SDT = 0; m_BAT = 0; m_NIT = 0;
+       m_SDT = 0; m_PAT = 0; m_BAT = 0; m_NIT = 0;
 
        m_ready = 0;
 
@@ -120,16 +120,7 @@ RESULT eDVBScan::nextChannel()
                return -ENOTSUP;
        }
 
-       int fetype;
-       fe->getFrontendType(fetype);
-       if ( fetype == iDVBFrontend::feSatellite)
-       {
-               eDVBFrontendParametersSatellite p;
-               m_ch_current->getDVBS(p);
-               m_chid_current = eDVBChannelID(p.orbital_position << 16, -1, -1);
-       }
-       else
-               m_chid_current = eDVBChannelID();
+       m_chid_current = eDVBChannelID();
 
        m_channel_state = iDVBChannel::state_idle;
        if (fe->tune(*m_ch_current))
@@ -453,19 +444,29 @@ void eDVBScan::channelDone()
                                                ePtr<eDVBFrontendParameters> feparm = new eDVBFrontendParameters;
                                                eDVBFrontendParametersSatellite sat;
                                                sat.set(d);
+
+                                               eDVBFrontendParametersSatellite p;
+                                               m_ch_current->getDVBS(p);
+
+                                               if ( abs(p.orbital_position - sat.orbital_position) < 5 )
+                                                       sat.orbital_position = p.orbital_position;
+
+                                               if ( abs(abs(3600 - p.orbital_position) - sat.orbital_position) < 5 )
+                                               {
+                                                       eDebug("found transponder with incorrect west/east flag ... correct this");
+                                                       sat.orbital_position = p.orbital_position;
+                                               }
+
                                                feparm->setDVBS(sat);
-                                               unsigned long hash=0;
-                                               feparm->getHash(hash);
-                                               
-                                               eDVBNamespace ns = buildNamespace(onid, tsid, hash);
-                                               
-                                               if ( m_chid_current.dvbnamespace.get() != -1 &&
-                                                       ((ns.get() ^ m_chid_current.dvbnamespace.get()) & 0xFFFF0000))
+
+                                               if ( p.orbital_position != sat.orbital_position)
                                                        SCAN_eDebug("dropping this transponder, it's on another satellite.");
                                                else
                                                {
+                                                       unsigned long hash=0;
+                                                       feparm->getHash(hash);
                                                        addChannelToScan(
-                                                                       eDVBChannelID(ns, tsid, onid),
+                                                                       eDVBChannelID(buildNamespace(onid, tsid, hash), tsid, onid),
                                                                        feparm);
                                                }
                                                break;
@@ -521,27 +522,25 @@ void eDVBScan::channelDone()
                   These are the reasons for adding the transponder
                   here, and not before.
                */
-
+       
        if (!m_chid_current)
                eWarning("SCAN: the current channel's ID was not corrected - not adding channel.");
        else
-       {
                addKnownGoodChannel(m_chid_current, m_ch_current);
        
-               m_ch_scanned.push_back(m_ch_current);
-
-               for (std::list<ePtr<iDVBFrontendParameters> >::iterator i(m_ch_toScan.begin()); i != m_ch_toScan.end();)
+       m_ch_scanned.push_back(m_ch_current);
+       
+       for (std::list<ePtr<iDVBFrontendParameters> >::iterator i(m_ch_toScan.begin()); i != m_ch_toScan.end();)
+       {
+               if (sameChannel(*i, m_ch_current))
                {
-                       if (sameChannel(*i, m_ch_current))
-                       {
-                               eDebug("remove dupe 2");
-                               m_ch_toScan.erase(i++);
-                               continue;
-                       }
-                       ++i;
+                       eDebug("remove dupe 2");
+                       m_ch_toScan.erase(i++);
+                       continue;
                }
+               ++i;
        }
-
+       
        nextChannel();
 }
 
@@ -681,7 +680,8 @@ void eDVBScan::insertInto(iDVBChannelList *db, bool dontRemoveOldFlags)
                else
                {
                        db->addService(service->first, service->second);
-                       service->second->m_flags |= eDVBService::dxNewFound;
+                       if (!(m_flags & scanRemoveServices))
+                               service->second->m_flags |= eDVBService::dxNewFound;
                }
        }
 }