- improved scan error handling
authorFelix Domke <tmbinc@elitedvb.net>
Thu, 21 Apr 2005 16:30:28 +0000 (16:30 +0000)
committerFelix Domke <tmbinc@elitedvb.net>
Thu, 21 Apr 2005 16:30:28 +0000 (16:30 +0000)
components.py
lib/components/scan.cpp
lib/components/scan.h
screens.py
skin.py

index deb3760..af0fbff 100644 (file)
@@ -312,12 +312,25 @@ class ServiceScan:
        Running = 2
        Done = 3
        Error = 4
+       
+       Errors = { 
+               1: "error while scanning",
+               2: "no resource manager",
+               3: "no channel list"
+               }
+               
                
        def scanStatusChanged(self):
                if self.state == self.Running:
                        self.progressbar.setValue(self.scan.getProgress())
                        if self.scan.isDone():
-                               self.state = self.Done
+                               errcode = self.scan.getError()
+                               
+                               if errcode == 0:
+                                       self.state = self.Done
+                               else:
+                                       self.state = self.Error
+                                       self.errorcode = errcode
                        else:
                                self.text.setText("scan in progress - %d %% done!\n%d services found!" % (self.scan.getProgress(), self.scan.getNumServices()))
                
@@ -325,7 +338,7 @@ class ServiceScan:
                        self.text.setText("scan done!")
                
                if self.state == self.Error:
-                       self.text.setText("ERROR - failed to scan!")
+                       self.text.setText("ERROR - failed to scan (%s)!" % (self.Errors[self.errorcode]) )
        
        def __init__(self, progressbar, text):
                self.progressbar = progressbar
@@ -336,10 +349,10 @@ class ServiceScan:
                
        def execBegin(self):
                self.scan.statusChanged.get().append(self.scanStatusChanged)
+               self.state = self.Running
                if self.scan.start():
                        self.state = self.Error
-               else:
-                       self.state = self.Running
+
                self.scanStatusChanged()
        
        def execEnd(self):
index c82d04e..ad2e4d1 100644 (file)
@@ -89,7 +89,10 @@ int eComponentScan::start()
        ePtr<iDVBChannel> channel;
 
        if (mgr->allocateRawChannel(channel))
+       {
                eDebug("scan: allocating raw channel failed!");
+               return -1;
+       }
 
        std::list<ePtr<iDVBFrontendParameters> > list;
                
@@ -98,7 +101,7 @@ int eComponentScan::start()
        m_scan = new eDVBScan(channel);
        m_scan->connectEvent(slot(*this, &eComponentScan::scanEvent), m_scan_event_connection);
        m_scan->start(list);
-
+       
        return 0;
 }
 
@@ -126,3 +129,8 @@ int eComponentScan::isDone()
 {
        return m_done;
 }
+
+int eComponentScan::getError()
+{
+       return m_failed;
+}
index ca64f5e..6245613 100644 (file)
@@ -26,9 +26,11 @@ public:
                /* get number of services */
        int getNumServices();
        
-               /* true when done. */
+               /* true when done or error */
        int isDone();
        
+       int getError();
+       
        int start();
 };
 
index 999ad4b..fe8d69d 100644 (file)
@@ -166,6 +166,9 @@ class serviceScan(Screen):
                if self["scan"].isDone():
                        self.close()
        
+       def cancel(self):
+               print "cancel not yet implemented ;)"
+       
        def __init__(self, session):
                Screen.__init__(self, session)
                
@@ -173,5 +176,9 @@ class serviceScan(Screen):
                self["scan_state"] = Label("scan state")
                self["scan"] = ServiceScan(self["scan_progress"], self["scan_state"])
 
-               self["okbutton"] = Button("ok", [self.ok])
-               self["okbutton"].disable()
+               self["actions"] = ActionMap(["OkCancelActions"], 
+                       {
+                               "ok": self.ok,
+                               "cancel": self.cancel
+                       })
+
diff --git a/skin.py b/skin.py
index 2986a44..2e913a0 100644 (file)
--- a/skin.py
+++ b/skin.py
@@ -69,7 +69,6 @@ dom = xml.dom.minidom.parseString(
                <screen name="serviceScan" position="150,100" size="300,200" title="Service Scan">
                        <widget name="scan_progress" position="10,10" size="280,50" />
                        <widget name="scan_state" position="10,60" size="280,30" />
-                       <widget name="okbutton" position="10,100" size="280,40" />
                </screen>
        </skin>""")