- # notify packet
- if data[1] == '\x01':
- nlen, tlen, dlen, alen = unpack("!HHHH",str(data[4:12]))
- notification, title, description = unpack(("%ds%ds%ds") % (nlen, tlen, dlen), data[12:Len-alen-16])
+ Len = len(data)
+ if proto == "growl":
+ if Len < 16:
+ return
+
+ digest = data[-16:]
+ password = config.plugins.growlee.password.value
+ checksum = md5_constructor()
+ checksum.update(data[:-16])
+ if password:
+ checksum.update(password)
+ if digest != checksum.digest():
+ return
+
+ # notify packet
+ if data[1] == '\x01':
+ nlen, tlen, dlen, alen = unpack("!HHHH",str(data[4:12]))
+ notification, title, description = unpack("%ds%ds%ds" % (nlen, tlen, dlen), data[12:Len-alen-16])
+
+ Notifications.AddNotificationWithID(
+ NOTIFICATIONID,
+ MessageBox,
+ text = title + '\n' + description,
+ type = MessageBox.TYPE_INFO,
+ timeout = 5,
+ close_on_any_key = True,
+ )
+
+ # TODO: do we want to handle register packets? :-)
+ else: #proto == "snarl":
+ if Len < 23 or not data[:23] == "type=SNP#?version=1.0#?":
+ return
+
+ items = data[23:].split('#?')
+
+ title = ''
+ description = ''
+ timeout = 5
+ for item in items:
+ key, value = item.split('=')
+ if key == "action":
+ if value != "notification":
+ # NOTE: we pretent to accept pretty much everything one throws at us
+ addr = (config.plugins.growlee.address.value, GROWL_UDP_PORT)
+ payload = "SNP/1.0/0/OK\r\n"
+ try:
+ self.transport.write(payload, addr)
+ except gaierror:
+ emergencyDisable()
+ return
+ elif key == "title":
+ title = value
+ elif key == "text":
+ description = value
+ elif key == "timeout":
+ timeout = int(value)