Merge branch 'vuplus_experimental' of code.vuplus.com:/opt/repository/dvbapp into...
[vuplus_dvbapp] / lib / python / Plugins / SystemPlugins / CrashlogAutoSubmit / plugin.py
old mode 100755 (executable)
new mode 100644 (file)
index 2563981..e45778a
@@ -8,12 +8,13 @@ from Screens.Screen import Screen
 from Screens.VirtualKeyBoard import VirtualKeyBoard
 from Screens.ChoiceBox import ChoiceBox
 from Screens.MessageBox import MessageBox
 from Screens.VirtualKeyBoard import VirtualKeyBoard
 from Screens.ChoiceBox import ChoiceBox
 from Screens.MessageBox import MessageBox
-from enigma import ePoint
+from enigma import ePoint, eTPM
 from Tools import Notifications
 
 import os
 from twisted.mail import smtp, relaymanager
 import MimeWriter, mimetools, StringIO
 from Tools import Notifications
 
 import os
 from twisted.mail import smtp, relaymanager
 import MimeWriter, mimetools, StringIO
+from __init__ import bin2long, long2bin, rsa_pub1024, decrypt_block, validate_cert, read_random
 
 config.plugins.crashlogautosubmit = ConfigSubsection()
 config.plugins.crashlogautosubmit.sendmail = ConfigSelection(default = "send", choices = [
 
 config.plugins.crashlogautosubmit = ConfigSubsection()
 config.plugins.crashlogautosubmit.sendmail = ConfigSelection(default = "send", choices = [
@@ -175,7 +176,7 @@ class CrashlogAutoSubmitConfiguration(Screen, ConfigListScreen):
                        self.enableVKeyIcon()
                        self.showKeypad()
                elif current == self.AnonCrashlogEntry:
                        self.enableVKeyIcon()
                        self.showKeypad()
                elif current == self.AnonCrashlogEntry:
-                       self["status"].setText(_("Adds enigma2 settings and dreambox model informations like SN, rev... if enabled."))
+                       self["status"].setText(_("Adds enigma2 settings and STB model informations like SN, rev... if enabled."))
                        self.disableVKeyIcon()
                elif current == self.NetworkEntry:
                        self["status"].setText(_("Adds network configuration if enabled."))
                        self.disableVKeyIcon()
                elif current == self.NetworkEntry:
                        self["status"].setText(_("Adds network configuration if enabled."))
@@ -332,15 +333,15 @@ def mxServerFound(mxServer,session):
                if crashlog.startswith("enigma2_crash_") and crashlog.endswith(".log"):
                        print "[CrashlogAutoSubmit] - found crashlog: ",os.path.basename(crashlog)
                        crashLogFilelist.append('/media/hdd/' + crashlog)
                if crashlog.startswith("enigma2_crash_") and crashlog.endswith(".log"):
                        print "[CrashlogAutoSubmit] - found crashlog: ",os.path.basename(crashlog)
                        crashLogFilelist.append('/media/hdd/' + crashlog)
-
-       if len(crashLogFilelist):
-               if config.plugins.crashlogautosubmit.sendmail.value == "send":
-                       Notifications.AddNotificationWithCallback(handleAnswer, ChoiceBox, title=_("Crashlogs found!\nSend them to Dream Multimedia?"), list = list)
-               elif config.plugins.crashlogautosubmit.sendmail.value == "send_always":
-                       send_mail()
-       else:
-               print "[CrashlogAutoSubmit] - no crashlogs found."
-
+#      if len(crashLogFilelist):
+#              if config.plugins.crashlogautosubmit.sendmail.value == "send":
+#                      session.openWithCallback(handleAnswer, ChoiceBox, title=_("Crashlogs found!\nSend them to Dream Multimedia ?"), list = list)
+#              elif config.plugins.crashlogautosubmit.sendmail.value == "send_always":
+#                      send_mail()
+#      else:   
+#              print "[CrashlogAutoSubmit] - no crashlogs found."
+#
+       print "block to handle Crashlogs "
 
 def getMailExchange(host):
        print "[CrashlogAutoSubmit] - getMailExchange"
 
 def getMailExchange(host):
        print "[CrashlogAutoSubmit] - getMailExchange"
@@ -376,11 +377,36 @@ def callCrashMailer(result,session):
 
 def autostart(reason, **kwargs):
        print "[CrashlogAutoSubmit] - autostart"
 
 def autostart(reason, **kwargs):
        print "[CrashlogAutoSubmit] - autostart"
-       if "session" in kwargs:
-               try:
-                       startMailer(kwargs["session"])
-               except ImportError, e:
-                       print "[CrashlogAutoSubmit] Twisted-mail not available, not starting CrashlogAutoSubmitter", e
+       try:
+               device = open("/proc/stb/info/model", "r").readline().strip()
+       except:
+               device = ""     
+       if device != "dm7025":
+               rootkey = ['\x9f', '|', '\xe4', 'G', '\xc9', '\xb4', '\xf4', '#', '&', '\xce', '\xb3', '\xfe', '\xda', '\xc9', 'U', '`', '\xd8', '\x8c', 's', 'o', '\x90', '\x9b', '\\', 'b', '\xc0', '\x89', '\xd1', '\x8c', '\x9e', 'J', 'T', '\xc5', 'X', '\xa1', '\xb8', '\x13', '5', 'E', '\x02', '\xc9', '\xb2', '\xe6', 't', '\x89', '\xde', '\xcd', '\x9d', '\x11', '\xdd', '\xc7', '\xf4', '\xe4', '\xe4', '\xbc', '\xdb', '\x9c', '\xea', '}', '\xad', '\xda', 't', 'r', '\x9b', '\xdc', '\xbc', '\x18', '3', '\xe7', '\xaf', '|', '\xae', '\x0c', '\xe3', '\xb5', '\x84', '\x8d', '\r', '\x8d', '\x9d', '2', '\xd0', '\xce', '\xd5', 'q', '\t', '\x84', 'c', '\xa8', ')', '\x99', '\xdc', '<', '"', 'x', '\xe8', '\x87', '\x8f', '\x02', ';', 'S', 'm', '\xd5', '\xf0', '\xa3', '_', '\xb7', 'T', '\t', '\xde', '\xa7', '\xf1', '\xc9', '\xae', '\x8a', '\xd7', '\xd2', '\xcf', '\xb2', '.', '\x13', '\xfb', '\xac', 'j', '\xdf', '\xb1', '\x1d', ':', '?']
+               etpm = eTPM()
+               l2cert = etpm.getCert(eTPM.TPMD_DT_LEVEL2_CERT)
+               if l2cert is None:
+                       return
+               l2key = validate_cert(l2cert, rootkey)
+               if l2key is None:
+                       return
+               l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT)
+               if l3cert is None:
+                       return
+               l3key = validate_cert(l3cert, l2key)
+               if l3key is None:
+                       return
+               rnd = read_random()
+               if rnd is None:
+                       return
+               val = etpm.challenge(rnd)
+               result = decrypt_block(val, l3key)
+       if device == "dm7025" or result[80:88] == rnd:
+               if "session" in kwargs:
+                       try:
+                               startMailer(kwargs["session"])
+                       except ImportError, e:
+                               print "[CrashlogAutoSubmit] Twisted-mail not available, not starting CrashlogAutoSubmitter", e
 
 
 def openconfig(session, **kwargs):
 
 
 def openconfig(session, **kwargs):
@@ -395,6 +421,6 @@ def selSetup(menuid, **kwargs):
 
 
 def Plugins(**kwargs):
 
 
 def Plugins(**kwargs):
-       return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart),
-               PluginDescriptor(name=_("CrashlogAutoSubmit"), description=_("CrashlogAutoSubmit settings"),where=PluginDescriptor.WHERE_MENU, fnc=selSetup)]
+       return [PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], needsRestart = False, fnc = autostart),
+               PluginDescriptor(name=_("CrashlogAutoSubmit"), description=_("CrashlogAutoSubmit settings"),where=PluginDescriptor.WHERE_MENU, needsRestart = False, fnc=selSetup)]