# Additional Integration- and Command Line Tools

This sections lists all the other smaller tools and script that come with kdebluetooth. Most of them are of limited use alone, but supposed to be called from within scripts or by other programs.

## kioclient: Script access to the KIO framework

This is a little utility to access kioslaves from the command line. So `kioclient` is actually a general purpose utility, but since it didn't seem to exist already, I had to program it myself.

With `kioclient` you can copy, list, delete any file or directory which is accessible by KDE's KIO Framework. You can copy a file from a FTP server directly to another server using WebDAV or list a directory via SSH with kio_fish. Or - and that's where it becomes interesting for us - you can access files on your mobile phone via kio_obex. kioclient is used by a sample script that comes with kbluetoothd: The `copy_images`-script.

You can list the possible arguments with `kioclient --help`, so here are just a few examples to get a first impression:

    $ kioclient cat http://www.kde.org | head -1
    <?xml version="1.0" encoding="UTF-8"?>
    $ kioclient ls -s ftp://ftp.kde.org | head -4
         4096 .
         4096 ..
         4096 bin
         4096 dev
    $ kioclient ls bluetooth:/
    local system
    Fred's 6230
    Fred's 3650
    $ kioclient ls "sdp://Fred's 6230/"
    OBEX Object Push
    OBEX File Transfer
    Dial-up networking
    Nokia PC Suite
    COM 1
    Voice Gateway
    Audio Gateway
    SIM ACCESS
    .More Services
    $

Please note that kioclient - even though it is a command line program - still needs to be run from within KDE, so you won't be able to use it in cronjobs for instance. But this limitation doesn't matter when you use it for deiscovery scripts in kbluetoothd.

## kbtsearch: Searching for devices from within scripts

Like `kioclient` or KDE's `kdialog`, this is a command line tool that is supposed be used in scripts. It provides a command line interface to the two common search dialogs of kdebluetooth - the device search dialog and the service search dialog.

You can use it when you want to the user to select a bluetooth device or find a specific service among the devices in range. Just like everywhere, the service selection dialog remembers the found devices and immendiatly fills the service list with previously found entries. The currently available services are added to the list after a few seconds.

To search for a device, simply type `kbtsearch --device`. When the user has selected a device or entered an address and clicked OK, kbtsearch will print the address of the device to stdout and return with status 0. If the user clicks Cancel, nothing is printed and the returned status code is 1:

    $ if ADDR=$(kbtsearch --device) ;
    > then echo "Selected address: $ADDR.";
    > else echo "No address selected."; fi
    Selected address: 00:60:57:5C:E6:BD.
    $

You can also search for a device that implements a given Bluetooth profile with `kbtsearch --uuid <Service-UUID>`. For a complete list of possible UUIDs for standard Bluetooth profile, see the Bluetooth Assigned Numbers (SDP). kbtsearch also defines some aliases for commonly used profiles. Run `kbtsearch --aliases` to get a list of possible aliases.

When the user selects a service and clicks OK, kbtsearch returns 0 and prints a line of the form '[address] [rfcommchannel]'. It is clear that this only makes sense for services that actually define an rfcomm channel. Currently there is no way to retrieve a L2CAP PSM for instance. Just tell me when you need it.

    $ if RET=( $(kbtsearch --uuid=FAX) ) ;
    > then ADDRESS=${RET[0]}; CHANNEL=${RET[1]};
    > echo "Selected addr=$ADDRESS, channel=$CHANNEL.";
    > else echo "No service selected.";
    > fi
    Selected addr=00:60:57:5C:E6:BD, channel=1.
    $

For additional options refer to `kbtsearch --help`.

## kbtfax: Sending fax messages with KDE applications

This is a helper script to make sending faxes from any KDE application easier. It depends on `efax` (third-party), `kdeprintfax` and `kdesu` (both part of kdebase) and the `rfcomm` tool (part of bluez-utils).

When you try to send a fax with `kdeprintfax`, you can select the fax backend to be used by kdeprintfax. One option is "EFax", anothe one is "Other". Select "Other", then find the kbtfax script in your kdebluetooth installation. Enter the command line as stated in the script itself. That's it. There are many things that could go wrong though. Feel free to improve the script and send patches :)