Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/control
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/control	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/control	(revision 8756)
@@ -0,0 +1,11 @@
+Package: enigma2-plugin-swapbrowsers-werbezapper
+Version: 1.0
+Description: With this plugin you can set a timer. When the time is over the plugin will switch back to the channel you activated the timer. Nice for commercials! SWAPSTICK IS NEEDED!
+Section: browsers
+Priority: optional
+Maintainer: AAF Forum
+Architecture: sh4
+OE: WerbeZapper v1.0 for Swapstick
+Homepage: http://www.aaf-digital.info
+Depends:
+Source: http://www.aaf-digital.info
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/postinst
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/postinst	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/postinst	(revision 8756)
@@ -0,0 +1,7 @@
+#!/bin/sh
+TMP=/tmp/.browsers
+echo "successfully installed"
+echo "syncing disk"
+echo "please reboot your box so that the extension will be mounted..."
+sync
+exit 0
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/postrm
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/postrm	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/postrm	(revision 8756)
@@ -0,0 +1,9 @@
+#!/bin/sh
+TMP=/tmp/.browsers
+
+rm -rf /var/swap/extensions/WerbeZapper
+
+echo "successfully removed"
+echo "syncing disk"
+sync
+exit 0
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/preinst
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/preinst	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/preinst	(revision 8756)
@@ -0,0 +1,38 @@
+#!/bin/sh
+#
+TMP=/tmp/.browsers
+echo "syncing disk"
+sync
+
+model=`cat /etc/model`
+echo""
+echo "Checking your Boxtype...."
+echo "Some Plugins will not work correctly on your $model!"
+echo ""
+if [ "$model" = "" ]; then
+	echo "Sorry! This Plugin is not available for your $model because it will not work correctly!!!"
+	echo "Aborting installation..."
+	exit 1
+else
+	echo "Boxtype: $model OK"
+fi
+
+echo "checking swapstick"
+if [ ! -d /var/swap/extensions/ ]; then
+  echo "--------------------------"
+	echo "no swapstick found...."
+	echo "--------------------------"
+	exit 1
+fi
+echo "swapstick found...."
+echo "installing WerbeZapper v1.0 to swapstick..."
+echo "checking OS"
+if  [ `cat /etc/motd | grep AAF | grep M | grep rev | wc -l` -eq 0 ]; then                      
+	echo ---------------------------
+	echo DONT USE this IPK Package!!
+	echo ---
+	echo Only for AAF Image!!
+	echo ---------------------------
+	exit 1
+fi
+exit 0
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/prerm
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/prerm	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/CONTROL/prerm	(revision 8756)
@@ -0,0 +1,6 @@
+#!/bin/sh
+TMP=/tmp/.browsers
+echo "syncing disk"
+sync
+echo "removing WerbeZapper v1.0 from swapstick"
+exit 0
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/LICENSE
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/LICENSE	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/LICENSE	(revision 8756)
@@ -0,0 +1,12 @@
+All Files of this Software are licensed under the Creative Commons 
+Attribution-NonCommercial-ShareAlike 3.0 Unported 
+License if not stated otherwise in a Files Head. To view a copy of this license, visit
+http://creativecommons.org/licenses/by-nc-sa/3.0/ or send a letter to Creative
+Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
+
+Alternatively, this plugin may be distributed and executed on hardware which
+is licensed by Dream Multimedia GmbH.
+
+This plugin is NOT free software. It is open source, you are allowed to
+modify it (if you keep the license), but it may not be commercially 
+distributed other than under the conditions noted above.
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/WerbeZapper.py
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/WerbeZapper.py	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/WerbeZapper.py	(revision 8756)
@@ -0,0 +1,157 @@
+# for localized messages
+from . import _
+
+# GUI (Screens)
+from Screens.MessageBox import MessageBox
+
+# Timer
+from enigma import eTimer
+
+class WerbeZapper:
+	"""Simple Plugin to automatically zap back to a Service after a given amount
+	   of time."""
+
+	def __init__(self, session, servicelist, cleanupfnc = None):
+		# Save Session&Servicelist
+		self.session = session
+		self.servicelist = servicelist
+
+		# Create Timer
+		self.zap_timer = eTimer()
+		self.zap_timer.callback.append(self.zap)
+
+		# Initialize services
+		self.zap_service = None
+		self.move_service = None
+		self.root = None
+
+		# Keep Cleanup
+		self.cleanupfnc = cleanupfnc
+
+	def showSelection(self):
+		# Check if timer is active
+		if self.zap_timer.isActive():
+			# Ask if we should stop the running timer
+			self.session.openWithCallback(
+				self.confirmStop,
+				MessageBox,
+				_("Timer already running.\nStop it?")
+			)
+		else:
+			from Screens.ChoiceBox import ChoiceBox
+
+			# Select Timer Length
+			self.session.openWithCallback(
+				self.choiceCallback,
+				ChoiceBox,
+				_("When to Zap back?"),
+				(
+					('1 ' + _('minute'), 1),
+					('2 ' + _('minutes'), 2),
+					('3 ' + _('minutes'), 3),
+					('4 ' + _('minutes'), 4),
+					('5 ' + _('minutes'), 5),
+					('6 ' + _('minutes'), 6),
+					('7 ' + _('minutes'), 7),
+					('8 ' + _('minutes'), 8),
+					('9 ' + _('minutes'), 9),
+					( _("Custom"), 'custom')
+				)
+			)
+
+	def confirmStop(self, result):
+		if result:
+			# Stop Timer
+			self.zap_timer.stop()
+
+			# Reset Vars
+			self.zap_service = None
+			self.move_service = None
+
+			# Clean up if possible
+			if self.cleanupfnc:
+				self.cleanupfnc()
+
+	def choiceCallback(self, result):
+		result = result and result[1]
+		if result == "custom":
+			from Screens.InputBox import InputBox
+			from Components.Input import Input
+
+			self.session.openWithCallback(
+				self.inputCallback,
+				InputBox,
+				title=_("How many minutes to wait until zapping back?"),
+				text="10",
+				maxSize=False,
+				type=Input.NUMBER
+			)
+		elif result is not None:
+			self.confirmStart(result)
+		# Clean up if possible
+		elif self.cleanupfnc:
+			self.cleanupfnc()
+
+	def inputCallback(self, result):
+		if result is not None:
+			self.confirmStart(int(result))
+		# Clean up if possible
+		elif self.cleanupfnc:
+			self.cleanupfnc()
+
+
+	def confirmStart(self, duration):
+		# Remind the User of what he just did
+		self.session.open(
+			MessageBox,
+			_("Zapping back in %d Minutes") % (duration),
+			type = MessageBox.TYPE_INFO,
+			timeout = 3
+		)
+
+		# Keep any service related information (zap_service might not equal move_service -> subservices)
+		self.zap_service = self.session.nav.getCurrentlyPlayingServiceReference()
+		self.move_service = self.servicelist.getCurrentSelection()
+		self.root = self.servicelist.getRoot()
+
+		#import ServiceReference
+		#print [str(ServiceReference.ServiceReference(x)) for x in self.servicelist.getCurrentServicePath()]
+		#print ServiceReference.ServiceReference(self.servicelist.getRoot())
+
+		# Start Timer
+		self.zap_timer.startLongTimer(duration*60)
+
+	def zap(self):
+		if self.zap_service is not None:
+			if self.root:
+				import ServiceReference
+				if not self.servicelist.preEnterPath(str(ServiceReference.ServiceReference(self.root))):
+					if self.servicelist.isBasePathEqual(self.root):
+						self.servicelist.pathUp()
+						self.servicelist.enterPath(self.root)
+					else:
+						currentRoot = self.servicelist.getRoot()
+						if currentRoot is None or currentRoot != self.root:
+							self.servicelist.clearPath()
+							self.servicelist.enterPath(self.root)
+
+			if self.move_service:
+				self.servicelist.setCurrentSelection(self.move_service)
+				self.servicelist.zap()
+
+			# Play zap_service (won't rezap if service equals to move_service)
+			self.session.nav.playService(self.zap_service)
+
+			# Reset services
+			self.zap_service = None
+			self.move_service = None
+			self.root = None
+
+		# Clean up if possible
+		if self.cleanupfnc:
+			self.cleanupfnc()
+
+	def shutdown(self):
+		self.zap_timer.callback.remove(self.zap)
+		self.zap_timer = None
+
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/__init__.py
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/__init__.py	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/__init__.py	(revision 8756)
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+from Components.Language import language
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
+from os import environ as os_environ
+import gettext
+
+def localeInit():
+	lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
+	os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
+	gettext.bindtextdomain("WerbeZapper", resolveFilename(SCOPE_PLUGINS, "Extensions/WerbeZapper/locale"))
+
+def _(txt):
+	t = gettext.dgettext("WerbeZapper", txt)
+	if t == txt:
+		print "[WerbeZapper] fallback to default translation for", txt
+		t = gettext.gettext(txt)
+	return t
+
+localeInit()
+language.addCallback(localeInit)
+
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/maintainer.info
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/maintainer.info	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/maintainer.info	(revision 8756)
@@ -0,0 +1,2 @@
+moritz.venn@freaque.net
+WerbeZapper
Index: /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/plugin.py
===================================================================
--- /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/plugin.py	(revision 8756)
+++ /ipk/source.sh4/swapbrowsers_werbezapper_1_0/var/swap/extensions/WerbeZapper/plugin.py	(revision 8756)
@@ -0,0 +1,33 @@
+# for localized messages
+from . import _
+
+# Plugin
+from Plugins.Plugin import PluginDescriptor
+
+zapperInstance = None
+
+# Mainfunction
+def main(session, servicelist, **kwargs):
+	# Create Instance if none present, show Dialog afterwards
+	global zapperInstance
+	if zapperInstance is None:
+		from WerbeZapper import WerbeZapper
+		zapperInstance = WerbeZapper(session, servicelist, cleanup)
+	zapperInstance.showSelection()
+
+def cleanup():
+	global zapperInstance
+	if zapperInstance is not None:
+		zapperInstance.shutdown()
+		zapperInstance = None
+
+def Plugins(**kwargs):
+ 	return [
+		PluginDescriptor(
+			name = "Werbezapper",
+			description = _("Automatically zaps back to current service after given Time"),
+			where = PluginDescriptor.WHERE_EXTENSIONSMENU,
+			fnc = main
+		)
+	]
+
