Notification support in TaskView
[enigma2.git] / lib / python / Components / Network.py
index 3d114c1c85dfc8a47f3e81e73c203a496f053f1c..06e81eaf21d8f6dc41947b4aa7956d768c3e48dc 100644 (file)
@@ -6,6 +6,7 @@ from enigma import eTimer, eConsoleAppContainer
 class Network:
        def __init__(self):
                self.ifaces = {}
+               self.configuredInterfaces = {}
                self.nameservers = []
                self.getInterfaces()
                self.ethtool_bin = "/usr/sbin/ethtool"
@@ -159,7 +160,8 @@ class Network:
                                        ifaces[currif]["netmask"] = map(int, split[1].split('.'))
                                if (split[0] == "gateway"):
                                        ifaces[currif]["gateway"] = map(int, split[1].split('.'))
-
+               
+               self.configuredInterfaces = ifaces
                print "read interfaces:", ifaces
                for ifacename, iface in ifaces.items():
                        if self.ifaces.has_key(ifacename):
@@ -281,8 +283,17 @@ class Network:
                        os.system("ifconfig wlan0 down")
 
        def checkNetworkState(self):
-               ret=os.system("ping -c 1 www.dream-multimedia-tv.de")
-               if ret == 0:
+               ok_counter = 0
+               ret1=os.system("ping -c 1 www.dream-multimedia-tv.de")
+               if ret1 != 0:
+                       ok_counter = ok_counter + 1
+               ret2=os.system("ping -c 1 www.heise.de")
+               if ret2 != 0:
+                       ok_counter = ok_counter + 1
+               ret3=os.system("ping -c 1 www.google.de")
+               if ret2 != 0:
+                       ok_counter = ok_counter + 1             
+               if ok_counter <= 2:
                        return True
                else:
                        return False
@@ -302,6 +313,29 @@ class Network:
                self.container.appClosed.get().remove(self.cmdFinished)
                self.container.dataAvail.get().remove(self.dataAvail)
 
+       def checkforInterface(self,iface):
+               ret=os.system("ifconfig " + iface + " up")
+               if ret == 0:
+                       return True
+               else:
+                       return False
+
+       def checkDNSLookup(self):
+               ok_counter = 0
+               ret1=os.system("nslookup www.dream-multimedia-tv.de")
+               if ret1 != 0:
+                       ok_counter = ok_counter + 1
+               ret2=os.system("nslookup www.heise.de")
+               if ret2 != 0:
+                       ok_counter = ok_counter + 1
+               ret3=os.system("nslookup www.google.de")
+               if ret2 != 0:
+                       ok_counter = ok_counter + 1             
+               if ok_counter <= 2:
+                       return True
+               else:
+                       return False
+               
 iNetwork = Network()
 
 def InitNetwork():