Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen Revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
|
user:tstoeber:howto:href-tel-handler:start [2019/11/13 21:27] Tobias Stöber [MIME-Type-Handler: Protokoll "tel" behandeln] |
user:tstoeber:howto:href-tel-handler:start [2019/11/14 00:03] (aktuell) Tobias Stöber [Aufgabe] |
||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| == tel-Link anrufen == | == tel-Link anrufen == | ||
| - | ====== tel-Verlinkung aus dem Firefox anrufen ====== | + | ====== Telefon-Nummern-Verlinkung aus dem Browser anrufen ====== |
| ===== Aufgabe ===== | ===== Aufgabe ===== | ||
| - | * verlinkte Telefonnummern in Webseiten aus dem Browser (Firefox) auf dem Notebook im Büro oder zu Hause auf dem Yealink IP-Telefon anrufen | + | * in Webseiten mit tel-Link (''<a href=”tel:123456”>...</a>'') verlinkte Telefonnummern aus dem Browser (Firefox) auf dem Notebook im Büro oder zu Hause auf dem Yealink IP-Telefon anrufen |
| Zeile 12: | Zeile 12: | ||
| Hier mal ein Beispiel, wie solche "Telefonnummern-Verknüpfungen" eingebaut werden. | Hier mal ein Beispiel, wie solche "Telefonnummern-Verknüpfungen" eingebaut werden. | ||
| - | Smartphones lesen diese i.d.R. korrekt aus und ermöglichen so, direkt aus der Website heraus anzurufen. | + | Smartphones lesen diese i.d.R. korrekt aus und ermöglichen so, direkt aus der Website heraus die Nummern anzurufen. |
| <code> | <code> | ||
| Zeile 39: | Zeile 39: | ||
| <body> | <body> | ||
| - | Ruf mich an <a href="tel:+49-176-123456789">(0176) 123 456789</a> | + | Ruf mich an <a href="tel:+49-30-123456789">(030) 123 45 67 89</a> |
| </body> | </body> | ||
| Zeile 76: | Zeile 76: | ||
| * tel-Link auseinander nehmen | * tel-Link auseinander nehmen | ||
| * den Wählvorgang am IP-Telefon vornehmen | * den Wählvorgang am IP-Telefon vornehmen | ||
| - | * per Desktop-Notification das auch am Rechner anzeigen | + | * per Desktop-Benachrichtigung das Wählen auch am Rechner anzeigen bzw. auch anzeigen, wenn etwas schief geht |
| Außerdem soll es: | Außerdem soll es: | ||
| - | * mehrere IP-Telefon nutzen können und | + | * mehrere IP-Telefone nutzen können und |
| - | * anhand des aktuellen IP-Adresse entscheiden, welches zu verwenden ist | + | * anhand der aktuellen IP-Adresse (Netzwerk) entscheiden, welches zu verwenden ist |
| + | === Quelltext === | ||
| - | ===== Links / Quellen ===== | + | <sxh perl> |
| + | #!/usr/bin/perl | ||
| + | |||
| + | # load modules | ||
| + | use Desktop::Notify; # DEB: apt install libdesktop-notify-perl | ||
| + | |||
| + | # defined ip phones | ||
| + | my $have_phone = 0; | ||
| + | my $iptel; | ||
| + | my %ipphone = ( | ||
| + | # im Home Office: Yealink #1 | ||
| + | '192.168.x.' => { 'ip' => '192.168.x.x', | ||
| + | 'user' => 'username', | ||
| + | 'pass' => 'password', | ||
| + | 'desc' => 'Home Office T28P' }, | ||
| + | # im Buero: Yealink #1 | ||
| + | '192.168.x.' => { 'ip' => '192.168.x.x', | ||
| + | 'user' => 'username', | ||
| + | 'pass' => 'password', | ||
| + | 'desc' => 'Office T46G' }, | ||
| + | ); | ||
| + | |||
| + | # get telephone number string from cli | ||
| + | my $telstr = shift; | ||
| + | my ($g, $tel) = split(/:/, $telstr); | ||
| + | |||
| + | # get my ip address | ||
| + | my $my_ip = get_ipaddr(); | ||
| + | |||
| + | # select a ipphone | ||
| + | foreach my $k ( keys %ipphone ) | ||
| + | { | ||
| + | if ( $my_ip =~ /$k/ ) | ||
| + | { | ||
| + | $have_phone = 1; | ||
| + | $iptel = $k; | ||
| + | } | ||
| + | } | ||
| + | |||
| + | # prepare the number to dial (remove non numeric parts) | ||
| + | my $num = $tel; | ||
| + | $num =~ s/[^\+0-9]//gi; | ||
| + | $num =~ s/^00/\%2B/gi; | ||
| + | $num =~ s/^\+/\%2B/gi; | ||
| + | |||
| + | # dial if ip phone found | ||
| + | if ( $have_phone ) | ||
| + | { | ||
| + | # phone's ip | ||
| + | my $ip = $ipphone{$iptel}{'ip'}; | ||
| + | |||
| + | # build dial-url | ||
| + | my $url = 'http://' . $ip . '/servlet?number=' . $num . '&outgoing_uri='; | ||
| + | |||
| + | # notify user on desktop | ||
| + | desktop_notify("Wähle die Nummer $tel\n | ||
| + | vom IP-Telefon $ipphone{$iptel}{'desc'} ($ip) ...", | ||
| + | $ipphone{$iptel}{'desc'}, 'phone'); | ||
| + | |||
| + | # dial url by retrieving url from phone | ||
| + | system("/usr/bin/wget -O /dev/null \\ | ||
| + | --http-user=\"$ipphone{$iptel}{'user'}\" \\ | ||
| + | --http-password=\"$ipphone{$iptel}{'pass'}\" \\ | ||
| + | '$url'"); | ||
| + | } | ||
| + | else | ||
| + | { | ||
| + | # well, can't dial without phone | ||
| + | desktop_notify("Kann $tel nicht anrufen.\nKein IP-Telefon gefunden ...", | ||
| + | "Yealink-Wähler", 'dialog-error'); | ||
| + | } | ||
| + | |||
| + | sub get_ipaddr { | ||
| + | ############################################################################## | ||
| + | # get ip address | ||
| + | ############################################################################## | ||
| + | |||
| + | # get network ip addr | ||
| + | my ($ip); | ||
| + | |||
| + | my $ipaddr = `ip addr | grep "inet "`; | ||
| + | chomp($ipaddr); | ||
| + | |||
| + | foreach my $i ( split(/\n/, $ipaddr) ) | ||
| + | { | ||
| + | $i =~ s/^\s+//gi; | ||
| + | $i =~ /inet\ ([^\s+]+)/gi; | ||
| + | $ip = (split(/\//, $1))[0]; | ||
| + | |||
| + | if ( $ip !~ /127\.0\.0/ ) | ||
| + | { | ||
| + | return $ip; | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | |||
| + | sub desktop_notify { | ||
| + | ############################################################################### | ||
| + | # send notification about dial process to desktop via dbus | ||
| + | ############################################################################### | ||
| + | |||
| + | my $n_text = shift; | ||
| + | my $n_title = shift; | ||
| + | my $n_icon = shift; | ||
| + | |||
| + | my $dbus_timeout = 10000; # 10 seconds | ||
| + | |||
| + | my $dbus_icon = 'dialog-information'; | ||
| + | $dbus_icon = $n_icon if ( (defined $n_icon) && (length($n_icon) > 0)); | ||
| + | |||
| + | my $dbus_title = 'Wähle auf dem Yealink ...'; | ||
| + | $dbus_title = $n_title if ( (defined $n_title) && (length($n_title) > 0)); | ||
| + | |||
| + | my $dbus_text = $n_text; | ||
| + | |||
| + | # open a connection to the notification daemon | ||
| + | my $notify = Desktop::Notify->new( | ||
| + | app_name => 'YealinkNotify', | ||
| + | app_icon => $dbus_icon, | ||
| + | ); | ||
| + | |||
| + | # create a notification to display | ||
| + | my $notification = $notify->create(summary => $dbus_title, | ||
| + | body => $dbus_text, | ||
| + | timeout => $dbus_timeout); | ||
| + | |||
| + | # display the notification | ||
| + | $notification->show(); | ||
| + | } | ||
| + | </sxh> | ||
| + | ===== Denk-Anstöße / Ideen-Grundlagen / Links / Quellen ===== | ||
| * [[https://uberubuntu.info/questions/309311/wie-kann-ich-yate-als-tel-protocol-handler-festlegen |Wie kann ich yate als Tel: Protocol-Handler festlegen? - UberUbuntu]] (2019-11-13) | * [[https://uberubuntu.info/questions/309311/wie-kann-ich-yate-als-tel-protocol-handler-festlegen |Wie kann ich yate als Tel: Protocol-Handler festlegen? - UberUbuntu]] (2019-11-13) | ||
| Zeile 93: | Zeile 224: | ||
| * [[https://wiki.debianforum.de/Desktop-Notification_von_Systemservice_mittels_dbus |Desktop-Notification von Systemservice mittels dbus – DebianforumWiki]] (2019-11-13) | * [[https://wiki.debianforum.de/Desktop-Notification_von_Systemservice_mittels_dbus |Desktop-Notification von Systemservice mittels dbus – DebianforumWiki]] (2019-11-13) | ||
| + | |||
| + | * [[https://css-tricks.com/the-current-state-of-telephone-links/ |The Current State of Telephone Links | CSS-Tricks]] (2019-11-13) | ||
| + | |||
| ==== Spezifikationen ==== | ==== Spezifikationen ==== | ||