from Components.ActionMap import ActionMap
from Components.config import config, getConfigListEntry, ConfigSubsection, \
ConfigText, ConfigPassword, ConfigYesNo, ConfigSelection, ConfigSet, \
- ConfigSubList, NoSave
+ ConfigSubList, ConfigNumber, NoSave
from Components.ConfigList import ConfigListScreen
from Components.Sources.StaticText import StaticText
growlee.hostcount = ConfigNumber(default=0)
growlee.hosts = ConfigSubList()
-i = 0
-while i < growlee.hostcount.value:
+def addHost(idx):
s = ConfigSubsection()
- s.name = ConfigText(default=str(i+1), fixed_size=False)
+ s.name = ConfigText(default=str(idx+1), fixed_size=False)
s.enable_incoming = ConfigYesNo(default=False)
s.enable_outgoing = ConfigYesNo(default=False)
s.address = ConfigText(fixed_size=False)
s.protocol = ConfigSelection(default="growl", choices=[("growl", "Growl"), ("snarl", "Snarl"), ("prowl", "Prowl")])
s.level = ConfigSelection(default="-1", choices=[("-1", _("Low (Yes/No)")), ("0", _("Normal (Information)")), ("1", _("High (Warning)")), ("2", _("Highest (Emergency)"))])
s.blacklist = ConfigSet(choices=[])
- growlee.hosts.append(s)
+ config.plugins.growlee.hosts.append(s)
+ return s
+
+i = 0
+while i < growlee.hostcount.value:
+ addHost(i)
i += 1
- del s
# XXX: change to new config format
-growlee.enable_outgoing = ConfigYesNo(default=False)
-if growlee.hostcount.value == 0 and growlee.enable_outgoing.value:
+# NOTE: after some time, remove this and hardcode default length to 1
+# since internally we assume to have at least 1 host configured
+if growlee.hostcount.value == 0:
+ growlee.enable_outgoing = ConfigYesNo(default=False)
growlee.enable_incoming = ConfigYesNo(default=False)
growlee.address = ConfigText(fixed_size=False)
growlee.password = ConfigPassword()
if growlee.protocol.value == "prowl":
password = growlee.prowl_api_key.value
- s = ConfigSubsection()
- s.name = ConfigText(default="1", fixed_size=False)
- s.enable_incoming = ConfigYesNo(default=False)
- s.enable_outgoing = ConfigYesNo(default=False)
- s.address = ConfigText(fixed_size=False)
- s.password = ConfigPassword()
- s.protocol = ConfigSelection(default="growl", choices=[("growl", "Growl"), ("snarl", "Snarl"), ("prowl", "Prowl")])
- s.level = ConfigSelection(default="-1", choices=[("-1", _("Low (Yes/No)")), ("0", _("Normal (Information)")), ("1", _("High (Warning)")), ("2", _("Highest (Emergency)"))])
- s.blacklist = ConfigSet(choices=[])
-
+ s = addHost(0)
s.enable_incoming.value = growlee.enable_incoming.value
s.enable_outgoing.value = growlee.enable_outgoing.value
s.address.value = growlee.address.value
growlee.blacklist.value = []
growlee.hostcount.value += 1
- growlee.hosts.append(s)
-
growlee.save()
del s
session=session,
on_change=self.changed
)
+ self.cur = self.hostElement.value
# Trigger change
self.setupList()
if self.setupList in last.protocol.notifiers:
last.protocol.notifiers.remove(self.setupList)
cur = self.hostElement.value
+ self.cur = cur
cur.protocol.notifiers.append(self.setupList)
l = [
def keySave(self):
if self["config"].isChanged():
- def maybeConnect(*args, **kwargs):
- if config.plugins.growlee.enable_incoming.value or config.plugins.growlee.enable_outgoing.value:
- growleeConnection.listen()
+ def doConnect(*args, **kwargs):
+ growleeConnection.listen()
d = growleeConnection.stop()
if d is not None:
- d.addCallback(maybeConnect).addErrback(emergencyDisable)
+ d.addCallback(doConnect).addErrback(emergencyDisable)
else:
maybeConnect()
self.close()
def close(self):
- config.plugins.growlee.protocol.notifiers.remove(self.setupList)
+ if self.setupList in self.cur.protocol.notifiers:
+ self.cur.protocol.notifiers.remove(self.setupList)
Screen.close(self)
def configuration(session, **kwargs):
# may remove the notifications from the list for good
Notifications.notificationAdded.insert(0, gotNotification)
- if config.plugins.growlee.enable_incoming.value or config.plugins.growlee.enable_outgoing.value:
- growleeConnection.listen()
+ growleeConnection.listen()
def Plugins(**kwargs):
return [