Index: /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/__init__.py
===================================================================
--- /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/__init__.py	(revision 14693)
+++ /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/__init__.py	(revision 14693)
@@ -0,0 +1,31 @@
+# -*- coding: ISO-8859-1 -*-
+#===============================================================================
+# NetworkServer System Plugin 0.1 by DarkVolli 2009
+#
+# This is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any later
+# version.
+#===============================================================================
+
+from Components.Language import language
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
+import os,gettext
+PluginLanguageDomain = "NetworkServer"
+PluginLanguagePath = "SystemPlugins/NetworkServer/locale"
+
+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!
+	print "[NetworkServer] set language to ", lang
+	gettext.bindtextdomain(PluginLanguageDomain, resolveFilename(SCOPE_PLUGINS, PluginLanguagePath))
+
+def _(txt):
+	t = gettext.dgettext(PluginLanguageDomain, txt)
+	if t == txt:
+		print "[NetworkServer] fallback to default translation for", txt
+		t = gettext.gettext(txt)
+	return t
+
+localeInit()
+language.addCallback(localeInit)
Index: /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/dirSelect.py
===================================================================
--- /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/dirSelect.py	(revision 14693)
+++ /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/dirSelect.py	(revision 14693)
@@ -0,0 +1,114 @@
+# -*- coding: utf-8 -*-
+#===============================================================================
+# dirSelectDlg 0.1 by DarkVolli 2009
+#
+# This is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any later
+# version.
+#===============================================================================
+
+# for localized messages
+from __init__ import _
+
+from Screens.Screen import Screen
+
+from Components.ActionMap import ActionMap
+from Components.Pixmap import Pixmap
+from Components.Label import Label
+from Components.Button import Button
+from Components.FileList import FileList
+
+class dirSelectDlg(Screen): # 90,140
+	skin = """
+		<screen name="dirSelectDlg" position="90,140" size="560,350">
+			<widget name="filelist" position="10,10" size="540,210" scrollbarMode="showOnDemand" />
+			<widget name="ButtonGreentext" position="50,270" size="460,21" halign="left" zPosition="10" font="Regular;21" transparent="1" />
+			<widget name="ButtonGreen" pixmap="skin_default/buttons/button_green.png" position="30,273" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+			<widget name="ButtonRedtext" position="50,300" size="460,21" halign="left" zPosition="10" font="Regular;21" transparent="1" />
+			<widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="30,303" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+		</screen>"""
+
+	def __init__(self, session, currDir):
+		self.skin = dirSelectDlg.skin
+		Screen.__init__(self, session)
+		self.session = session
+
+		self["ButtonGreen"] = Pixmap()
+		self["ButtonGreentext"] = Button()
+		self["ButtonRed"] = Pixmap()
+		self["ButtonRedtext"] = Label(_("Close"))
+		self["filelist"] = FileList(currDir, showDirectories = True, showFiles = False, showMountpoints = False, useServiceRef = False)
+
+		self["actions"] = ActionMap(["WizardActions", "DirectionActions", "ColorActions"],
+		{
+			"ok": self.ok,
+			"back": self.cancel,
+			"left": self.left,
+			"right": self.right,
+			"up": self.up,
+			"down": self.down,
+			"green": self.green,
+			"red": self.red
+		}, -1)
+
+		self.onLayoutFinish.append(self.setStartDir)
+
+	def setStartDir(self):
+		if self["filelist"].canDescent():
+			self["filelist"].descent()
+		self.CurrentDirectory = self["filelist"].getCurrentDirectory()
+		self.instance.setTitle(self.CurrentDirectory)
+		self.setPathName()
+
+	def updatePathName(self):
+		if len(self["filelist"].getFilename()) > len(self.CurrentDirectory):
+			self.setPathName()
+		else:
+			self["ButtonGreentext"].hide()
+			self["ButtonGreen"].hide()
+		self.instance.setTitle(self.CurrentDirectory)
+
+	def setPathName(self):
+		self.epath = self["filelist"].getFilename()
+		if len(self.epath) > 1 and self.epath.endswith('/'):
+			self.epath = self.epath[:-1]
+		self["ButtonGreentext"].setText(_("select:") + " " + self.epath)
+		self["ButtonGreentext"].show()
+		self["ButtonGreen"].show()
+
+	def ok(self):
+		if self["filelist"].canDescent():
+			self["filelist"].descent()
+			if len(self["filelist"].getFilename()) > len(self["filelist"].getCurrentDirectory()):
+				self.setPathName()
+			else:
+				self["ButtonGreentext"].hide()
+				self["ButtonGreen"].hide()
+			self.CurrentDirectory = self["filelist"].getCurrentDirectory()
+			self.instance.setTitle(self.CurrentDirectory)
+
+	def up(self):
+		self["filelist"].up()
+		self.updatePathName()
+
+	def down(self):
+		self["filelist"].down()
+		self.updatePathName()
+
+	def left(self):
+		self["filelist"].pageUp()
+		self.updatePathName()
+
+	def right(self):
+		self["filelist"].pageDown()
+		self.updatePathName()
+
+	def cancel(self):
+		self.close(False)
+
+	def red(self):
+		self.close(False)
+
+	def green(self):
+		self.close(self.epath)
Index: /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/plugin.py
===================================================================
--- /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/plugin.py	(revision 14693)
+++ /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/plugin.py	(revision 14693)
@@ -0,0 +1,59 @@
+# -*- coding: utf-8 -*-
+#===============================================================================
+# NetworkServer System Plugin 0.1 by DarkVolli 2009
+#
+# This is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any later
+# version.
+#===============================================================================
+
+# for localized messages Package: nfs-utils Package: sambaserver
+from __init__ import _
+
+from Plugins.Plugin import PluginDescriptor
+from setupSamba import setupSamba
+from setupNfs import setupNfs
+
+plugin_path = ""
+
+def isInstalled(package):
+	package = 'Package: ' + package
+	try:
+		f = open('/usr/lib/ipkg/status', 'r')
+		for line in f:
+			if line.strip() == package:
+				f.close()
+				return True
+	except IOError:
+		pass
+
+	return False
+
+def setupSambaMain(session, iface = None, **kwargs):
+	session.open(setupSamba, iface, plugin_path)
+
+def setupNfsMain(session, iface = None, **kwargs):
+	session.open(setupNfs, iface, plugin_path)
+
+def setupSambaCallFunction(iface):
+	return setupSambaMain
+#	if isInstalled('sambaserver') and not isInstalled('samba'): #ipkg package samba starts with init, not valid at this time...
+#		return setupSambaMain
+#	else:
+#		return None
+
+def setupNfsCallFunction(iface):
+	return setupNfsMain
+#	if isInstalled('nfs-utils'):
+#		return setupNfsMain
+#	else:
+#		return None
+
+def Plugins(path, **kwargs):
+	global plugin_path
+	plugin_path = path
+	return [
+		PluginDescriptor(name=_("setupSamba"), description=_("Activate and configurate your Samba-Server"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": setupSambaCallFunction, "menuEntryName": lambda x: _("Samba-Server Setup"), "menuEntryDescription": lambda x: _("Start/Stop and manage your Samba-Server...\n")}),
+		PluginDescriptor(name=_("setupNFS"), description=_("Activate and configurate your NFS-Server"), where = PluginDescriptor.WHERE_NETWORKSETUP, fnc={"ifaceSupported": setupNfsCallFunction, "menuEntryName": lambda x: _("NFS-Server Setup"), "menuEntryDescription": lambda x: _("Start/Stop and manage your NFS-Server...\n")})
+	]
Index: /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/setupNfs.py
===================================================================
--- /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/setupNfs.py	(revision 14693)
+++ /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/setupNfs.py	(revision 14693)
@@ -0,0 +1,454 @@
+# -*- coding: utf-8 -*-
+#===============================================================================
+# Setup NFS-Server 0.3 by DarkVolli 2009
+#
+# This is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any later
+# version.
+#===============================================================================
+
+# for localized messages
+from __init__ import _
+
+from Screens.Screen import Screen
+from Screens.MessageBox import MessageBox
+
+from Components.ActionMap import ActionMap
+from Components.Pixmap import Pixmap
+from Components.Label import Label
+from Components.Button import Button
+from Components.ConfigList import ConfigListScreen
+
+from Components.config import NoSave
+from Components.config import ConfigEnableDisable
+from Components.config import ConfigSelection
+from Components.config import ConfigText
+from Components.config import ConfigIP
+from Components.config import ConfigDirectory
+from Components.config import getConfigListEntry
+
+from Components.Sources.List import List
+
+from dirSelect import dirSelectDlg
+
+from enigma import eConsoleAppContainer
+import os
+from os import path
+
+def isRunning(pname):
+	for f in os.listdir('/proc'):
+		try:
+			cmdline = open(path.join('/', 'proc', f, 'status'), 'r')
+			if pname in cmdline.read():
+				cmdline.close()
+				return True
+		except IOError:
+			pass
+	return False
+
+class editExportEntry(Screen, ConfigListScreen): # 90,140
+	skin = """	
+		<screen name="editExportEntry" position="center,center" size="560,350" title="edit Export Entry">
+			<widget name="config" position="10,10" size="540,150" scrollbarMode="showOnDemand" />
+			<widget name="ButtonGreentext" position="50,270" size="460,21" halign="left" zPosition="10" font="Regular;21" transparent="1" />
+			<widget name="ButtonGreen" pixmap="skin_default/buttons/button_green.png" position="30,273" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+			<widget name="ButtonRedtext" position="50,300" size="460,21" halign="left" zPosition="10" font="Regular;21" transparent="1" />
+			<widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="30,303" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+		</screen>"""
+
+	def __init__(self, session, exportDir, client, options):
+		self.skin = editExportEntry.skin		
+		self.session = session
+		Screen.__init__(self, session)
+
+		nfsoptions = [\
+		"ro,sync",
+		"rw,sync",
+		"ro,async",
+		"rw,async",
+		"ro,no_root_squash",
+		"rw,no_root_squash",
+		"ro,no_subtree_check",
+		"rw,no_subtree_check",
+		"ro,insecure",
+		"rw,insecure",
+		"ro,insecure,no_subtree_check",
+		"rw,insecure,no_subtree_check",
+		"ro,sync,no_subtree_check",
+		"rw,sync,no_subtree_check",
+		"ro,async,no_subtree_check",
+		"rw,async,no_subtree_check",
+		"ro,no_root_squash,no_subtree_check",
+		"rw,no_root_squash,no_subtree_check",
+		"ro,no_root_squash,sync",
+		"rw,no_root_squash,sync",
+		"ro,no_root_squash,sync,no_subtree_check",
+		"rw,no_root_squash,sync,no_subtree_check",
+		"ro,no_root_squash,async",
+		"rw,no_root_squash,async",
+		"ro,no_root_squash,async,no_subtree_check",
+		"rw,no_root_squash,async,no_subtree_check"]
+
+		# create dictionary for optionsConfigEntry...
+		optionsEntrys = {}
+		for x in nfsoptions:
+			optionsEntrys[x] = x
+
+		clientIP = [192, 168, 0, 0]
+		self.netmask = ''
+
+		tmp = client.split('/')
+		if len(tmp) > 1: #is there a netmask?
+			client = tmp[0] #if yes - cut netmask
+			self.netmask = tmp[1]
+
+		if client == '*':
+			everyIP = True
+		else:
+			everyIP = False
+			theIP = client.split('.')
+			clientIP = []
+			for x in theIP:
+				clientIP.append(int(x))
+
+		self.exportDirConfigEntry = NoSave(ConfigDirectory(exportDir))
+		self.everyIPConfigEntry = NoSave(ConfigEnableDisable(default = everyIP))
+		self.clientConfigEntry = NoSave(ConfigIP(clientIP))
+		self.optionsConfigEntry = NoSave(ConfigSelection(optionsEntrys, options))
+
+		ConfigListScreen.__init__(self, [])
+		self.createSetup()
+		self.everyIPConfigEntry.addNotifier(self.toggleEveryIP)
+
+		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
+		{
+			"cancel": self.cancel,
+			"red"   : self.cancel,
+			"green" : self.green,
+			"ok"    : self.ok
+		}, -2)
+
+		self["ButtonGreen"] = Pixmap()
+		self["ButtonGreentext"] = Label(_("Save and Close"))
+		self["ButtonRed"] = Pixmap()
+		self["ButtonRedtext"] = Label(_("Close"))
+
+	def createSetup(self):
+		self.list = []
+		self.list.append(getConfigListEntry(_("export directory"), self.exportDirConfigEntry))
+		self.list.append(getConfigListEntry(_("every ip"), self.everyIPConfigEntry))
+		if not self.everyIPConfigEntry.value:
+			self.list.append(getConfigListEntry(_("client ip"), self.clientConfigEntry))
+		self.list.append(getConfigListEntry(_("options"), self.optionsConfigEntry))
+		self["config"].setList(self.list)
+
+	def toggleEveryIP(self, configElement):
+		self.createSetup()
+
+	def cancel(self):
+		self.close(False)
+
+	def ok(self):
+		if self["config"].getCurrent()[1] == self.exportDirConfigEntry:
+			self.session.openWithCallback(self.dirSelectDlgClosed, dirSelectDlg, self.exportDirConfigEntry.value+'/')
+
+	def dirSelectDlgClosed(self, path):
+		if path != False:
+			if path.endswith('/'):
+				path = path[:-1]
+			self.exportDirConfigEntry.setValue(path)
+
+	def green(self):
+		data = []
+		data.append(self.exportDirConfigEntry.value)
+		if self.everyIPConfigEntry.value:
+			ipdata = '*'
+		else:
+			ipdata = "%d.%d.%d.%d" % tuple(self.clientConfigEntry.value)
+		if len(self.netmask) > 0:
+			ipdata = ipdata + "/" + self.netmask
+		data.append(ipdata)
+		data.append(self.optionsConfigEntry.value)
+		self.close(data)
+
+class setupNfs(Screen, ConfigListScreen): # 90,140
+	skin = """
+		<screen name="setupNfs" position="center,center" size="560,350" title="setup NFS-Server">
+			<widget name="config" position="10,10" size="540,30" scrollbarMode="showOnDemand" />
+			<widget source="exportlist" render="Listbox" position="10,50" size="540,100" scrollbarMode="showOnDemand">
+				<convert type="TemplatedMultiContent">
+					{"template": [
+						MultiContentEntryText(pos = (0, 13), size = (200, 25), font=0, flags = RT_HALIGN_LEFT, text = 0), # index 0 is the exportdir
+						MultiContentEntryText(pos = (210, 3), size = (330, 18), font=1, flags = RT_HALIGN_LEFT, text = 1), # index 1 is the client
+						MultiContentEntryText(pos = (210, 28), size = (330, 18), font=1, flags = RT_HALIGN_LEFT, text = 2), # index 2 is the options
+					],
+					"fonts": [gFont("Regular", 20),gFont("Regular", 14)],
+					"itemHeight": 50
+					}
+				</convert>
+			</widget>
+			<widget name="nfsdLabel" position="20,170" size="520,30" font="Regular;21"/>
+			<widget name="portmapLabel" position="20,200" size="520,30" font="Regular;21"/>
+			<widget name="ButtonGreentext" position="50,270" size="460,21" halign="left" zPosition="10" font="Regular;20" transparent="1" />
+			<widget name="ButtonGreen" pixmap="skin_default/buttons/button_green.png" position="30,273" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+			<widget name="ButtonRedtext" position="50,300" size="145,21" halign="left" zPosition="10" font="Regular;20" transparent="1" />
+			<widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="30,303" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+			<widget name="ButtonYellowtext" position="220,300" size="145,21" halign="left" zPosition="10" font="Regular;20" transparent="1" />
+			<widget name="ButtonYellow" pixmap="skin_default/buttons/button_yellow.png" position="200,303" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+			<widget name="ButtonBluetext" position="390,300" size="145,21" halign="left" zPosition="10" font="Regular;20" transparent="1" />
+			<widget name="ButtonBlue" pixmap="skin_default/buttons/button_blue.png" position="370,303" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+		</screen>"""
+
+	def __init__(self, session, iface ,plugin_path):
+		self.skin = setupNfs.skin		
+		self.session = session
+		Screen.__init__(self, session)
+
+		self.container = eConsoleAppContainer()
+		self.container.appClosed.append(self.runFinished)
+		self.container.dataAvail.append(self.dataAvail)
+
+		if isRunning('portmap') and isRunning('nfsd'):
+			isEnabled = True
+		else:
+			isEnabled = False
+
+		self.activeConfigEntry = NoSave(ConfigEnableDisable(default = isEnabled))
+
+		self["nfsdLabel"] = Label()
+		self["portmapLabel"] = Label()
+		self["ButtonGreen"] = Pixmap()
+		self["ButtonGreentext"] = Button(_("save and start/restart NFS-Server"))
+		self["ButtonRed"] = Pixmap()
+		self["ButtonRedtext"] = Label(_("Close"))
+		self["ButtonYellow"] = Pixmap()
+		self["ButtonYellowtext"] = Label(_("New Entry"))
+		self["ButtonBlue"] = Pixmap()
+		self["ButtonBluetext"] = Label(_("Remove Entry"))
+
+		self.startingUp = False
+		self.goingDown = False
+		self.cmdlist = []
+		self.run = 0
+
+		self.exportlist = []
+		data = self.readExports()
+		if data is not None:
+			for line in data:
+				exportDir = line[0]
+				client = line[1]
+				options = line[2]
+				options = options.replace('(', '')
+				options = options.replace(')', '')
+				self.exportlist.append((exportDir, client, options))
+		else:
+#			self.exportlist.append(('/media/hdd', '*', 'rw,no_root_squash,sync'))
+			self.exportlist.append(('/media', '*', 'rw,no_root_squash,sync'))
+
+		self["exportlist"] = List(self.exportlist)
+		self.hideList = self["exportlist"].list
+
+		self.createSetup()
+		ConfigListScreen.__init__(self, self.list, session = session)
+		self.activeConfigEntry.addNotifier(self.toggleServer)
+
+		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
+		{
+			"cancel" : self.cancel,
+			"ok"     : self.editExportEntry,
+			"green"  : self.green,
+			"red   " : self.cancel,
+			"yellow" : self.newExportEntry,
+			"blue"   : self.deleteExportEntry
+		}, -2)
+
+	def readExports(self):
+		try:
+			exportfile = open('/etc/exports', 'r')
+			lines = []
+			for line in exportfile:
+				if line[0] != '#' and line != '\n':
+					tmp = []
+					line = line.replace('\t', ' ')
+					val = line.strip().split(' ')
+					exportdir = val[0].strip()
+					tmp.append(exportdir)
+					line = line[len(exportdir):].strip()
+					val = line.strip().split('(')
+					client = val[0].strip()
+					tmp.append(client)
+					options = line[len(client):].strip()
+					tmp.append(options)
+					lines.append(tmp)
+			return lines
+		except IOError:
+			pass
+			return None
+	
+	def writeExports(self, data):
+		exportfile = open('/etc/exports', 'w')
+		for line in data:
+			exportfile.write(line[0] + ' ' + line[1] + '(' + line[2] + ')' + '\n')
+		exportfile.close()
+
+	def createSetup(self):
+		self.list = []
+		self.list.append(getConfigListEntry(_("Enable/Disable NFS-Server"), self.activeConfigEntry))
+		if self.activeConfigEntry.value:
+			self.exportlistShow()
+			self["nfsdLabel"].show()
+			self["portmapLabel"].show()
+			self["ButtonGreentext"].show()
+			self["ButtonGreen"].show()
+			self["ButtonYellow"].show()
+			self["ButtonYellowtext"].show()
+			self["ButtonBlue"].show()
+			self["ButtonBluetext"].show()
+			if self.goingDown or self.startingUp:
+				if self.goingDown:
+					self["nfsdLabel"].setText(_("Status nfsd: going down..."))
+					self["portmapLabel"].setText(_("Status portmap: going down..."))
+				if self.startingUp:
+					self["nfsdLabel"].setText(_("Status nfsd: starting up..."))
+					self["portmapLabel"].setText(_("Status portmap: starting up..."))
+			else:
+				self.nfsdLabelSet()
+				self.portmapLabelSet()
+		else:
+			self.exportlistHide()
+			self["nfsdLabel"].hide()
+			self["portmapLabel"].hide()
+			self["ButtonGreentext"].hide()
+			self["ButtonGreen"].hide()
+			self["ButtonYellow"].hide()
+			self["ButtonYellowtext"].hide()
+			self["ButtonBlue"].hide()
+			self["ButtonBluetext"].hide()
+
+	def toggleServer(self, configElement):
+		self.createSetup()
+		self["config"].l.setList(self.list)
+		if not configElement.value:
+			if not self.goingDown or not self.startingUp:
+				if isRunning('portmap') and isRunning('nfsd'):
+					self.nfsServerDown()
+
+	def exportlistShow(self):
+		self.exportlist = []
+		for line in self.hideList:
+			self.exportlist.append((line[0], line[1], line[2]))
+		self["exportlist"].setList(self.exportlist)
+
+	def exportlistHide(self):
+		if len(self["exportlist"].list) == 0:
+			return
+		self.hideList = self["exportlist"].list
+		self.exportlist = []
+		self["exportlist"].setList(self.exportlist)
+
+	def cancel(self):
+		if self.run == len(self.cmdlist):
+			self.close()
+			self.container.appClosed.remove(self.runFinished)
+
+	def editExportEntry(self):
+		if self.activeConfigEntry.value:
+			sel = self["exportlist"].getCurrent()
+			if sel:
+				self.tmpList = self["exportlist"].list
+				self.session.openWithCallback(self.editExportEntryClosed, editExportEntry, sel[0], sel[1], sel[2])
+
+	def editExportEntryClosed(self, data):
+		if data:
+			self.tmpList[self["exportlist"].getIndex()] = data
+			self.exportlist = []
+			for line in self.tmpList:
+				self.exportlist.append((line[0], line[1], line[2]))
+			self["exportlist"].setList(self.exportlist)
+
+	def newExportEntry(self):
+		if self.activeConfigEntry.value:
+			self.tmpList = self["exportlist"].list
+			self.session.openWithCallback(self.newExportEntryClosed, editExportEntry, '/media/hdd', '*', 'rw,no_root_squash,sync')
+
+	def newExportEntryClosed(self, data):
+		if data:
+			self.tmpList.append(data)
+			self.exportlist = []
+			for line in self.tmpList:
+				self.exportlist.append((line[0], line[1], line[2]))
+			self["exportlist"].setList(self.exportlist)
+
+	def deleteExportEntry(self):
+		if self.activeConfigEntry.value:
+			if len(self["exportlist"].list) < 2:
+				return
+			self.tmpList = self["exportlist"].list
+			mbox = self.session.openWithCallback(self.deleteExportEntryClosed, MessageBox,_("Really delete this entry?"), MessageBox.TYPE_YESNO)
+			mbox.setTitle(_("delete entry"))
+
+	def deleteExportEntryClosed(self, answer):
+		if answer is True:
+			itemIndex = self["exportlist"].getIndex()
+			self.exportlist = []
+			for cnt, line in enumerate(self.tmpList):
+				if cnt != itemIndex:
+					self.exportlist.append((line[0], line[1], line[2]))
+			self["exportlist"].setList(self.exportlist)			
+
+	def green(self):
+		if self.activeConfigEntry.value:
+			self.nfsServerDown()
+			self.writeExports(self["exportlist"].list)
+			self.nfsServerUp()
+
+	def nfsdLabelSet(self):
+		if isRunning('nfsd'):
+			self["nfsdLabel"].setText(_("Status nfsd: started"))
+		else:
+			self["nfsdLabel"].setText(_("Status nfsd: stopped"))
+
+	def portmapLabelSet(self):
+		if isRunning('portmap'):
+			self["portmapLabel"].setText(_("Status portmap: started"))
+		else:
+			self["portmapLabel"].setText(_("Status portmap: stopped"))
+
+	def dataAvail(self, str):
+		print str,
+
+	def runFinished(self, retval):
+		self.run += 1
+		if self.run != len(self.cmdlist):
+			self.container.execute(self.cmdlist[self.run])
+		else:
+			self.run = 0
+			self.cmdlist = []
+			self.startingUp = False
+			self.goingDown = False
+			self.nfsdLabelSet()
+			self.portmapLabelSet()
+
+	# Thanks to weazle for hints belonging nfs up/down stuff...
+	def nfsServerUp(self):
+		self["nfsdLabel"].setText(_("Status nfsd: starting up..."))
+		self["portmapLabel"].setText(_("Status portmap: starting up..."))
+		self.cmdlist.append("/etc/init.d/portmap start")
+		self.cmdlist.append("/etc/init.d/nfs-kernel-server start")
+#		self.cmdlist.append("update-rc.d -s portmap start 43 S . start 32 0 6 . stop 81 1 .")
+#		self.cmdlist.append("update-rc.d -s nfsserver defaults")
+		self.startingUp = True
+		self.container.execute(self.cmdlist[self.run])
+
+	def nfsServerDown(self):
+		self["nfsdLabel"].setText(_("Status nfsd: going down..."))
+		self["portmapLabel"].setText(_("Status portmap: going down..."))
+		self.cmdlist.append("/etc/init.d/portmap stop")
+#		self.cmdlist.append("/etc/init.d/nfsserver stop")
+		self.cmdlist.append("/etc/init.d/nfs-kernel-server stop")
+#		self.cmdlist.append("update-rc.d -f portmap remove")
+#		self.cmdlist.append("update-rc.d -f nfsserver remove")
+		self.cmdlist.append("killall portmap mountd")
+		self.goingDown = True
+		self.container.execute(self.cmdlist[self.run])
Index: /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/setupSamba.py
===================================================================
--- /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/setupSamba.py	(revision 14693)
+++ /ipk/source/network_networkserver_1_0/usr/lib/enigma2/python/Plugins/SystemPlugins/NetworkServer/setupSamba.py	(revision 14693)
@@ -0,0 +1,301 @@
+# -*- coding: utf-8 -*-
+#===============================================================================
+# Setup Samba-Server 0.2 by DarkVolli 2009
+#
+# This is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation; either version 2, or (at your option) any later
+# version.
+#===============================================================================
+
+# for localized messages
+from __init__ import _
+
+from Screens.Screen import Screen
+from Screens.MessageBox import MessageBox
+
+from Components.ActionMap import ActionMap
+from Components.Pixmap import Pixmap
+from Components.Label import Label
+from Components.Button import Button
+from Components.ConfigList import ConfigListScreen
+
+from Components.config import NoSave
+from Components.config import ConfigEnableDisable
+from Components.config import ConfigText
+from Components.config import getConfigListEntry
+
+from enigma import eConsoleAppContainer
+
+import os
+from os import path
+
+def isRunning(pname):
+	for f in os.listdir('/proc'):
+		try:
+			cmdline = open(path.join('/', 'proc', f, 'status'), 'r')
+			if pname in cmdline.read():
+				cmdline.close()
+				return True
+		except IOError:
+			pass
+	return False
+
+def getAttribute(filename, section, attribute):
+	try:
+		inifile = open(filename, 'r')
+		flag = False
+		for line in inifile:
+			if line[0] == '#' or line[0] == ';':
+				continue
+			if line[0] == '[' and flag:
+				flag = False
+			if '['+section+']' in line:
+				flag = True
+			if attribute in line and flag:
+				value = line.strip().split('=')
+				inifile.close()
+				return value[1].strip()
+	except IOError:
+		pass
+
+	return None
+
+def writeAttribute(filename, section, attribute, value):
+	try:
+		inifile = open(filename, 'r')
+		buf = []
+		flag = False
+		for line in inifile:
+			if line[0] == '[' and flag:
+				flag = False
+			if '['+section+']' in line:
+				flag = True
+			if attribute in line and flag:
+				attrib = line.strip().split('=')
+				newline = "   " + attrib[0].strip() + ' = ' + value
+				buf.append(newline)
+				retval = 1
+			else:
+				buf.append(line.replace('\n', '')) # strip entfernt auch die fuehrenden Leerzeichen
+		inifile.close()
+
+	except IOError:
+		pass
+		return -1
+
+	if retval:
+		inifile = open(filename, 'w')
+		for line in buf:
+			inifile.write(line + '\n')
+		inifile.close()
+		return retval
+	else:
+		return 0
+
+class setupSamba(Screen, ConfigListScreen): # 90,140
+	skin = """
+		<screen name="setupSamba" position="center,center" size="560,350" title="setup Samba-Server">
+			<widget name="config" position="10,10" size="540,150" scrollbarMode="showOnDemand" />
+			<widget name="smbdLabel" position="20,160" size="520,30" font="Regular;21"/>
+			<widget name="nmbdLabel" position="20,190" size="520,30" font="Regular;21"/>
+			<widget name="ButtonGreentext" position="50,270" size="460,21" halign="left" zPosition="10" font="Regular;21" transparent="1" />
+			<widget name="ButtonGreen" pixmap="skin_default/buttons/button_green.png" position="30,273" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+			<widget name="ButtonRedtext" position="50,300" size="460,21" halign="left" zPosition="10" font="Regular;21" transparent="1" />
+			<widget name="ButtonRed" pixmap="skin_default/buttons/button_red.png" position="30,303" zPosition="10" size="15,16" transparent="1" alphatest="on" />
+		</screen>"""
+
+	def __init__(self, session, iface ,plugin_path):
+		self.skin = setupSamba.skin		
+		self.session = session
+		Screen.__init__(self, session)
+
+		self.container = eConsoleAppContainer()
+		self.container.appClosed.append(self.runFinished)
+		self.container.dataAvail.append(self.dataAvail)
+
+		if isRunning('smbd') and isRunning('nmbd'):
+			isEnabled = True
+		else:
+			isEnabled = False
+
+		confError = False
+		tmp = getAttribute('/var/etc/smb.conf', 'global', 'server string')
+		if tmp is not None:
+			serverString = tmp
+		else:
+			serverString = 'READERROR server string'
+			confError = True
+
+		tmp = getAttribute('/var/etc/smb.conf', 'global', 'netbios name')
+		if tmp is not None:
+			netbiosName = tmp
+		else:
+			netbiosName = 'READERROR netbios name'
+			confError = True
+
+		tmp = getAttribute('/var/etc/smb.conf', 'global', 'workgroup')
+		if tmp is not None:
+			workgroup = tmp
+		else:
+			workgroup = 'READERROR workgroup'
+			confError = True
+
+		self.activeConfigEntry = NoSave(ConfigEnableDisable(default = isEnabled))
+		self.serverStringConfigEntry = NoSave(ConfigText(default = serverString, visible_width = 50, fixed_size = False))
+		self.netbiosNameConfigEntry = NoSave(ConfigText(default = netbiosName, visible_width = 50, fixed_size = False))
+		self.workgroupConfigEntry = NoSave(ConfigText(default = workgroup, visible_width = 50, fixed_size = False))
+
+		self["smbdLabel"] = Label()
+		self["nmbdLabel"] = Label()
+		self["ButtonGreen"] = Pixmap()
+		self["ButtonGreentext"] = Button(_("save and start/restart Samba-Server"))
+		self["ButtonRed"] = Pixmap()
+		self["ButtonRedtext"] = Label(_("Close"))
+
+		self.startingUp = False
+		self.goingDown = False
+		self.cmdlist = []
+		self.run = 0
+
+		self.createSetup()
+		ConfigListScreen.__init__(self, self.list, session = session)
+		self.activeConfigEntry.addNotifier(self.toggleServer)
+
+		self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
+		{
+			"cancel": self.cancel,
+			"red"   : self.cancel,
+			"green" : self.green
+		}, -2)
+
+		if confError:
+			self.onExecBegin.append(self.errorMbox)
+
+	def errorMbox(self):
+		info = self.session.open(MessageBox,_("/var/etc/smb.conf not found or readerror!"), MessageBox.TYPE_ERROR)
+		info.setTitle("setup Samba-Server")
+		self.close()
+
+	def createSetup(self):
+		self.list = []
+		self.list.append(getConfigListEntry(_("Enable/Disable Samba-Server"), self.activeConfigEntry))
+		if self.activeConfigEntry.value:
+			self.list.append(getConfigListEntry(_("server string"), self.serverStringConfigEntry))
+			self.list.append(getConfigListEntry(_("netbios name"), self.netbiosNameConfigEntry))
+			self.list.append(getConfigListEntry(_("workgroup"), self.workgroupConfigEntry))
+			self["smbdLabel"].show()
+			self["nmbdLabel"].show()
+			self["ButtonGreentext"].show()
+			self["ButtonGreen"].show()
+			if self.goingDown or self.startingUp:
+				if self.goingDown:
+					self["smbdLabel"].setText(_("Status smbd: going down..."))
+					self["nmbdLabel"].setText(_("Status nmbd: going down..."))
+				if self.startingUp:
+					self["smbdLabel"].setText(_("Status smbd: starting up..."))
+					self["nmbdLabel"].setText(_("Status nmbd: starting up..."))
+			else:
+				self.smbdLabelSet()
+				self.nmbdLabelSet()
+		else:
+			self["smbdLabel"].hide()
+			self["nmbdLabel"].hide()
+			self["ButtonGreentext"].hide()
+			self["ButtonGreen"].hide()
+
+	def toggleServer(self, configElement):
+		self.createSetup()
+		self["config"].l.setList(self.list)
+		if not configElement.value:
+			if not self.goingDown or not self.startingUp:
+				if isRunning('smbd') or isRunning('nmbd'):
+					self.sambaDown()
+					self.deleteScripts()
+
+	def cancel(self):
+		if self.run == len(self.cmdlist):
+			self.close()
+			self.container.appClosed.remove(self.runFinished)
+
+	def green(self):
+		if self.activeConfigEntry.value:
+			self.sambaDown()
+	
+			confError = 0
+			confError += writeAttribute('/var/etc/smb.conf', 'global', 'server string', self.serverStringConfigEntry.value)
+			confError += writeAttribute('/var/etc/smb.conf', 'global', 'netbios name', self.netbiosNameConfigEntry.value)
+			confError += writeAttribute('/var/etc/smb.conf', 'global', 'workgroup', self.workgroupConfigEntry.value)
+			if confError < 3:
+				info = self.session.open(MessageBox,_("/var/etc/smb.conf not found or writeerror!"), MessageBox.TYPE_ERROR)
+				info.setTitle("setup Samba-Server")
+				self.cancel()
+			else:
+				self.sambaUp()
+				self.createUpScript()
+				self.createDownScript()
+
+	def smbdLabelSet(self):
+		if isRunning('smbd'):
+			self["smbdLabel"].setText(_("Status smbd: started"));
+		else:
+			self["smbdLabel"].setText(_("Status smbd: stopped"));
+
+	def nmbdLabelSet(self):
+		if isRunning('nmbd'):
+			self["nmbdLabel"].setText(_("Status nmbd: started"));
+		else:
+			self["nmbdLabel"].setText(_("Status nmbd: stopped"));
+
+	def dataAvail(self, str):
+		print str,
+
+	def runFinished(self, retval):
+		self.run += 1
+		if self.run != len(self.cmdlist):
+			self.container.execute(self.cmdlist[self.run])
+		else:
+			self.run = 0
+			self.cmdlist = []
+			self.startingUp = False
+			self.goingDown = False
+			self.smbdLabelSet()
+			self.nmbdLabelSet()
+
+	def sambaUp(self):
+		self["smbdLabel"].setText(_("Status smbd: starting up..."))
+		self["nmbdLabel"].setText(_("Status nmbd: starting up..."))
+		self.cmdlist.append("/var/bin/nmbd -D")
+		self.cmdlist.append("/var/bin/smbd -D")
+		self.startingUp = True
+		self.container.execute(self.cmdlist[self.run])
+
+	def sambaDown(self):
+		self["smbdLabel"].setText(_("Status smbd: going down..."))
+		self["nmbdLabel"].setText(_("Status nmbd: going down..."))
+		self.cmdlist.append("killall -9 smbd")
+		self.cmdlist.append("killall -9 nmbd")
+		self.goingDown = True
+		self.container.execute(self.cmdlist[self.run])
+
+	def createUpScript(self):
+		scriptfile= open("/etc/network/if-up.d/01samba-start", "w")
+		scriptfile.write("#!/bin/sh\n")
+		scriptfile.write("nmbd -D\n")
+		scriptfile.write("smbd -D\n")
+		scriptfile.close()
+		os.system("chmod 755 /etc/network/if-up.d/01samba-start")
+
+	def createDownScript(self):
+		scriptfile= open("/etc/network/if-down.d/01samba-kill", "w")
+		scriptfile.write("#!/bin/sh\n")
+		scriptfile.write("killall -9 smbd\n")
+		scriptfile.write("rm -rf /var/log/log.smbd\n")
+		scriptfile.write("killall -9 nmbd\n")
+		scriptfile.write("rm -rf /var/log/log.nmbd\n")
+		scriptfile.close()
+		os.system("chmod 755 /etc/network/if-down.d/01samba-kill")
+
+	def deleteScripts(self):
+		os.system("rm -rf /etc/network/if-up.d/01samba-start")
+		os.system("rm -rf /etc/network/if-down.d/01samba-kill")
