Code reorganisation
authorMichael Schmidt <drmichael@users.schwerkraft.elitedvb.net>
Sun, 22 Jun 2008 10:03:18 +0000 (10:03 +0000)
committerMichael Schmidt <drmichael@users.schwerkraft.elitedvb.net>
Sun, 22 Jun 2008 10:03:18 +0000 (10:03 +0000)
New:
- nice buttons to end the config dialog :-)
- added Flash as location for the Phonebook.txt
- support for locales

Fixes:
- the display of a call 0 to 0 should be history

fritzcall/CONTROL/control
fritzcall/Makefile.am
fritzcall/po/FritzCall.pot [new file with mode: 0644]
fritzcall/po/Makefile.am [new file with mode: 0644]
fritzcall/po/de.po [new file with mode: 0644]
fritzcall/src/Makefile.am
fritzcall/src/plugin.py

index 0f5c7f4..5049e67 100644 (file)
@@ -1,5 +1,5 @@
 Package: enigma2-plugin-extensions-fritzcall
-Version: 1.5-20070909-r0
+Version: 1.6-20080626-r0
 Description: Show Incoming and Outgoing Calls on your TV Screen with a Fritz!Box
 Architecture: mipsel
 Section: extra
index af437a6..dd6709f 100644 (file)
@@ -1 +1 @@
-SUBDIRS = src
+SUBDIRS = src po
diff --git a/fritzcall/po/FritzCall.pot b/fritzcall/po/FritzCall.pot
new file mode 100644 (file)
index 0000000..880b9c8
--- /dev/null
@@ -0,0 +1,197 @@
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
+# This file is distributed under the same license as the PACKAGE package.
+# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-06-22 11:54+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=CHARSET\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../plugin.py:45
+msgid "Flash"
+msgstr ""
+
+#: ../plugin.py:45
+msgid "USB Stick"
+msgstr ""
+
+#: ../plugin.py:45
+msgid "CF Drive"
+msgstr ""
+
+#: ../plugin.py:45
+msgid "Harddisk"
+msgstr ""
+
+#: ../plugin.py:67
+#, python-format
+msgid "Fritz!Box Login failed! - Error: %s"
+msgstr ""
+
+#: ../plugin.py:71
+#, python-format
+msgid "Could not load phonebook from Fritz!Box - Error: %s"
+msgstr ""
+
+#: ../plugin.py:109
+msgid "mobile"
+msgstr ""
+
+#: ../plugin.py:111
+msgid "home"
+msgstr ""
+
+#: ../plugin.py:113
+msgid "work"
+msgstr ""
+
+#: ../plugin.py:116 ../plugin.py:137
+msgid "Shortcut"
+msgstr ""
+
+#: ../plugin.py:118 ../plugin.py:139
+msgid "Vanity"
+msgstr ""
+
+#: ../plugin.py:144
+msgid "Could not parse Fritz!Box Phonebook entry"
+msgstr ""
+
+#: ../plugin.py:186
+msgid "Fritz!Box Login failed! - Wrong Password!"
+msgstr ""
+
+#: ../plugin.py:261
+msgid "You need to enable the monitoring on your Fritz!Box by dialing #96*5*!"
+msgstr ""
+
+#: ../plugin.py:265
+msgid "Cancel"
+msgstr ""
+
+#: ../plugin.py:266
+msgid "OK"
+msgstr ""
+
+#: ../plugin.py:289
+msgid "Call monitoring"
+msgstr ""
+
+#: ../plugin.py:291
+msgid "Fritz!Box FON IP address"
+msgstr ""
+
+#: ../plugin.py:293
+msgid "Show Calls for specific MSN"
+msgstr ""
+
+#: ../plugin.py:295
+msgid "MSN to show"
+msgstr ""
+
+#: ../plugin.py:297
+msgid "Show Outgoing Calls"
+msgstr ""
+
+#: ../plugin.py:298
+msgid "Timeout for Call Notifications (seconds)"
+msgstr ""
+
+#: ../plugin.py:299
+msgid "Reverse Lookup Caller ID (DE only)"
+msgstr ""
+
+#: ../plugin.py:301
+msgid "Read PhoneBook from Fritz!Box"
+msgstr ""
+
+#: ../plugin.py:303
+msgid "Password Accessing Fritz!Box"
+msgstr ""
+
+#: ../plugin.py:305
+msgid "Use internal PhoneBook"
+msgstr ""
+
+#: ../plugin.py:307
+msgid "PhoneBook Location"
+msgstr ""
+
+#: ../plugin.py:308
+msgid "Automatically add new Caller to PhoneBook"
+msgstr ""
+
+#: ../plugin.py:310
+msgid "Strip Leading 0"
+msgstr ""
+
+#: ../plugin.py:311
+msgid "Prefix for Outgoing Calls"
+msgstr ""
+
+#: ../plugin.py:326
+msgid "Can't create PhoneBook.txt"
+msgstr ""
+
+#: ../plugin.py:358 ../plugin.py:471
+#, python-format
+msgid ""
+"Incoming Call on %s from\n"
+"---------------------------------------------\n"
+"%s\n"
+"%s\n"
+"---------------------------------------------\n"
+"to: %s"
+msgstr ""
+
+#: ../plugin.py:360 ../plugin.py:473
+#, python-format
+msgid ""
+"Outgoing Call on %s to\n"
+"---------------------------------------------\n"
+"%s\n"
+"%s\n"
+"---------------------------------------------\n"
+"from: %s"
+msgstr ""
+
+#: ../plugin.py:425 ../plugin.py:452 ../plugin.py:514
+msgid "UNKNOWN"
+msgstr ""
+
+#: ../plugin.py:527
+msgid "Connecting to Fritz!Box..."
+msgstr ""
+
+#: ../plugin.py:530
+msgid "Connected to Fritz!Box!"
+msgstr ""
+
+#: ../plugin.py:536
+#, python-format
+msgid ""
+"Connection to Fritz!Box! lost\n"
+" (%s)\n"
+"retrying..."
+msgstr ""
+
+#: ../plugin.py:540
+#, python-format
+msgid ""
+"Connecting to Fritz!Box failed\n"
+" (%s)\n"
+"retrying..."
+msgstr ""
+
+#: ../plugin.py:588 ../plugin.py:591
+msgid "Display Fritzbox-Fon calls on screen"
+msgstr ""
diff --git a/fritzcall/po/Makefile.am b/fritzcall/po/Makefile.am
new file mode 100644 (file)
index 0000000..946a127
--- /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=FritzCall
+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/fritzcall/po/de.po b/fritzcall/po/de.po
new file mode 100644 (file)
index 0000000..e60a054
--- /dev/null
@@ -0,0 +1,219 @@
+# FritzCall plugin german localization
+# Copyright (C) 2008 Michael Schmidt
+# This file is distributed under the same license as the PACKAGE package.
+# Michael Schmidt <michael@schmidt-schmitten.com>, 2008.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: Enigma2 FritzCall Plugin\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2008-06-22 11:54+0200\n"
+"PO-Revision-Date: 2008-06-22 11:57+0200\n"
+"Last-Translator: Michael Schmidt <michael@schmidt-schmitten.com>\n"
+"Language-Team: german <de@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+
+#: ../plugin.py:45
+msgid "Flash"
+msgstr "Flash"
+
+#: ../plugin.py:45
+msgid "USB Stick"
+msgstr "USB Stick"
+
+#: ../plugin.py:45
+msgid "CF Drive"
+msgstr "CF Laufwerk"
+
+#: ../plugin.py:45
+msgid "Harddisk"
+msgstr "Festplatte"
+
+#: ../plugin.py:67
+#, python-format
+msgid "Fritz!Box Login failed! - Error: %s"
+msgstr "Fritz!Box Login fehlgeschlagen! - Fehler: %s"
+
+#: ../plugin.py:71
+#, python-format
+msgid "Could not load phonebook from Fritz!Box - Error: %s"
+msgstr "Konnte Telefonbuch nicht von Fritz!Box laden - Fehler: %s"
+
+#: ../plugin.py:109
+msgid "mobile"
+msgstr "mobil"
+
+#: ../plugin.py:111
+msgid "home"
+msgstr "privat"
+
+#: ../plugin.py:113
+msgid "work"
+msgstr "geschäftlich"
+
+#: ../plugin.py:116 ../plugin.py:137
+msgid "Shortcut"
+msgstr "Kurzwahl"
+
+#: ../plugin.py:118 ../plugin.py:139
+msgid "Vanity"
+msgstr "Vanity"
+
+#: ../plugin.py:144
+msgid "Could not parse Fritz!Box Phonebook entry"
+msgstr "Konnte Eintrag in Frritz!Box-Telefonbuch nicht lesen"
+
+#: ../plugin.py:186
+msgid "Fritz!Box Login failed! - Wrong Password!"
+msgstr "Fritz!Box Login fehlgeschlagen! - Falsches Passwort"
+
+#: ../plugin.py:261
+msgid "You need to enable the monitoring on your Fritz!Box by dialing #96*5*!"
+msgstr ""
+"Monitoring auf der Fritz!Box muss durch Wählen von #96*5* eingeschaltet "
+"werden!"
+
+#: ../plugin.py:265
+msgid "Cancel"
+msgstr "Abbruch"
+
+#: ../plugin.py:266
+msgid "OK"
+msgstr "OK"
+
+#: ../plugin.py:289
+msgid "Call monitoring"
+msgstr "Anrufanzeige"
+
+#: ../plugin.py:291
+msgid "Fritz!Box FON IP address"
+msgstr "Fritz!Box FON IP-Adresse"
+
+#: ../plugin.py:293
+msgid "Show Calls for specific MSN"
+msgstr "Zeige nur Anrufe bestimmter Nummern"
+
+#: ../plugin.py:295
+msgid "MSN to show"
+msgstr "anzuzeigende MSN"
+
+#: ../plugin.py:297
+msgid "Show Outgoing Calls"
+msgstr "Zeige ausgehende Anrufe an"
+
+#: ../plugin.py:298
+msgid "Timeout for Call Notifications (seconds)"
+msgstr "Anzeigedauer in Sekunden"
+
+#: ../plugin.py:299
+msgid "Reverse Lookup Caller ID (DE only)"
+msgstr "Rückwärtssuche (nur DE)"
+
+#: ../plugin.py:301
+msgid "Read PhoneBook from Fritz!Box"
+msgstr "Telefonbuch der Fritz!Box auslesen"
+
+#: ../plugin.py:303
+msgid "Password Accessing Fritz!Box"
+msgstr "Passwort der Fritz!Box"
+
+#: ../plugin.py:305
+msgid "Use internal PhoneBook"
+msgstr "Benutze internes Telefonbuch"
+
+#: ../plugin.py:307
+msgid "PhoneBook Location"
+msgstr "Speicherort des Telefonbuchs"
+
+#: ../plugin.py:308
+msgid "Automatically add new Caller to PhoneBook"
+msgstr "Anrufer automatisch dem Telefonbuch hinzufügen"
+
+#: ../plugin.py:310
+msgid "Strip Leading 0"
+msgstr "Führende 0 entfernen"
+
+#: ../plugin.py:311
+msgid "Prefix for Outgoing Calls"
+msgstr "Vorwahl für ausgehende Anrufe"
+
+#: ../plugin.py:326
+msgid "Can't create PhoneBook.txt"
+msgstr "Kann Phonebook.txt nicht anlegen"
+
+#: ../plugin.py:358 ../plugin.py:471
+#, python-format
+msgid ""
+"Incoming Call on %s from\n"
+"---------------------------------------------\n"
+"%s\n"
+"%s\n"
+"---------------------------------------------\n"
+"to: %s"
+msgstr ""
+"Eingehender Anruf um %s von\n"
+"---------------------------------------------\n"
+"%s\n"
+"%s\n"
+"---------------------------------------------\n"
+"an: %s"
+
+#: ../plugin.py:360 ../plugin.py:473
+#, python-format
+msgid ""
+"Outgoing Call on %s to\n"
+"---------------------------------------------\n"
+"%s\n"
+"%s\n"
+"---------------------------------------------\n"
+"from: %s"
+msgstr ""
+"Abgehender Anruf um %s an\n"
+"---------------------------------------------\n"
+"%s\n"
+"%s\n"
+"---------------------------------------------\n"
+"von: %s"
+
+#: ../plugin.py:425 ../plugin.py:452 ../plugin.py:514
+msgid "UNKNOWN"
+msgstr "UNBEKANNT"
+
+#: ../plugin.py:527
+msgid "Connecting to Fritz!Box..."
+msgstr "Verbinde mit Fritz!Box..."
+
+#: ../plugin.py:530
+msgid "Connected to Fritz!Box!"
+msgstr "Verbunden mit Fritz!Box!"
+
+#: ../plugin.py:536
+#, python-format
+msgid ""
+"Connection to Fritz!Box! lost\n"
+" (%s)\n"
+"retrying..."
+msgstr ""
+"Verbindung mit Fritz!Box verloren\n"
+" (%s)\n"
+"neuer Versuch..."
+
+#: ../plugin.py:540
+#, python-format
+msgid ""
+"Connecting to Fritz!Box failed\n"
+" (%s)\n"
+"retrying..."
+msgstr ""
+"Verbindung zur Fritz!Box fehlgeschlagen\n"
+" (%s)\n"
+"neuer Versuch..."
+
+#: ../plugin.py:588 ../plugin.py:591
+msgid "Display Fritzbox-Fon calls on screen"
+msgstr "Anzeige der Anrufe auf der Fritzbox-Fon"
+
+#~ msgid "Could not read Fritz!Box Phonebook"
+#~ msgstr "Konnte Fritz!Box-Telefonbuch nicht lesen"
index 1b45f3d..f26662a 100644 (file)
@@ -1,3 +1,5 @@
 installdir = /usr/lib/enigma2/python/Plugins/Extensions/FritzCall
 
 install_PYTHON = __init__.py plugin.py
+
+# install_DATA = plugin.png
index ede8e9c..f69880b 100644 (file)
@@ -4,6 +4,7 @@ from Screens.MessageBox import MessageBox
 
 from Components.ActionMap import ActionMap
 from Components.Label import Label
+from Components.Button import Button
 from Components.config import config, ConfigSubsection, ConfigSelection, ConfigIP, ConfigEnableDisable, getConfigListEntry, ConfigText, ConfigInteger
 from Components.ConfigList import ConfigListScreen
 
@@ -16,12 +17,13 @@ from twisted.protocols.basic import LineReceiver
 from twisted.web.client import getPage
 
 from os import path as os_path
-from urllib import urlencode
+from urllib import urlencode 
 import re
 
 import gettext
+from Tools.Directories import resolveFilename, SCOPE_PLUGINS
 try:
-               _ = gettext.translation('fritzcall', '/usr/lib/enigma2/python/Plugins/Extensions/FritzCall/po', [config.osd.language.getText()]).gettext
+               _ = gettext.translation('FritzCall', resolveFilename(SCOPE_PLUGINS, "Extensions/FritzCall/locale"), [config.osd.language.getText()]).gettext
 except IOError:
                pass
 
@@ -40,7 +42,7 @@ config.plugins.FritzCall.internal = ConfigEnableDisable(default = False)
 config.plugins.FritzCall.fritzphonebook = ConfigEnableDisable(default = False)
 config.plugins.FritzCall.phonebook = ConfigEnableDisable(default = False)
 config.plugins.FritzCall.addcallers = ConfigEnableDisable(default = False)
-config.plugins.FritzCall.phonebookLocation = ConfigSelection(choices = [("/media/usb/PhoneBook.txt", _("USB Stick")), ("/media/cf/PhoneBook.txt", _("CF Drive")), ("/media/hdd/PhoneBook.txt", _("Harddisk"))])
+config.plugins.FritzCall.phonebookLocation = ConfigSelection(choices = [("/etc/enigma2/PhoneBook.txt", _("Flash")), ("/media/usb/PhoneBook.txt", _("USB Stick")), ("/media/cf/PhoneBook.txt", _("CF Drive")), ("/media/hdd/PhoneBook.txt", _("Harddisk"))])
 config.plugins.FritzCall.password = ConfigText(default = "", fixed_size = False)
 config.plugins.FritzCall.prefix = ConfigText(default = "", fixed_size = False)
 
@@ -132,7 +134,7 @@ class FritzCallPhonebook:
                                                name = found.group(1)
                                                thisnumber = found.group(2)
                                                if found.group(3):
-                                                       name = name + ", " + _("Kurzwahl") + ": " + found.group(3)
+                                                       name = name + ", " + _("Shortcut") + ": " + found.group(3)
                                                if found.group(4):
                                                        name = name + ", " +_("Vanity") +": " + found.group(4)
                                                name = name.replace("&amp;", "&").replace("&szlig;", "ß").replace("&auml;", "ä").replace("&ouml;", "ö").replace("&uuml;", "ü").replace("&Auml;", "Ä").replace("&Ouml;", "Ö").replace("&Uuml;", "Ü")
@@ -221,7 +223,11 @@ class FritzCallPhonebook:
 
        def add(self, number, name):
                print "[FritzCallPhonebook] add"
-               if config.plugins.FritzCall.phonebook.value and config.plugins.FritzCall.addcallers.value:
+#===============================================================================
+#        It could happen, that two reverseLookups are running in parallel,
+#        so check first, whether we have already added the number to the phonebook.
+#===============================================================================
+               if phonebook.search(number) is None and number <> 0 and config.plugins.FritzCall.phonebook.value and config.plugins.FritzCall.addcallers.value:
                        try:
                                f = open(config.plugins.FritzCall.phonebookLocation.value, 'a')
                                name = name.strip() + "\n"
@@ -229,6 +235,7 @@ class FritzCallPhonebook:
                                self.phonebook[number] = name;
                                f.write(string)
                                f.close()
+                               print "[FritzCallPhonebook] added %s with %sto Phonebook.txt" %(number, name)
                                return True
 
                        except IOError:
@@ -241,6 +248,10 @@ class FritzCallSetup(ConfigListScreen, Screen):
                <screen position="100,90" size="550,420" title="FritzCall Setup" >
                <widget name="config" position="20,10" size="510,300" scrollbarMode="showOnDemand" />
                <widget name="consideration" position="20,320" font="Regular;20" halign="center" size="510,50" />
+               <ePixmap position="135,375" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
+               <ePixmap position="275,375" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
+               <widget name="key_red" position="135,375" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+               <widget name="key_green" position="275,375" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
                </screen>"""
 
        def __init__(self, session, args = None):
@@ -250,6 +261,10 @@ class FritzCallSetup(ConfigListScreen, Screen):
                self["consideration"] = Label(_("You need to enable the monitoring on your Fritz!Box by dialing #96*5*!"))
                self.list = []
 
+               # Initialize Buttons
+               self["key_red"] = Button(_("Cancel"))
+               self["key_green"] = Button(_("OK"))
+
                self["setupActions"] = ActionMap(["SetupActions"],
                {
                        "save": self.save,
@@ -321,175 +336,184 @@ class FritzCallSetup(ConfigListScreen, Screen):
                        x[1].cancel()
                self.close()
 
-class FritzProtocol(LineReceiver):
-       def __init__(self):
-#              print "[FritzProtocol] __init__"
-               self.resetValues()
+#===============================================================================
+#              We need a separate class for each invocation of reverseLookup to retain
+#              the necessary data for the notification
+#===============================================================================
 
-       def resetValues(self):
-#              print "[FritzProtocol] resetValues"
-               self.number = '0'
-               self.caller = None
-               self.phone = None
-               self.date = '0'
+class FritzReverseLookupAndNotifier():
+       def __init__(self, event, number, caller, phone, date):
+               self.event = event
+               self.number = number
+               self.caller = caller
+               self.phone = phone
+               self.date = date
 
-       def notify(self, text, timeout=config.plugins.FritzCall.timeout.value):
-               Notifications.AddNotification(MessageBox, text, type=MessageBox.TYPE_INFO, timeout=timeout)
-
-       def handleIncoming(self):
-#              print "[FritzProtocol] handle Incoming!"
-
-               text = _("Incoming Call ")
-               if self.caller is not None:
-                       text += _("on %s from\n---------------------------------------------\n%s\n%s\n---------------------------------------------\nto: %s") % (self.date, self.number, self.caller, self.phone)
+               print "[FritzReverseLookupAndNotifier] reverse Lookup for %s!" %self.number
+               url = "http://www.dasoertliche.de/?form_name=search_inv&ph=%s" %self.number
+               getPage(url, method="GET").addCallback(self.gotPageDasOertliche).addErrback(self.gotErrorDasOertliche)
+               
+       def notifyAndReset(self, timeout=config.plugins.FritzCall.timeout.value):
+               if self.event == "RING":
+                       text = _("Incoming Call on %s from\n---------------------------------------------\n%s\n%s\n---------------------------------------------\nto: %s") % (self.date, self.number, self.caller, self.phone)
                else:
-                       text += _("on %s from\n---------------------------------------------\n%s (UNKNOWN)\n---------------------------------------------\nto: %s") % (self.date, self.number, self.phone)
+                       text = _("Outgoing Call on %s to\n---------------------------------------------\n%s\n%s\n---------------------------------------------\nfrom: %s") % (self.date, self.number, self.caller, self.phone)
+               print "[FritzReverseLookupAndNotifier] notifyAndReset:\n%s" %text
+               Notifications.AddNotification(MessageBox, text, type=MessageBox.TYPE_INFO, timeout=timeout)
+               #       at this point we could destroy the object, but I dunno how :-)
 
-               self.notify(text)
-               self.resetValues()
+       def gotErrorDasOertliche(self, error):                   # so we try Klicktel
+               url = "http://www.klicktel.de/telefonbuch/backwardssearch.html?newSearch=1&boxtype=backwards&vollstaendig=%s" %self.number
+               getPage(url, method="GET").addCallback(self.gotPageKlicktel).addErrback(self.gotErrorKlicktel)
 
-       def handleOutgoing(self):
-#              print "[FritzProtocol] handle Outgoing!"
-               text = _("Outgoing Call ")
-               if(self.caller is not None):
-                       text += _("on %s to\n---------------------------------------------\n%s\n%s\n---------------------------------------------\nfrom: %s") % (self.date, self.number, self.caller, self.phone)
-               else:
-                       text += _("on %s to\n---------------------------------------------\n%s (UNKNOWN)\n\n---------------------------------------------\nfrom: %s") % (self.date, self.number, self.phone)#
+       def gotPageDasOertliche(self, html):
+               print "[FritzReverseLookupAndNotifier] gotPageDasOertliche"
+               try:
+                       found = re.match('.*<td.*?class="cel-data border.*?>(.*?)</td>', html, re.S)
+                       if found:
+                               td = found.group(1)                                     # group(1) is the content of (.*?) in our pattern
+                               td.decode("ISO-8859-1").encode("UTF-8")
+                               text = re.sub("<.*?>", "", td)          # remove tags and their content
+                               text = text.split("\n")
+                               #===============================================================================
+                               # 
+                               #       The logic here is as follows:
+                               #
+                               #       The first line in the table, which has a word followed by a space
+                               #       followed by a word is the name. As of the time of writing that was line 3,
+                               #       but that could change in the future.
+                               #       
+                               #       Starting from the next line after that we are looking for a line
+                               #       containing 5 digits (PLZ) followed by a space followed by a word at the
+                               #       end of the line. If found, we assume, that that is the address. The right
+                               #       one at time of writing was 10.
+                               #       
+                               #===============================================================================
+                               nameLine = 3     # as of 08.06.08
+                               if not re.search('\S+ \S+', text[nameLine].replace("&nbsp;", " ").strip()):
+                                       for i in range(0,len(text)-1):
+                                               if re.search('\S+ \S+', text[i].replace("&nbsp;", " ").strip()):
+                                                       nameLine = i
+                                                       break
+                               name = text[nameLine].replace("&nbsp;", " ").strip()
+       
+                               addrLine = 10   # as of 08.06.08 that was the correct one
+                               for i in range(nameLine+1,len(text)-1):   # look for a line containing the address, i.e. "PLZ Name" at the end of the line
+                                       if re.search('\d\d\d\d\d \S+$', text[i].replace("&nbsp;", " ").strip()):
+                                               addrLine = i
+                                               break
+                               address = text[addrLine].replace("&nbsp;", " ").replace(", ", "\n").strip();
+                               print "[FritzReverseLookupAndNotifier] Reverse lookup succeeded with DasOertliche:\nName: %s\n\nAddress: %s" %(name, address)
+       
+                               self.caller = "%s\n%s" %(name, address)
+       
+                               if self.event == "RING":
+                                       phonebook.add(self.number, self.caller.replace("\n", ", "))
 
-               self.notify(text)
-               self.resetValues()
+                               self.notifyAndReset()
+                               return
 
-       def handleEvent(self):
-#              print "[FritzProtocol] handleEvent!"
-               if self.event == "RING":
-                       self.handleIncoming()
-               elif self.event == "CALL":
-                       self.handleOutgoing()
+               except:
+                       import traceback, sys
+                       traceback.print_exc(file=sys.stdout)
+                       #raise e
 
-       def handleEventOnError(self, error):
-#              print "[FritzProtocol] handleEventOnError - Error :%s" %error
-               self.handleEvent()
+               url = "http://www.klicktel.de/telefonbuch/backwardssearch.html?newSearch=1&boxtype=backwards&vollstaendig=%s" %self.number
+               getPage(url, method="GET").addCallback(self.gotPageKlicktel).addErrback(self.gotErrorKlicktel)
 
-       def _gotPage(self, data):
-#              print "[FritzProtocol] _gotPage"
+       def gotErrorKlicktel(self, error):
+               self.caller = _("UNKNOWN")
+               self.notifyAndReset()
+               
+       def gotPageKlicktel(self, html):
+               print "[FritzReverseLookupAndNotifier] gotPageKlicktel"
                try:
-                       self.gotPage(data)
+                       html.decode("ISO-8859-1").encode("UTF-8")
+                       html = html.replace("<br />", ", ")
+                       found = re.match('.*<a class="head" href=".*" title=""><span class="title">(.*)</span></a>.*<span class="location">([\S ,]+)</span>', html, re.S)
+                       if found:
+                               name = found.group(1)
+                               address = found.group(2)
+                               print "[FritzProtocol] Reverse lookup succeeded with Klicktel:\nName: %s\n\nAddress: %s" %(name, address)
+
+                               self.caller = "%s\n%s" %(name, address)
+
+                               if self.event == "RING":
+                                       phonebook.add(self.number, self.caller.replace("\n", ", "))
+                       
+                               self.notifyAndReset()
+                               return True
+
                except:
                        import traceback, sys
                        traceback.print_exc(file=sys.stdout)
                        #raise e
-                       self.handleEvent()
-
-       def gotPage(self, html):
-#              print "[FritzProtocol] gotPage"
-               found = re.match('.*<td.*?class="cel-data border.*?>(.*?)</td>', html, re.S)
-               if found:
-                       td = found.group(1)                                     # group(1) is the content of (.*?) in our pattern
-                       td.decode("ISO-8859-1").encode("UTF-8")
-                       text = re.sub("<.*?>", "", td)          # remove tags and their content
-                       text = text.split("\n")
-                       #===============================================================================
-                       # 
-                       #       The logic here is as follows:
-                       #
-                       #       The first line in the table, which has a word followed by a space
-                       #       followed by a word is the name. As of the time of writing that was line 3,
-                       #       but that could change in the future.
-                       #       
-                       #       Starting from the next line after that we are looking for a line
-                       #       containing 5 digits (PLZ) followed by a space followed by a word at the
-                       #       end of the line. If found, we assume, that that is the address. The right
-                       #       one at time of writing was 10.
-                       #       
-                       #===============================================================================
-                       nameLine = 3     # as of 08.06.08
-                       if not re.search('\S+ \S+', text[nameLine].replace("&nbsp;", " ").strip()):
-                               for i in range(0,len(text)-1):
-                                       if re.search('\S+ \S+', text[i].replace("&nbsp;", " ").strip()):
-                                               nameLine = i
-                                               break
-                       name = text[nameLine].replace("&nbsp;", " ").strip()
 
-                       addrLine = 10   # as of 08.06.08 that was the correct one
-                       for i in range(nameLine+1,len(text)-1):   # look for a line containing the address, i.e. "PLZ Name" at the end of the line
-                               if re.search('\d\d\d\d\d \S+$', text[i].replace("&nbsp;", " ").strip()):
-                                       addrLine = i
-                                       break
-                       address = text[addrLine].replace("&nbsp;", " ").replace(", ", "\n").strip();
-                       print "[FritzProtocol] Reverse lookup succeeded:\nName: %s\n\nAddress: %s" %(name, address)
+               self.caller = _("UNKNOWN")
+               self.notifyAndReset()
 
-                       self.caller = "%s\n%s" %(name, address)
+               
 
-                       #Autoadd to PhoneBook.txt if enabled
-                       if config.plugins.FritzCall.addcallers.value and self.event == "RING":
-                               phonebook.add(self.number, self.caller.replace("\n", ", "))
-#              else:
-#                      print "[FritzProtocol] Reverse lookup without result!"
+class FritzProtocol(LineReceiver):
+       def __init__(self):
+               print "[FritzProtocol] __init__"
+               self.resetValues()
 
-               self.handleEvent()
+       def resetValues(self):
+               print "[FritzProtocol] resetValues"
+               self.number = '0'
+               self.caller = None
+               self.phone = None
+               self.date = '0'
 
-       def reverseLookup(self):
-#              print "[FritzProtocol] reverse Lookup!"
-               url = "http://www.dasoertliche.de/?form_name=search_inv&ph=%s" %self.number
-               getPage(url,method="GET").addCallback(self._gotPage).addErrback(self.handleEventOnError)
+       def notifyAndReset(self, timeout=config.plugins.FritzCall.timeout.value):
+               if self.event == "RING":
+                       text = _("Incoming Call on %s from\n---------------------------------------------\n%s\n%s\n---------------------------------------------\nto: %s") % (self.date, self.number, self.caller, self.phone)
+               else:
+                       text = _("Outgoing Call on %s to\n---------------------------------------------\n%s\n%s\n---------------------------------------------\nfrom: %s") % (self.date, self.number, self.caller, self.phone)
+               print "[FritzProtocol] notifyAndReset:\n%s" %text
+               Notifications.AddNotification(MessageBox, text, type=MessageBox.TYPE_INFO, timeout=timeout)
+               self.resetValues()
 
        def lineReceived(self, line):
-#              print "[FritzProtocol] lineReceived"
-#15.07.06 00:38:54;CALL;1;4;<provider>;<callee>;
+               print "[FritzProtocol] lineReceived: %s" %line
+#15.07.06 00:38:54;CALL;1;4;<from/extern>;<to/our msn>;
 #15.07.06 00:38:58;DISCONNECT;1;0;
-#15.07.06 00:39:22;RING;0;<caller>;<outgoing msn>;
+#15.07.06 00:39:22;RING;0;<from/extern>;<to/our msn>;
 #15.07.06 00:39:27;DISCONNECT;0;0;
 
                a = line.split(';')
                (self.date, self.event) = a[0:2]
 
-               #incoming Call
-               if self.event == "RING":
-                       phone = a[4]
-
-                       if not config.plugins.FritzCall.filter.value or config.plugins.FritzCall.filtermsn.value == phone:
-                               phonename = phonebook.search(phone)
-                               if phonename is not None:
-                                       self.phone = "%s (%s)" %(phone, phonename)
-                               else:
-                                       self.phone = phone
-
-                               if config.plugins.FritzCall.internal.value and len(a[3]) > 3 and a[3][0]=="0":
-                                       self.number = a[3][1:]
-                               else:
-                                       self.number = a[3]
-
-                               self.caller = phonebook.search(self.number)
-                               if (self.caller is None) and config.plugins.FritzCall.lookup.value:
-                                       self.reverseLookup()
-                               else:
-                                       self.handleEvent()
-
-               #Outgoing Call
-               elif config.plugins.FritzCall.showOutgoing.value and self.event == "CALL":
+               if self.event == "RING" or (self.event == "CALL" and config.plugins.FritzCall.showOutgoing.value):
                        phone = a[4]
+                       number = (a[3] if self.event == "RING" else a[5])
 
-                       if not config.plugins.FritzCall.filter.value or config.plugins.FritzCall.filtermsn.value == phone:
-                               phonename = phonebook.search(phone)
+                       if not (config.plugins.FritzCall.filter.value and config.plugins.FritzCall.filtermsn.value == phone):
+                               phonename = phonebook.search(phone)                # do we have a name for the number of our side?
                                if phonename is not None:
                                        self.phone = "%s (%s)" %(phone, phonename)
                                else:
                                        self.phone = phone
 
-                               if config.plugins.FritzCall.internal.value and len(a[5]) > 3 and a[5][0]=="0":
-                                       self.number = a[5][1:]
+                               if config.plugins.FritzCall.internal.value and len(number) > 3 and number[0]=="0":
+                                       self.number = number[1:]
                                else:
-                                       self.number = a[5]
+                                       self.number = number
 
-                               if self.number[0] != '0':
+                               if self.event == "CALL" and self.number[0] != '0':                                        # should only happen for outgoing
                                        self.number = config.plugins.FritzCall.prefix.value + self.number
 
-                               self.caller = phonebook.search(self.number)
+                               if self.number is not "":
+                                       self.caller = phonebook.search(self.number)
+                                       if (self.caller is None) and config.plugins.FritzCall.lookup.value:
+                                               FritzReverseLookupAndNotifier(self.event, self.number, self.caller, self.phone, self.date)
+                                               return                                                  # reverselookup is supposed to handle the message itself 
 
-                               if (self.caller is None) and config.plugins.FritzCall.lookup.value:
-                                       self.reverseLookup()
-                               else:
-                                       self.handleEvent()
+                               if self.caller is None:
+                                       self.caller = _("UNKNOWN")
+
+                               self.notifyAndReset()
 
 
 class FritzClientFactory(ReconnectingClientFactory):
@@ -560,5 +584,10 @@ def autostart(reason, **kwargs):
                fritz_call = None
 
 def Plugins(**kwargs):
-        return [ PluginDescriptor(name="FritzCall", description=_("Display Fritzbox-Fon calls on screen"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
-                PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart) ]
+       if os_path.exists("plugin.png"):
+               return [ PluginDescriptor(name="FritzCall", description=_("Display Fritzbox-Fon calls on screen"), where = PluginDescriptor.WHERE_PLUGINMENU, icon = "plugin.png", fnc=main),
+               PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart) ]
+       else:
+               return [ PluginDescriptor(name="FritzCall", description=_("Display Fritzbox-Fon calls on screen"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
+               PluginDescriptor(where = [PluginDescriptor.WHERE_SESSIONSTART, PluginDescriptor.WHERE_AUTOSTART], fnc = autostart) ]
+               
\ No newline at end of file