Index: /ipk/source.sh4/titaninfos_callmonitor/CONTROL/control
===================================================================
--- /ipk/source.sh4/titaninfos_callmonitor/CONTROL/control	(revision 10561)
+++ /ipk/source.sh4/titaninfos_callmonitor/CONTROL/control	(revision 10562)
@@ -1,4 +1,4 @@
 Package: titan-plugin-infos-callmonitor
-Version: 0.3
+Version: 0.5
 Architecture: sh4
 OE: Callmonitor for your AAF Duckbox 
Index: /ipk/source.sh4/titaninfos_callmonitor/var/usr/local/share/titan/plugins/callmonitor1/callmon.conf
===================================================================
--- /ipk/source.sh4/titaninfos_callmonitor/var/usr/local/share/titan/plugins/callmonitor1/callmon.conf	(revision 10561)
+++ /ipk/source.sh4/titaninfos_callmonitor/var/usr/local/share/titan/plugins/callmonitor1/callmon.conf	(revision 10562)
@@ -1,3 +1,5 @@
 FRITZBOXIP=10.0.0.99
+FritzPass=hugo
+usePhoneBook=0
 Alle=1
 anzeigewennaus=0
Index: /ipk/source.sh4/titaninfos_callmonitor/var/usr/local/share/titan/plugins/callmonitor1/fritzbox_msg_new.sh
===================================================================
--- /ipk/source.sh4/titaninfos_callmonitor/var/usr/local/share/titan/plugins/callmonitor1/fritzbox_msg_new.sh	(revision 10561)
+++ /ipk/source.sh4/titaninfos_callmonitor/var/usr/local/share/titan/plugins/callmonitor1/fritzbox_msg_new.sh	(revision 10562)
@@ -3,4 +3,9 @@
 CONFIG=`echo "$0callmon.conf" | sed s/fritzbox_msg_new.sh//`
 NC=`echo "$0nc" | sed s/fritzbox_msg_new.sh//`
+ICONV=`echo "$0iconv" | sed s/fritzbox_msg_new.sh//`
+CURL=`echo "$0curl" | sed s/fritzbox_msg_new.sh//`
+LPATH=`echo "$0" | sed s/'\/fritzbox_msg_new.sh'//`
+LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LPATH
+export LD_LIBRARY_PATH
 
 . $CONFIG
@@ -74,5 +79,6 @@
 #additional paths to files we use (will be created automatically if not present)
 #detecting Dreambox-Type (DM7020 or DM7000 or DM500 or DM600PVR)
- FRITZCACHE=/var/fritzbox.cache        		 #stores successfull reverse searches
+ FRITZCACHE=/tmp/fritzbox.cache        		 #stores successfull reverse searches
+ FRITZBUCH=/var/fritzbuch.tele
  TMPFILE=/tmp/fritzbox.tmp             		 #stores page from wget command
  TMPSTATUS=/tmp/fritzdream.status      		 #status der Dreambox (standby usw)
@@ -192,4 +198,38 @@
 fi;
 };
+
+loadFritzBook () {
+ if [ $usePhoneBook = "1" ]; then
+	 	if [ ! -f $FRITZBUCH ]; then
+	 	 	# Challenge abholen
+			ChallengeXML=`wget -O - "http://$FRITZBOXIP/cgi-bin/webcm?getpage=../html/login_sid.xml" 2>/dev/null| grep Challenge`
+			Challenge=`echo $ChallengeXML | awk '{match($0,/>[^<>]+</); print substr($0,RSTART+1,RLENGTH-2)}'`
+			Passwd="$FritzPass"
+
+			# login aufbauen und hashen
+			CPSTR="$Challenge-$Passwd"
+			MD5=`echo -n $CPSTR | $ICONV -f ISO8859-1 -t UTF-16LE > /tmp/help; md5sum /tmp/help | awk '{print substr($0,1,32)}'`
+			RESPONSE="$Challenge-$MD5"
+			POSTDATA="login:command/response=$RESPONSE&getpage=../html/de/menus/menu2.html"
+			# login senden und SID herausfischen
+			SID=`wget -O - --post-data="$POSTDATA" "http://$FRITZBOXIP/cgi-bin/webcm" 2>/dev/null| grep "name=\"sid\"" | head -1 | awk '{match($0,/value="[^"]+"/); print substr($0,RSTART+7,RLENGTH-8)}'`
+
+			./$CURL --data "telcfg:settings/Phonebook/Books/Select=0&getpage=../html/de/menus/menu2.html&var:pagename=fonbuch&sid=$SID&var:menu=fon&var:lang=de" http://$FRITZBOXIP/cgi-bin/webcm  | grep ">TrFon" | sed s/'<script type="text\/javascript">'// | sed s/';<\/script>'// | sed s/'('/'"'/ | sed s/')'/'"'/ > /tmp/curlhelp.tmp
+
+			while read line 
+				do
+				art=`echo $line | cut -d'"' -f1`
+				if [ $art = "TrFonName" ]; then
+					name=`echo $line | cut -d'"' -f5`
+				elif [ $art = "TrFonNr" ]; then
+					nummer=`echo $line | cut -d'"' -f5`
+					echo "$nummer#$name" >> $FRITZBUCH 
+				fi
+			done < /tmp/curlhelp.tmp
+			rm /tmp/curlhelp.tmp
+		fi
+		cp $FRITZBUCH $FRITZCACHE
+	fi	
+};
 #-------------------------------------------------------------------------------
 #Script has been initiated with parameters
@@ -210,7 +250,8 @@
   echo "Anzeigetimeout: " $anzeigetimeout
   echo "Anzeigewennaus: " $anzeigewennaus
-  echo "Übersichtsseite: " $uebersichtsseite
+  #echo "Übersichtsseite: " $uebersichtsseite
+  echo "Fritzbox Telefonbuch: " $usePhoneBook
   echo "------------------------------------"
-  
+  loadFritzBook
   if [ $debug = 0 ]; then
      wget -q -O /dev/null "http://$ip/cgi-bin/xmessage?caption=Skript%20gestartet&body=FritzBox!%20Callmonitor%20gestartet&timeout=3"
@@ -476,4 +517,5 @@
   
   TEST|test)
+  		loadFritzBook
       echo "Testing the script: "$0
       mysearch "$2"
@@ -511,71 +553,9 @@
       if [ -f $TMPFILE ];     then  rm $TMPFILE; fi
       if [ -f $TMPSTATUS ];     then  rm $TMPSTATUS; fi
-      ;; 
-  install|INSTALL) #only for DM7020 at the moment
-     #kill all processes we spawned
-     #hopefully only a single tail task is running so we kill it :)
-     echo 'Killing spawned processes...'     
-     pid=`ps | grep "tail.-f"| grep -v grep | awk '{print $1}'`
-     if [ "X${pid}" != "X" ] ; then
-        kill -9 ${pid}
-     fi
-     pid=`ps |grep "Unbekannt" | grep -v grep | awk '{print $1}'`
-     if [ "X${pid}" != "X" ] ; then
-        kill -9 ${pid}
-     fi
-     pid=`ps |grep ".*nc.*$TELDPORT" | grep -v grep | awk '{print $1}'`
-     if [ "X${pid}" != "X" ] ; then
-        kill -9 ${pid}
-     fi
-     #pid=`ps |grep $SCRIPT | grep -v grep | awk '{print $1}'`
-     #if [ "X${pid}" != "X" ] ; then
-     #   kill -9 ${pid}
-     #fi  
-     #here starts the installer  
-     if [ "$DREAMTYPE" = "DM7020" ]; then
-	  cp $SCRIPT /etc/fritzbox_msg_new.sh
-	  #rm /etc/rc2.d/S40Fritz
-      #ln -s /etc/fritzbox_msg_new.sh /etc/rc2.d/S40Fritz    #create softlinks in rcX
-	  update-rc.d `basename $0`  start 41 S . stop  39 0 1 6 .
-      echo ''
-      echo "You should now test the script with"
-      echo $SCRIPT 'TEST 089906426'
-      echo ''
-      echo 'If it works correct, reboot your dreambox!'
-      echo ''
-     fi
-     ;;
-  remove|REMOVE)
-     #kill all processes we spawned
-     #hopefully only a single tail task is running so we kill it :)
-     echo 'Killing spawned processes...'
-     pid=`ps | grep "tail.-f"| grep -v grep | awk '{print $1}'`
-     if [ "X${pid}" != "X" ] ; then
-        kill -9 ${pid}
-     fi
-     pid=`ps |grep "Unbekannt" | grep -v grep | awk '{print $1}'`
-     if [ "X${pid}" != "X" ] ; then
-        kill -9 ${pid}
-     fi
-     pid=`ps |grep ".*nc.*$TELDPORT" | grep -v grep | awk '{print $1}'`
-     if [ "X${pid}" != "X" ] ; then
-        kill -9 ${pid}
-     fi
-     #pid=`ps |grep $SCRIPT | grep -v grep | awk '{print $1}'`
-     #if [ "X${pid}" != "X" ] ; then
-     #   kill -9 ${pid}
-     #fi  
-    #here starts the uninstaller
-    if [ "$DREAMTYPE" = "DM7020" ]; then
-      #rm /etc/rc2.d/S40Fritz    						#remove softlink in rc2
-	  update-rc.d -f `basename $0` remove
-	fi
-    echo ''
-    echo 'If you want a complete cleanup you can execute:'
-    echo '   /bin/sh '"$SCRIPT"' cleanup'
-    echo ''
-    echo 'and then   rm '"$SCRIPT"
-    echo ''
-    ;;         
+  ;; 
+  loadPhoneBook|loadphonebook)
+  	rm $FRITZBUCH
+   	loadFritzBook
+  ;;
 esac
 
