;;; org-dial.el --- Provide org links to dial with the softphone
;;; application linphone
;; Copyright (C) 2011 Michael Strey
;; Author: Michael Strey
;; Keywords: dial, phone, softphone, contacts, hypermedia
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This program is distaributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see .
;;; Commentary:
;; `org-dial.el' defines the new link type `dial' for telephone
;; numbers in contacts (refer to org-contacts). Calling this link type
;; leads to the execution of a linphone command dialing this number.
;;; Code:
(require 'org)
;; org link functions
;; dial link
(org-add-link-type "tel" 'org-dial)
(defcustom org-dial-program "linphonecsh dial "
"Name of the softphone executable used to dial a phone number in a `tel:' link."
:type '(string)
:group 'org)
(defun org-dial (phonenumber)
"Dial the phone number. The variable phonenumber should contain only numbers, whitespaces, backslash and maybe a `+' at the beginning."
;; remove whitespaces from phonenumber
(shell-command (concat org-dial-program (trim-phone-number phonenumber))))
(defun trim-phone-number (phonenumber)
"Remove whitespaces from a telephone number"
(setq trimmed_phonenumber
(mapconcat 'identity
(delete "(0)" (split-string phonenumber "[ /-]")) "")))
(provide 'org-dial)
;;; org-dial.el ends here