added zapstatistic plugin
authorNabil Hanna <ali@users.schwerkraft.elitedvb.net>
Thu, 21 Jan 2010 16:51:34 +0000 (16:51 +0000)
committerNabil Hanna <ali@users.schwerkraft.elitedvb.net>
Thu, 21 Jan 2010 16:51:34 +0000 (16:51 +0000)
Makefile.am
configure.ac
zapstatistic/CONTROL/control [new file with mode: 0644]
zapstatistic/Makefile.am [new file with mode: 0644]
zapstatistic/po/Makefile.am [new file with mode: 0644]
zapstatistic/po/ZapStatistic.pot [new file with mode: 0644]
zapstatistic/po/de.po [new file with mode: 0644]
zapstatistic/src/Makefile.am [new file with mode: 0644]
zapstatistic/src/__init__.py [new file with mode: 0644]
zapstatistic/src/maintainer.info [new file with mode: 0644]
zapstatistic/src/plugin.py [new file with mode: 0644]

index 6c88e78..0694d79 100644 (file)
@@ -60,7 +60,8 @@ SUBDIRS = \
        webinterface \
        werbezapper \
        youtubeplayer \
-       zaphistorybrowser
+       zaphistorybrowser \
+       zapstatistic
 
 
 LANGS := $(shell cat $(srcdir)/LINGUAS)
index 3dc63f6..df0147c 100644 (file)
@@ -336,4 +336,8 @@ zaphistorybrowser/meta/Makefile
 zaphistorybrowser/po/Makefile
 zaphistorybrowser/src/Makefile
 
+zapstatistic/Makefile
+zapstatistic/po/Makefile
+zapstatistic/src/Makefile
+
 ])
diff --git a/zapstatistic/CONTROL/control b/zapstatistic/CONTROL/control
new file mode 100644 (file)
index 0000000..d6a68c6
--- /dev/null
@@ -0,0 +1,10 @@
+Package: enigma2-plugin-extensions-zapstatistic
+Version: 0.1-r0
+Description: Shows the watched services with some statistic
+Architecture: all
+Section: extra
+Priority: optional
+Maintainer: Nabil Hanna <nabil1978@web.de>
+Homepage: http://www.lt-forums.org/ali
+Depends: enigma2(>=2.6git20090615)
+Source: http://enigma2-plugins.schwerkraft.elitedvb.net/
diff --git a/zapstatistic/Makefile.am b/zapstatistic/Makefile.am
new file mode 100644 (file)
index 0000000..cc366b1
--- /dev/null
@@ -0,0 +1 @@
+SUBDIRS = po src
diff --git a/zapstatistic/po/Makefile.am b/zapstatistic/po/Makefile.am
new file mode 100644 (file)
index 0000000..98f8cd7
--- /dev/null
@@ -0,0 +1,57 @@
+#
+# to use this for the localisation of other plugins,
+# just change the DOMAIN to the name of the Plugin.
+# It is assumed, that the domain ist the same as
+# the directory name of the plugin.
+#
+
+DOMAIN=ZapStatistic
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/$(DOMAIN)
+#GETTEXT=./pygettext.py
+GETTEXT=xgettext
+
+#MSGFMT = ./msgfmt.py
+MSGFMT = msgfmt
+
+LANGS := de
+LANGPO := $(foreach LANG, $(LANGS),$(LANG).po)
+LANGMO := $(foreach LANG, $(LANGS),$(LANG).mo)
+
+default: $(DOMAIN).pot $(LANGPO) merge $(LANGMO)
+       for lang in $(LANGS); do \
+               mkdir -p $$lang/LC_MESSAGES; \
+               cp $$lang.mo $$lang/LC_MESSAGES/$(DOMAIN).mo; \
+       done
+
+merge:
+       for lang in $(LANGS); do \
+               msgmerge --no-location -s -N -U $$lang.po $(DOMAIN).pot; \
+       done
+
+
+# the TRANSLATORS: allows putting translation comments before the to-be-translated line.
+$(DOMAIN).pot:
+       $(GETTEXT) -L python --add-comments="TRANSLATORS:" -d $(DOMAIN) -s -o $(DOMAIN).pot ../src/*.py
+       msguniq -o $(DOMAIN)uniq.pot $(DOMAIN).pot
+       $(RM) $(DOMAIN).pot
+       mv $(DOMAIN)uniq.pot $(DOMAIN).pot
+
+.PHONY: $(DOMAIN).pot
+
+
+%.mo: %.po
+       $(MSGFMT) -o $@ $<
+
+%.po:
+       msginit -l $@ -o $@ -i $(DOMAIN).pot --no-translator
+
+CLEANFILES = $(foreach LANG, $(LANGS),$(LANG).mo)
+
+clean-local:
+       $(RM) -r $(LANGS)
+
+install-data-am: default
+       for lang in $(LANGS); do \
+               mkdir -p $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES; \
+               cp $$lang.mo $(DESTDIR)$(installdir)/locale/$$lang/LC_MESSAGES/$(DOMAIN).mo; \
+       done
diff --git a/zapstatistic/po/ZapStatistic.pot b/zapstatistic/po/ZapStatistic.pot
new file mode 100644 (file)
index 0000000..cea0c75
--- /dev/null
@@ -0,0 +1,111 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: ZapStatistic\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-01-13 17:39+0100\n"
+"PO-Revision-Date: \n"
+"Last-Translator: AliAbdul <aliabdul1978@hotmail.de>\n"
+"Language-Team: Nabil Hanna <nabil1978@web.de>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: German\n"
+"X-Poedit-Country: GERMANY\n"
+"X-Poedit-Basepath: .\n"
+"X-Poedit-SearchPath-0: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src\n"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:220
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:317
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:422
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:598
+msgid "Zap Statistic"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:227
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:325
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:451
+msgid "Sort (name+)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:228
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:326
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:454
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:524
+msgid "Sort (name-)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:229
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:327
+msgid "Sort (duration+)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:230
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:328
+msgid "Sort (duration-)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:431
+msgid "Delete"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:434
+msgid "Durations"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:452
+msgid "Sort (date+)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:456
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:539
+msgid "Sort (date-)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:561
+msgid "Play entry"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:562
+msgid "Delete entry"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:563
+msgid "Delete all entries"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:564
+msgid "Sort by name (ascending)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:565
+msgid "Sort by name (descending)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:566
+msgid "Sort by date (ascending)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:567
+msgid "Sort by date (descending)"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:568
+msgid "Show duration window"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:569
+msgid "Show combined duration window"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:570
+msgid "Close plugin"
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:571
+msgid "Please choose a function..."
+msgstr ""
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:598
+msgid "Shows the watched services with some statistic"
+msgstr ""
+
diff --git a/zapstatistic/po/de.po b/zapstatistic/po/de.po
new file mode 100644 (file)
index 0000000..eac3c3b
--- /dev/null
@@ -0,0 +1,114 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: ZapStatistic\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2010-01-13 17:39+0100\n"
+"PO-Revision-Date: \n"
+"Last-Translator: AliAbdul <aliabdul1978@hotmail.de>\n"
+"Language-Team: Nabil Hanna <nabil1978@web.de>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"X-Poedit-Language: German\n"
+"X-Poedit-Country: GERMANY\n"
+"X-Poedit-Basepath: .\n"
+"X-Poedit-SearchPath-0: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src\n"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:220
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:317
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:422
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:598
+msgid "Zap Statistic"
+msgstr "Zap Statistik"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:227
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:325
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:451
+msgid "Sort (name+)"
+msgstr "Sortiere (Name+)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:228
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:326
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:454
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:524
+msgid "Sort (name-)"
+msgstr "Sortiere (Name-)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:229
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:327
+msgid "Sort (duration+)"
+msgstr "Sortiere (Dauer+)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:230
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:328
+msgid "Sort (duration-)"
+msgstr "Sortiere (Dauer-)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:431
+msgid "Delete"
+msgstr "Lösche"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:434
+msgid "Durations"
+msgstr "Dauer"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:452
+msgid "Sort (date+)"
+msgstr "Sortiere (Datum+)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:456
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:539
+msgid "Sort (date-)"
+msgstr "Sortiere (Datum-)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:561
+msgid "Play entry"
+msgstr "Eintrag abspielen"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:562
+msgid "Delete entry"
+msgstr "Eintrag entfernen"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:563
+msgid "Delete all entries"
+msgstr "Alle Einträge entfernen"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:564
+msgid "Sort by name (ascending)"
+msgstr "Sortiere nach Name (aufsteigend)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:565
+msgid "Sort by name (descending)"
+msgstr "Sortiere nach Name (absteigend)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:566
+msgid "Sort by date (ascending)"
+msgstr "Sortiere nach Datum (aufsteigend)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:567
+msgid "Sort by date (descending)"
+msgstr "Sortiere nach Datum (absteigend)"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:568
+msgid "Show duration window"
+msgstr "Zeige Dauer Fenster"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:569
+msgid "Show combined duration window"
+msgstr "Zeige kombiniertes Dauer Fenster"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:570
+msgid "Close plugin"
+msgstr "Schließe Plugin"
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:571
+msgid "Please choose a function..."
+msgstr "Bitte selektiere eine Funktion..."
+
+#: /home/aliabdul/dream/ltteam/trunk/additions/plugins/zapstatistic/src/plugin.py:598
+msgid "Shows the watched services with some statistic"
+msgstr "Zeige die angeschauten Sendungen mit einigen Statistiken"
+
+#~ msgid "Zap-Statistic"
+#~ msgstr "Zap-Statistik"
+
diff --git a/zapstatistic/src/Makefile.am b/zapstatistic/src/Makefile.am
new file mode 100644 (file)
index 0000000..30eeece
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = /usr/lib/enigma2/python/Plugins/Extensions/ZapStatistic
+install_PYTHON = *.py
+install_DATA = maintainer.info
diff --git a/zapstatistic/src/__init__.py b/zapstatistic/src/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/zapstatistic/src/maintainer.info b/zapstatistic/src/maintainer.info
new file mode 100644 (file)
index 0000000..a604636
--- /dev/null
@@ -0,0 +1,2 @@
+nabil1978@web.de
+Zap Statistic
diff --git a/zapstatistic/src/plugin.py b/zapstatistic/src/plugin.py
new file mode 100644 (file)
index 0000000..8ff06c0
--- /dev/null
@@ -0,0 +1,600 @@
+# -*- coding: UTF-8 -*-
+# Zap Statistic by AliAbdul
+from Components.ActionMap import ActionMap
+from Components.config import config
+from Components.Label import Label
+from Components.Language import language
+from Components.MenuList import MenuList
+from Components.MultiContent import MultiContentEntryText
+from enigma import eListboxPythonMultiContent, eServiceReference, gFont
+from os import environ
+from Plugins.Plugin import PluginDescriptor\r
+from Screens.ChoiceBox import ChoiceBox
+from Screens.ParentalControlSetup import ProtectedScreen
+from Screens.Screen import Screen
+from ServiceReference import ServiceReference
+from time import localtime, time
+from Tools.Directories import fileExists, resolveFilename, SCOPE_LANGUAGE, SCOPE_PLUGINS
+from xml.etree.cElementTree import parse
+import gettext
+
+###########################################################
+
+def localeInit():
+       lang = language.getLanguage()
+       environ["LANGUAGE"] = lang[:2]
+       gettext.bindtextdomain("enigma2", resolveFilename(SCOPE_LANGUAGE))
+       gettext.textdomain("enigma2")
+       gettext.bindtextdomain("ZapStatistic", "%s%s" % (resolveFilename(SCOPE_PLUGINS), "Extensions/ZapStatistic/locale/"))
+
+def _(txt):
+       t = gettext.dgettext("ZapStatistic", txt)
+       if t == txt:
+               t = gettext.gettext(txt)
+       return t
+
+localeInit()\r
+language.addCallback(localeInit)
+
+###########################################################
+
+def decode_charset(str, charset):
+       try:
+               uni = unicode(str, charset, 'strict')
+       except:
+               uni = str
+       return uni
+
+###########################################################
+
+def deformXml(xml):
+       xml = xml.replace("&", "&amp;")
+       xml = xml.replace("'", "&apos;")
+       xml = xml.replace("<", "&lt;")
+       xml = xml.replace(">", "&gt;")
+       xml = xml.replace('"', "&quot;")
+       return xml
+
+def reformXml(xml):
+       xml = xml.replace("&amp;", "&")
+       xml = xml.replace("&apos;", "'")
+       xml = xml.replace("&lt;", "<")
+       xml = xml.replace("&gt;", ">")
+       xml = xml.replace("&quot;", '"')
+       return xml
+
+###########################################################
+
+class ZapEntry:
+       def __init__(self, ref, begin=None, end=None):
+               self.ref = ref
+               self.name = ServiceReference(eServiceReference(ref)).getServiceName()
+               if begin:
+                       self.begin = begin
+               else:
+                       self.begin = time()
+               self.end = end
+
+       def stop(self):
+               self.end = time()
+
+###########################################################
+
+class DurationZapEntry:
+       def __init__(self, zapentry):
+               self.ref = zapentry.ref
+               self.name = zapentry.name
+               duration = zapentry.end - zapentry.begin
+               self.duration = "%02d:%02d:%02d" % (duration/3600, (duration/60) - ((duration/3600) * 60), duration%60)
+               t = localtime(zapentry.begin)
+               self.begin = "%02d.%02d. %02d:%02d:%02d" % (t[2], t[1], t[3], t[4], t[5])
+
+###########################################################
+
+class CombinedZapEntry:
+       def __init__(self, zapentry):
+               self.ref = zapentry.ref
+               self.name = zapentry.name
+               self.duration = zapentry.end - zapentry.begin
+
+       def addDuration(self, zapentry):
+               self.duration = self.duration + zapentry.end - zapentry.begin
+
+       def getDurationText(self):
+               return "%02d:%02d:%02d" % (self.duration/3600, (self.duration/60) - ((self.duration/3600) * 60), self.duration%60)
+
+###########################################################
+
+class ZapStatistic:
+       def __init__(self):
+               self.xmlFile = "/etc/zapstastistic.xml"
+               self.zapEntries = []
+               self.currentEntry = None
+
+       def loadZapEntries(self):
+               if fileExists(self.xmlFile):
+                       try:
+                               menu = parse(self.xmlFile).getroot()
+                               for item in menu.findall("entry"):
+                                       ref = item.get("ref") or None
+                                       if ref:
+                                               ref = decode_charset(ref, "UTF-8").encode("UTF-8")
+                                               ref = reformXml(ref)
+                                       begin = item.get("begin") or None
+                                       end = item.get("end") or None
+                                       if ref and begin and end:
+                                               self.zapEntries.append(ZapEntry(ref, float(begin), float(end)))
+                       except:
+                               print "[ZapStatistic] Error while reading xml file"
+
+       def saveZapEntries(self):
+               xml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<zapstastistic>\n'
+               for x in self.zapEntries:
+                       if not x.end:
+                               x.end = time()
+                       xml += '\t<entry ref="%s" begin="%s" end ="%s" />\n' % (decode_charset(deformXml(x.ref), "UTF-8"), str(x.begin), str(x.end))
+               xml += '</zapstastistic>'
+               try:
+                       f = open(self.xmlFile, "w")
+                       f.write(xml.encode("UTF-8"))
+                       f.close()
+               except:
+                       print "[ZapStatistic] Error while writing xml file"
+
+       def handlePlayServiceCommand(self, ref):
+               self.handleStopServiceCommand()
+               if ref:
+                       self.currentEntry = ZapEntry(ref.toString())
+
+       def handleStopServiceCommand(self):
+               if self.currentEntry:
+                       self.currentEntry.stop()
+                       self.zapEntries.append(self.currentEntry)
+                       self.currentEntry = None
+
+zapstatistic = ZapStatistic()
+
+###########################################################
+
+global PlayService
+global StopService
+PlayService = None
+StopService = None
+
+def playService(ref, checkParentalControl=True, forceRestart=False):
+       if PlayService:
+               zapstatistic.handlePlayServiceCommand(ref)
+               PlayService(ref, checkParentalControl, forceRestart)
+
+def stopService():
+       if StopService:
+               zapstatistic.handleStopServiceCommand()
+               StopService()
+
+###########################################################
+
+class ZapStatisticBrowserList(MenuList):
+       def __init__(self, list, enableWrapAround=False):
+               MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
+               self.l.setItemHeight(25)
+               self.l.setFont(0, gFont("Regular", 20))
+
+def ZapStatisticBrowserListEntry(entry):
+       res = [entry]
+       t_begin = localtime(entry.begin)
+       t_end = localtime(entry.end)
+       res.append(MultiContentEntryText(pos=(0, 0), size=(240, 25), font=0, text="%02d.%02d. %02d:%02d:%02d - %02d:%02d:%02d" % (t_begin[2], t_begin[1], t_begin[3], t_begin[4], t_begin[5], t_end[3], t_end[4], t_end[5])))
+       res.append(MultiContentEntryText(pos=(250, 0), size=(310, 25), font=0, text=entry.name))
+       return res
+
+def ZapStatisticBrowserDurationListEntry(entry):
+       res = [entry]
+       res.append(MultiContentEntryText(pos=(0, 0), size=(240, 25), font=0, text="%s (%s)" % (entry.duration, entry.begin)))
+       res.append(MultiContentEntryText(pos=(250, 0), size=(310, 25), font=0, text=entry.name))
+       return res
+
+def ZapStatisticBrowserCombinedListEntry(entry):
+       res = [entry]
+       res.append(MultiContentEntryText(pos=(0, 0), size=(150, 25), font=0, text="%s" % (entry.getDurationText())))
+       res.append(MultiContentEntryText(pos=(160, 0), size=(400, 25), font=0, text=entry.name))
+       return res
+
+###########################################################
+
+class ZapStatisticDurationScreen(Screen):
+       SORT_NAME_ASCENDING = 0
+       SORT_NAME_DESCENDING = 1
+       SORT_DURATION_ASCENDING = 2
+       SORT_DURATION_DESCENDING = 3
+       skin = """
+               <screen position="center,center" size="560,450" title="%s" >
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
+                       <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="list" position="0,40" size="560,400" scrollbarMode="showOnDemand" />
+               </screen>""" % _("Zap Statistic")
+
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               
+               self.sortType = self.SORT_NAME_ASCENDING
+               
+               self["key_red"] = Label(_("Sort (name+)"))
+               self["key_green"] = Label(_("Sort (name-)"))
+               self["key_yellow"] = Label(_("Sort (duration+)"))
+               self["key_blue"] = Label(_("Sort (duration-)"))
+               self["list"] = ZapStatisticBrowserList([])
+               
+               self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
+                       {
+                               "ok": self.play,
+                               "cancel": self.close,
+                               "red": self.sortByNameAscending,
+                               "green": self.sortByNameDescending,
+                               "yellow": self.sortByDurationAscending,
+                               "blue": self.sortByDurationDescending
+                       }, prio=-1)
+               
+               self.onLayoutFinish.append(self.buildList)
+
+       def sortList(self, l):
+               if self.sortType == self.SORT_NAME_ASCENDING:
+                       return l.sort(key=self.buildSortNameKey, reverse=False)
+               elif self.sortType == self.SORT_NAME_DESCENDING:
+                       return l.sort(key=self.buildSortNameKey, reverse=True)
+               elif self.sortType == self.SORT_DURATION_ASCENDING:
+                       return l.sort(key=self.buildSortDurationKey, reverse=False)
+               elif self.sortType == self.SORT_DURATION_DESCENDING:
+                       return l.sort(key=self.buildSortDurationKey, reverse=True)
+               else:
+                       return l
+
+       def buildSortNameKey(self, x):
+               try: name = x.name
+               except: name = ""
+               return (name and name.lower() or "")
+
+       def buildSortDurationKey(self, x):
+               try: name = str(x.duration)
+               except: name = ""
+               return (name and name.lower() or "")
+
+       def buildList(self):
+               list = []
+               l = []
+               for x in zapstatistic.zapEntries:
+                       l.append(DurationZapEntry(x))
+               self.sortList(l)
+               for x in l:
+                       list.append(ZapStatisticBrowserDurationListEntry(x))
+               self["list"].setList(list)
+
+       def play(self):
+               cur = self["list"].getCurrent()
+               if cur:
+                       entry = cur[0]
+                       self.session.nav.playService(eServiceReference(entry.ref))
+
+       def sortByNameAscending(self):
+               self.sortType = self.SORT_NAME_ASCENDING
+               self.buildList()
+
+       def sortByNameDescending(self):
+               self.sortType = self.SORT_NAME_DESCENDING
+               self.buildList()
+
+       def sortByDurationAscending(self):
+               self.sortType = self.SORT_DURATION_ASCENDING
+               self.buildList()
+
+       def sortByDurationDescending(self):
+               self.sortType = self.SORT_DURATION_DESCENDING
+               self.buildList()
+
+###########################################################
+
+class ZapStatisticCombinedScreen(Screen):
+       SORT_NAME_ASCENDING = 0
+       SORT_NAME_DESCENDING = 1
+       SORT_DURATION_ASCENDING = 2
+       SORT_DURATION_DESCENDING = 3
+       skin = """
+               <screen position="center,center" size="560,450" title="%s" >
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
+                       <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="list" position="0,40" size="560,400" scrollbarMode="showOnDemand" />
+               </screen>""" % _("Zap Statistic")
+
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               
+               self.list = []
+               self.sortType = self.SORT_DURATION_DESCENDING
+               
+               self["key_red"] = Label(_("Sort (name+)"))
+               self["key_green"] = Label(_("Sort (name-)"))
+               self["key_yellow"] = Label(_("Sort (duration+)"))
+               self["key_blue"] = Label(_("Sort (duration-)"))
+               self["list"] = ZapStatisticBrowserList([])
+               
+               self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
+                       {
+                               "ok": self.play,
+                               "cancel": self.close,
+                               "red": self.sortByNameAscending,
+                               "green": self.sortByNameDescending,
+                               "yellow": self.sortByDurationAscending,
+                               "blue": self.sortByDurationDescending
+                       }, prio=-1)
+               
+               self.onLayoutFinish.append(self.buildList)
+
+       def sortList(self, l):
+               if self.sortType == self.SORT_NAME_ASCENDING:
+                       return l.sort(key=self.buildSortNameKey, reverse=False)
+               elif self.sortType == self.SORT_NAME_DESCENDING:
+                       return l.sort(key=self.buildSortNameKey, reverse=True)
+               elif self.sortType == self.SORT_DURATION_ASCENDING:
+                       return l.sort(key=self.buildSortDurationKey, reverse=False)
+               elif self.sortType == self.SORT_DURATION_DESCENDING:
+                       return l.sort(key=self.buildSortDurationKey, reverse=True)
+               else:
+                       return l
+
+       def buildSortNameKey(self, x):
+               try: name = x.name
+               except: name = ""
+               return (name and name.lower() or "")
+
+       def buildSortDurationKey(self, x):
+               try: name = x.getDurationText()
+               except: name = ""
+               return (name and name.lower() or "")
+
+       def buildList(self):
+               list = []
+               if len(self.list) == 0:
+                       for x in zapstatistic.zapEntries:
+                               added = False
+                               for y in self.list:
+                                       if x.ref == y.ref:
+                                               y.addDuration(x)
+                                               added = True
+                                               break
+                               if added == False:
+                                       self.list.append(CombinedZapEntry(x))
+               self.sortList(self.list)
+               for x in self.list:
+                       list.append(ZapStatisticBrowserCombinedListEntry(x))
+               self["list"].setList(list)
+
+       def play(self):
+               cur = self["list"].getCurrent()
+               if cur:
+                       entry = cur[0]
+                       self.session.nav.playService(eServiceReference(entry.ref))
+
+       def sortByNameAscending(self):
+               self.sortType = self.SORT_NAME_ASCENDING
+               self.buildList()
+
+       def sortByNameDescending(self):
+               self.sortType = self.SORT_NAME_DESCENDING
+               self.buildList()
+
+       def sortByDurationAscending(self):
+               self.sortType = self.SORT_DURATION_ASCENDING
+               self.buildList()
+
+       def sortByDurationDescending(self):
+               self.sortType = self.SORT_DURATION_DESCENDING
+               self.buildList()
+
+###########################################################
+
+class ZapStatisticScreen(Screen, ProtectedScreen):
+       SORT_NAME_ASCENDING = 0
+       SORT_NAME_DESCENDING = 1
+       SORT_DATE_ASCENDING = 2
+       SORT_DATE_DESCENDING = 3
+       skin = """
+               <screen position="center,center" size="560,450" title="%s" >
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
+                       <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget name="list" position="0,40" size="560,400" scrollbarMode="showOnDemand" />
+               </screen>""" % _("Zap Statistic")
+
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               ProtectedScreen.__init__(self)
+               
+               self.session = session
+               self.sortType = self.SORT_DATE_ASCENDING
+               
+               self["key_red"] = Label(_("Delete"))
+               self["key_green"] = Label(" ")
+               self["key_yellow"] = Label(" ")
+               self["key_blue"] = Label(_("Durations"))
+               self["list"] = ZapStatisticBrowserList([])
+               
+               self["actions"] = ActionMap(["ColorActions", "OkCancelActions", "InfobarMenuActions"],
+                       {
+                               "ok": self.play,
+                               "cancel": self.close,
+                               "red": self.delete,
+                               "green": self.sortByName,
+                               "yellow": self.sortByDate,
+                               "blue": self.duration,\r
+                               "mainMenu": self.menu
+                       }, prio=-1)
+               
+               self.onLayoutFinish.append(self.buildList)
+
+       def updateLabels(self):
+               self["key_green"].setText(_("Sort (name+)"))
+               self["key_yellow"].setText(_("Sort (date+)"))
+               if self.sortType == self.SORT_NAME_ASCENDING:
+                       self["key_green"].setText(_("Sort (name-)"))
+               if self.sortType == self.SORT_DATE_ASCENDING:
+                       self["key_yellow"].setText(_("Sort (date-)"))
+
+       def sortList(self, l):
+               if self.sortType == self.SORT_NAME_ASCENDING:
+                       return l.sort(key=self.buildSortNameKey, reverse=False)
+               elif self.sortType == self.SORT_NAME_DESCENDING:
+                       return l.sort(key=self.buildSortNameKey, reverse=True)
+               elif self.sortType == self.SORT_DATE_ASCENDING:
+                       return l.sort(key=self.buildSortDateKey, reverse=False)
+               elif self.sortType == self.SORT_DATE_DESCENDING:
+                       return l.sort(key=self.buildSortDateKey, reverse=True)
+               else:
+                       return l
+
+       def buildSortNameKey(self, x):
+               try: name = x.name
+               except: name = ""
+               return (name and name.lower() or "")
+
+       def buildSortDateKey(self, x):
+               try: name = str(x.begin)
+               except: name = ""
+               return (name and name.lower() or "")
+
+       def buildList(self):
+               list = []
+               l = zapstatistic.zapEntries
+               self.sortList(l)
+               for x in l:
+                       list.append(ZapStatisticBrowserListEntry(x))
+               self["list"].setList(list)
+               self.updateLabels()
+
+       def isProtected(self):
+               return config.ParentalControl.setuppinactive.value and config.ParentalControl.configured.value
+       
+       def pinEntered(self, result):
+               if result is None:
+                       self.close()
+               elif not result:
+                       self.close()
+
+       def play(self):
+               cur = self["list"].getCurrent()
+               if cur:
+                       entry = cur[0]
+                       self.session.nav.playService(eServiceReference(entry.ref))
+
+       def delete(self):
+               cur = self["list"].getCurrent()
+               if cur:
+                       entry = cur[0]
+                       idx = 0
+                       for x in zapstatistic.zapEntries:
+                               if x == entry:
+                                       del zapstatistic.zapEntries[idx]
+                                       break
+                               else:
+                                       idx += 1
+                       self.buildList()
+
+       def deleteAll(self):
+               if len(zapstatistic.zapEntries):
+                       del zapstatistic.zapEntries
+                       zapstatistic.zapEntries = []
+                       self.buildList()
+
+       def sortByName(self):
+               if self["key_green"].getText() == _("Sort (name-)"):
+                       self.sortType = self.SORT_NAME_DESCENDING
+               else:
+                       self.sortType = self.SORT_NAME_ASCENDING
+               self.buildList()
+
+       def sortByNameAscending(self):
+               self.sortType = self.SORT_NAME_ASCENDING
+               self.buildList()
+
+       def sortByNameDescending(self):
+               self.sortType = self.SORT_NAME_DESCENDING
+               self.buildList()
+
+       def sortByDate(self):
+               if self["key_yellow"].getText() == _("Sort (date-)"):
+                       self.sortType = self.SORT_DATE_DESCENDING
+               else:
+                       self.sortType = self.SORT_DATE_ASCENDING
+               self.buildList()
+
+       def sortByDateAscending(self):
+               self.sortType = self.SORT_DATE_ASCENDING
+               self.buildList()
+
+       def sortByDateDescending(self):
+               self.sortType = self.SORT_DATE_DESCENDING
+               self.buildList()
+
+       def duration(self):
+               self.session.open(ZapStatisticDurationScreen)
+
+       def combined(self):
+               self.session.open(ZapStatisticCombinedScreen)
+
+       def menu(self):
+               list = []\r
+               list.append((_("Play entry"), self.play))\r
+               list.append((_("Delete entry"), self.delete))\r
+               list.append((_("Delete all entries"), self.deleteAll))\r
+               list.append((_("Sort by name (ascending)"), self.sortByNameAscending))\r
+               list.append((_("Sort by name (descending)"), self.sortByNameDescending))\r
+               list.append((_("Sort by date (ascending)"), self.sortByDateAscending))\r
+               list.append((_("Sort by date (descending)"), self.sortByDateDescending))\r
+               list.append((_("Show duration window"), self.duration))\r
+               list.append((_("Show combined duration window"), self.combined))\r
+               list.append((_("Close plugin"), self.close))\r
+               self.session.openWithCallback(self.menuCallback, ChoiceBox, title=_("Please choose a function..."), list=list)
+
+       def menuCallback(self, callback=None):\r
+               if callback is not None:\r
+                       callback[1]()
+
+###########################################################
+
+def main(session, **kwargs):
+       session.open(ZapStatisticScreen)
+
+def sessionstart(reason, **kwargs):
+       if reason == 0:
+               zapstatistic.loadZapEntries()
+               session = kwargs["session"]
+               global PlayService
+               global StopService
+               PlayService = session.nav.playService
+               StopService = session.nav.stopService
+               session.nav.playService = playService
+               session.nav.stopService = stopService
+
+def autostart(reason, **kwargs):
+       if reason == 1:
+               zapstatistic.saveZapEntries()
+
+def Plugins(**kwargs):
+       return [PluginDescriptor(name=_("Zap Statistic"), description=_("Shows the watched services with some statistic"), where=PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
+               PluginDescriptor(where=PluginDescriptor.WHERE_SESSIONSTART, fnc=sessionstart),
+               PluginDescriptor(where=PluginDescriptor.WHERE_AUTOSTART, fnc=autostart)]