diff options
Diffstat (limited to 'src')
150 files changed, 16197 insertions, 0 deletions
diff --git a/src/AUTHORS b/src/AUTHORS new file mode 100644 index 0000000..91f72db --- /dev/null +++ b/src/AUTHORS @@ -0,0 +1 @@ +Emanoil Kotsev <[email protected]> diff --git a/src/interfaces/org.bluez.MediaPlayer1.xml b/src/interfaces/org.bluez.MediaPlayer1.xml new file mode 100644 index 0000000..1ce4d59 --- /dev/null +++ b/src/interfaces/org.bluez.MediaPlayer1.xml @@ -0,0 +1,55 @@ +<?xml version="1.0"?> +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> +<!-- + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="xml" type="s" direction="out"/> + </method> + </interface> +--> + <interface name="org.bluez.MediaPlayer1"> + <method name="Play"/> + <method name="Pause"/> + <method name="Stop"/> + <method name="Next"/> + <method name="Previous"/> + <method name="FastForward"/> + <method name="Rewind"/> + <property name="Name" type="s" access="read"/> + <property name="Type" type="s" access="read"/> + <property name="Subtype" type="s" access="read"/> + <property name="Position" type="u" access="read"/> + <property name="Status" type="s" access="read"/> + <property name="Equalizer" type="s" access="readwrite"/> + <property name="Repeat" type="s" access="readwrite"/> + <property name="Shuffle" type="s" access="readwrite"/> + <property name="Scan" type="s" access="readwrite"/> + <property name="Track" type="a{sv}" access="read"/> + <property name="Device" type="o" access="read"/> + <property name="Browsable" type="b" access="read"/> + <property name="Searchable" type="b" access="read"/> + <property name="Playlist" type="o" access="read"/> + </interface> + <interface name="org.freedesktop.DBus.Properties"> + <method name="Get"> + <arg name="interface" type="s" direction="in"/> + <arg name="name" type="s" direction="in"/> + <arg name="value" type="v" direction="out"/> + </method> + <method name="Set"> + <arg name="interface" type="s" direction="in"/> + <arg name="name" type="s" direction="in"/> + <arg name="value" type="v" direction="in"/> + </method> + <method name="GetAll"> + <arg name="interface" type="s" direction="in"/> + <arg name="properties" type="a{sv}" direction="out"/> + </method> + <signal name="PropertiesChanged"> + <arg name="interface" type="s"/> + <arg name="changed_properties" type="a{sv}"/> + <arg name="invalidated_properties" type="as"/> + </signal> + </interface> +</node> diff --git a/src/interfaces/org.bluez.adapter.xml b/src/interfaces/org.bluez.adapter.xml new file mode 100644 index 0000000..4cdd6a5 --- /dev/null +++ b/src/interfaces/org.bluez.adapter.xml @@ -0,0 +1,88 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> +<!-- + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="xml" type="s" direction="out" /> + </method> + </interface> + --> + <interface name="org.bluez.Adapter1"> + <method name="StartDiscovery"></method> + <method name="SetDiscoveryFilter"> + <arg name="properties" type="a{sv}" direction="in" /> + </method> + <method name="StopDiscovery"></method> + <method name="RemoveDevice"> + <arg name="device" type="o" direction="in" /> + </method> + <property name="Address" type="s" access="read"></property> + <property name="Name" type="s" access="read"></property> + <property name="Alias" type="s" access="readwrite"></property> + <property name="Class" type="u" access="read"></property> + <property name="Powered" type="b" access="readwrite"></property> + <property name="Discoverable" type="b" access="readwrite"></property> + <property name="DiscoverableTimeout" type="u" access="readwrite"></property> + <property name="Pairable" type="b" access="readwrite"></property> + <property name="PairableTimeout" type="u" access="readwrite"></property> + <property name="Discovering" type="b" access="read"></property> + <property name="UUIDs" type="as" access="read"></property> + <property name="Modalias" type="s" access="read"></property> + </interface> + <interface name="org.freedesktop.DBus.Properties"> + <method name="Get"> + <arg name="interface" type="s" direction="in" /> + <arg name="name" type="s" direction="in" /> + <arg name="value" type="v" direction="out" /> + </method> + <method name="Set"> + <arg name="interface" type="s" direction="in" /> + <arg name="name" type="s" direction="in" /> + <arg name="value" type="v" direction="in" /> + </method> + <method name="GetAll"> + <arg name="interface" type="s" direction="in" /> + <arg name="properties" type="a{sv}" direction="out" /> + </method> + <signal name="PropertiesChanged"> + <arg name="interface" type="s" /> + <arg name="changed_properties" type="a{sv}" /> + <arg name="invalidated_properties" type="as" /> + </signal> + </interface> + <interface name="org.bluez.GattManager1"> + <method name="RegisterApplication"> + <arg name="application" type="o" direction="in" /> + <arg name="options" type="a{sv}" direction="in" /> + </method> + <method name="UnregisterApplication"> + <arg name="application" type="o" direction="in" /> + </method> + </interface> + <interface name="org.bluez.Media1"> + <method name="RegisterEndpoint"> + <arg name="endpoint" type="o" direction="in" /> + <arg name="properties" type="a{sv}" direction="in" /> + </method> + <method name="UnregisterEndpoint"> + <arg name="endpoint" type="o" direction="in" /> + </method> + <method name="RegisterPlayer"> + <arg name="player" type="o" direction="in" /> + <arg name="properties" type="a{sv}" direction="in" /> + </method> + <method name="UnregisterPlayer"> + <arg name="player" type="o" direction="in" /> + </method> + </interface> + <interface name="org.bluez.NetworkServer1"> + <method name="Register"> + <arg name="uuid" type="s" direction="in" /> + <arg name="bridge" type="s" direction="in" /> + </method> + <method name="Unregister"> + <arg name="uuid" type="s" direction="in" /> + </method> + </interface> +</node>
\ No newline at end of file diff --git a/src/interfaces/org.bluez.device.xml b/src/interfaces/org.bluez.device.xml new file mode 100644 index 0000000..7715379 --- /dev/null +++ b/src/interfaces/org.bluez.device.xml @@ -0,0 +1,112 @@ +<?xml version="1.0" encoding="UTF-8"?> +<node> +<!-- + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="xml" type="s" direction="out" /> + </method> + </interface> +--> + <interface name="org.bluez.Device1"> + <method name="Disconnect"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + </method> + <method name="Connect"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + </method> + <method name="ConnectProfile"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="UUID" type="s" direction="in" /> + </method> + <method name="DisconnectProfile"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="UUID" type="s" direction="in" /> + </method> + <method name="Pair"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + </method> + <method name="CancelPairing"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + </method> + <property name="Address" type="s" access="read"></property> + <property name="Name" type="s" access="read"></property> + <property name="Alias" type="s" access="readwrite"></property> + <property name="Class" type="u" access="read"></property> + <property name="Appearance" type="q" access="read"></property> + <property name="Icon" type="s" access="read"></property> + <property name="Paired" type="b" access="read"></property> + <property name="Trusted" type="b" access="readwrite"></property> + <property name="Blocked" type="b" access="readwrite"></property> + <property name="LegacyPairing" type="b" access="read"></property> + <property name="RSSI" type="n" access="read"></property> + <property name="Connected" type="b" access="read"></property> + <property name="UUIDs" type="as" access="read"></property> + <property name="Modalias" type="s" access="read"></property> + <property name="Adapter" type="o" access="read"></property> + <property name="ManufacturerData" type="a{qv}" access="read"></property> + <property name="ServiceData" type="a{sv}" access="read"></property> + <property name="TxPower" type="n" access="read"></property> + <property name="ServicesResolved" type="b" access="read"></property> + </interface> + <interface name="org.freedesktop.DBus.Properties"> + <method name="Get"> + <arg name="interface" type="s" direction="in" /> + <arg name="name" type="s" direction="in" /> + <arg name="value" type="v" direction="out" /> + </method> + <method name="Set"> + <arg name="interface" type="s" direction="in" /> + <arg name="name" type="s" direction="in" /> + <arg name="value" type="v" direction="in" /> + </method> + <method name="GetAll"> + <arg name="interface" type="s" direction="in" /> + <arg name="properties" type="a{sv}" direction="out" /> + </method> + <signal name="PropertiesChanged"> + <arg name="interface" type="s" /> + <arg name="changed_properties" type="a{sv}" /> + <arg name="invalidated_properties" type="as" /> + </signal> + </interface> + <interface name="org.bluez.MediaControl1"> + <method name="Play"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <method name="Pause"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <method name="Stop"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <method name="Next"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <method name="Previous"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <method name="VolumeUp"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <method name="VolumeDown"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <method name="FastForward"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <method name="Rewind"> + <annotation name="org.freedesktop.DBus.Deprecated" + value="true" /> + </method> + <property name="Connected" type="b" access="read"></property> + <property name="Player" type="o" access="read"></property> + </interface> +</node>
\ No newline at end of file diff --git a/src/interfaces/org.bluez.manager.xml b/src/interfaces/org.bluez.manager.xml new file mode 100644 index 0000000..5c16ffa --- /dev/null +++ b/src/interfaces/org.bluez.manager.xml @@ -0,0 +1,43 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> +<!-- + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="xml" type="s" direction="out" /> + </method> + </interface> + --> + <interface name="org.bluez.AgentManager1"> + <method name="RegisterAgent"> + <arg name="agent" type="o" direction="in" /> + <arg name="capability" type="s" direction="in" /> + </method> + <method name="UnregisterAgent"> + <arg name="agent" type="o" direction="in" /> + </method> + <method name="RequestDefaultAgent"> + <arg name="agent" type="o" direction="in" /> + </method> + </interface> + <interface name="org.bluez.ProfileManager1"> + <method name="RegisterProfile"> + <arg name="profile" type="o" direction="in" /> + <arg name="UUID" type="s" direction="in" /> + <arg name="options" type="a{sv}" direction="in" /> + </method> + <method name="UnregisterProfile"> + <arg name="profile" type="o" direction="in" /> + </method> + </interface> + <interface name="org.bluez.HealthManager1"> + <method name="CreateApplication"> + <arg name="config" type="a{sv}" direction="in" /> + <arg name="application" type="o" direction="out" /> + </method> + <method name="DestroyApplication"> + <arg name="application" type="o" direction="in" /> + </method> + </interface> + <node name="hci0" /> +</node>
\ No newline at end of file diff --git a/src/interfaces/org.bluez.obex.Agent1.xml b/src/interfaces/org.bluez.obex.Agent1.xml new file mode 100644 index 0000000..e7a0289 --- /dev/null +++ b/src/interfaces/org.bluez.obex.Agent1.xml @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- https://github.com/r10r/bluez/blob/master/doc/obex-agent-api.txt --> +<node name="/org/trinitydesktop/tdeobex"> +<!-- <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="xml" type="s" direction="out"/> + </method> + </interface> +--> + <interface name="org.bluez.obex.Agent1"> + <method name="Release"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + </method> + <method name="AuthorizePush"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="transfer" direction="in" type="o"/> + <arg name="filepath" direction="out" type="s"/> + </method> + <method name="Cancel"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + </method> + </interface> +</node> diff --git a/src/interfaces/org.bluez.obex.client.xml b/src/interfaces/org.bluez.obex.client.xml new file mode 100644 index 0000000..1eadf29 --- /dev/null +++ b/src/interfaces/org.bluez.obex.client.xml @@ -0,0 +1,201 @@ +<?xml version="1.0"?> +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<!-- https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-api.txt --> +<node name="/org/bluez/obex"> +<!-- + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="xml" type="s" direction="out"/> + </method> + </interface> +--> + <interface name="org.bluez.obex.AgentManager1"> + <method name="RegisterAgent"> + <arg name="agent" type="o" direction="in" /> + </method> + <method name="UnregisterAgent"> + <arg name="agent" type="o" direction="in" /> + </method> + </interface> + + <!-- https://git.merproject.org/jpoutiai/kf5bluezqt/blob/master/bluez-qt/src/interfaces/org.bluez.obex.Client1.xml --> + <interface name="org.bluez.obex.Client1"> + <method name="CreateSession"> + <arg name="destination" type="s" direction="in" /> + <arg name="args" type="a{sv}" direction="in" /> + <arg name="session" type="o" direction="out" /> + </method> + <method name="RemoveSession"> + <arg name="session" type="o" direction="in" /> + </method> + </interface> + <!-- https://git.merproject.org/jpoutiai/kf5bluezqt/blob/master/bluez-qt/src/interfaces/org.bluez.obex.FileTransfer1.xml --> + <interface name="org.bluez.obex.FileTransfer1"> + <method name="ChangeFolder"> + <arg name="folder" type="s" direction="in" /> + </method> + <method name="CreateFolder"> + <arg name="folder" type="s" direction="in" /> + </method> + <method name="ListFolder"> + <arg name="folderinfo" type="aa{sv}" direction="out" /> + </method> + <method name="GetFile"> + <arg name="targetfile" type="s" direction="in" /> + <arg name="sourcefile" type="s" direction="in" /> + <arg name="transfer" type="o" direction="out" /> + <arg name="properties" type="a{sv}" direction="out" /> + </method> + <method name="PutFile"> + <arg name="sourcefile" type="s" direction="in" /> + <arg name="targetfile" type="s" direction="in" /> + <arg name="transfer" type="o" direction="out" /> + <arg name="properties" type="a{sv}" direction="out" /> + </method> + <method name="CopyFile"> + <arg name="sourcefile" type="s" direction="in" /> + <arg name="targetfile" type="s" direction="in" /> + </method> + <method name="MoveFile"> + <arg name="sourcefile" type="s" direction="in" /> + <arg name="targetfile" type="s" direction="in" /> + </method> + <method name="Delete"> + <arg name="file" type="s" direction="in" /> + </method> + </interface> + <!-- https://git.merproject.org/jpoutiai/kf5bluezqt/blob/master/bluez-qt/src/interfaces/org.bluez.obex.ObjectPush1.xml --> + <interface name="org.bluez.obex.ObjectPush1"> + <method name="SendFile"> + <arg name="sourcefile" type="s" direction="in" /> + <arg name="transfer" type="o" direction="out" /> + <arg name="properties" type="a{sv}" direction="out" /> + </method> + <method name="PullBusinessCard"> + <arg name="targetfile" type="s" direction="in" /> + <arg name="transfer" type="o" direction="out" /> + <arg name="properties" type="a{sv}" direction="out" /> + </method> + <method name="ExchangeBusinessCards"> + <arg name="clientfile" type="s" direction="in" /> + <arg name="targetfile" type="s" direction="in" /> + <arg name="transfer" type="o" direction="out" /> + <arg name="properties" type="a{sv}" direction="out" /> + </method> + </interface> + <!-- https://git.merproject.org/jpoutiai/kf5bluezqt/blob/master/bluez-qt/src/interfaces/org.bluez.obex.Session1.xml --> + <interface name="org.bluez.obex.Session1"> + <method name="GetCapabilities"> + <arg name="capabilities" type="s" direction="out" /> + </method> + + <property name="Source" type="s" access="read" /> + <property name="Destination" type="s" access="read" /> + <property name="Channel" type="b" access="read" /> + <property name="Target" type="s" access="read" /> + <property name="Root" type="s" access="read" /> + + </interface> + + <!-- https://git.merproject.org/jpoutiai/kf5bluezqt/blob/master/bluez-qt/src/interfaces/org.bluez.obex.Transfer1.xml --> + <interface name="org.bluez.obex.Transfer1"> + <method name="Cancel" /> + <method name="Suspend" /> + <method name="Resume" /> + + <property name="Status" type="s" access="read" /> + <property name="Session" type="o" access="read" /> + <property name="Name" type="s" access="read" /> + <property name="Type" type="s" access="read" /> + <property name="Time" type="t" access="read" /> + <property name="Size" type="t" access="read" /> + <property name="Transferred" type="t" access="read" /> + <property name="Filename" type="s" access="read" /> + + </interface> + + <!-- https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-api.txt --> + <interface name="org.bluez.obex.Synchronization1"> + <method name="SetLocation"> + <arg name="location" type="s" direction="in" /> + </method> + <method name="GetPhonebook"> + <arg name="phonebook" type="o" direction="out" /> + <arg name="sourcefile" type="s" direction="in" /> + <arg name="targetfile" type="s" direction="in" /> + </method> + <method name="PutPhonebook"> + <arg name="sourcefile" type="s" direction="in" /> + </method> + </interface> + +<!-- TODO --> + <!-- https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-api.txt --> + <interface name="org.bluez.obex.PhonebookAccess1"> + <method name="Select"> + <arg name="location" type="s" direction="in" /> + <arg name="phonebook" type="s" direction="in" /> + </method> + <method name="PullAll"> + <arg name="path" type="o" direction="out" /> + <arg name="properties" type="a{sv}" direction="out" /> + <arg name="targetfile" type="s" direction="in" /> + <arg name="filters" type="as" direction="in" /> + </method> + <method name="List"> + <arg name="vcard" type="a{ss}" direction="out" /> + <arg name="filters" type="as" direction="in" /> + </method> + <method name="Pull"> + <arg name="transfer" type="o" direction="out" /> + <arg name="vcards" type="a{sv}" direction="out" /> + <arg name="vcard" type="s" direction="in" /> + <arg name="targetfile" type="s" direction="in" /> + <arg name="filters" type="as" direction="in" /> + </method> + + <property name="Folder" type="s" access="read" /> + <property name="DatabaseIdentifier" type="s" access="read" /> + <property name="PrimaryCounter" type="s" access="read" /> + <property name="SecondaryCounter" type="s" access="read" /> + <property name="FixedImageSize" type="s" access="read" /> + + </interface> + +<!-- TODO --> + <!-- https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/obex-api.txt --> + <!-- <interface name="org.bluez.obex.MessageAccess1"> --> + <!-- <method name="SetLocation"> --> + <!-- <arg name="location" type="s" direction="in" /> --> + <!-- </method> --> + <!-- <method name="GetPhonebook"> --> + <!-- <arg name="phonebook" type="o" direction="out" /> --> + <!-- <arg name="sourcefile" type="s" direction="in" /> --> + <!-- <arg name="targetfile" type="s" direction="in" /> --> + <!-- </method> --> + <!-- <method name="PutPhonebook"> --> + <!-- <arg name="sourcefile" type="s" direction="in" /> --> + <!-- </method> --> + <!-- </interface> --> + <interface name="org.freedesktop.DBus.Properties"> + <method name="Get"> + <arg name="interface" type="s" direction="in" /> + <arg name="name" type="s" direction="in" /> + <arg name="value" type="v" direction="out" /> + </method> + <method name="Set"> + <arg name="interface" type="s" direction="in" /> + <arg name="name" type="s" direction="in" /> + <arg name="value" type="v" direction="in" /> + </method> + <method name="GetAll"> + <arg name="interface" type="s" direction="in" /> + <arg name="properties" type="a{sv}" direction="out" /> + </method> + <signal name="PropertiesChanged"> + <arg name="interface" type="s" /> + <arg name="changed_properties" type="a{sv}" /> + <arg name="invalidated_properties" type="as" /> + </signal> + </interface> +</node>
\ No newline at end of file diff --git a/src/interfaces/org.freedesktop.DBus.ObjectManager.xml b/src/interfaces/org.freedesktop.DBus.ObjectManager.xml new file mode 100644 index 0000000..cf73bea --- /dev/null +++ b/src/interfaces/org.freedesktop.DBus.ObjectManager.xml @@ -0,0 +1,24 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" +"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<node> +<!-- + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="xml" type="s" direction="out" /> + </method> + </interface> +--> + <interface name="org.freedesktop.DBus.ObjectManager"> + <method name="GetManagedObjects"> + <arg name="objects" type="a{oa{sa{sv}}}" direction="out" /> + </method> + <signal name="InterfacesAdded"> + <arg name="object" type="o" /> + <arg name="interfaces" type="a{sa{sv}}" /> + </signal> + <signal name="InterfacesRemoved"> + <arg name="object" type="o" /> + <arg name="interfaces" type="as" /> + </signal> + </interface> +</node>
\ No newline at end of file diff --git a/src/interfaces/org.mpris.MediaPlayer2.xml b/src/interfaces/org.mpris.MediaPlayer2.xml new file mode 100644 index 0000000..12d1099 --- /dev/null +++ b/src/interfaces/org.mpris.MediaPlayer2.xml @@ -0,0 +1,143 @@ +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> +<!-- GDBus 2.40.0 --> +<node> + <interface name="org.freedesktop.DBus.Properties"> + <method name="Get"> + <arg type="s" name="interface_name" direction="in"/> + <arg type="s" name="property_name" direction="in"/> + <arg type="v" name="value" direction="out"/> + </method> + <method name="GetAll"> + <arg type="s" name="interface_name" direction="in"/> + <arg type="a{sv}" name="properties" direction="out"/> + </method> + <method name="Set"> + <arg type="s" name="interface_name" direction="in"/> + <arg type="s" name="property_name" direction="in"/> + <arg type="v" name="value" direction="in"/> + </method> + <signal name="PropertiesChanged"> + <arg type="s" name="interface_name"/> + <arg type="a{sv}" name="changed_properties"/> + <arg type="as" name="invalidated_properties"/> + </signal> + </interface> + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg type="s" name="xml_data" direction="out"/> + </method> + </interface> + <interface name="org.freedesktop.DBus.Peer"> + <method name="Ping"/> + <method name="GetMachineId"> + <arg type="s" name="machine_uuid" direction="out"/> + </method> + </interface> + <interface name="org.mpris.MediaPlayer2"> + <method name="Raise"> + </method> + <method name="Quit"> + </method> + <property type="b" name="CanQuit" access="read"> + </property> + <property type="b" name="CanRaise" access="read"> + </property> + <property type="b" name="HasTrackList" access="read"> + </property> + <property type="s" name="Identity" access="read"> + </property> + <property type="s" name="DesktopEntry" access="read"> + </property> + <property type="as" name="SupportedUriSchemes" access="read"> + </property> + <property type="as" name="SupportedMimeTypes" access="read"> + </property> + </interface> + <interface name="org.mpris.MediaPlayer2.Playlists"> + <method name="ActivatePlaylist"> + <arg type="o" name="PlaylistId" direction="in"> + </arg> + </method> + <method name="GetPlaylists"> + <arg type="u" name="Index" direction="in"> + </arg> + <arg type="u" name="MaxCount" direction="in"> + </arg> + <arg type="s" name="Order" direction="in"> + </arg> + <arg type="b" name="ReverseOrder" direction="in"> + </arg> + <arg type="a(oss)" name="arg_4" direction="out"> + </arg> + </method> + <property type="u" name="PlaylistCount" access="read"> + </property> + <property type="as" name="Orderings" access="read"> + </property> + <property type="(b(oss))" name="ActivePlaylist" access="read"> + </property> + </interface> + <interface name="org.mpris.MediaPlayer2.Player"> + <method name="Next"> + </method> + <method name="Previous"> + </method> + <method name="Pause"> + </method> + <method name="PlayPause"> + </method> + <method name="Stop"> + </method> + <method name="Play"> + </method> + <method name="Seek"> + <arg type="x" name="Offset" direction="in"> + </arg> + </method> + <method name="SetPosition"> + <arg type="o" name="TrackId" direction="in"> + </arg> + <arg type="x" name="Position" direction="in"> + </arg> + </method> + <method name="OpenUri"> + <arg type="s" name="Uri" direction="in"> + </arg> + </method> + <signal name="Seeked"> + <arg type="x" name="Position"> + </arg> + </signal> + <property type="s" name="PlaybackStatus" access="read"> + </property> + <property type="s" name="LoopStatus" access="readwrite"> + </property> + <property type="d" name="Rate" access="readwrite"> + </property> + <property type="b" name="Shuffle" access="readwrite"> + </property> + <property type="a{sv}" name="Metadata" access="read"> + </property> + <property type="d" name="Volume" access="readwrite"> + </property> + <property type="x" name="Position" access="read"> + </property> + <property type="d" name="MinimumRate" access="read"> + </property> + <property type="d" name="MaximumRate" access="read"> + </property> + <property type="b" name="CanGoNext" access="read"> + </property> + <property type="b" name="CanGoPrevious" access="read"> + </property> + <property type="b" name="CanPlay" access="read"> + </property> + <property type="b" name="CanPause" access="read"> + </property> + <property type="b" name="CanSeek" access="read"> + </property> + <property type="b" name="CanControl" access="read"> + </property> + </interface> +</node> diff --git a/src/interfaces/org.tdebluez.agent.xml b/src/interfaces/org.tdebluez.agent.xml new file mode 100644 index 0000000..36bac01 --- /dev/null +++ b/src/interfaces/org.tdebluez.agent.xml @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<node name="/org/trinitydesktop/tdebluez"> +<!-- The Introspectable Interface gets autogenerated + <interface name="org.freedesktop.DBus.Introspectable"> + <method name="Introspect"> + <arg name="xml" type="s" direction="out"/> + </method> + </interface> +--> + <interface name="org.bluez.Agent1"> + <method name="Release"> + </method> + <method name="RequestPinCode"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="device" direction="in" type="o"/> + <arg name="pincode" direction="out" type="s"/> + </method> + <method name="DisplayPinCode"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="device" direction="in" type="o"/> + <arg name="pincode" direction="in" type="s"/> + </method> + <method name="RequestPasskey"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="device" direction="in" type="o"/> + <arg name="passkey" direction="out" type="u"/> + </method> + <method name="DisplayPasskey"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="device" direction="in" type="o"/> + <arg name="passkey" direction="in" type="u"/> + <arg name="entered" direction="in" type="q"/> + </method> + <method name="RequestConfirmation"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="device" direction="in" type="o"/> + <arg name="passkey" direction="in" type="u"/> + </method> + <method name="RequestAuthorization"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="device" direction="in" type="o"/> + </method> + <method name="AuthorizeService"> + <annotation name="org.freedesktop.DBus.GLib.Async"/> + <arg name="device" direction="in" type="o"/> + <arg name="uuid" direction="in" type="s"/> + </method> + <method name="Cancel"> + </method> + </interface> +</node> diff --git a/src/libtdebluez/CMakeLists.txt b/src/libtdebluez/CMakeLists.txt new file mode 100644 index 0000000..bb80327 --- /dev/null +++ b/src/libtdebluez/CMakeLists.txt @@ -0,0 +1,96 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +project( libtdebluez ) +set(LIBRARY_VERSION 0.0.1) + +# include( ConfigureChecks.cmake ) +foreach( f ${TQT_LIBRARIES} ) + if( ${f} STREQUAL "tqt-mt" ) + set(TQUI_LIBRARIES "tqui" CACHE TYPE STRING FORCE) + endif() + if( ${f} STREQUAL "qt-mt" ) + set(TQUI_LIBRARIES "qui" CACHE TYPE STRING FORCE) + endif() +endforeach() + +# import required +#tde_import( lib... ) + +add_subdirectory( interfaces ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### headers ################################### +# implementations +install( + FILES adapterImpl.h + btuuids.h + deviceImpl.h + devicemimeconverter.h + objectmanagerImpl.h + DESTINATION ${INCLUDE_INSTALL_DIR}/tdebluez ) + +##### other data ################################ +# install( FILES xxxxxxxx.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) + +##### tdebluetoothwidgets (module) #################### +# +# add_custom_command( OUTPUT tdebluetoothwidgets.cpp +# COMMAND +# ${KDE3_MAKETDEWIDGETS_EXECUTABLE} +# -o tdebluetoothwidgets.cpp +# ${CMAKE_CURRENT_SOURCE_DIR}/tdebluez.widgets +# DEPENDS +# ${CMAKE_CURRENT_SOURCE_DIR}/tdebluez.widgets ) +# +# set_source_files_properties( tdebluetoothwidgets.cpp PROPERTIES COMPILE_FLAGS "-DQT_PLUGIN" ) +# +# tde_add_kpart( tdebluetoothwidgets +# SOURCES tdebluetoothwidgets.cpp +# LINK tdebluez-shared +# DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/designer +# ) + +set( target tdebluez ) + +set( ${target}_SRCS + objectmanagerImpl.cpp + adapterImpl.cpp + deviceImpl.cpp + devicemimeconverter.cpp +# agent/introspectableinterface.cpp agent/org_trinitydesktop_tdeblueznode.cpp + ) + +##### tdebluez (shared) ########################### +# set( KDE3_DCOPIDL_EXECUTABLE ${KDE3_DCOPIDLNG_EXECUTABLE} ) +tde_add_library( ${target} SHARED AUTOMOC + SOURCES ${${target}_SRCS} + VERSION ${LIBRARY_VERSION} + DEPENDS bluezinterfaces-static + LINK ${DBUS_TQT_LIBRARIES} tdeparts-shared bluezinterfaces-static ${TQUI_LIBRARIES} + DESTINATION ${LIB_INSTALL_DIR} + ) + +##### install import cmake modules ############### +tde_install_export( ) diff --git a/src/libtdebluez/README b/src/libtdebluez/README new file mode 100644 index 0000000..fa8b639 --- /dev/null +++ b/src/libtdebluez/README @@ -0,0 +1,29 @@ +interfaces + source interfaces for autogenerating with dbusxml2qt3 +libtdebluez/ + Implementations and other files part of the library + +libtdebluez/ + +libtdebluez/interfaces + interfaces autogenerated with dbusxml2qt3 + - autogenerated proxy to objectmanager + - adapter + adapter1 proxy + gattmanager1 proxy + media1 proxy + neworkserver1 proxy + - obexagent + autogenerated obex agent - interface and proxy + - properties + autogenerated dbus properties proxy + - device + autogenerated device1 proxy + autogenerated mediacontrol1 proxy + - agent + autogenerated agent1 interface and proxy + autogenerated introspectable interface + autogenerated trinity desktop tdebluez node interface + - manager + autogenerated proxies to managers +
\ No newline at end of file diff --git a/src/libtdebluez/adapterImpl.cpp b/src/libtdebluez/adapterImpl.cpp new file mode 100644 index 0000000..703f06f --- /dev/null +++ b/src/libtdebluez/adapterImpl.cpp @@ -0,0 +1,144 @@ +/* + * + * Adapter Implementation of bluez5 for libtdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <linux/rfkill.h> +#include <unistd.h> + +#include <tqfile.h> +#include <tqregexp.h> +#include <tqdir.h> + +#include <tqdbusproxy.h> +#include <tqmessagebox.h> + +#include "adapterImpl.h" + +namespace TDEBluetooth +{ + +AdapterImpl::AdapterImpl(const TQString& service, const TQString& path, TQObject* parent, const char* name) : + Adapter1Proxy(service, path, parent, name) /*,properties(service,path,parent,name)*/ +{ +} + +AdapterImpl::~AdapterImpl() +{ +} + +void AdapterImpl::powerOn(bool state) +{ + // https://www.kernel.org/doc/Documentation/rfkill.txt + // http://jwhsmith.net/2015/02/manipulating-rfkill-using-devices-programmatically/ + // https://cpp.hotexamples.com/examples/-/-/rfkill_alloc/cpp-rfkill_alloc-function-examples.html + // https://github.com/systemd/systemd/blob/main/src/rfkill/rfkill.c + + TQString device = getPath(); + device = device.replace(TQRegExp("^/.*/"), ""); + int hcidx = -1; + TQDir d("/sys/class/rfkill"); + d.setFilter(TQDir::Dirs); + for (int i = 0; i < d.count(); i++) + { + // expected is rfkill<n> + TQFile f("/sys/class/rfkill/" + d[i] + "/name"); + TQString content; + if (f.exists() && f.open(IO_ReadOnly)) + { + TQTextStream stream(&f); + content = stream.readLine(); + f.close(); + } + else + { + continue; + } + if (content.startsWith(device)) + { + TQFile f("/sys/class/rfkill/" + d[i] + "/index"); + if (f.exists() && f.open(IO_ReadOnly)) + { + TQTextStream stream(&f); + hcidx = stream.readLine().toUInt(); + f.close(); + } + break; + } + } + + if (hcidx < 0) + { + // error handling + tqDebug("Index for the device %s not found", device.local8Bit().data()); + return; + } + + struct rfkill_event event = { 0 }; + + TQFile file("/dev/rfkill"); + if (!file.open(IO_ReadWrite)) + { + tqDebug("Failed to open %s", file.name().utf8().data()); + return; + } + + event.idx = hcidx; + event.op = RFKILL_OP_CHANGE; + if (state) + event.soft = 0; + else + event.soft = 1; + + tqDebug("Bluetooth device %s switches: idx(%i), soft(%d).", device.local8Bit().data(), event.idx, event.soft); + + if (write(file.handle(), &event, sizeof(event)) < 0) + tqDebug("Failed to write to %s", file.name().utf8().data()); + file.close(); +} + +TQString AdapterImpl::getPath() +{ + return TQString(m_baseProxy->path()); +} + +void AdapterImpl::slotSetAlias(const TQString& alias) +{ + TQT_DBusError error; + setAlias(alias, error); + if (error.isValid()) + tqDebug("AdapterImpl::slotSetAlias(%s) failed: %s", alias.utf8().data(), error.message().utf8().data()); +} + +void AdapterImpl::slotSetTimeout(int timeout) +{ + TQT_DBusError error; + setDiscoverableTimeout(timeout, error); + if (error.isValid()) + tqDebug("AdapterImpl::slotSetTimeout(%i) failed: %s", timeout, error.message().utf8().data()); +} + +} // namespace TDEBluetooth + +#include "adapterImpl.moc" +// End of File diff --git a/src/libtdebluez/adapterImpl.h b/src/libtdebluez/adapterImpl.h new file mode 100644 index 0000000..e192a17 --- /dev/null +++ b/src/libtdebluez/adapterImpl.h @@ -0,0 +1,59 @@ +/* + * + * Adapter Implementation of bluez5 for libtdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#if !defined(ADAPTERIMPL_H_INCLUDED) +#define ADAPTERIMPL_H_INCLUDED + +#include "interfaces/adapter1Proxy.h" + +using namespace org::bluez; + +namespace TDEBluetooth +{ + +class AdapterImpl: public Adapter1Proxy +{ + Q_OBJECT + +public: + AdapterImpl(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0); + + virtual ~AdapterImpl(); + void powerOn(bool state); + TQString getPath(); + +public slots: + void slotSetAlias(const TQString& alias); + void slotSetTimeout(int timeout); + +}; +// class AdapterImpl + +}; +// namespace TDEBluetooth + +#endif //ADAPTERIMPL_H_INCLUDED + +// End of File diff --git a/src/libtdebluez/btuuids.h b/src/libtdebluez/btuuids.h new file mode 100644 index 0000000..597f037 --- /dev/null +++ b/src/libtdebluez/btuuids.h @@ -0,0 +1,148 @@ +/* + * + * List of BT UUIDs and resolver for libtdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +/* + * This was taken from bluez/lib/uuid.h 2018-07-22 + * + */ + + +#include <map> +#include <string> + +#ifndef BTUUIDS_H_ +#define BTUUIDS_H_ + +static const std::map<std::string, std::string> my_map = +{ + { "00001203-0000-1000-8000-00805f9b34fb", "Generic Audio" }, + { "00001108-0000-1000-8000-00805f9b34fb", "Headset" }, + { "00001112-0000-1000-8000-00805f9b34fb", "Headset AG" }, + + { "0000111e-0000-1000-8000-00805f9b34fb", "Handsfree" }, + { "0000111f-0000-1000-8000-00805f9b34fb", "Handsfree AG" }, + + { "0000110d-0000-1000-8000-00805f9b34fb", "Advanced Audio" }, + + { "0000110a-0000-1000-8000-00805f9b34fb", "A2DP Source" }, //Advanced Audio Distribution Profile + { "0000110b-0000-1000-8000-00805f9b34fb", "A2DP Sink" }, + + { "0000110e-0000-1000-8000-00805f9b34fb", "A/V Remote Ctrl" }, //Audio/Video Remote Control Profile + { "0000110c-0000-1000-8000-00805f9b34fb", "A/V Remote Ctrl Tgt" }, + + { "00001115-0000-1000-8000-00805f9b34fb", "PANU" }, + { "00001116-0000-1000-8000-00805f9b34fb", "NAP" }, + { "00001117-0000-1000-8000-00805f9b34fb", "GN" }, + { "0000000f-0000-1000-8000-00805f9b34fb", "BNEP Service" }, //Bluetooth Network Encapsulation Protocol + + { "00002a50-0000-1000-8000-00805f9b34fb", "PNPID" }, + { "0000180a-0000-1000-8000-00805f9b34fb", "Device Information" }, + + { "00001801-0000-1000-8000-00805f9b34fb", "GATT" }, //Generic Access Profile (Generic Attributes) + { "00001802-0000-1000-8000-00805f9b34fb", "Immediate Alert" }, + { "00001803-0000-1000-8000-00805f9b34fb", "Link Loss" }, + { "00001804-0000-1000-8000-00805f9b34fb", "TX Power" }, + + { "0000112d-0000-1000-8000-00805f9b34fb", "SAP" }, + + { "0000180d-0000-1000-8000-00805f9b34fb", "Heart Rate" }, + { "00002a37-0000-1000-8000-00805f9b34fb", "Heart Rate Measurement" }, + { "00002a38-0000-1000-8000-00805f9b34fb", "Body Sensor Location" }, + { "00002a39-0000-1000-8000-00805f9b34fb", "Heart Rate Control Point" }, + + { "00001809-0000-1000-8000-00805f9b34fb", "Health Thermometer" }, + { "00002a1c-0000-1000-8000-00805f9b34fb", "Temp Measurement" }, + { "00002a1d-0000-1000-8000-00805f9b34fb", "Temp Type" }, + { "00002a1e-0000-1000-8000-00805f9b34fb", "Immediate Temp" }, + { "00002a21-0000-1000-8000-00805f9b34fb", "Measurement Interval" }, + + { "00001816-0000-1000-8000-00805f9b34fb", "Cycling SC" }, + { "00002a5b-0000-1000-8000-00805f9b34fb", "CSC Measurement" }, + { "00002a5c-0000-1000-8000-00805f9b34fb", "CSC Feature" }, + { "00002a5d-0000-1000-8000-00805f9b34fb", "Sensor Location" }, + { "00002a55-0000-1000-8000-00805f9b34fb", "SC Control Point" }, + + { "00000003-0000-1000-8000-00805f9b34fb", "RFCOMM" }, + + { "00001400-0000-1000-8000-00805f9b34fb", "HDP" }, + { "00001401-0000-1000-8000-00805f9b34fb", "HDP Source" }, + { "00001402-0000-1000-8000-00805f9b34fb", "HDP Sink" }, + + { "00001124-0000-1000-8000-00805f9b34fb", "HID" }, + + { "00001103-0000-1000-8000-00805f9b34fb", "DUN Gateway" }, //Dial-up Networking Profile + + { "00001800-0000-1000-8000-00805f9b34fb", "GAP" }, //Generic Access Profile + { "00001200-0000-1000-8000-00805f9b34fb", "PNP" }, + + { "00001101-0000-1000-8000-00805f9b34fb", "SPP" }, //Serial Port Profile + + { "00001104-0000-1000-8000-00805f9b34fb", "OBEX Sync" }, + { "00001105-0000-1000-8000-00805f9b34fb", "OBEX OPP" }, + { "00001106-0000-1000-8000-00805f9b34fb", "OBEX FTP" }, + { "f9ec7bc4-953c-11d2-984e-525400dc9e09", "OBEX DIR" }, + { "0000112e-0000-1000-8000-00805f9b34fb", "OBEX PCE" }, + { "0000112f-0000-1000-8000-00805f9b34fb", "OBEX PSE" }, + { "00001130-0000-1000-8000-00805f9b34fb", "OBEX PBAP" }, + { "00001132-0000-1000-8000-00805f9b34fb", "OBEX Msg Access Srv" }, + { "00001133-0000-1000-8000-00805f9b34fb", "OBEX Msg Notif. Srv" }, + { "00001134-0000-1000-8000-00805f9b34fb", "OBEX MAP" }, + // taken from + // https://www.vistax64.com/threads/bluetooth-peripheral-device-cannot-be-found.62944/ + // https://together.jolla.com/question/64565/accessing-bluetooth-profiles/ + // http://www.sensi.org/~ak/tmp/n95.txt + { "00005005-0000-1000-8000-0002ee000001", "Nokia PC Suite" }, + { "00005601-0000-1000-8000-0002ee000001", "Nokia SyncML Server" }, + { "00000001-0000-1000-8000-0002ee000001", "SyncML Server" }, + { "00000002-0000-1000-8000-0002ee000002", "OBEX Syncevolution" }, + { "00000004-0000-1000-8000-0002ee000002", "SyncML DM Client" } + +}; + +/*! + * This function resolves UUID to human readable service name. + * \return string service name + * \retval the service name + */ + +static const TQString resolveUUID(const TQString &uuid) +{ + + TQString name; + + for (auto i = my_map.begin(); i != my_map.end(); ++i) + { + if (i->first == uuid.latin1()) + { + name = TQString(i->second.c_str()); + break; + } + } + // name = i18n("Unknown"); + return (!name.isEmpty()) ? name : uuid; +} + +#endif // BTUUIDS_H_ diff --git a/src/libtdebluez/deviceImpl.cpp b/src/libtdebluez/deviceImpl.cpp new file mode 100644 index 0000000..7b8a971 --- /dev/null +++ b/src/libtdebluez/deviceImpl.cpp @@ -0,0 +1,49 @@ +/* + * + * Device Implementation of bluez5 for libtdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "deviceImpl.h" + +namespace TDEBluetooth +{ + +DeviceImpl::DeviceImpl(const TQString& service, const TQString& path, TQObject* parent, const char* name) : org::bluez::Device1Proxy(service, path, parent, name) +{ + m_path = path; +} + +DeviceImpl::~DeviceImpl() +{ +} + +const TQString DeviceImpl::getPath() +{ + return m_path; +} + +}; +// namespace TDEBluetooth + +#include "deviceImpl.moc" +// End of File diff --git a/src/libtdebluez/deviceImpl.h b/src/libtdebluez/deviceImpl.h new file mode 100644 index 0000000..45b355b --- /dev/null +++ b/src/libtdebluez/deviceImpl.h @@ -0,0 +1,62 @@ +/* + * + * Device Implementation of bluez5 for libtdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#if !defined(DEVICEIMPL_H_INCLUDED) +#define DEVICEIMPL_H_INCLUDED + +// QT - Header +#include <tqtimer.h> + +// debug +#include <kdebug.h> + +#include "interfaces/device1Proxy.h" +#include "interfaces/propertiesProxy.h" + +namespace TDEBluetooth +{ + +class DeviceImpl: public org::bluez::Device1Proxy +{ + Q_OBJECT + +public: + DeviceImpl(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0); + + virtual ~DeviceImpl(); + const TQString getPath(); + +private: + TQString m_path; + +}; +// class DeviceImpl + +}; +// namespace TDEBluetooth + +#endif //DEVICEIMPL_H_INCLUDED + +// End of File diff --git a/src/libtdebluez/devicemimeconverter.cpp b/src/libtdebluez/devicemimeconverter.cpp new file mode 100644 index 0000000..b14669e --- /dev/null +++ b/src/libtdebluez/devicemimeconverter.cpp @@ -0,0 +1,147 @@ +/* + * + * Device Mime Converter for libtdebluez + * + * Copyright (C) 2003 by Fred Schaettgen + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <kmimetype.h> + +#include "devicemimeconverter.h" + +namespace TDEBluetooth +{ + +DeviceMimeConverter::DeviceMimeConverter() +{ + getIconName("bluetooth/unknown-device-class"); + getIconName("bluetooth/misc-device-class"); + getIconName("bluetooth/computer-device-class"); + getIconName("bluetooth/phone-device-class"); + getIconName("bluetooth/lan-device-class"); + getIconName("bluetooth/av-device-class"); + getIconName("bluetooth/peripheral-device-class"); + getIconName("bluetooth/mouse-device-class"); + getIconName("bluetooth/keyboard-device-class"); + getIconName("bluetooth/imaging-device-class"); +} + +void DeviceMimeConverter::getIconName(TQString mime) +{ + TQString iconName = KMimeType::mimeType(mime)->icon(TQString::null, false); + mimeTypeToIconMap[mime] = iconName; +} + +DeviceMimeConverter* DeviceMimeConverter::getInstance() +{ + static DeviceMimeConverter instance; + return &instance; +} + +TQString DeviceMimeConverter::classToIconName(int n) +{ + return DeviceMimeConverter::mimeTypeToIcon(DeviceMimeConverter::classToMimeType(n)); +} + +/* + * device classes + * + AUDIO_VIDEO (Value: 0x00000400) + COMPUTER (Value: 0x00000100) + HEALTH (Value: 0x00000900) + IMAGING (Value: 0x00000600) + MISC (Value: 0x00000000) + NETWORKING (Value: 0x00000300) + PERIPHERAL (Value: 0x00000500) + PHONE (Value: 0x00000200) + TOY (Value: 0x00000800) + UNCATEGORIZED (Value: 0x00001f00) + WEARABLE (Value: 0x00000700) +*/ + +TQString DeviceMimeConverter::classToMimeType(int n) +{ + TQString mimeType; + int major = ((n & 0x001F00) >> 8); + int minor = ((n >> 2) & 0x30); + switch (major) + { + case 0x00: + mimeType = "bluetooth/misc-device-class"; + break; + case 0x01: + mimeType = "bluetooth/computer-device-class"; + break; + case 0x02: + mimeType = "bluetooth/phone-device-class"; + break; + case 0x03: + mimeType = "bluetooth/lan-device-class"; + break; + case 0x04: + mimeType = "bluetooth/av-device-class"; + break; + case 0x05: + switch (minor) + { + case 0x10: + mimeType = "bluetooth/keyboard-device-class"; + break; + case 0x20: + mimeType = "bluetooth/mouse-device-class"; + break; + default: + mimeType = "bluetooth/peripheral-device-class"; + } + break; + case 0x06: + mimeType = "bluetooth/imaging-device-class"; + break; + case 0x07: + mimeType = "bluetooth/wearable-device-class"; + break; + case 0x08: + mimeType = "bluetooth/toy-device-class"; + break; + case 0x09: + mimeType = "bluetooth/health-device-class"; + break; + default: + mimeType = "bluetooth/unknown-device-class"; + } + return mimeType; +} + +TQString DeviceMimeConverter::mimeTypeToIcon(TQString mime) +{ + DeviceMimeConverter* c = DeviceMimeConverter::getInstance(); + if (c->mimeTypeToIconMap.find(mime) != c->mimeTypeToIconMap.end()) + { + return c->mimeTypeToIconMap[mime]; + } + else + { + return c->mimeTypeToIconMap["bluetooth/unknown-device-class"]; + } +} + +} // TDEBluetooth diff --git a/src/libtdebluez/devicemimeconverter.h b/src/libtdebluez/devicemimeconverter.h new file mode 100644 index 0000000..63a1d9f --- /dev/null +++ b/src/libtdebluez/devicemimeconverter.h @@ -0,0 +1,53 @@ +/* + * + * Device Mime Converter for libtdebluez + * + * Copyright (C) 2003 by Fred Schaettgen + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef DEVICEMIMECONVERTER_H +#define DEVICEMIMECONVERTER_H + +#include <map> + +namespace TDEBluetooth +{ +/** + @author Fred Schaettgen + */ +class DeviceMimeConverter +{ +public: + static TQString classToMimeType(int deviceClass); + static TQString mimeTypeToIcon(TQString mimeType); + static TQString classToIconName(int deviceClass); +protected: + DeviceMimeConverter(); + static DeviceMimeConverter *getInstance(); +private: + std::map<TQString, TQString> mimeTypeToIconMap; + void getIconName(TQString mimetype); +}; + +} // TDEBluetooth + +#endif diff --git a/src/libtdebluez/interfaces/CMakeLists.txt b/src/libtdebluez/interfaces/CMakeLists.txt new file mode 100644 index 0000000..2f44a83 --- /dev/null +++ b/src/libtdebluez/interfaces/CMakeLists.txt @@ -0,0 +1,135 @@ +################################################# +# +# (C) 2020 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${TQT_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) + +set( INTROSPECTIONPATH ${CMAKE_SOURCE_DIR}/src/interfaces ) +set( DBUSXML2QT3_EXECUTABLE dbusxml2qt3 ) + +set( ObjectManager_HDRS objectmanagerInterface.h objectmanagerProxy.h introspectableInterface.h ) +set( ObjectManager_SRCS objectmanagerInterface.cpp objectmanagerProxy.cpp introspectableInterface.cpp) + +set( AgentManager_HDRS agentmanager1Interface.h agentmanager1Proxy.h healthmanager1Interface.h healthmanager1Proxy.h profilemanager1Interface.h profilemanager1Proxy.h ) +set( AgentManager_SRCS agentmanager1Interface.cpp agentmanager1Proxy.cpp healthmanager1Interface.cpp healthmanager1Proxy.cpp profilemanager1Interface.cpp profilemanager1Proxy.cpp ) + +set( Agent_HDRS agent1Interface.h agent1Proxy.h dbusbaseNode.h tdebluezNode.h ) +set( Agent_SRCS agent1Interface.cpp agent1Proxy.cpp dbusbaseNode.cpp tdebluezNode.cpp ) + +set( Adapter_HDRS adapter1Interface.h adapter1Proxy.h gattmanager1Interface.h gattmanager1Proxy.h media1Interface.h media1Proxy.h networkserver1Interface.h networkserver1Proxy.h propertiesInterface.h propertiesProxy.h) +set( Adapter_SRCS adapter1Interface.cpp adapter1Proxy.cpp gattmanager1Interface.cpp gattmanager1Proxy.cpp media1Interface.cpp media1Proxy.cpp networkserver1Interface.cpp networkserver1Proxy.cpp propertiesInterface.cpp propertiesProxy.cpp ) + +set( Device_HDRS device1Interface.h device1Proxy.h mediacontrol1Interface.h mediacontrol1Proxy.h) +set( Device_SRCS device1Interface.cpp device1Proxy.cpp mediacontrol1Interface.cpp mediacontrol1Proxy.cpp ) + +function( make_moc fileinput ) + add_custom_command( OUTPUT ${fileinput}.moc + COMMAND ${TMOC_EXECUTABLE} ${fileinput}.h -o ${fileinput}.moc + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.h + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + set_property( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.cpp APPEND + PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.moc ) +endfunction( ) + +#function( install_header fileinput target ) +# install( +# FILES ${CMAKE_CURRENT_BUILD_DIR}/${fileinput} +# DESTINATION ${target} +# ) +#endfunction( ) + + +##### ObjectManager ######################### +add_custom_command( + OUTPUT ${ObjectManager_HDRS} ${ObjectManager_SRCS} + COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.freedesktop.DBus.ObjectManager.xml 2>/dev/null + DEPENDS ${INTROSPECTIONPATH}/org.freedesktop.DBus.ObjectManager.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +make_moc ( objectmanagerProxy ) + +##### AgentManager ######################### +add_custom_command( + OUTPUT ${AgentManager_HDRS} ${AgentManager_SRCS} + COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.bluez.manager.xml 2>/dev/null + DEPENDS ${INTROSPECTIONPATH}/org.bluez.manager.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +make_moc ( agentmanager1Proxy ) +make_moc ( healthmanager1Proxy ) +make_moc ( profilemanager1Proxy ) + +##### Agent ######################### +add_custom_command( + OUTPUT ${Agent_HDRS} ${Agent_SRCS} + COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.tdebluez.agent.xml 2>/dev/null + DEPENDS ${INTROSPECTIONPATH}/org.tdebluez.agent.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +make_moc ( agent1Proxy ) + +##### Adapter ######################### +add_custom_command( + OUTPUT ${Adapter_HDRS} ${Adapter_SRCS} + COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.bluez.adapter.xml 2>/dev/null + DEPENDS ${INTROSPECTIONPATH}/org.bluez.adapter.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +make_moc ( adapter1Proxy ) +make_moc ( gattmanager1Proxy ) +make_moc ( networkserver1Proxy ) +make_moc ( propertiesProxy ) + +##### Device ######################### +add_custom_command( + OUTPUT ${Device_HDRS} ${Device_SRCS} + COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.bluez.device.xml 2>/dev/null + DEPENDS ${INTROSPECTIONPATH}/org.bluez.device.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +make_moc ( device1Proxy ) +make_moc ( propertiesProxy ) +make_moc ( mediacontrol1Proxy ) +make_moc ( media1Proxy ) + +tde_add_library( bluezinterfaces STATIC_PIC AUTOMOC + SOURCES ${ObjectManager_SRCS} ${AgentManager_SRCS} ${Agent_SRCS} ${Adapter_SRCS} ${Device_SRCS} + LINK ${DBUS_TQT_LIBRARIES} +) + +##### install headers ################################### + + +#file( GLOB _bin_dirs RELATIVE ${CMAKE_CURRENT_BINARY_DIR} +# ${CMAKE_CURRENT_BINARY_DIR}/* ) +#unset( _exclude_dirs ) +#foreach( _dir IN LISTS _bin_dirs ) +# if(IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_dir} ) +# list( APPEND _exclude_dirs PATTERN ${_dir} EXCLUDE ) +# endif() +#endforeach() +# +#install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +# DESTINATION ${INCLUDE_INSTALL_DIR}/tdeobex +# USE_SOURCE_PERMISSIONS +# FILES_MATCHING PATTERN PATTERN "*.h" +# ${_exclude_dirs} +#) + +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR}/tdebluez + USE_SOURCE_PERMISSIONS + FILES_MATCHING PATTERN PATTERN "*.h" + PATTERN "CMakeFiles" EXCLUDE) diff --git a/src/libtdebluez/objectmanagerImpl.cpp b/src/libtdebluez/objectmanagerImpl.cpp new file mode 100644 index 0000000..789e221 --- /dev/null +++ b/src/libtdebluez/objectmanagerImpl.cpp @@ -0,0 +1,607 @@ +/* + * + * Object Manager implementation of bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <tqstringlist.h> + +#include <tqdbusmessage.h> +#include <tqdbusobjectpath.h> +#include <tqdbusdatamap.h> +#include <tqdbusdata.h> +#include <tqdbusdatalist.h> +#include <tqdbusvariant.h> + +#include "objectmanagerImpl.h" +#include "btuuids.h" + +namespace TDEBluetooth +{ + +ObjectManagerImpl::ObjectManagerImpl(const TQString& service, const TQString& path, TQObject* parent, const char* name) : + ObjectManagerProxy(service, path, parent, name) +{ + agentManager = 0; + profileManager = 0; + healthManager = 0; + agentRegisteredStatus = false; + agentIsDefaultAgent = false; + // init connection to dbus + initDBUS(); +} + +ObjectManagerImpl::~ObjectManagerImpl() +{ + // close D-Bus connection + close(); + + if(agentManager) + delete agentManager; + if(profileManager) + delete profileManager; + if(healthManager) + delete healthManager; +} + +/*! + * This function try a reconnect to D-Bus. + * \return boolean with the result of the operation + * \retval true if successful reconnected to D-Bus + * \retval false if unsuccessful + */ +bool ObjectManagerImpl::reconnect() +{ + // close D-Bus connection + close(); + // init D-Bus conntection + return (initDBUS()); +} + +/*! + * This function return information about connection status to the DBUS daemon. + * \return boolean with the state of the connection to D-Bus + * \retval true if connected + * \retval false if disconnected + */ +bool ObjectManagerImpl::isConnectedToDBUS() +{ + return dBusConn.isConnected(); +} + +/*! + * This function returns pointer to connection of the DBUS. + * \return TQT_DBusConnection* of the connection to D-Bus + * \retval TQT_DBusConnection* + */ +TQT_DBusConnection* ObjectManagerImpl::getConnection() +{ + return &dBusConn; +} + +/*! + * This function close the connection to manager over the D-Bus daemon. + * \return boolean with the result of the operation + * \retval true if successful closed the connection + * \retval false if any problems + */ +bool ObjectManagerImpl::close() +{ + disconnect(this, SIGNAL(InterfacesAdded(const TQT_DBusObjectPath&, const TQT_DBusDataMap< TQString >&)), + this, SLOT(slotInterfacesAdded(const TQT_DBusObjectPath&, const TQT_DBusDataMap< TQString >& ))); + disconnect(this, SIGNAL(InterfacesRemoved(const TQT_DBusObjectPath& , const TQStringList& )), + this, SLOT(slotInterfacesRemoved(const TQT_DBusObjectPath& , const TQStringList& ))); + + for (PropertiesMap::iterator it = adapters.begin(); it != adapters.end(); + ++it) + { + org::freedesktop::DBus::PropertiesProxy *p; + p = it.data(); + if (p != NULL) + delete p; + } + for (PropertiesMap::iterator it = devices.begin(); it != devices.end(); + ++it) + { + org::freedesktop::DBus::PropertiesProxy *p; + p = it.data(); + if (p != NULL) + delete p; + } + adapters.clear(); + devices.clear(); + + dBusConn.closeConnection(DBUS_CONN_NAME); + return true; +} + +/*! + * This function initializes the connection to the D-Bus daemon. + * \return pointer to AgentManager1Proxy + */ +AgentManager1Proxy * ObjectManagerImpl::getAgentManager() +{ + return agentManager; +} + +/*! + * This function initializes the connection to the D-Bus daemon. + * \return pointer to ProfileManager1Proxy + */ +ProfileManager1Proxy * ObjectManagerImpl::getProfileManager() +{ + return profileManager; +} + +/*! + * This function initializes the connection to the D-Bus daemon. + * \return pointer to HealthManager1Proxy + */ +HealthManager1Proxy * ObjectManagerImpl::getHealthManager() +{ + return healthManager; +} + +/*! + * This function returns a list of objectpaths + * \return TQValueList<TQString> + * \retval TQValueList<TQString> + */ +ObjectManagerImpl::AdapterList ObjectManagerImpl::getAdapters() +{ + return adapters.keys(); +} + +/*! + * This function returns a list of objectpaths + * \return TQValueList<TQString> + * \retval TQValueList<TQString> + */ +ObjectManagerImpl::DeviceList ObjectManagerImpl::getDevices() +{ + return devices.keys(); +} + +ObjectManagerImpl::ConnectionList ObjectManagerImpl::listConnections(const TQString &adapter) +{ + ConnectionList list; + return list; +} + +bool ObjectManagerImpl::registerAgent() +{ + if (!agentRegisteredStatus) + { + TQT_DBusError error; + agentManager->RegisterAgent( + TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), DEVICE_PIN_CAPABILITY, error); + if (error.isValid()) + { + tqDebug("Could not register agent: %s", error.message().local8Bit().data()); + return false; + } + agentRegisteredStatus = true; + } + return true; +} + +bool ObjectManagerImpl::unregisterAgent() +{ + kdDebug() << k_funcinfo << endl; + if (agentRegisteredStatus) + { + TQT_DBusError error; + getAgentManager()->UnregisterAgent( + TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), error); + if (error.isValid()) + { + tqDebug("Could not unregister agent"); + return false; + } + agentRegisteredStatus = false; + agentIsDefaultAgent = false; + } + return true; +} + +bool ObjectManagerImpl::requestDefaultAgent() +{ + TQT_DBusError error; + agentManager->RequestDefaultAgent( + TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), error); + if (error.isValid()) + { + tqDebug("Could not request default agent: %s", error.message().local8Bit().data()); + return false; + } + agentIsDefaultAgent = true; + return true; +} + +bool ObjectManagerImpl::isAgentRegistered() +{ + return agentRegisteredStatus; +} + +bool ObjectManagerImpl::isAgentDefaultAgent() +{ + return agentIsDefaultAgent; +} + +/*! + * This function initializes the connection to the D-Bus daemon. + * \return boolean with the result of the operation + * \retval true if successful initialized D-Bus connection + * \retval false if unsuccessful + */ +bool ObjectManagerImpl::initDBUS() +{ + dBusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus, DBUS_CONN_NAME); + if (!dBusConn.isConnected()) + { + tqDebug("Failed to open connection to system message bus: %s", dBusConn.lastError().message().local8Bit().data()); + TQTimer::singleShot(4000, this, TQT_SLOT(reconnect())); + return false; + } + setConnection(dBusConn); + + TQT_DBusDataMap<TQT_DBusObjectPath> objects; + TQT_DBusError error; + if (!GetManagedObjects(objects, error)) + { + tqDebug("GetManagedObjects(objects,error) FAILED:\n%s\n", error.message().latin1()); + return false; + } + + TQT_DBusDataMap<TQT_DBusObjectPath>::const_iterator it = objects.begin(); + for (it; it != objects.end(); ++it) + { + bool ok = false; + slotInterfacesAdded(it.key(), it.data().toStringKeyMap(&ok)); + if (!ok) + tqWarning("Failed to convert dbus data to string map: %s", it.key().latin1()); + } + + connect(this, SIGNAL(InterfacesAdded(const TQT_DBusObjectPath&, const TQT_DBusDataMap< TQString >&)), + this, SLOT(slotInterfacesAdded(const TQT_DBusObjectPath&, const TQT_DBusDataMap< TQString >& ))); + connect(this, SIGNAL(InterfacesRemoved(const TQT_DBusObjectPath& , const TQStringList& )), + this, SLOT(slotInterfacesRemoved(const TQT_DBusObjectPath& , const TQStringList& ))); + + return true; +} + +void ObjectManagerImpl::adapterPropertiesChanged(TQString path, const TQMap< + TQString, TQT_DBusVariant>& changed_properties) +{ + TQMap<TQString, TQT_DBusVariant>::const_iterator it; + for (it = changed_properties.begin(); it != changed_properties.end(); ++it) + { + bool ok = false; + if (it.key() == "Powered") + emit adapterPowerOnChanged(path, it.data().value.toBool(&ok)); + else if (it.key() == "Class") + emit adapterClassChanged(path, it.data().value.toUInt32(&ok)); + else if (it.key() == "Name") + emit adapterNameChanged(path, it.data().value.toString(&ok)); + else if (it.key() == "Alias") + emit adapterAliasChanged(path, it.data().value.toString(&ok)); + else if (it.key() == "DiscoverableTimeout") + emit adapterDiscoverableTimeoutChanged(path, it.data().value.toUInt32(&ok)); + else if (it.key() == "Discoverable") + emit adapterDiscoverableChanged(path, it.data().value.toBool(&ok)); + else if (it.key() == "Discovering") + emit adapterDiscoveringChanged(path, it.data().value.toBool(&ok)); + else + continue; + if (!ok) + tqDebug("ObjectManagerImpl::adapterPropertiesChanged conversion failed"); + } +} + +void ObjectManagerImpl::devicePropertiesChanged(TQString path, const TQMap<TQString, TQT_DBusVariant>& changed_properties) +{ + // https://github.com/r10r/bluez/blob/master/doc/device-api.txt + TQMap<TQString, TQT_DBusVariant>::const_iterator it; + for (it = changed_properties.begin(); it != changed_properties.end(); ++it) + { + bool ok = false; + if (it.key() == "Address") + emit deviceAddressChanged(path, it.data().value.toString(&ok)); + else if (it.key() == "Class") + emit deviceClassChanged(path, it.data().value.toUInt32(&ok)); + else if (it.key() == "Name") + emit deviceNameChanged(path, it.data().value.toString(&ok)); + else if (it.key() == "Alias") + emit deviceAliasChanged(path, it.data().value.toString(&ok)); +// https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.gap.appearance.xml + else if (it.key() == "Appearance") + emit deviceAppearanceChanged(path, it.data().value.toUInt16(&ok)); + else if (it.key() == "Icon") + emit deviceIconChanged(path, it.data().value.toString(&ok)); + else if (it.key() == "Paired") + emit devicePairedChanged(path, it.data().value.toBool(&ok)); + else if (it.key() == "Trusted") + emit deviceTrustedChanged(path, it.data().value.toBool(&ok)); + else if (it.key() == "Blocked") + emit deviceBlockedChanged(path, it.data().value.toBool(&ok)); + else if (it.key() == "LegacyPairing") + emit deviceLegacyPairingChanged(path, it.data().value.toBool(&ok)); + else if (it.key() == "RSSI") + emit deviceRSSIChanged(path, it.data().value.toInt16(&ok)); //INT16 + else if (it.key() == "Connected") + emit deviceConnectedChanged(path, it.data().value.toBool(&ok)); + else if (it.key() == "UUIDs") + { + TQT_DBusDataList vl = TQT_DBusDataList(it.data().value.toTQValueList(&ok)); + emit deviceUUIDsChanged(path, vl.toStringList(&ok)); + } + else if (it.key() == "Adapter") + emit deviceAdapterChanged(path, it.data().value.toObjectPath(&ok)); + else if (it.key() == "ManufacturerData") + emit deviceManufacturerDataChanged(path, it.data().value.toUInt16KeyMap(&ok)); //a{qv} + else if (it.key() == "ServiceData") + emit deviceServiceDataChanged(path, it.data().value.toStringKeyMap(&ok)); //a{sv} + else if (it.key() == "TxPower") + emit deviceTxPowerChanged(path, it.data().value.toInt16(&ok)); //INT16 + else if (it.key() == "ServicesResolved") + emit deviceServicesResolvedChanged(path, it.data().value.toBool(&ok)); + else + continue; + if (!ok) + tqDebug("ObjectManagerImpl::devicePropertiesChanged conversion failed"); + } + +} + +void ObjectManagerImpl::mediaControlPropertiesChanged(TQString path, const TQMap<TQString, TQT_DBusVariant>& changed_properties) +{ + TQMap<TQString, TQT_DBusVariant>::const_iterator it; + for (it = changed_properties.begin(); it != changed_properties.end(); ++it) + { + bool ok = false; + if (it.key() == "Connected") + emit mediaControlConnectedChanged(path, it.data().value.toBool(&ok)); + else if (it.key() == "Player") + emit mediaControlPlayerChanged(path, it.data().value.toObjectPath(&ok)); + else + continue; + if (!ok) + tqDebug("ObjectManagerImpl::mediaControlPropertiesChanged conversion failed"); + } +} + +void ObjectManagerImpl::slotInterfacesAdded(const TQT_DBusObjectPath& object, const TQT_DBusDataMap<TQString>& interfaces) +{ + TQT_DBusDataMap<TQString>::const_iterator it1 = interfaces.begin(); + for (it1; it1 != interfaces.end(); it1++) + { + TQString interface = it1.key(); + if (interface == "org.bluez.AgentManager1") + { + agentManager = new AgentManager1Proxy("org.bluez", object/*, this, "AgentManager1"*/); + if (agentManager) + agentManager->setConnection(dBusConn); + } + else if (interface == "org.bluez.ProfileManager1") + { + profileManager = new ProfileManager1Proxy("org.bluez", object/*, this, "ProfileManager1"*/); + if (profileManager) + profileManager->setConnection(dBusConn); + } + else if (interface == "org.bluez.HealthManager1") + { + healthManager = new HealthManager1Proxy("org.bluez", object/*, this, "HealthManager1"*/); + if (healthManager) + healthManager->setConnection(dBusConn); + } + else if (interface == "org.bluez.Adapter1") + { + org::freedesktop::DBus::PropertiesProxy *properties; + properties = new org::freedesktop::DBus::PropertiesProxy("org.bluez", object); + properties->setConnection(dBusConn); + connect(properties, SIGNAL(PropertiesChanged ( const TQString&, const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& )), this, SLOT(slotPropertiesChanged ( const TQString& , const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& ))); + adapters.insert(TQString(object), properties); + //notify others + emit adapterAdded(TQString(object)); + } + else if (interface == "org.bluez.GattManager1") + { + kdDebug() << "Interface not implemented: org.bluez.GattManager1" << endl; + // TODO: Implement GattManager1 + } + else if (interface == "org.bluez.Media1") + { + kdDebug() << "Interface not implemented: org.bluez.Media1" << endl; + // TODO: Implement Media1 + } + else if (interface == "org.bluez.NetworkServer1") + { + kdDebug() << "Interface not implemented: org.bluez.NetworkServer1" << endl; + // TODO: Implement NetworkServer1 + } + else if (interface == "org.bluez.Device1") + { + org::freedesktop::DBus::PropertiesProxy *properties; + properties = new org::freedesktop::DBus::PropertiesProxy("org.bluez", object); + properties->setConnection(dBusConn); + connect(properties, SIGNAL(PropertiesChanged ( const TQString&, const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& )), this, SLOT(slotPropertiesChanged ( const TQString& , const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& ))); + devices.insert(TQString(object), properties); + //notify others + emit deviceAdded(TQString(object)); + } + else if (interface == "org.bluez.MediaControl1") + { + kdDebug() << "Interface not implemented: org.bluez.MediaControl1" << endl; + kdDebug() << "as the media control is triggered via properties changed." << endl; + } + else if (interface == "org.bluez.MediaTransport1") + { + kdDebug() << "Interface not implemented: org.bluez.MediaTransport1" << endl; + // TODO: Implement MediaTransport1 + } + else if (interface == "org.freedesktop.DBus.Introspectable") + { + // do nothing + } + else if (interface == "org.freedesktop.DBus.Properties") + { + // do nothing + } + else + { + tqWarning("Interface not implemented: %s", interface.local8Bit().data()); + } + } +} + +void ObjectManagerImpl::slotInterfacesRemoved(const TQT_DBusObjectPath& object, const TQStringList& interfaces) +{ + // TODO: remove interface + for (TQValueListConstIterator<TQString> it = interfaces.begin(); + it != interfaces.end(); ++it) + { + if ((*it) == "org.bluez.AgentManager1") + { + kdDebug() << "Remove org.bluez.AgentManager1" << endl; + // TODO: remove AgentManager1 + } + else if ((*it) == "org.bluez.ProfileManager1") + { + kdDebug() << "Interface not implemented: org.bluez.ProfileManager1" << endl; + // TODO: remove ProfileManager1 + } + else if ((*it) == "org.bluez.HealthManager1") + { + kdDebug() << "Interface not implemented: org.bluez.HealthManager1" << endl; + // TODO: remove HealthManager1 + } + else if ((*it) == "org.bluez.Adapter1") + { + kdDebug() << "Remove org.bluez.Adapter1" << endl; + disconnect(adapters[object], SIGNAL(PropertiesChanged ( const TQString&, const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& )), this, SLOT(slotPropertiesChanged ( const TQString& , const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& ))); + adapters.remove(object); + emit adapterRemoved(TQString(object)); + } + else if ((*it) == "org.bluez.GattManager1") + { + kdDebug() << "Interface not implemented: org.bluez.GattManager1" << endl; + // TODO: Implement GattManager1 + } + else if ((*it) == "org.bluez.Media1") + { + kdDebug() << "Interface not implemented: org.bluez.Media1" << endl; + // TODO: Implement Media1 + } + else if ((*it) == "org.bluez.NetworkServer1") + { + kdDebug() << "Interface not implemented: org.bluez.NetworkServer1" << endl; + // TODO: Implement NetworkServer1 + } + else if ((*it) == "org.bluez.Device1") + { + kdDebug() << "Remove org.bluez.Device1" << endl; + disconnect(devices[object], SIGNAL(PropertiesChanged ( const TQString&, const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& )), this, SLOT(slotPropertiesChanged ( const TQString& , const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& ))); + devices.remove(object); + emit deviceRemoved(TQString(object)); + } + else if ((*it) == "org.bluez.MediaControl1") + { + kdDebug() << "Interface not implemented: org.bluez.MediaControl1" << endl; + kdDebug() << "as the media control is triggered via properties changed." << endl; + // emit mediaControlRemoved(TQString ( object.data() )); + } + else if ((*it) == "org.freedesktop.DBus.Introspectable") + { + // do nothing + } + else if ((*it) == "org.freedesktop.DBus.Properties") + { + // do nothing + } + else + { + tqWarning("Interface not implemented: %s", (*it).local8Bit().data()); + } + } +} + +void ObjectManagerImpl::slotPropertiesChanged(const TQString& interface, const TQMap<TQString, TQT_DBusVariant>& changed_properties, const TQStringList& invalidated_properties) +{ + // who send the signal ? + const TQObject * o = TQObject::sender(); + org::freedesktop::DBus::PropertiesProxy *obj; + obj = const_cast<org::freedesktop::DBus::PropertiesProxy*>(reinterpret_cast<const org::freedesktop::DBus::PropertiesProxy*>(o)); + TQString path; + + if (interface == "org.bluez.Adapter1") + { + for (PropertiesMap::Iterator it = adapters.begin(); + it != adapters.end(); ++it) + { + if (obj == it.data()) + path = it.key(); + } + if (!path.isEmpty()) + adapterPropertiesChanged(path, changed_properties); + } + else if (interface == "org.bluez.Device1") + { + for (PropertiesMap::Iterator it = devices.begin(); it != devices.end(); + ++it) + { + if (obj == it.data()) + path = it.key(); + } + if (!path.isEmpty()) + devicePropertiesChanged(path, changed_properties); + } + else if (interface == "org.bluez.MediaControl1") + { + for (PropertiesMap::Iterator it = devices.begin(); it != devices.end(); + ++it) + { + if (obj == it.data()) + path = it.key(); + } + if (!path.isEmpty()) + mediaControlPropertiesChanged(path, changed_properties); + } + +// TQStringList::const_iterator it1; +// for ( it1 = invalidated_properties.begin(); it1 != invalidated_properties.end(); ++it1 ) +// { +// kdDebug() << "Invalidated Key: " << (*it1) << endl; +//// if ( it.key() == "Powered" ) +//// emit powerOnChanged(TQT_DBusData::fromVariant ( it.data() ).toBool()); +//// if ( it.key() == "DiscoverableTimeout" ) +//// emit discoverableTimeoutChanged(TQT_DBusData::fromVariant ( it.data() ).toUInt32()); +//// if ( it.key() == "Discoverable" ) +//// emit discoverableTimeoutChanged(TQT_DBusData::fromVariant ( it.data() ).toBool()); +// } + +} + +}; // namespace TDEBluetooth + +#include "objectmanagerImpl.moc" +// End of File + diff --git a/src/libtdebluez/objectmanagerImpl.h b/src/libtdebluez/objectmanagerImpl.h new file mode 100644 index 0000000..f8f9c2f --- /dev/null +++ b/src/libtdebluez/objectmanagerImpl.h @@ -0,0 +1,177 @@ +/* + * + * Object Manager implementation of bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef OBJECTMANAGERIMPL_H_INCLUDED +#define OBJECTMANAGERIMPL_H_INCLUDED + +#include <tqdbusconnection.h> +#include <tdelocale.h> + +#include "interfaces/objectmanagerProxy.h" +#include "interfaces/agentmanager1Proxy.h" +#include "interfaces/profilemanager1Proxy.h" +#include "interfaces/healthmanager1Proxy.h" +#include "interfaces/propertiesProxy.h" + +#include "adapterImpl.h" +#include "deviceImpl.h" + +//using namespace org::bluez; + +#define DBUS_CONN_NAME "TDEBluez" + +#define DBUS_AUTH_SERVICE_PATH "/org/trinitydesktop/tdebluez" +#define DEVICE_PIN_CAPABILITY "KeyboardDisplay" + +namespace TDEBluetooth +{ + +class ObjectManagerImpl : public org::freedesktop::DBus::ObjectManagerProxy +{ + Q_OBJECT + +public: + ObjectManagerImpl(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0); + + virtual ~ObjectManagerImpl(); + typedef TQMap<TQString,org::freedesktop::DBus::PropertiesProxy*> PropertiesMap; + typedef TQValueList<TQString> AdapterList; + typedef TQValueList<TQString> DeviceList; + typedef TQValueList<TQString> ConnectionList; + // typedef TQValueList<TQString> ServiceList; + + // --- helper to get private members of the class --- // + //! to get information if TDEBluez is connected to D-Bus + bool isConnectedToDBUS(); + //! pointer to the D-Bus connection + TQT_DBusConnection* getConnection(); + //! to close the connection to D-Bus + bool close(); + + // + AgentManager1Proxy* getAgentManager(); + ProfileManager1Proxy* getProfileManager(); + HealthManager1Proxy* getHealthManager(); + AdapterList getAdapters(); + DeviceList getDevices(); + // ServiceList getServices(); + ConnectionList listConnections(const TQString&); + + + //! to register the agent to D-Bus + bool registerAgent(); //TQT_DBusError& + //! to unregister the agent to D-Bus + bool unregisterAgent(); //TQT_DBusError& + //! to register the agent to D-Bus + bool requestDefaultAgent(); //TQT_DBusError& + + bool isAgentRegistered(); + + bool isAgentDefaultAgent(); + +private: + bool initDBUS(); + void adapterPropertiesChanged(TQString path, const TQMap<TQString, TQT_DBusVariant>& changed_properties); + void devicePropertiesChanged(TQString path, const TQMap<TQString, TQT_DBusVariant>& changed_properties); + void mediaControlPropertiesChanged(TQString path, const TQMap<TQString, TQT_DBusVariant>& changed_properties); + +private: + //! TQt connection to D-Bus + TQT_DBusConnection dBusConn; + AgentManager1Proxy* agentManager; + ProfileManager1Proxy* profileManager; + HealthManager1Proxy* healthManager; + PropertiesMap adapters; + PropertiesMap devices; + bool agentRegisteredStatus; + bool agentIsDefaultAgent; + +signals: + // from ObjectManager + void adapterAdded(const TQString&); + void adapterRemoved(const TQString&); + + void deviceAdded(const TQString&); + void deviceRemoved(const TQString&); + + void mediaControlAdded(const TQString&); + void mediaControlRemoved(const TQString&); + + // from Adapter1 + void adapterNameChanged(const TQString&, const TQString&); + // void adapterModeChanged(const TQString&, const TQString&); + void adapterAliasChanged(const TQString&, const TQString&); + void adapterPowerOnChanged(const TQString&, bool state); + void adapterClassChanged(const TQString&, TQ_UINT32 classvalue); + void adapterDiscoverableTimeoutChanged(const TQString&, TQ_UINT32 timeout); + // TODO: this should be same as modeChanged + void adapterDiscoverableChanged(const TQString&, bool state); + void adapterDiscoveringChanged(const TQString&, bool state); + + // from Device1 + void deviceAddressChanged(const TQString&, const TQString&); + void deviceClassChanged(const TQString&, TQ_UINT32); + void deviceNameChanged(const TQString&, const TQString&); + void deviceAliasChanged(const TQString&, const TQString&); + // https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.gap.appearance.xml + void deviceAppearanceChanged(const TQString&, TQ_UINT32); + void deviceIconChanged(const TQString&, const TQString&); + void devicePairedChanged(const TQString&, bool); + void deviceTrustedChanged(const TQString&, bool); + void deviceBlockedChanged(const TQString&, bool); + void deviceLegacyPairingChanged(const TQString&, bool); + void deviceRSSIChanged(const TQString&, TQ_INT16); + void deviceConnectedChanged(const TQString&, bool); + void deviceUUIDsChanged(const TQString&, TQStringList); + void deviceAdapterChanged(const TQString&, const TQT_DBusObjectPath&); + void deviceManufacturerDataChanged(const TQString&, TQT_DBusDataMap<TQ_UINT16>); + void deviceServiceDataChanged(const TQString&, TQT_DBusDataMap<TQString>); + void deviceTxPowerChanged(const TQString&, TQ_INT16); + void deviceServicesResolvedChanged(const TQString&, bool); + + // from MediaControl1 + void mediaControlConnectedChanged(const TQString&, bool state); + void mediaControlPlayerChanged(const TQString&, const TQT_DBusObjectPath&); + +private slots: + bool reconnect(); + + // inherited from ObjectManager + void slotInterfacesAdded(const TQT_DBusObjectPath& object, const TQT_DBusDataMap< TQString >& interfaces); + void slotInterfacesRemoved(const TQT_DBusObjectPath& object, const TQStringList& interfaces); + + /** + * parse properties changed on any interface + * emit signal for the interface and property + */ + void slotPropertiesChanged(const TQString& interface, const TQMap< TQString, TQT_DBusVariant >& changed_properties, const TQStringList& invalidated_properties); + +}; // class ObjectManagerImpl + +}; // namespace TDEBluetooth + +#endif //OBJECTMANAGERIMPL_H_INCLUDED + +// End of File diff --git a/src/libtdeobex/CMakeLists.txt b/src/libtdeobex/CMakeLists.txt new file mode 100644 index 0000000..c998ff0 --- /dev/null +++ b/src/libtdeobex/CMakeLists.txt @@ -0,0 +1,66 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +project( libtdeobex ) +set(LIBRARY_VERSION 0.0.1) + +# include( ConfigureChecks.cmake ) +foreach( f ${TQT_LIBRARIES} ) + if( ${f} STREQUAL "tqt-mt" ) + set(TQUI_LIBRARIES "tqui" CACHE TYPE STRING FORCE) + endif() + if( ${f} STREQUAL "qt-mt" ) + set(TQUI_LIBRARIES "qui" CACHE TYPE STRING FORCE) + endif() +endforeach() + +# import required +#tde_import( lib... ) + +add_subdirectory( interfaces ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### headers ################################### +# implementations +install( + FILES obexobjectmanagerImpl.h + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeobex ) + +set( target tdeobex ) + +set( ${target}_SRCS obexobjectmanagerImpl.cpp ) + + +##### tdeobex (shared) ########################### +# set( KDE3_DCOPIDL_EXECUTABLE ${KDE3_DCOPIDLNG_EXECUTABLE} ) +tde_add_library( ${target} SHARED AUTOMOC + SOURCES ${${target}_SRCS} + VERSION ${LIBRARY_VERSION} + DEPENDS obexinterfaces-static + LINK ${DBUS_TQT_LIBRARIES} tdeparts-shared obexinterfaces-static ${TQUI_LIBRARIES} + DESTINATION ${LIB_INSTALL_DIR} + ) + +##### install import cmake modules ############### +tde_install_export( ) diff --git a/src/libtdeobex/interfaces/CMakeLists.txt b/src/libtdeobex/interfaces/CMakeLists.txt new file mode 100644 index 0000000..60a9659 --- /dev/null +++ b/src/libtdeobex/interfaces/CMakeLists.txt @@ -0,0 +1,103 @@ +################################################# +# +# (C) 2020 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${TQT_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) + +set( INTROSPECTIONPATH ${CMAKE_SOURCE_DIR}/src/interfaces ) +set( DBUSXML2QT3_EXECUTABLE dbusxml2qt3 ) + +function( make_moc fileinput ) + add_custom_command( OUTPUT ${fileinput}.moc + COMMAND ${TMOC_EXECUTABLE} ${fileinput}.h -o ${fileinput}.moc + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.h + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + set_property( SOURCE ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.cpp APPEND + PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${fileinput}.moc ) +endfunction( ) + +set( ObjectManager_HDRS objectmanagerInterface.h objectmanagerProxy.h introspectableInterface.h ) +set( ObjectManager_SRCS objectmanagerInterface.cpp objectmanagerProxy.cpp introspectableInterface.cpp ) + +set (Agent_HDRS agent1Interface.h agent1Proxy.h dbusbaseNode.h tdeobexNode.h) +set (Agent_SRCS agent1Interface.cpp agent1Proxy.cpp dbusbaseNode.cpp tdeobexNode.cpp) + +set (Client_HDRS agentmanager1Interface.h agentmanager1Proxy.h client1Interface.h client1Proxy.h filetransfer1Interface.h filetransfer1Proxy.h obexNode.h objectpush1Interface.h objectpush1Proxy.h phonebookaccess1Interface.h phonebookaccess1Proxy.h session1Interface.h session1Proxy.h synchronization1Interface.h synchronization1Proxy.h transfer1Interface.h transfer1Proxy.h) +set (Client_SRCS agentmanager1Interface.cpp agentmanager1Proxy.cpp client1Interface.cpp client1Proxy.cpp filetransfer1Interface.cpp filetransfer1Proxy.cpp obexNode.cpp objectpush1Interface.cpp objectpush1Proxy.cpp phonebookaccess1Interface.cpp phonebookaccess1Proxy.cpp session1Interface.cpp session1Proxy.cpp synchronization1Interface.cpp synchronization1Proxy.cpp transfer1Interface.cpp transfer1Proxy.cpp propertiesProxy.h propertiesProxy.cpp ) + + +##### ObjectManager ######################### +add_custom_command( + OUTPUT ${ObjectManager_HDRS} ${ObjectManager_SRCS} + COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.freedesktop.DBus.ObjectManager.xml 2>/dev/null + DEPENDS ${INTROSPECTIONPATH}/org.freedesktop.DBus.ObjectManager.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +make_moc ( objectmanagerProxy ) + +##### Agent ######################### +add_custom_command( + OUTPUT ${Agent_HDRS} ${Agent_SRCS} + COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.bluez.obex.Agent1.xml 2>/dev/null + DEPENDS ${INTROSPECTIONPATH}/org.bluez.obex.Agent1.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +make_moc ( agent1Proxy ) + +##### Client ######################### +add_custom_command( + OUTPUT ${Client_HDRS} ${Client_SRCS} + COMMAND ${DBUSXML2QT3_EXECUTABLE} ${INTROSPECTIONPATH}/org.bluez.obex.client.xml 2>/dev/null + DEPENDS ${INTROSPECTIONPATH}/org.bluez.obex.client.xml + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +) +make_moc ( agentmanager1Proxy ) +make_moc ( client1Proxy ) +make_moc ( filetransfer1Proxy ) +make_moc ( objectpush1Proxy ) +make_moc ( phonebookaccess1Proxy ) +make_moc ( session1Proxy ) +make_moc ( synchronization1Proxy ) +make_moc ( transfer1Proxy ) +make_moc ( propertiesProxy ) + +tde_add_library( obexinterfaces STATIC_PIC AUTOMOC + SOURCES ${ObjectManager_SRCS} ${Agent_SRCS} ${Client_SRCS} + LINK ${DBUS_TQT_LIBRARIES} +) + +##### headers ################################### + +#file( GLOB _bin_dirs RELATIVE ${CMAKE_CURRENT_BINARY_DIR} +# ${CMAKE_CURRENT_BINARY_DIR}/* ) +#unset( _exclude_dirs ) +#foreach( _dir IN LISTS _bin_dirs ) +# if( IS_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_dir} ) +# list( APPEND _exclude_dirs PATTERN ${_dir} EXCLUDE ) +# endif() +#endforeach() +# +#install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} +# DESTINATION ${INCLUDE_INSTALL_DIR}/tdeobex +# USE_SOURCE_PERMISSIONS +# FILES_MATCHING PATTERN PATTERN "*.h" +# ${_exclude_dirs} +#) + +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DESTINATION ${INCLUDE_INSTALL_DIR}/tdeobex + USE_SOURCE_PERMISSIONS + FILES_MATCHING PATTERN PATTERN "*.h" + PATTERN "CMakeFiles" EXCLUDE ) diff --git a/src/libtdeobex/obexobjectmanagerImpl.cpp b/src/libtdeobex/obexobjectmanagerImpl.cpp new file mode 100644 index 0000000..56a8798 --- /dev/null +++ b/src/libtdeobex/obexobjectmanagerImpl.cpp @@ -0,0 +1,286 @@ +/* + * + * Object Manager implementation of bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +// QT - Header +#include <tqtimer.h> +// +// debug +#include <kdebug.h> + +// declaration include +#include <tqdbusproxy.h> +#include <tqdbusmessage.h> +#include <tqdbusobjectpath.h> +#include <tqdbusdatamap.h> +#include <tqdbusdata.h> +// +#include <tqstringlist.h> + +#include "obexobjectmanagerImpl.h" +#include "../libtdebluez/btuuids.h" + +namespace TDEObex +{ + +ObexObjectManagerImpl::ObexObjectManagerImpl(const TQString& service, const TQString& path, TQObject* parent, const char* name) : + org::freedesktop::DBus::ObjectManagerProxy(service, path, parent, name) +{ + kdDebug() << k_funcinfo << endl; + // init connection to dbus + initDBUS(); +} + +ObexObjectManagerImpl::~ObexObjectManagerImpl() +{ + kdDebug() << k_funcinfo << endl; + close(); +} + +/*! + * This function try a reconnect to D-Bus. + * \return boolean with the result of the operation + * \retval true if successful reconnected to D-Bus + * \retval false if unsuccessful + */ +bool ObexObjectManagerImpl::reconnect() +{ + kdDebug() << k_funcinfo << endl; + // close D-Bus connection + close(); + // init D-Bus conntection + return (initDBUS()); +} + +/*! + * This function return information about connection status to the DBUS daemon. + * \return boolean with the state of the connection to D-Bus + * \retval true if connected + * \retval false if disconnected + */ +bool ObexObjectManagerImpl::isConnectedToDBUS() +{ + kdDebug() << k_funcinfo << endl; + return dBusConn.isConnected(); +} + +/*! + * This function returns pointer to connection of the DBUS. + * \return TQT_DBusConnection* of the connection to D-Bus + * \retval TQT_DBusConnection* + */ +TQT_DBusConnection* ObexObjectManagerImpl::getConnection() +{ + kdDebug() << k_funcinfo << endl; + return &dBusConn; +} + +/*! + * This function close the connection to manager over the D-Bus daemon. + * \return boolean with the result of the operation + * \retval true if successful closed the connection + * \retval false if any problems + */ +bool ObexObjectManagerImpl::close() +{ + kdDebug() << k_funcinfo << endl; + + if (mSession) + delete mSession; + if (mFileTransfer) + delete mFileTransfer; + if (mClient) + delete mClient; + if (dBusConn.isConnected()) + dBusConn.closeConnection(DBUS_CONN_NAME); + return true; +} + +/*! + * This function initialise the connection to the D-Bus daemon. + * \return boolean with the result of the operation + * \retval true if successful initialised D-Bus connection + * \retval false if unsuccessful + */ +bool ObexObjectManagerImpl::initDBUS() +{ + kdDebug() << k_funcinfo << endl; + dBusConn = TQT_DBusConnection::addConnection(TQT_DBusConnection::SessionBus, DBUS_CONN_NAME); + if (!dBusConn.isConnected()) + { + kdError() << "Failed to open connection to system message bus: " << dBusConn.lastError().message() << endl; + TQTimer::singleShot(4000, this, TQT_SLOT(reconnect())); + return false; + } + setConnection(dBusConn); + + TQT_DBusDataMap<TQT_DBusObjectPath> objects; + TQT_DBusError error; + if (!GetManagedObjects(objects, error)) + { + tqDebug("GetManagedObjects(objects,error) FAILED\n"); + return false; + } + + TQT_DBusDataMap<TQT_DBusObjectPath>::const_iterator it = objects.begin(); + for (it; it != objects.end(); ++it) + { + bool ok = false; + TQT_DBusDataMap<TQString> tqMap1 = it.data().toStringKeyMap(&ok); + if (!ok) + { + tqWarning("Failed to convert dbus data to string map: %s", it.key().latin1()); + return false; + } + slotInterfacesAdded(it.key(), tqMap1); + } + + connect(this, SIGNAL(InterfacesAdded(const TQT_DBusObjectPath&, const TQT_DBusDataMap< TQString >&)), this, SLOT(slotInterfacesAdded(const TQT_DBusObjectPath&, const TQT_DBusDataMap< TQString >& ))); + connect(this, SIGNAL(InterfacesRemoved(const TQT_DBusObjectPath& , const TQStringList& )), this, SLOT(slotInterfacesRemoved(const TQT_DBusObjectPath& , const TQStringList& ))); + return true; +} + +/*! + * This function initialise the connection to the D-Bus daemon. + * \return pointer to AgentManager1 + */ +org::bluez::obex::AgentManager1Proxy * ObexObjectManagerImpl::getAgentManager() +{ + kdDebug() << k_funcinfo << endl; + return mAgentManager; +} + +/*! + * This function initialise the connection to the D-Bus daemon. + * \return pointer to AgentManager1 + */ +org::bluez::obex::Client1Proxy * ObexObjectManagerImpl::getClient() +{ + kdDebug() << k_funcinfo << endl; + return mClient; +} + +void ObexObjectManagerImpl::slotInterfacesAdded(const TQT_DBusObjectPath& object, const TQT_DBusDataMap<TQString>& interfaces) +{ + kdDebug() << k_funcinfo << endl; + + TQT_DBusDataMap<TQString>::const_iterator it1 = interfaces.begin(); + for (it1; it1 != interfaces.end(); it1++) + { + TQString interface = it1.key(); + if (interface == "org.bluez.obex.AgentManager1") + { + mAgentManager = new org::bluez::obex::AgentManager1Proxy("org.bluez.obex", object); + if (mAgentManager) + { + mAgentManager->setConnection(dBusConn); + } + else + { + tqDebug("org.bluez.obex.AgentManager1 initialization failed\n"); + } + } + else if (interface == "org.bluez.obex.Client1") + { + mClient = new org::bluez::obex::Client1Proxy("org.bluez.obex", object); + if (mClient) + { + mClient->setConnection(dBusConn); + } + else + { + tqDebug("org.bluez.obex.Client1 initialization failed\n"); + } + } + else if (interface == "org.bluez.obex.Session1") + { + mSession = new org::bluez::obex::Session1Proxy("org.bluez.obex", object); + if (mSession) + { + mSession->setConnection(dBusConn); + } + else + { + tqDebug("org.bluez.obex.Session1 initialization failed\n"); + } + } + else if (interface == "org.bluez.obex.FileTransfer1") + { + mFileTransfer = new org::bluez::obex::FileTransfer1Proxy("org.bluez.obex", object); + if (mFileTransfer) + { + mFileTransfer->setConnection(dBusConn); + } + else + { + tqDebug("org.bluez.obex.FileTransfer1 initialization failed\n"); + } + } + else if (interface == "org.freedesktop.DBus.Introspectable") + { + // do nothing + } + else + { + tqWarning("Interface not implemented: %s", interface.local8Bit().data()); + } + } +} + +void ObexObjectManagerImpl::slotInterfacesRemoved(const TQT_DBusObjectPath& object, const TQStringList& interfaces) +{ + kdDebug() << k_funcinfo << endl; + // TODO: remove interface + for (TQValueListConstIterator<TQString> it = interfaces.begin(); + it != interfaces.end(); ++it) + { + if ((*it) == "org.bluez.obex.AgentManager1") + { + // TODO: remove AgentManager1 + } + else if ((*it) == "org.bluez.obex.Client1") + { + // TODO: remove Client1 + } + else if ((*it) == "org.bluez.obex.Session1") + { + // TODO: remove Session1 + } + else if ((*it) == "org.bluez.obex.FileTransfer1") + { + // TODO: remove FileTransfer1 + } + else + { + tqWarning("Interface not implemented: %s", (*it).local8Bit().data()); + } + } +} + +}; +// namespace TDEObex + +#include "obexobjectmanagerImpl.moc" +// End of File + diff --git a/src/libtdeobex/obexobjectmanagerImpl.h b/src/libtdeobex/obexobjectmanagerImpl.h new file mode 100644 index 0000000..65ef978 --- /dev/null +++ b/src/libtdeobex/obexobjectmanagerImpl.h @@ -0,0 +1,94 @@ +/* + * + * Obex Object Manager implementation of bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of libtdebluez. + * + * libtdebluez 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 2 of the License, or + * (at your option) any later version. + * + * libtdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef OBEXOBJECTMANAGERIMPL_H_INCLUDED +#define OBEXOBJECTMANAGERIMPL_H_INCLUDED + +#include <tqdbusconnection.h> +#include <tdelocale.h> + +#include "interfaces/propertiesProxy.h" +#include "interfaces/objectmanagerProxy.h" +#include "interfaces/agentmanager1Proxy.h" +#include "interfaces/client1Proxy.h" +#include "interfaces/session1Proxy.h" +#include "interfaces/filetransfer1Proxy.h" + +namespace TDEObex +{ + +#define DBUS_CONN_NAME "TDEBluezObex" + +class ObexObjectManagerImpl: public org::freedesktop::DBus::ObjectManagerProxy +{ + Q_OBJECT + +public: + // ObexObjectManagerImpl(){} + ObexObjectManagerImpl(const TQString& service, const TQString& path, TQObject* parent = 0, const char* name = 0); + + virtual ~ObexObjectManagerImpl(); + + // --- helper to get private members of the class --- // + //! to get information if TDEBluez is connected to D-Bus + bool isConnectedToDBUS(); + //! pointer to the D-Bus connection + TQT_DBusConnection* getConnection(); + //! to close the connection to D-Bus + bool close(); + + // + org::bluez::obex::AgentManager1Proxy* getAgentManager(); + org::bluez::obex::Client1Proxy* getClient(); + // ConnectionList listConnections(const TQString&); + +private: + bool initDBUS(); + + void slotInterfacesAdded(const TQT_DBusObjectPath& object, const TQT_DBusDataMap< + TQString>& interfaces); + + void slotInterfacesRemoved(const TQT_DBusObjectPath& object, const TQStringList& interfaces); + +private: + //! TQt connection to D-Bus + TQT_DBusConnection dBusConn; + org::bluez::obex::AgentManager1Proxy* mAgentManager; + org::bluez::obex::Client1Proxy* mClient; + org::bluez::obex::Session1Proxy* mSession; + org::bluez::obex::FileTransfer1Proxy* mFileTransfer; + +private slots: + bool reconnect(); + +}; +// class ObexObjectManagerImpl + +}; +// namespace TDEObex + +#endif //OBEXOBJECTMANAGERIMPL_H_INCLUDED + +// End of File diff --git a/src/tdebluez-common/CMakeLists.txt b/src/tdebluez-common/CMakeLists.txt new file mode 100644 index 0000000..8dbf649 --- /dev/null +++ b/src/tdebluez-common/CMakeLists.txt @@ -0,0 +1,67 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +project( tdebluez-common ) + +# include( ConfigureChecks.cmake ) + +# import required +#tde_import( lib... ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/tdebluez-common + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +#link_directories( +# ${TQT_LIBRARY_DIRS} +#) + + +##### other data ################################ +# Example +#install( FILES knotes.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) +#install( FILES knoteconfig.kcfg knotesglobalconfig.kcfg DESTINATION ${KCFG_INSTALL_DIR} ) +#install( FILES knotesappui.rc knotesui.rc DESTINATION ${DATA_INSTALL_DIR}/knotes ) +#install( FILES local.desktop DESTINATION ${SERVICES_INSTALL_DIR}/tderesources/knotes ) +#install( FILES knotes_manager.desktop DESTINATION ${SERVICES_INSTALL_DIR}/tderesources ) + +# # from tdebase/applnk/Makefile.am +# install-data-local: +# $(mkinstalldirs) $(DESTDIR)$(kde_appsdir)/Settings/Network/Bluetooth +# $(INSTALL_DATA) $(srcdir)/kde-settings-network-bluetooth.directory \ +# $(DESTDIR)$(kde_appsdir)/Settings/Network/Bluetooth/.directory +# +# uninstall-local: +# -rm -f $(DESTDIR)$(kde_appsdir)/Settings/Network/Bluetooth/.directory + +##### install import cmake modules ############### +#tde_install_export( ) + +# Bluetooth directory entry in the control center +install( FILES tde-settings-network-bluetooth.directory + DESTINATION ${DATA_INSTALL_DIR}/tdebluez ) + +# Bluetooth access to system debus org.bluez +install( FILES org.trinitydesktop.tdebluez.conf + DESTINATION ${DBUS_SYS_DIR} ) +# DESTINATION ${DBUS_SYSTEM_CONF_DIRECTORY} ) + + + +add_subdirectory( icons ) +add_subdirectory( mimetypes ) +#add_subdirectory( dunhandler ) +#add_subdirectory( faxhandler )
\ No newline at end of file diff --git a/src/tdebluez-common/README b/src/tdebluez-common/README new file mode 100644 index 0000000..a397554 --- /dev/null +++ b/src/tdebluez-common/README @@ -0,0 +1,3 @@ +This directory contains some files which are shared +among the various modules in tdebluez. + diff --git a/src/tdebluez-common/dunhandler/CMakeLists.txt b/src/tdebluez-common/dunhandler/CMakeLists.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/src/tdebluez-common/dunhandler/CMakeLists.txt diff --git a/src/tdebluez-common/dunhandler/Makefile.am b/src/tdebluez-common/dunhandler/Makefile.am new file mode 100644 index 0000000..17b1e17 --- /dev/null +++ b/src/tdebluez-common/dunhandler/Makefile.am @@ -0,0 +1,7 @@ + +dunhandlerdir = $(kde_datadir)/kdebluetooth/dunhandler +dunhandler_SCRIPTS=dunhandler + +# The desktop file +servicemenudir = $(kde_appsdir)/Utilities +servicemenu_DATA = dunhandler.desktop
\ No newline at end of file diff --git a/src/tdebluez-common/dunhandler/Makefile.in b/src/tdebluez-common/dunhandler/Makefile.in new file mode 100644 index 0000000..cf05434 --- /dev/null +++ b/src/tdebluez-common/dunhandler/Makefile.in @@ -0,0 +1,804 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# KDE tags expanded automatically by am_edit - $Revision$ +# @configure_input@ + +# Copyright (C) 1994-2014 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = kdebluetooth/kdebluetooth-common/dunhandler +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = dunhandler.desktop +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(dunhandlerdir)" \ + "$(DESTDIR)$(servicemenudir)" +SCRIPTS = $(dunhandler_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +DATA = $(servicemenu_DATA) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(srcdir)/dunhandler.desktop.in \ + $(top_srcdir)/admin/mkinstalldirs +#>- DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +#>+ 1 +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) $(KDE_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ARTSCCONFIG = @ARTSCCONFIG@ +AUTOCONF = @AUTOCONF@ +AUTODIRS = @AUTODIRS@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BLUETOOTH_CFLAGS = @BLUETOOTH_CFLAGS@ +BLUETOOTH_LIBS = @BLUETOOTH_LIBS@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONF_FILES = @CONF_FILES@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUSTQT_CFLAGS = @DBUSTQT_CFLAGS@ +DBUSTQT_LIBS = @DBUSTQT_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DCOPIDL = @DCOPIDL@ +DCOPIDL2CPP = @DCOPIDL2CPP@ +DCOPIDLNG = @DCOPIDLNG@ +DCOP_DEPENDENCIES = @DCOP_DEPENDENCIES@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOXYGEN = @DOXYGEN@ +DOXYGEN_PROJECT_NAME = @DOXYGEN_PROJECT_NAME@ +DOXYGEN_PROJECT_NUMBER = @DOXYGEN_PROJECT_NUMBER@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_PERMISSIVE_FLAG = @ENABLE_PERMISSIVE_FLAG@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FRAMEWORK_COREAUDIO = @FRAMEWORK_COREAUDIO@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +HAVE_GCC_VISIBILITY = @HAVE_GCC_VISIBILITY@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KBTOBEXSRV_BINDIR = @KBTOBEXSRV_BINDIR@ +KCFG_DEPENDENCIES = @KCFG_DEPENDENCIES@ +KCONFIG_COMPILER = @KCONFIG_COMPILER@ +KDEBLUETOOTH_VERSION = @KDEBLUETOOTH_VERSION@ +KDECONFIG = @KDECONFIG@ +KDE_CHECK_PLUGIN = @KDE_CHECK_PLUGIN@ +KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@ +KDE_HAS_DOXYGEN = @KDE_HAS_DOXYGEN@ +KDE_HAVE_DOT = @KDE_HAVE_DOT@ +KDE_INCLUDES = @KDE_INCLUDES@ +KDE_LDFLAGS = @KDE_LDFLAGS@ +KDE_MT_LDFLAGS = @KDE_MT_LDFLAGS@ +KDE_MT_LIBS = @KDE_MT_LIBS@ +KDE_NO_UNDEFINED = @KDE_NO_UNDEFINED@ +KDE_PLUGIN = @KDE_PLUGIN@ +KDE_RPATH = @KDE_RPATH@ +KDE_USE_CLOSURE_FALSE = @KDE_USE_CLOSURE_FALSE@ +KDE_USE_CLOSURE_TRUE = @KDE_USE_CLOSURE_TRUE@ +KDE_USE_FINAL_FALSE = @KDE_USE_FINAL_FALSE@ +KDE_USE_FINAL_TRUE = @KDE_USE_FINAL_TRUE@ +KDE_USE_FPIE = @KDE_USE_FPIE@ +KDE_USE_NMCHECK_FALSE = @KDE_USE_NMCHECK_FALSE@ +KDE_USE_NMCHECK_TRUE = @KDE_USE_NMCHECK_TRUE@ +KDE_USE_PIE = @KDE_USE_PIE@ +KDE_XSL_STYLESHEET = @KDE_XSL_STYLESHEET@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDFLAGS_AS_NEEDED = @LDFLAGS_AS_NEEDED@ +LDFLAGS_NEW_DTAGS = @LDFLAGS_NEW_DTAGS@ +LIBCOMPAT = @LIBCOMPAT@ +LIBCRYPT = @LIBCRYPT@ +LIBDL = @LIBDL@ +LIBJPEG = @LIBJPEG@ +LIBOBJS = @LIBOBJS@ +LIBPNG = @LIBPNG@ +LIBPTHREAD = @LIBPTHREAD@ +LIBRESOLV = @LIBRESOLV@ +LIBS = @LIBS@ +LIBSM = @LIBSM@ +LIBSOCKET = @LIBSOCKET@ +LIBTOOL = @LIBTOOL@ +LIBTQT_LDFLAGS = @LIBTQT_LDFLAGS@ +LIBUCB = @LIBUCB@ +LIBUTIL = @LIBUTIL@ +LIBXML_CFLAGS = @LIBXML_CFLAGS@ +LIBXML_LIBS = @LIBXML_LIBS@ +LIBZ = @LIBZ@ +LIB_ARTS = @LIB_ARTS@ +LIB_BLUETOOTH = @LIB_BLUETOOTH@ +LIB_KAB = @LIB_KAB@ +LIB_KDED = @LIB_KDED@ +LIB_KFM = @LIB_KFM@ +LIB_KJS = @LIB_KJS@ +LIB_LOCKDEV = @LIB_LOCKDEV@ +LIB_POLL = @LIB_POLL@ +LIB_QPE = @LIB_QPE@ +LIB_QT = @LIB_QT@ +LIB_QUI = @LIB_QUI@ +LIB_SDP = @LIB_SDP@ +LIB_SMB = @LIB_SMB@ +LIB_TDEABC = @LIB_TDEABC@ +LIB_TDECORE = @LIB_TDECORE@ +LIB_TDEDNSSD = @LIB_TDEDNSSD@ +LIB_TDEFILE = @LIB_TDEFILE@ +LIB_TDEHTML = @LIB_TDEHTML@ +LIB_TDEIMPROXY = @LIB_TDEIMPROXY@ +LIB_TDEIO = @LIB_TDEIO@ +LIB_TDENEWSTUFF = @LIB_TDENEWSTUFF@ +LIB_TDEPARTS = @LIB_TDEPARTS@ +LIB_TDEPIM = @LIB_TDEPIM@ +LIB_TDEPRINT = @LIB_TDEPRINT@ +LIB_TDESPELL = @LIB_TDESPELL@ +LIB_TDESYCOCA = @LIB_TDESYCOCA@ +LIB_TDEUI = @LIB_TDEUI@ +LIB_TDEUNITTEST = @LIB_TDEUNITTEST@ +LIB_TDEUTILS = @LIB_TDEUTILS@ +LIB_X11 = @LIB_X11@ +LIB_XEXT = @LIB_XEXT@ +LIB_XRENDER = @LIB_XRENDER@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKETDEWIDGETS = @MAKETDEWIDGETS@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MCOPIDL = @MCOPIDL@ +MEINPROC = @MEINPROC@ +MKDIR_P = @MKDIR_P@ +MOC = @MOC@ +MSGFMT = @MSGFMT@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOOPT_CFLAGS = @NOOPT_CFLAGS@ +NOOPT_CXXFLAGS = @NOOPT_CXXFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENOBEX_CFLAGS = @OPENOBEX_CFLAGS@ +OPENOBEX_LIBS = @OPENOBEX_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +QTDOCDIR = @QTDOCDIR@ +QTE_NORTTI = @QTE_NORTTI@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TOPSUBDIRS = @TOPSUBDIRS@ +TQTDCOPIDL = @TQTDCOPIDL@ +TQTDCOPIDL2CPP = @TQTDCOPIDL2CPP@ +TQTDCOPIDLNG = @TQTDCOPIDLNG@ +TQTMCOPIDL = @TQTMCOPIDL@ +TQTMOC = @TQTMOC@ +UIC = @UIC@ +UIC_TR = @UIC_TR@ +USER_INCLUDES = @USER_INCLUDES@ +USER_LDFLAGS = @USER_LDFLAGS@ +USE_EXCEPTIONS = @USE_EXCEPTIONS@ +USE_RTTI = @USE_RTTI@ +USE_THREADS = @USE_THREADS@ +VERSION = @VERSION@ +WOVERLOADED_VIRTUAL = @WOVERLOADED_VIRTUAL@ +XGETTEXT = @XGETTEXT@ +XMKMF = @XMKMF@ +XMLLINT = @XMLLINT@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_INCLUDES = @X_INCLUDES@ +X_LDFLAGS = @X_LDFLAGS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_RPATH = @X_RPATH@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +all_includes = @all_includes@ +all_libraries = @all_libraries@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dunhandler_dir = @dunhandler_dir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +faxhandler_dir = @faxhandler_dir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kde_appsdir = @kde_appsdir@ +kde_bindir = @kde_bindir@ +kde_confdir = @kde_confdir@ +kde_datadir = @kde_datadir@ +kde_htmldir = @kde_htmldir@ +kde_icondir = @kde_icondir@ +kde_includes = @kde_includes@ +kde_kcfgdir = @kde_kcfgdir@ +kde_libraries = @kde_libraries@ +kde_libs_htmldir = @kde_libs_htmldir@ +kde_libs_prefix = @kde_libs_prefix@ +kde_locale = @kde_locale@ +kde_mimedir = @kde_mimedir@ +kde_moduledir = @kde_moduledir@ +kde_qtver = @kde_qtver@ +kde_servicesdir = @kde_servicesdir@ +kde_servicetypesdir = @kde_servicetypesdir@ +kde_sounddir = @kde_sounddir@ +kde_styledir = @kde_styledir@ +kde_templatesdir = @kde_templatesdir@ +kde_wallpaperdir = @kde_wallpaperdir@ +kde_widgetdir = @kde_widgetdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +qt_includes = @qt_includes@ +qt_libraries = @qt_libraries@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tdeinitdir = @tdeinitdir@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +x_includes = @x_includes@ +x_libraries = @x_libraries@ +xdg_appsdir = @xdg_appsdir@ +xdg_directorydir = @xdg_directorydir@ +xdg_menudir = @xdg_menudir@ +dunhandlerdir = $(kde_datadir)/kdebluetooth/dunhandler +dunhandler_SCRIPTS = dunhandler + +# The desktop file +servicemenudir = $(kde_appsdir)/Utilities +servicemenu_DATA = dunhandler.desktop +#>- all: all-am +#>+ 1 +all: docs-am all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) +#>- @for dep in $?; do \ +#>- case '$(am__configure_deps)' in \ +#>- *$$dep*) \ +#>- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ +#>- && { if test -f $@; then exit 0; else break; fi; }; \ +#>- exit 1;; \ +#>- esac; \ +#>- done; \ +#>- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/dunhandler/Makefile'; \ +#>- $(am__cd) $(top_srcdir) && \ +#>- $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/dunhandler/Makefile +#>+ 12 + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/dunhandler/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/dunhandler/Makefile + cd $(top_srcdir) && perl admin/am_edit kdebluetooth/kdebluetooth-common/dunhandler/Makefile.in +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +dunhandler.desktop: $(top_builddir)/config.status $(srcdir)/dunhandler.desktop.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-dunhandlerSCRIPTS: $(dunhandler_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(dunhandler_SCRIPTS)'; test -n "$(dunhandlerdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(dunhandlerdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(dunhandlerdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(dunhandlerdir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(dunhandlerdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-dunhandlerSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(dunhandler_SCRIPTS)'; test -n "$(dunhandlerdir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(dunhandlerdir)'; $(am__uninstall_files_from_dir) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-servicemenuDATA: $(servicemenu_DATA) + @$(NORMAL_INSTALL) + @list='$(servicemenu_DATA)'; test -n "$(servicemenudir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(servicemenudir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(servicemenudir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(servicemenudir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(servicemenudir)" || exit $$?; \ + done + +uninstall-servicemenuDATA: + @$(NORMAL_UNINSTALL) + @list='$(servicemenu_DATA)'; test -n "$(servicemenudir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(servicemenudir)'; $(am__uninstall_files_from_dir) +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(dunhandlerdir)" "$(DESTDIR)$(servicemenudir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +#>- clean: clean-am +#>+ 1 +clean: kde-rpo-clean clean-am + +#>- clean-am: clean-generic clean-libtool mostlyclean-am +#>+ 1 +clean-am: clean-bcheck clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-dunhandlerSCRIPTS install-servicemenuDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dunhandlerSCRIPTS uninstall-servicemenuDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-dunhandlerSCRIPTS install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am \ + install-servicemenuDATA install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am uninstall-dunhandlerSCRIPTS \ + uninstall-servicemenuDATA + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: + +#>+ 2 +KDE_DIST=dunhandler dunhandler.desktop.in configure.in.in Makefile.in Makefile.am + +#>+ 2 +docs-am: + +#>+ 15 +force-reedit: + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/dunhandler/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/dunhandler/Makefile + cd $(top_srcdir) && perl admin/am_edit kdebluetooth/kdebluetooth-common/dunhandler/Makefile.in + + +#>+ 21 +clean-bcheck: + rm -f *.bchecktest.cc *.bchecktest.cc.class a.out + +bcheck: bcheck-am + +bcheck-am: + @for i in ; do \ + if test $(srcdir)/$$i -nt $$i.bchecktest.cc; then \ + echo "int main() {return 0;}" > $$i.bchecktest.cc ; \ + echo "#include \"$$i\"" >> $$i.bchecktest.cc ; \ + echo "$$i"; \ + if ! $(CXX) $(DEFS) -I. -I$(srcdir) -I$(top_builddir) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) --dump-class-hierarchy -c $$i.bchecktest.cc; then \ + rm -f $$i.bchecktest.cc; exit 1; \ + fi ; \ + echo "" >> $$i.bchecktest.cc.class; \ + perl $(top_srcdir)/admin/bcheck.pl $$i.bchecktest.cc.class || { rm -f $$i.bchecktest.cc; exit 1; }; \ + rm -f a.out; \ + fi ; \ + done + + +#>+ 3 +final: + $(MAKE) all-am + +#>+ 3 +final-install: + $(MAKE) install-am + +#>+ 3 +no-final: + $(MAKE) all-am + +#>+ 3 +no-final-install: + $(MAKE) install-am + +#>+ 3 +kde-rpo-clean: + -rm -f *.rpo + +#>+ 3 +nmcheck: +nmcheck-am: nmcheck diff --git a/src/tdebluez-common/dunhandler/configure.in.in b/src/tdebluez-common/dunhandler/configure.in.in new file mode 100644 index 0000000..505e06a --- /dev/null +++ b/src/tdebluez-common/dunhandler/configure.in.in @@ -0,0 +1,4 @@ +dnl AC_OUTPUT(kdebluetooth/kdebluetooth-common/dunhandler/dunhandler.desktop) +KDE_EXPAND_MAKEVAR(dunhandler_dir, kde_datadir) +AC_SUBST(dunhandler_dir) + diff --git a/src/tdebluez-common/dunhandler/dunhandler b/src/tdebluez-common/dunhandler/dunhandler new file mode 100644 index 0000000..ab7aa83 --- /dev/null +++ b/src/tdebluez-common/dunhandler/dunhandler @@ -0,0 +1,70 @@ +#!/bin/sh +#/*************************************************************************** +# dunhandler - a script for tdeio_sdp +# ------------------- +# begin : Mon March 29 2004 +# copyright : (C) 2004 by Simone Gotti +# email : [email protected] +# ***************************************************************************/ +# +#/*************************************************************************** +# * * +# * 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 2 of the License, or * +# * (at your option) any later version. * +# * * +# ***************************************************************************/ + + + +# get the btaddress and the rfcomm channel from the command line +BTADDR=$(echo $1 | cut -d'/' -f3 | cut -d'[' -f2 | cut -d']' -f1) +PARAMS=$(echo $1 | cut -d'?' -f2 ) + +OLDIFS=$IFS +IFS='&' +for i in $PARAMS; do + if test $(echo $i | cut -d'=' -f1) = "rfcommchannel"; then + RFCOMM_CHANNEL=$(echo $i | cut -d'=' -f2) + fi +done; +IFS=$OLDIFS + +RFCOMM_SHOW_OUT=$(rfcomm show) + +# Check if the channel is already binded +BINDED_CHANNEL=$(echo $RFCOMM_SHOW_OUT | grep -i $BTADDR | grep -i " "$RFCOMM_CHANNEL" " | cut -d' ' -f1 | cut -d':' -f1) + +if test "x"$BINDED_CHANNEL != "x"; then + MESSAGE1="A bind between the bluetooth device (using the dial-up-networking profile) and /dev/rfcomm$DEV_NUMBER already exists. You can use any connection program (kppp, pppd script etc...) using /dev/rfcomm$DEV_NUMBER like the modem device" + + kdialog --msgbox "$MESSAGE1" +else + +# Find the first unbinded /dev/rfcommX +DEV_NUMBER=0 +while test "x"$(echo $RFCOMM_SHOW_OUT | grep "rfcomm"$DEV_NUMBER":"| cut -d' ' -f1 ) != "x"; do + DEV_NUMBER=$[$DEV_NUMBER+1] + if test $DEV_NUMBER -gt 255; then break; fi; +done; + + +# do the bind +echo "doing: rfcomm bind $DEV_NUMBER $BTADDR $RFCOMM_CHANNEL" + +if test -e /def/rfcomm$DEV_NUMBER; then +EXIT_CODE=$(tdesu -f/dev/rfcomm$DEV_NUMBER -c "rfcomm bind $DEV_NUMBER $BTADDR $RFCOMM_CHANNEL") +else +EXIT_CODE=$(tdesu -c "rfcomm bind $DEV_NUMBER $BTADDR $RFCOMM_CHANNEL") +fi + +echo $EXIT_CODE + +MESSAGE1="Created a bind between the bluetooth device (using the dial-up-networking profile) and /dev/rfcomm$DEV_NUMBER. You can use any connection program (kppp, pppd script etc...) using /dev/rfcomm$DEV_NUMBER like the modem device" + +kdialog --msgbox "$MESSAGE1" + +fi; + + diff --git a/src/tdebluez-common/dunhandler/dunhandler.desktop.in b/src/tdebluez-common/dunhandler/dunhandler.desktop.in new file mode 100644 index 0000000..057ba2c --- /dev/null +++ b/src/tdebluez-common/dunhandler/dunhandler.desktop.in @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=@dunhandler_dir@/kdebluetooth/dunhandler/dunhandler +Exec=dunhandler %u +Icon=network_local +Type=Application +Comment=An OBEX Object Push client for the KdeBluetooth Framework +Comment[et]=OBEX objekti saatmise klient KdeBluetooth raamistikule +MimeType=bluetooth/dun-profile; +Hidden=true diff --git a/src/tdebluez-common/faxhandler/Makefile.am b/src/tdebluez-common/faxhandler/Makefile.am new file mode 100644 index 0000000..61db809 --- /dev/null +++ b/src/tdebluez-common/faxhandler/Makefile.am @@ -0,0 +1,7 @@ + +dunhandlerdir = $(kde_datadir)/kdebluetooth/faxhandler +dunhandler_SCRIPTS=faxhandler kbtfax + +# The desktop file +servicemenudir = $(kde_appsdir)/Utilities +servicemenu_DATA = faxhandler.desktop diff --git a/src/tdebluez-common/faxhandler/Makefile.in b/src/tdebluez-common/faxhandler/Makefile.in new file mode 100644 index 0000000..f4e7952 --- /dev/null +++ b/src/tdebluez-common/faxhandler/Makefile.in @@ -0,0 +1,804 @@ +# Makefile.in generated by automake 1.15 from Makefile.am. +# KDE tags expanded automatically by am_edit - $Revision$ +# @configure_input@ + +# Copyright (C) 1994-2014 Free Software Foundation, Inc. + +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +am__is_gnu_make = { \ + if test -z '$(MAKELEVEL)'; then \ + false; \ + elif test -n '$(MAKE_HOST)'; then \ + true; \ + elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ + true; \ + else \ + false; \ + fi; \ +} +am__make_running_with_option = \ + case $${target_option-} in \ + ?) ;; \ + *) echo "am__make_running_with_option: internal error: invalid" \ + "target option '$${target_option-}' specified" >&2; \ + exit 1;; \ + esac; \ + has_opt=no; \ + sane_makeflags=$$MAKEFLAGS; \ + if $(am__is_gnu_make); then \ + sane_makeflags=$$MFLAGS; \ + else \ + case $$MAKEFLAGS in \ + *\\[\ \ ]*) \ + bs=\\; \ + sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ + | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ + esac; \ + fi; \ + skip_next=no; \ + strip_trailopt () \ + { \ + flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ + }; \ + for flg in $$sane_makeflags; do \ + test $$skip_next = yes && { skip_next=no; continue; }; \ + case $$flg in \ + *=*|--*) continue;; \ + -*I) strip_trailopt 'I'; skip_next=yes;; \ + -*I?*) strip_trailopt 'I';; \ + -*O) strip_trailopt 'O'; skip_next=yes;; \ + -*O?*) strip_trailopt 'O';; \ + -*l) strip_trailopt 'l'; skip_next=yes;; \ + -*l?*) strip_trailopt 'l';; \ + -[dEDm]) skip_next=yes;; \ + -[JT]) skip_next=yes;; \ + esac; \ + case $$flg in \ + *$$target_option*) has_opt=yes; break;; \ + esac; \ + done; \ + test $$has_opt = yes +am__make_dryrun = (target_option=n; $(am__make_running_with_option)) +am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +target_triplet = @target@ +subdir = kdebluetooth/kdebluetooth-common/faxhandler +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.in +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(SHELL) $(top_srcdir)/admin/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = faxhandler.desktop +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(dunhandlerdir)" \ + "$(DESTDIR)$(servicemenudir)" +SCRIPTS = $(dunhandler_SCRIPTS) +AM_V_P = $(am__v_P_@AM_V@) +am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) +am__v_P_0 = false +am__v_P_1 = : +AM_V_GEN = $(am__v_GEN_@AM_V@) +am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) +am__v_GEN_0 = @echo " GEN " $@; +am__v_GEN_1 = +AM_V_at = $(am__v_at_@AM_V@) +am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) +am__v_at_0 = @ +am__v_at_1 = +SOURCES = +DIST_SOURCES = +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +DATA = $(servicemenu_DATA) +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +am__DIST_COMMON = $(srcdir)/Makefile.in \ + $(srcdir)/faxhandler.desktop.in \ + $(top_srcdir)/admin/mkinstalldirs +#>- DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +#>+ 1 +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) $(KDE_DIST) +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ARTSCCONFIG = @ARTSCCONFIG@ +AUTOCONF = @AUTOCONF@ +AUTODIRS = @AUTODIRS@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BLUETOOTH_CFLAGS = @BLUETOOTH_CFLAGS@ +BLUETOOTH_LIBS = @BLUETOOTH_LIBS@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONF_FILES = @CONF_FILES@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DBUSTQT_CFLAGS = @DBUSTQT_CFLAGS@ +DBUSTQT_LIBS = @DBUSTQT_LIBS@ +DBUS_CFLAGS = @DBUS_CFLAGS@ +DBUS_LIBS = @DBUS_LIBS@ +DCOPIDL = @DCOPIDL@ +DCOPIDL2CPP = @DCOPIDL2CPP@ +DCOPIDLNG = @DCOPIDLNG@ +DCOP_DEPENDENCIES = @DCOP_DEPENDENCIES@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DOXYGEN = @DOXYGEN@ +DOXYGEN_PROJECT_NAME = @DOXYGEN_PROJECT_NAME@ +DOXYGEN_PROJECT_NUMBER = @DOXYGEN_PROJECT_NUMBER@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +ENABLE_PERMISSIVE_FLAG = @ENABLE_PERMISSIVE_FLAG@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FRAMEWORK_COREAUDIO = @FRAMEWORK_COREAUDIO@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +HAVE_GCC_VISIBILITY = @HAVE_GCC_VISIBILITY@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KBTOBEXSRV_BINDIR = @KBTOBEXSRV_BINDIR@ +KCFG_DEPENDENCIES = @KCFG_DEPENDENCIES@ +KCONFIG_COMPILER = @KCONFIG_COMPILER@ +KDEBLUETOOTH_VERSION = @KDEBLUETOOTH_VERSION@ +KDECONFIG = @KDECONFIG@ +KDE_CHECK_PLUGIN = @KDE_CHECK_PLUGIN@ +KDE_EXTRA_RPATH = @KDE_EXTRA_RPATH@ +KDE_HAS_DOXYGEN = @KDE_HAS_DOXYGEN@ +KDE_HAVE_DOT = @KDE_HAVE_DOT@ +KDE_INCLUDES = @KDE_INCLUDES@ +KDE_LDFLAGS = @KDE_LDFLAGS@ +KDE_MT_LDFLAGS = @KDE_MT_LDFLAGS@ +KDE_MT_LIBS = @KDE_MT_LIBS@ +KDE_NO_UNDEFINED = @KDE_NO_UNDEFINED@ +KDE_PLUGIN = @KDE_PLUGIN@ +KDE_RPATH = @KDE_RPATH@ +KDE_USE_CLOSURE_FALSE = @KDE_USE_CLOSURE_FALSE@ +KDE_USE_CLOSURE_TRUE = @KDE_USE_CLOSURE_TRUE@ +KDE_USE_FINAL_FALSE = @KDE_USE_FINAL_FALSE@ +KDE_USE_FINAL_TRUE = @KDE_USE_FINAL_TRUE@ +KDE_USE_FPIE = @KDE_USE_FPIE@ +KDE_USE_NMCHECK_FALSE = @KDE_USE_NMCHECK_FALSE@ +KDE_USE_NMCHECK_TRUE = @KDE_USE_NMCHECK_TRUE@ +KDE_USE_PIE = @KDE_USE_PIE@ +KDE_XSL_STYLESHEET = @KDE_XSL_STYLESHEET@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LDFLAGS_AS_NEEDED = @LDFLAGS_AS_NEEDED@ +LDFLAGS_NEW_DTAGS = @LDFLAGS_NEW_DTAGS@ +LIBCOMPAT = @LIBCOMPAT@ +LIBCRYPT = @LIBCRYPT@ +LIBDL = @LIBDL@ +LIBJPEG = @LIBJPEG@ +LIBOBJS = @LIBOBJS@ +LIBPNG = @LIBPNG@ +LIBPTHREAD = @LIBPTHREAD@ +LIBRESOLV = @LIBRESOLV@ +LIBS = @LIBS@ +LIBSM = @LIBSM@ +LIBSOCKET = @LIBSOCKET@ +LIBTOOL = @LIBTOOL@ +LIBTQT_LDFLAGS = @LIBTQT_LDFLAGS@ +LIBUCB = @LIBUCB@ +LIBUTIL = @LIBUTIL@ +LIBXML_CFLAGS = @LIBXML_CFLAGS@ +LIBXML_LIBS = @LIBXML_LIBS@ +LIBZ = @LIBZ@ +LIB_ARTS = @LIB_ARTS@ +LIB_BLUETOOTH = @LIB_BLUETOOTH@ +LIB_KAB = @LIB_KAB@ +LIB_KDED = @LIB_KDED@ +LIB_KFM = @LIB_KFM@ +LIB_KJS = @LIB_KJS@ +LIB_LOCKDEV = @LIB_LOCKDEV@ +LIB_POLL = @LIB_POLL@ +LIB_QPE = @LIB_QPE@ +LIB_QT = @LIB_QT@ +LIB_QUI = @LIB_QUI@ +LIB_SDP = @LIB_SDP@ +LIB_SMB = @LIB_SMB@ +LIB_TDEABC = @LIB_TDEABC@ +LIB_TDECORE = @LIB_TDECORE@ +LIB_TDEDNSSD = @LIB_TDEDNSSD@ +LIB_TDEFILE = @LIB_TDEFILE@ +LIB_TDEHTML = @LIB_TDEHTML@ +LIB_TDEIMPROXY = @LIB_TDEIMPROXY@ +LIB_TDEIO = @LIB_TDEIO@ +LIB_TDENEWSTUFF = @LIB_TDENEWSTUFF@ +LIB_TDEPARTS = @LIB_TDEPARTS@ +LIB_TDEPIM = @LIB_TDEPIM@ +LIB_TDEPRINT = @LIB_TDEPRINT@ +LIB_TDESPELL = @LIB_TDESPELL@ +LIB_TDESYCOCA = @LIB_TDESYCOCA@ +LIB_TDEUI = @LIB_TDEUI@ +LIB_TDEUNITTEST = @LIB_TDEUNITTEST@ +LIB_TDEUTILS = @LIB_TDEUTILS@ +LIB_X11 = @LIB_X11@ +LIB_XEXT = @LIB_XEXT@ +LIB_XRENDER = @LIB_XRENDER@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAINT = @MAINT@ +MAKEINFO = @MAKEINFO@ +MAKETDEWIDGETS = @MAKETDEWIDGETS@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MCOPIDL = @MCOPIDL@ +MEINPROC = @MEINPROC@ +MKDIR_P = @MKDIR_P@ +MOC = @MOC@ +MSGFMT = @MSGFMT@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NOOPT_CFLAGS = @NOOPT_CFLAGS@ +NOOPT_CXXFLAGS = @NOOPT_CXXFLAGS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OPENOBEX_CFLAGS = @OPENOBEX_CFLAGS@ +OPENOBEX_LIBS = @OPENOBEX_LIBS@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PERL = @PERL@ +PKG_CONFIG = @PKG_CONFIG@ +QTDOCDIR = @QTDOCDIR@ +QTE_NORTTI = @QTE_NORTTI@ +QT_INCLUDES = @QT_INCLUDES@ +QT_LDFLAGS = @QT_LDFLAGS@ +RANLIB = @RANLIB@ +SED = @SED@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +TOPSUBDIRS = @TOPSUBDIRS@ +TQTDCOPIDL = @TQTDCOPIDL@ +TQTDCOPIDL2CPP = @TQTDCOPIDL2CPP@ +TQTDCOPIDLNG = @TQTDCOPIDLNG@ +TQTMCOPIDL = @TQTMCOPIDL@ +TQTMOC = @TQTMOC@ +UIC = @UIC@ +UIC_TR = @UIC_TR@ +USER_INCLUDES = @USER_INCLUDES@ +USER_LDFLAGS = @USER_LDFLAGS@ +USE_EXCEPTIONS = @USE_EXCEPTIONS@ +USE_RTTI = @USE_RTTI@ +USE_THREADS = @USE_THREADS@ +VERSION = @VERSION@ +WOVERLOADED_VIRTUAL = @WOVERLOADED_VIRTUAL@ +XGETTEXT = @XGETTEXT@ +XMKMF = @XMKMF@ +XMLLINT = @XMLLINT@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_INCLUDES = @X_INCLUDES@ +X_LDFLAGS = @X_LDFLAGS@ +X_PRE_LIBS = @X_PRE_LIBS@ +X_RPATH = @X_RPATH@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +all_includes = @all_includes@ +all_libraries = @all_libraries@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dunhandler_dir = @dunhandler_dir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +faxhandler_dir = @faxhandler_dir@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +kde_appsdir = @kde_appsdir@ +kde_bindir = @kde_bindir@ +kde_confdir = @kde_confdir@ +kde_datadir = @kde_datadir@ +kde_htmldir = @kde_htmldir@ +kde_icondir = @kde_icondir@ +kde_includes = @kde_includes@ +kde_kcfgdir = @kde_kcfgdir@ +kde_libraries = @kde_libraries@ +kde_libs_htmldir = @kde_libs_htmldir@ +kde_libs_prefix = @kde_libs_prefix@ +kde_locale = @kde_locale@ +kde_mimedir = @kde_mimedir@ +kde_moduledir = @kde_moduledir@ +kde_qtver = @kde_qtver@ +kde_servicesdir = @kde_servicesdir@ +kde_servicetypesdir = @kde_servicetypesdir@ +kde_sounddir = @kde_sounddir@ +kde_styledir = @kde_styledir@ +kde_templatesdir = @kde_templatesdir@ +kde_wallpaperdir = @kde_wallpaperdir@ +kde_widgetdir = @kde_widgetdir@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +qt_includes = @qt_includes@ +qt_libraries = @qt_libraries@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target = @target@ +target_alias = @target_alias@ +target_cpu = @target_cpu@ +target_os = @target_os@ +target_vendor = @target_vendor@ +tdeinitdir = @tdeinitdir@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +x_includes = @x_includes@ +x_libraries = @x_libraries@ +xdg_appsdir = @xdg_appsdir@ +xdg_directorydir = @xdg_directorydir@ +xdg_menudir = @xdg_menudir@ +dunhandlerdir = $(kde_datadir)/kdebluetooth/faxhandler +dunhandler_SCRIPTS = faxhandler kbtfax + +# The desktop file +servicemenudir = $(kde_appsdir)/Utilities +servicemenu_DATA = faxhandler.desktop +#>- all: all-am +#>+ 1 +all: docs-am all-am + +.SUFFIXES: +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) +#>- @for dep in $?; do \ +#>- case '$(am__configure_deps)' in \ +#>- *$$dep*) \ +#>- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ +#>- && { if test -f $@; then exit 0; else break; fi; }; \ +#>- exit 1;; \ +#>- esac; \ +#>- done; \ +#>- echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/faxhandler/Makefile'; \ +#>- $(am__cd) $(top_srcdir) && \ +#>- $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/faxhandler/Makefile +#>+ 12 + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/faxhandler/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/faxhandler/Makefile + cd $(top_srcdir) && perl admin/am_edit kdebluetooth/kdebluetooth-common/faxhandler/Makefile.in +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +faxhandler.desktop: $(top_builddir)/config.status $(srcdir)/faxhandler.desktop.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +install-dunhandlerSCRIPTS: $(dunhandler_SCRIPTS) + @$(NORMAL_INSTALL) + @list='$(dunhandler_SCRIPTS)'; test -n "$(dunhandlerdir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(dunhandlerdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(dunhandlerdir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ + done | \ + sed -e 'p;s,.*/,,;n' \ + -e 'h;s|.*|.|' \ + -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ + $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ + { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ + if ($$2 == $$4) { files[d] = files[d] " " $$1; \ + if (++n[d] == $(am__install_max)) { \ + print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ + else { print "f", d "/" $$4, $$1 } } \ + END { for (d in files) print "f", d, files[d] }' | \ + while read type dir files; do \ + if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ + test -z "$$files" || { \ + echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(dunhandlerdir)$$dir'"; \ + $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(dunhandlerdir)$$dir" || exit $$?; \ + } \ + ; done + +uninstall-dunhandlerSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(dunhandler_SCRIPTS)'; test -n "$(dunhandlerdir)" || exit 0; \ + files=`for p in $$list; do echo "$$p"; done | \ + sed -e 's,.*/,,;$(transform)'`; \ + dir='$(DESTDIR)$(dunhandlerdir)'; $(am__uninstall_files_from_dir) + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-servicemenuDATA: $(servicemenu_DATA) + @$(NORMAL_INSTALL) + @list='$(servicemenu_DATA)'; test -n "$(servicemenudir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(servicemenudir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(servicemenudir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(servicemenudir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(servicemenudir)" || exit $$?; \ + done + +uninstall-servicemenuDATA: + @$(NORMAL_UNINSTALL) + @list='$(servicemenu_DATA)'; test -n "$(servicemenudir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(servicemenudir)'; $(am__uninstall_files_from_dir) +tags TAGS: + +ctags CTAGS: + +cscope cscopelist: + + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(dunhandlerdir)" "$(DESTDIR)$(servicemenudir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +#>- clean: clean-am +#>+ 1 +clean: kde-rpo-clean clean-am + +#>- clean-am: clean-generic clean-libtool mostlyclean-am +#>+ 1 +clean-am: clean-bcheck clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + -rm -f Makefile +distclean-am: clean-am distclean-generic + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-dunhandlerSCRIPTS install-servicemenuDATA + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-dunhandlerSCRIPTS uninstall-servicemenuDATA + +.MAKE: install-am install-strip + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + cscopelist-am ctags-am distclean distclean-generic \ + distclean-libtool distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am \ + install-dunhandlerSCRIPTS install-dvi install-dvi-am \ + install-exec install-exec-am install-html install-html-am \ + install-info install-info-am install-man install-pdf \ + install-pdf-am install-ps install-ps-am \ + install-servicemenuDATA install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags-am uninstall \ + uninstall-am uninstall-dunhandlerSCRIPTS \ + uninstall-servicemenuDATA + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: + +#>+ 2 +KDE_DIST=faxhandler kbtfax configure.in.in Makefile.am faxhandler.desktop.in Makefile.in + +#>+ 2 +docs-am: + +#>+ 15 +force-reedit: + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/faxhandler/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign kdebluetooth/kdebluetooth-common/faxhandler/Makefile + cd $(top_srcdir) && perl admin/am_edit kdebluetooth/kdebluetooth-common/faxhandler/Makefile.in + + +#>+ 21 +clean-bcheck: + rm -f *.bchecktest.cc *.bchecktest.cc.class a.out + +bcheck: bcheck-am + +bcheck-am: + @for i in ; do \ + if test $(srcdir)/$$i -nt $$i.bchecktest.cc; then \ + echo "int main() {return 0;}" > $$i.bchecktest.cc ; \ + echo "#include \"$$i\"" >> $$i.bchecktest.cc ; \ + echo "$$i"; \ + if ! $(CXX) $(DEFS) -I. -I$(srcdir) -I$(top_builddir) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(KDE_CXXFLAGS) --dump-class-hierarchy -c $$i.bchecktest.cc; then \ + rm -f $$i.bchecktest.cc; exit 1; \ + fi ; \ + echo "" >> $$i.bchecktest.cc.class; \ + perl $(top_srcdir)/admin/bcheck.pl $$i.bchecktest.cc.class || { rm -f $$i.bchecktest.cc; exit 1; }; \ + rm -f a.out; \ + fi ; \ + done + + +#>+ 3 +final: + $(MAKE) all-am + +#>+ 3 +final-install: + $(MAKE) install-am + +#>+ 3 +no-final: + $(MAKE) all-am + +#>+ 3 +no-final-install: + $(MAKE) install-am + +#>+ 3 +kde-rpo-clean: + -rm -f *.rpo + +#>+ 3 +nmcheck-am: nmcheck +nmcheck: diff --git a/src/tdebluez-common/faxhandler/configure.in.in b/src/tdebluez-common/faxhandler/configure.in.in new file mode 100644 index 0000000..f6b5479 --- /dev/null +++ b/src/tdebluez-common/faxhandler/configure.in.in @@ -0,0 +1,4 @@ +dnl AC_OUTPUT(kdebluetooth/kdebluetooth-common/faxhandler/faxhandler.desktop) +KDE_EXPAND_MAKEVAR(faxhandler_dir, kde_datadir) +AC_SUBST(faxhandler_dir) + diff --git a/src/tdebluez-common/faxhandler/faxhandler b/src/tdebluez-common/faxhandler/faxhandler new file mode 100755 index 0000000..6b757b5 --- /dev/null +++ b/src/tdebluez-common/faxhandler/faxhandler @@ -0,0 +1,10 @@ +#!/bin/sh + +# copyright 2004 by Fred Schaettgen <[email protected]> + + +MESSAGE="To send faxes you can set up tdeprintfax to use the kbtfax script, which comes with kdebluetooth. Do you want to read more about that?" + +if $(kdialog --yesno "$MESSAGE" --title "KDE Bluetooth Framework") ; then + konqueror help:/kdebluetooth/otherprofiles.html#fax +fi diff --git a/src/tdebluez-common/faxhandler/faxhandler.desktop.in b/src/tdebluez-common/faxhandler/faxhandler.desktop.in new file mode 100644 index 0000000..7b8707d --- /dev/null +++ b/src/tdebluez-common/faxhandler/faxhandler.desktop.in @@ -0,0 +1,9 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=@faxhandler_dir@/kdebluetooth/faxhandler/faxhandler +Exec=faxhandler %u +Icon=network_local +Type=Application +Comment=A handler for the fax profile +MimeType=bluetooth/fax-profile; +Hidden=true diff --git a/src/tdebluez-common/faxhandler/kbtfax b/src/tdebluez-common/faxhandler/kbtfax new file mode 100755 index 0000000..577c999 --- /dev/null +++ b/src/tdebluez-common/faxhandler/kbtfax @@ -0,0 +1,105 @@ +#!/bin/bash + +# A wrapper for efax to be used together with a bluetooth mobile phone +# and tdeprintfax to send faxes via bluetooth from any kde application. +# +# This script does basically the same as the "efax" command, which is +# already configured in tdeprintfax. +# The difference is that kbtfax will ask you which bluetooth device +# you want to connect to and then sets up a virtual serial device +# with the rfcomm utility. Then the fax command is started and +# finally the rfcomm binding is released. + +# Use the following fax command when printing (without the 'FAXCMDLINE=') +FAXCMDLINE="kbtfax NAME=%user PAGE=%page FROM=%from send %res %number %files" +# This is the same as for eFax, but without the DEV parameter + +# If your device does not support the fax profile +# and works of the serial port profile instead, +# you will have to change this script to use +# SPP instead of FAX for the search UUID. +# Default: SEARCH_UUID="FAX" +SEARCH_UUID="FAX" + +# This will list all possibly relevant services, including fax, +# dialup and serial port profile. It will also list many +# unrelated services like obex push etc., but it should be +# easy to see what's the right choice. +#SEARCH_UUID="0x0003" + +# If you don't want to use the default rfcomm +# device (/dev/rfcomm1) you can specify another one here. +# Default: RFCOMM_DEVICE=1 +RFCOMM_DEVICE=1 + +# ----- End of options ----- + +BIND_ERROR=10 +FAX_ERROR=11 +RELEASE_ERROR=12 +RFCOMM_PERM_ERROR=13 +DEV_ERROR=14 + +if [ "x$1" == "x" ] ; then + + kdialog --inputbox "Use this command for \"Other fax system\" in tdeprintfax:" "$FAXCMDLINE" + + +elif [ "x$KBTFAX_ROOTMODE" != "xYES" ] ; then + +# The script was not called with the special +# argument RFCOMM, so the script was called +# by the user/kprintfax + +# We search for a service now + SEARCH_RESULT=( $(kbtsearch -u $SEARCH_UUID --title "Select fax service") ) + SEARCH_STATUS=$? + echo "Status: $SEARCH_STATUS" + + if [ $SEARCH_STATUS -eq 0 ] ; then + +# The user has selected a service + export ADDRESS=${SEARCH_RESULT[0]} + export CHANNEL=${SEARCH_RESULT[1]} + export KBTFAX_ROOTMODE="YES" + echo "Address=$ADDRESS Channel=$CHANNEL" + tdesu -t -- $0 "$@" + RET=$? + if [ $RET == $BIND_ERROR ] ; then + kdialog --error "Error binding rfcomm device." + elif [ $RET == $FAX_ERROR ] ; then + kdialog --error "Failed to send the fax." + elif [ $RET == $RELEASE_ERROR ] ; then + kdialog --error "Could not release rfcomm device." + elif [ $ERT == 0 ] ; then + kdialog --msgbox "Fax sent." + elif [ $RET == $DEV_ERROR ] ; then + kdialog --error "The rfcomm device /dev/rfcomm$RFCOMM_DEVICE did \ +not exist or had wrong permissions. Please check if the rfcomm utility is wworking correctly." + else + kdialog --error "Unknown error in kbtfax: Root mode returned with code $RET" + fi + exit $RET + else + +# The search dialog was aborted + kdialog --msgbox "Sending fax was aborted." + fi +else + +# Recursive call. We should be running as root +# now, so we can set up rfcomm and call fax + echo "Binding /dev/rfcomm$RFCOMM_DEVICE to $ADDRESS, channel $CHANNEL" + rfcomm bind $RFCOMM_DEVICE $ADDRESS $CHANNEL || exit $BIND_ERROR +# Rfcomm (or is it udev?) seems to need some time +# to set up the device + sleep 5 + [ -w /dev/rfcomm$RFCOMM_DEVICE -a -r /dev/rfcomm$RFCOMM_DEVICE ] || exit $DEV_ERROR + fax "DEV=rfcomm$RFCOMM_DEVICE" "$@" + FAXRET=$? + echo -n "Releasing rfcomm device... " + rfcomm release $ADDRESS || exit $RELEASE_ERROR + [ $FAXRET -eq 0 ] || exit $FAX_ERROR + echo "done." + kdialog --msgbox "kbtfax script root mode done" +fi diff --git a/src/tdebluez-common/icons/CMakeLists.txt b/src/tdebluez-common/icons/CMakeLists.txt new file mode 100644 index 0000000..1978ba9 --- /dev/null +++ b/src/tdebluez-common/icons/CMakeLists.txt @@ -0,0 +1,14 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +##### install icons in /opt/trinity/share/icons ############### +tde_install_icons( DESTINATION ${DATA_INSTALL_DIR}/tdebluez/icons ) + diff --git a/src/tdebluez-common/icons/bluetooth.svg b/src/tdebluez-common/icons/bluetooth.svg new file mode 100644 index 0000000..de8078d --- /dev/null +++ b/src/tdebluez-common/icons/bluetooth.svg @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + viewBox="0 0 976 976" + version="1.1" + id="svg6" + sodipodi:docname="bluetooth.svg" + inkscape:version="0.92.4 (5da689c313, 2019-01-14)" + width="976" + height="976"> + <metadata + id="metadata12"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <defs + id="defs10" /> + <sodipodi:namedview + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1" + objecttolerance="10" + gridtolerance="10" + guidetolerance="10" + inkscape:pageopacity="0" + inkscape:pageshadow="2" + inkscape:window-width="1887" + inkscape:window-height="873" + id="namedview8" + showgrid="false" + inkscape:zoom="0.48360656" + inkscape:cx="136.78185" + inkscape:cy="443.014" + inkscape:window-x="25" + inkscape:window-y="0" + inkscape:window-maximized="0" + inkscape:current-layer="svg6" /> + <rect + y="2.0677919" + x="163.86441" + style="fill:#0a3d91" + ry="291" + height="976" + width="640" + id="rect2" /> + <path + d="M 262.34658,304.21164 676.45662,643.63499 476.86916,840.43425 V 137.264 L 676.45662,325.2183 262.34658,655.79674" + id="path4" + inkscape:connector-curvature="0" + style="fill:none;stroke:#ffffff;stroke-width:64.93599701" /> + <flowRoot + xml:space="preserve" + id="flowRoot18" + style="font-style:normal;font-weight:normal;font-size:12px;line-height:1.25;font-family:Arial;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + transform="translate(72.881352,217.11865)"><flowRegion + id="flowRegion20"><rect + id="rect22" + width="31.016949" + height="29.983051" + x="68.754234" + y="-300.86441" /></flowRegion><flowPara + id="flowPara24" /></flowRoot> <flowRoot + xml:space="preserve" + id="flowRoot26" + style="font-style:normal;font-weight:normal;font-size:12px;line-height:1.25;font-family:Arial;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + transform="translate(72.881352,217.11865)"><flowRegion + id="flowRegion28"><rect + id="rect30" + width="11.372881" + height="12.406779" + x="-48.59322" + y="-301.89832" /></flowRegion><flowPara + id="flowPara32" /></flowRoot></svg> diff --git a/src/tdebluez-common/icons/hi128-app-bluetooth.png b/src/tdebluez-common/icons/hi128-app-bluetooth.png Binary files differnew file mode 100644 index 0000000..c8479fb --- /dev/null +++ b/src/tdebluez-common/icons/hi128-app-bluetooth.png diff --git a/src/tdebluez-common/icons/hi128-app-tdebluez.png b/src/tdebluez-common/icons/hi128-app-tdebluez.png Binary files differnew file mode 100644 index 0000000..969a909 --- /dev/null +++ b/src/tdebluez-common/icons/hi128-app-tdebluez.png diff --git a/src/tdebluez-common/icons/hi16-app-bluetooth.png b/src/tdebluez-common/icons/hi16-app-bluetooth.png Binary files differnew file mode 100644 index 0000000..e00780b --- /dev/null +++ b/src/tdebluez-common/icons/hi16-app-bluetooth.png diff --git a/src/tdebluez-common/icons/hi16-app-tdebluez.png b/src/tdebluez-common/icons/hi16-app-tdebluez.png Binary files differnew file mode 100644 index 0000000..614b79e --- /dev/null +++ b/src/tdebluez-common/icons/hi16-app-tdebluez.png diff --git a/src/tdebluez-common/icons/hi22-app-bluetooth.png b/src/tdebluez-common/icons/hi22-app-bluetooth.png Binary files differnew file mode 100644 index 0000000..e08a297 --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-bluetooth.png diff --git a/src/tdebluez-common/icons/hi22-app-media-playback-pause.png b/src/tdebluez-common/icons/hi22-app-media-playback-pause.png Binary files differnew file mode 100644 index 0000000..dc90c8b --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-media-playback-pause.png diff --git a/src/tdebluez-common/icons/hi22-app-media-playback-start.png b/src/tdebluez-common/icons/hi22-app-media-playback-start.png Binary files differnew file mode 100644 index 0000000..8ea1a5a --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-media-playback-start.png diff --git a/src/tdebluez-common/icons/hi22-app-media-playback-stop.png b/src/tdebluez-common/icons/hi22-app-media-playback-stop.png Binary files differnew file mode 100644 index 0000000..3156247 --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-media-playback-stop.png diff --git a/src/tdebluez-common/icons/hi22-app-media-seek-backward.png b/src/tdebluez-common/icons/hi22-app-media-seek-backward.png Binary files differnew file mode 100644 index 0000000..8b4781a --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-media-seek-backward.png diff --git a/src/tdebluez-common/icons/hi22-app-media-seek-forward.png b/src/tdebluez-common/icons/hi22-app-media-seek-forward.png Binary files differnew file mode 100644 index 0000000..054b4cb --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-media-seek-forward.png diff --git a/src/tdebluez-common/icons/hi22-app-media-skip-backward.png b/src/tdebluez-common/icons/hi22-app-media-skip-backward.png Binary files differnew file mode 100644 index 0000000..ad460b4 --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-media-skip-backward.png diff --git a/src/tdebluez-common/icons/hi22-app-media-skip-forward.png b/src/tdebluez-common/icons/hi22-app-media-skip-forward.png Binary files differnew file mode 100644 index 0000000..82c5b49 --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-media-skip-forward.png diff --git a/src/tdebluez-common/icons/hi22-app-tdebluelock.png b/src/tdebluez-common/icons/hi22-app-tdebluelock.png Binary files differnew file mode 100644 index 0000000..b380ab8 --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-tdebluelock.png diff --git a/src/tdebluez-common/icons/hi22-app-tdebluez.png b/src/tdebluez-common/icons/hi22-app-tdebluez.png Binary files differnew file mode 100644 index 0000000..cb9d886 --- /dev/null +++ b/src/tdebluez-common/icons/hi22-app-tdebluez.png diff --git a/src/tdebluez-common/icons/hi32-app-bluetooth.png b/src/tdebluez-common/icons/hi32-app-bluetooth.png Binary files differnew file mode 100644 index 0000000..6ee36fd --- /dev/null +++ b/src/tdebluez-common/icons/hi32-app-bluetooth.png diff --git a/src/tdebluez-common/icons/hi32-app-tdebluelock.png b/src/tdebluez-common/icons/hi32-app-tdebluelock.png Binary files differnew file mode 100644 index 0000000..066a496 --- /dev/null +++ b/src/tdebluez-common/icons/hi32-app-tdebluelock.png diff --git a/src/tdebluez-common/icons/hi32-app-tdebluez.png b/src/tdebluez-common/icons/hi32-app-tdebluez.png Binary files differnew file mode 100644 index 0000000..20974ff --- /dev/null +++ b/src/tdebluez-common/icons/hi32-app-tdebluez.png diff --git a/src/tdebluez-common/icons/hi48-app-bluetooth.png b/src/tdebluez-common/icons/hi48-app-bluetooth.png Binary files differnew file mode 100644 index 0000000..5ea294a --- /dev/null +++ b/src/tdebluez-common/icons/hi48-app-bluetooth.png diff --git a/src/tdebluez-common/icons/hi48-app-tdebluez.png b/src/tdebluez-common/icons/hi48-app-tdebluez.png Binary files differnew file mode 100644 index 0000000..863ce50 --- /dev/null +++ b/src/tdebluez-common/icons/hi48-app-tdebluez.png diff --git a/src/tdebluez-common/icons/hi64-app-bluetooth.png b/src/tdebluez-common/icons/hi64-app-bluetooth.png Binary files differnew file mode 100644 index 0000000..47aa24f --- /dev/null +++ b/src/tdebluez-common/icons/hi64-app-bluetooth.png diff --git a/src/tdebluez-common/icons/hi64-app-tdebluez.png b/src/tdebluez-common/icons/hi64-app-tdebluez.png Binary files differnew file mode 100644 index 0000000..03f6dcb --- /dev/null +++ b/src/tdebluez-common/icons/hi64-app-tdebluez.png diff --git a/src/tdebluez-common/icons/hisc-app-tdebluez.svgz b/src/tdebluez-common/icons/hisc-app-tdebluez.svgz Binary files differnew file mode 100644 index 0000000..413e74f --- /dev/null +++ b/src/tdebluez-common/icons/hisc-app-tdebluez.svgz diff --git a/src/tdebluez-common/icons/inkscape-converter.sh b/src/tdebluez-common/icons/inkscape-converter.sh new file mode 100644 index 0000000..37ba75f --- /dev/null +++ b/src/tdebluez-common/icons/inkscape-converter.sh @@ -0,0 +1,14 @@ +inkscape -z -e hi128-app-tdebluez.png -h128 tde-bluetooth.svg +inkscape -z -e hi16-app-tdebluez.png -h16 tde-bluetooth.svg +inkscape -z -e hi22-app-tdebluez.png -h22 tde-bluetooth.svg +inkscape -z -e hi32-app-tdebluez.png -h32 tde-bluetooth.svg +inkscape -z -e hi48-app-tdebluez.png -h48 tde-bluetooth.svg +inkscape -z -e hi64-app-tdebluez.png -h64 tde-bluetooth.svg + +inkscape -z -e hi128-app-bluetooth.png -h128 bluetooth.svg +inkscape -z -e hi16-app-bluetooth.png -h16 bluetooth.svg +inkscape -z -e hi22-app-bluetooth.png -h22 bluetooth.svg +inkscape -z -e hi32-app-bluetooth.png -h32 bluetooth.svg +inkscape -z -e hi48-app-bluetooth.png -h48 bluetooth.svg +inkscape -z -e hi64-app-bluetooth.png -h64 bluetooth.svg + diff --git a/src/tdebluez-common/icons/tde-bluetooth.svg b/src/tdebluez-common/icons/tde-bluetooth.svg new file mode 100644 index 0000000..8d4a7d1 --- /dev/null +++ b/src/tdebluez-common/icons/tde-bluetooth.svg @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="210mm" + height="210mm" + viewBox="0 0 210 210" + version="1.1" + id="svg3740" + inkscape:version="0.92.4 (5da689c313, 2019-01-14)" + sodipodi:docname="tde-bluetooth.svg"> + <defs + id="defs3734" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.35" + inkscape:cx="-232.85714" + inkscape:cy="445.71429" + inkscape:document-units="mm" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1887" + inkscape:window-height="1018" + inkscape:window-x="25" + inkscape:window-y="0" + inkscape:window-maximized="1" /> + <metadata + id="metadata3737"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,-87)"> + <rect + y="93.044044" + x="43.845242" + style="fill:#0a3d91;stroke-width:0.1917409" + ry="58.060863" + height="194.73334" + width="117.92857" + id="rect2" /> + <path + d="m 62.179732,153.31429 76.305318,67.72238 -36.77666,39.26575 V 120.00459 l 36.77666,37.501 -76.305318,65.95762" + id="path4" + inkscape:connector-curvature="0" + style="fill:none;stroke:#ffffff;stroke-width:12.45088673" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:95.53657532px;line-height:1.25;font-family:Arial;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:7.96138191px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + x="82.105263" + y="209.84634" + id="text16" + transform="scale(0.9224945,1.0840173)"><tspan + sodipodi:role="line" + id="tspan14" + x="82.105263" + y="209.84634" + style="fill:#ffffff;stroke-width:7.96138191px">T</tspan></text> + </g> +</svg> diff --git a/src/tdebluez-common/mimetypes/CMakeLists.txt b/src/tdebluez-common/mimetypes/CMakeLists.txt new file mode 100644 index 0000000..9e912b8 --- /dev/null +++ b/src/tdebluez-common/mimetypes/CMakeLists.txt @@ -0,0 +1,37 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +#shellmimedir = $(kde_mimedir)/bluetooth +#/opt/trinity/share/mimelnk +install( FILES + av-device-class.desktop + computer-device-class.desktop + imaging-device-class.desktop + health-device-class.desktop + keyboard-device-class.desktop + lan-device-class.desktop + misc-device-class.desktop + mouse-device-class.desktop + peripheral-device-class.desktop + phone-device-class.desktop + toy-device-class.desktop + wearable-device-class.desktop + unknown-device-class.desktop + dun-profile.desktop + fax-profile.desktop + handsfree-profile.desktop + headset-profile.desktop + obex-ftp-profile.desktop + obex-objectpush-profile.desktop + serial-port-profile.desktop + synchronization-profile.desktop + unknown-profile.desktop + DESTINATION ${MIME_INSTALL_DIR}/bluetooth ) diff --git a/src/tdebluez-common/mimetypes/av-device-class.desktop b/src/tdebluez-common/mimetypes/av-device-class.desktop new file mode 100644 index 0000000..befe686 --- /dev/null +++ b/src/tdebluez-common/mimetypes/av-device-class.desktop @@ -0,0 +1,32 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/av-device-class +Icon=audio-x-generic +Comment=Audio/Video Bluetooth Device +Comment[ar]=جهاز صوتي/مرئي Bluetooth +Comment[bg]=Аудио/видео Bluetooth устройство +Comment[bs]=Audio/video Bluetooth uređaj +Comment[ca]=Dispositiu Bluetooth àudio/vídeo +Comment[da]=Audio/Video Bluetooth-enhed +Comment[de]=Audio/Video Bluetooth-Gerät +Comment[el]=Συσκευή ήχου/βίντεο Bluetooth +Comment[es]=Dispositivo Bluetooth audio/vídeo +Comment[et]=Audio/video Bluetoothi seade +Comment[fr]=Périphérique Audio/Vidéo Bluetooth +Comment[gl]=Dispositivo Bluetooth Áudio/Vídeo +Comment[it]=Dispositivo Bluetooth Audio/Video +Comment[ja]=オーディオ/ビデオ Bluetooth デバイス +Comment[lt]=Audio/video Bluetooth įrenginys +Comment[nl]=Bluetooth Audio/Video-apparaat +Comment[pa]=ਆਡੀਓ/ਵੀਡਿਓ ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Urządzenie Bluetooth Audio/Wideo +Comment[pt]=Dispositivo Bluetooth Áudio/Vídeo +Comment[pt_BR]=Dispositivo Bluetooth Áudio/Vídeo +Comment[sr]=Аудио-видео bluetooth уређај +Comment[sr@Latn]=Audio-video bluetooth uređaj +Comment[sv]=Blåtandsenhet med ljud eller video +Comment[ta]=அடியோ/விடியோ புலுடுத் கருவி +Comment[tg]=Дастгоҳи аудио/видео Bluetoot +Comment[tr]=Bluetooth Ses/Görüntü Aygıtı +Comment[xx]=xxAudio/Video Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/computer-device-class.desktop b/src/tdebluez-common/mimetypes/computer-device-class.desktop new file mode 100644 index 0000000..c20ff0f --- /dev/null +++ b/src/tdebluez-common/mimetypes/computer-device-class.desktop @@ -0,0 +1,32 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/computer-device-class +Icon=konsole +X-TDE-IsAlso=inode/directory +Comment=Computer/PDA Bluetooth Device +Comment[bg]=Компютърно/PDA Bluetooth устройство +Comment[bs]=Računar/PDA Bluetooth uređaj +Comment[ca]=Dispositiu Bluetooth ordinador/PDA +Comment[da]=Computer/PDA Bluetooth-enhed +Comment[de]=Computer/PDA Bluetooth-Gerät +Comment[el]=Συσκευή υπολογιστή/PDA Bluetooth +Comment[es]=Dispositivo Bluetooth computadora/PDA +Comment[et]=Arvuti/PDA Bluetoothi seade +Comment[fr]=Périphérique ordinateur ou PDA Bluetooth +Comment[gl]=Dispositivo Bluetooth Computador/PDA +Comment[it]=Dispositivo Bluetooth Computer/PDA +Comment[ja]=コンピュータ/PDA Bluetooth デバイス +Comment[lt]=Kompiuterio/PDA Bluetooth įrenginys +Comment[nl]=Bluetooth computer/PDA-apparaat +Comment[pa]=ਕੰਪਿਊਟਰ/PDA ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Urządzenie Bluetooth komputer/PDA +Comment[pt]=Dispositivo Bluetooth Computador/PDA +Comment[pt_BR]=Dispositivo Bluetooth Computador/PDA +Comment[sr]=Рачунар/PDA bluetooth уређај +Comment[sr@Latn]=Računar/PDA bluetooth uređaj +Comment[sv]=Blåtandsenhet i dator eller handdator +Comment[ta]=கணிணி/PDA புலுடுத் கருவி +Comment[tg]=Дастгоҳи компютер/PDA Bluetooth +Comment[tr]=Bluetooth Bilgisayar/PDA Aygıtı +Comment[xx]=xxComputer/PDA Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/dun-profile.desktop b/src/tdebluez-common/mimetypes/dun-profile.desktop new file mode 100644 index 0000000..dd0d5de --- /dev/null +++ b/src/tdebluez-common/mimetypes/dun-profile.desktop @@ -0,0 +1,30 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/dun-profile +Icon=network_local +Comment=Bluetooth Dial-Up Networking Profile +Comment[bg]=Профил за връзка с Bluetooth (Dial-Up) +Comment[bs]=Bluetooth dial-up networking profil +Comment[ca]=Perfil de xarxa telefònica Bluetooth +Comment[da]=Bluetooth opkalds-netværkprofil +Comment[de]=Bluetooth Netzwerkeinwahl-Profil +Comment[el]=Προφίλ δικτύου μέσω τηλεφωνικής κλήσης Bluetooth +Comment[es]=Perfil de red telefónica Bluetooth +Comment[et]=Bluetoothi sissehelistamisteenuse profiil +Comment[fr]=Profil Réseau Bluetooth +Comment[gl]=Perfil de Rede Dial-Up Bluetooth +Comment[it]=Profilo di rete telefonica Bluetooth +Comment[ja]=Bluetooth ダイアルアップ ネットワーク プロファイル (DUN) +Comment[lt]=Bluetooth Dial-Up ryšio profilis +Comment[nl]=Bluetooth inbelnetwerkprofiel +Comment[pa]=ਬਲਿਊਟੁੱਥ ਡਾਇਲਅੱਪ ਨੈਟਵਰਕ ਪ੍ਰੋਫਾਇਲ +Comment[pl]=Profil sieci wdzwanianej Bluetooth +Comment[pt]=Perfil de Rede 'Dial-Up' Bluetooth +Comment[pt_BR]=Perfil de Rede 'Dial-Up' Bluetooth +Comment[sr]=Bluetooth профил повезивања преко телефона +Comment[sr@Latn]=Bluetooth profil povezivanja preko telefona +Comment[sv]=Blåtandsprofil för uppringt nätverk +Comment[ta]=புலுடுத் தொலைபேசி முலம் இனைகும் முறை +Comment[tr]=Bluetooth Çevirmeli Bağlantı Profili +Comment[xx]=xxBluetooth Dial-Up Networking Profilexx diff --git a/src/tdebluez-common/mimetypes/fax-profile.desktop b/src/tdebluez-common/mimetypes/fax-profile.desktop new file mode 100644 index 0000000..1c4ff8c --- /dev/null +++ b/src/tdebluez-common/mimetypes/fax-profile.desktop @@ -0,0 +1,31 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/fax-profile +Icon=printer2 +Comment=Bluetooth Fax Profile +Comment[ar]=مواصفات فاكس Bluetooth +Comment[bg]=Профил за факс с Bluetooth +Comment[bs]=Bluetooth fax profil +Comment[ca]=Perfil de fax Bluetooth +Comment[da]=Bluetooth fax-profil +Comment[de]=Bluetooth Fax-Profil +Comment[el]=Προφίλ Bluetooth Fax +Comment[es]=Perfil de fax Bluetooth +Comment[et]=Bluetoothi faksiprofiil +Comment[fr]=Profil de Fax Bluetooth +Comment[gl]=Perfil de Fax Bluetooth +Comment[it]=Profilo Fax Bluetooth +Comment[ja]=Bluetooth ファクス プロファイル (FAX) +Comment[lt]=Bluetooth fakso profilis +Comment[nl]=Bluetooth faxprofiel +Comment[pa]=ਬਲਿਊਟੁੱਥ ਫੈਕਸ ਪ੍ਰੋਫਾਇਲ +Comment[pl]=Profil Bluetooth faksowania +Comment[pt]=Perfil de Fax Bluetooth +Comment[pt_BR]=Perfil de Fax Bluetooth +Comment[sr]=Bluetooth профил за факс +Comment[sr@Latn]=Bluetooth profil za faks +Comment[sv]=Blåtandsprofil för telefax +Comment[ta]=புலுடுத் தொலை நகல் பக்கநோக்கு +Comment[tr]=Bluetooth Faks Profili +Comment[xx]=xxBluetooth Fax Profilexx diff --git a/src/tdebluez-common/mimetypes/handsfree-profile.desktop b/src/tdebluez-common/mimetypes/handsfree-profile.desktop new file mode 100644 index 0000000..90ecf70 --- /dev/null +++ b/src/tdebluez-common/mimetypes/handsfree-profile.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/handsfree-profile +Icon=kaddressbook +Comment=Bluetooth Hands-Free Profile +Comment[bg]=Профил Hands-Free за Bluetooth +Comment[bs]=Bluetooth hands-free profil +Comment[ca]=Perfil de mans lliures Bluetooth +Comment[da]=Bluetooth Hands-Free-profil +Comment[de]=Bluetooth Hands-Free-Profil +Comment[el]=Προφίλ Bluetooth Hands-Free +Comment[es]=Perfil manos libres Bluetooth +Comment[et]=Bluetoothi handsfree profiil +Comment[fr]=Profil Hands-Free Bluetooth +Comment[gl]=Perfil de Maos-Libres Bluetooth +Comment[it]=Profilo viva voce Bluetooth +Comment[ja]=Bluetooth ハンズフリー プロファイル (HFP) +Comment[lt]=Bluetooth laisvų rankų profilis +Comment[nl]=Bluetooth Hands-Free-profiel +Comment[pl]=Profil Bluetooth zestawu słuchawkowego +Comment[pt]=Perfil Mãos-Livres Bluetooth +Comment[pt_BR]=Perfil Mãos-Livres Bluetooth +Comment[sr]=Bluetooth хендсфри профил +Comment[sr@Latn]=Bluetooth hendsfri profil +Comment[sv]=Blåtandsprofil för handsfree +Comment[ta]=புலுடுத் கைஇல்லா பக்கநோக்கு +Comment[tr]=Bluetooth Eller Serbest Profili +Comment[xx]=xxBluetooth Hands-Free Profilexx diff --git a/src/tdebluez-common/mimetypes/headset-profile.desktop b/src/tdebluez-common/mimetypes/headset-profile.desktop new file mode 100644 index 0000000..e5c38cf --- /dev/null +++ b/src/tdebluez-common/mimetypes/headset-profile.desktop @@ -0,0 +1,30 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/headset-profile +Icon=kaddressbook +Comment=Bluetooth Headset Profile +Comment[bg]=Профил Headset за Bluetooth +Comment[bs]=Bluetooth headset profil +Comment[ca]=Perfil d'auriculars Bluetooth +Comment[da]=Bluetooth Headset-profil +Comment[de]=Bluetooth Headset-Profil +Comment[el]=Προφίλ Bluetooth ακουστικών +Comment[es]=Perfil de auriculares Bluetooth +Comment[et]=Bluetoothi peakomplekti profiil +Comment[fr]=Profil Headset Bluetooth +Comment[gl]=Perfil de Auricular Bluetooth +Comment[it]=Profilo cuffie Bluetooth +Comment[ja]=Bluetooth ヘッドセット プロファイル (HSP) +Comment[lt]=Bluetooth ausinių profilis +Comment[nl]=Bluetooth Headset-profiel +Comment[pa]=ਬਲਿਊਟੁੱਥ ਹੈਡਸੈਟ ਪ੍ਰੋਫਾਇਲ +Comment[pl]=Profil Bluetooth zestawu słuchawek z mikrofonem +Comment[pt]=Perfil de Auricular Bluetooth +Comment[pt_BR]=Perfil de Auricular Bluetooth +Comment[sr]=Bluetooth профил за слушалице +Comment[sr@Latn]=Bluetooth profil za slušalice +Comment[sv]=Blåtandsprofil för headset +Comment[ta]=புலுடுத் தலைஅமைப்பு பக்கநோக்கு +Comment[tr]=Bluetooth Kulaklıklı Mikrofon Profili +Comment[xx]=xxBluetooth Headset Profilexx diff --git a/src/tdebluez-common/mimetypes/health-device-class.desktop b/src/tdebluez-common/mimetypes/health-device-class.desktop new file mode 100644 index 0000000..fbc682d --- /dev/null +++ b/src/tdebluez-common/mimetypes/health-device-class.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/health-device-class +Icon=health +X-TDE-IsAlso=inode/directory +Comment=Health Bluetooth Device +Comment[bg]=Медицинско Bluetooth устройство +Comment[xx]=xxHealth Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/imaging-device-class.desktop b/src/tdebluez-common/mimetypes/imaging-device-class.desktop new file mode 100644 index 0000000..24b5f48 --- /dev/null +++ b/src/tdebluez-common/mimetypes/imaging-device-class.desktop @@ -0,0 +1,30 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/imaging-device-class +Icon=camera_unmount +Comment=Imaging Bluetooth Device +Comment[bg]=Bluetooth устройство за снимка +Comment[bs]=Imaging Bluetooth uređaj +Comment[ca]=Dispositiu Bluetooth d'imatges +Comment[da]=Imaging Bluetooth-enhed +Comment[de]=Imaging Bluetooth-Gerät +Comment[el]=Συσκευή εικόνας Bluetooth +Comment[es]=Dispositivo Bluetooth de imágenes +Comment[et]=Bluetoothi pildiseade +Comment[fr]=Périphérique d'imagerie Bluetooth +Comment[gl]=Dispositivo Bluetooth con Imaxe +Comment[it]=Dispositivo fotografico Bluetooth +Comment[ja]=イメージング Bluetooth デバイス +Comment[lt]=Bluetooth paveikslėlių įrenginys +Comment[nl]=Bluetooth imaging-apparaat +Comment[pa]=ਚਿੱਤਰ ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Urządzenie Bluetooth obrazowania +Comment[pt]=Dispositivo Bluetooth com Imagem +Comment[pt_BR]=Dispositivo Bluetooth com Imagem +Comment[sr]=Bluetooth уређај за прављење слика +Comment[sr@Latn]=Bluetooth uređaj za pravljenje slika +Comment[sv]=Blåtandsenhet med kamera +Comment[ta]=புலுடுத் நினைக்கும் கருவி +Comment[tr]=Bluetooth Görüntü Aygıtı +Comment[xx]=xxImaging Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/keyboard-device-class.desktop b/src/tdebluez-common/mimetypes/keyboard-device-class.desktop new file mode 100644 index 0000000..1445b7b --- /dev/null +++ b/src/tdebluez-common/mimetypes/keyboard-device-class.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/keyboard-device-class +Icon=keyboard +Comment=Peripheral Bluetooth Device +Comment[bg]=Периферно Bluetooth устройство +Comment[ca]=Dispositiu Bluetooth perifèric +Comment[da]=Perifer Bluetooth-enhed +Comment[de]=Peripheriegerät für Bluetooth +Comment[el]=Περιφερειακή συσκευή Bluetooth +Comment[es]=Dispositivo Bluetooth periférico +Comment[et]=Väline Bluetoothi seade +Comment[fr]=Périphérique Bluetooth +Comment[gl]=Dispositivo Bluetooth Periférico +Comment[it]=Dispositivo Bluetooth periferico +Comment[ja]=周辺機器 Bluetooth デバイス +Comment[lt]=Periferinis Bluetooth įrenginys +Comment[nl]=Bluetooth randapparaat +Comment[pa]=ਪੈਰਾਫੀਰਲ ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Urządzenie peryferyjne Bluetooth +Comment[pt]=Dispositivo Bluetooth Periférico +Comment[pt_BR]=Dispositivo Bluetooth Periférico +Comment[sr]=Периферијски bluetooth уређај +Comment[sr@Latn]=Periferijski bluetooth uređaj +Comment[sv]=Extern Blåtandsenhet +Comment[ta]=புற புலுடுத் கருவி +Comment[tr]=Çevresel Bluetooth Aygıtı +Comment[xx]=xxPeripheral Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/lan-device-class.desktop b/src/tdebluez-common/mimetypes/lan-device-class.desktop new file mode 100644 index 0000000..5035fd7 --- /dev/null +++ b/src/tdebluez-common/mimetypes/lan-device-class.desktop @@ -0,0 +1,30 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/lan-device-class +Icon=nfs_unmount +Comment=LAN/Networking Bluetooth Device +Comment[bg]=Мрежово/LAN Bluetooth устройство +Comment[ca]=Dispositiu Bluetooth de xarxa +Comment[da]=LAN/Netværk Bluetooth-enhed +Comment[de]=LAN/Netwerk Bluetooth-Gerät +Comment[el]=Δικτυακή συσκευή Bluetooth +Comment[es]=Dispositivo Bluetooth de redes +Comment[et]=Kohtvõrgu/interneti Bluetoothi seade +Comment[fr]=Périphérique LAN/Réseau Bluetooth +Comment[gl]=Dispositivo de Rede Bluetooth +Comment[it]=Dispositivo Bluetooth di LAN/Rete +Comment[ja]=LAN/ネットワーク Bluetooth デバイス +Comment[lt]=Bluetooth LAN/tinklo įrenginys +Comment[nl]=Bluetooth LAN-/netwerk-apparaat +Comment[pa]=LAN/ਨੈਟਵਰਕ ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Urządzenie Bluetooth LAN/sieciowe +Comment[pt]=Dispositivo de Rede Bluetooth +Comment[pt_BR]=Dispositivo de Rede Bluetooth +Comment[sr]=LAN/мрежни bluetooth уређај +Comment[sr@Latn]=LAN/mrežni bluetooth uređaj +Comment[sv]=Blåtandsenhet för lokalt nätverk +Comment[ta]=LAN/புலுடுத் வலை இனைப்பு கருவி +Comment[tg]=Дастгоҳи шабака/LAN Bluetooth +Comment[tr]=LAN/Ağ Bluetooth Aygıtı +Comment[xx]=xxLAN/Networking Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/misc-device-class.desktop b/src/tdebluez-common/mimetypes/misc-device-class.desktop new file mode 100644 index 0000000..67a510b --- /dev/null +++ b/src/tdebluez-common/mimetypes/misc-device-class.desktop @@ -0,0 +1,30 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/misc-device-class +Icon=tdebluez +X-TDE-IsAlso=inode/directory +Comment=Miscellaneous Bluetooth Device +Comment[bg]=Разни Bluetooth устройства +Comment[ca]=Dispositiu Bluetooth divers +Comment[da]=Diverse Bluetooth-enheder +Comment[de]=Vielseitiges Bluetooth-Gerät +Comment[el]=Συσκευή Bluetooth άλλης κατηγορίας +Comment[es]=Dispositivo Bluetooth diverso +Comment[et]=Mitmesugused Bluetoothi seadmed +Comment[fr]=Périphérique Bluetooth divers +Comment[gl]=Dispositivo Bluetooth +Comment[it]=Dispositivo Bluetooth vario +Comment[ja]=その他の Bluetooth デバイス +Comment[lt]=Kitas Bluetooth įrenginys +Comment[nl]=Ander Bluetooth-apparaat +Comment[pa]=ਫੁਟਕਲ ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Inne urządzenie Bluetooth +Comment[pt]=Dispositivo Bluetooth Variado +Comment[pt_BR]=Dispositivo Bluetooth Variado +Comment[sr]=Неодређени bluetooth уређај +Comment[sr@Latn]=Neodređeni bluetooth uređaj +Comment[sv]=Annan Blåtandsenhet +Comment[ta]=இதர புலுடுத் கருவி +Comment[tr]=Çeşitli Bluetooth Aygıtları +Comment[xx]=xxMiscellaneous Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/mouse-device-class.desktop b/src/tdebluez-common/mimetypes/mouse-device-class.desktop new file mode 100644 index 0000000..00a5880 --- /dev/null +++ b/src/tdebluez-common/mimetypes/mouse-device-class.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/mouse-device-class +Icon=mouse +Comment=Peripheral Bluetooth Device +Comment[bg]=Периферно Bluetooth устройство +Comment[ca]=Dispositiu Bluetooth perifèric +Comment[da]=Perifer Bluetooth-enhed +Comment[de]=Peripheriegerät für Bluetooth +Comment[el]=Περιφερειακή συσκευή Bluetooth +Comment[es]=Dispositivo Bluetooth periférico +Comment[et]=Väline Bluetoothi seade +Comment[fr]=Périphérique Bluetooth +Comment[gl]=Dispositivo Bluetooth Periférico +Comment[it]=Dispositivo Bluetooth periferico +Comment[ja]=周辺機器 Bluetooth デバイス +Comment[lt]=Periferinis Bluetooth įrenginys +Comment[nl]=Bluetooth randapparaat +Comment[pa]=ਪੈਰਾਫੀਰਲ ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Urządzenie peryferyjne Bluetooth +Comment[pt]=Dispositivo Bluetooth Periférico +Comment[pt_BR]=Dispositivo Bluetooth Periférico +Comment[sr]=Периферијски bluetooth уређај +Comment[sr@Latn]=Periferijski bluetooth uređaj +Comment[sv]=Extern Blåtandsenhet +Comment[ta]=புற புலுடுத் கருவி +Comment[tr]=Çevresel Bluetooth Aygıtı +Comment[xx]=xxPeripheral Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/obex-ftp-profile.desktop b/src/tdebluez-common/mimetypes/obex-ftp-profile.desktop new file mode 100644 index 0000000..a16bcbd --- /dev/null +++ b/src/tdebluez-common/mimetypes/obex-ftp-profile.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/obex-ftp-profile +Icon=nfs_unmount +Comment=OBEX File Transfer Profile +Comment[bg]=Профил за пренос на OBEX файл +Comment[ca]=Perfil de transferència de fitxers OBEX +Comment[da]=OBEX filoverførselsprofil +Comment[de]=OBEX Dateitransferprotokoll +Comment[el]=Προφίλ μεταφοράς αρχείων OBEX +Comment[es]=Perfil de transferencia de archivos OBEX +Comment[et]=OBEX failiedastuse profiil +Comment[fr]=Profil de transfert de fichiers via OBEX +Comment[gl]=Perfil de Transferéncia de Ficheiros OBEX +Comment[it]=Profilo di trasferimento file OBEX +Comment[ja]=OBEX ファイル転送プロファイル (FTP) +Comment[lt]=OBEX bylų persiuntimo profilis +Comment[nl]=OBEX bestandsoverdrachtprofiel +Comment[pa]=OBEX ਫਾਇਲ ਸੰਚਾਰ ਪ੍ਰੋਫਾਇਲ +Comment[pl]=Profil transferu plików OBEX +Comment[pt]=Perfil de Transferência de Ficheiros OBEX +Comment[pt_BR]=Perfil de Transferência de Ficheiros OBEX +Comment[sr]=Профил за OBEX пренос фајлова +Comment[sr@Latn]=Profil za OBEX prenos fajlova +Comment[sv]=OBEX-filöverföringsprofil +Comment[ta]=OBEX கோப்பு மாற்று பக்கநோக்கு +Comment[tr]=OBEX Dosya Transfer Profili +Comment[xx]=xxOBEX File Transfer Profilexx diff --git a/src/tdebluez-common/mimetypes/obex-objectpush-profile.desktop b/src/tdebluez-common/mimetypes/obex-objectpush-profile.desktop new file mode 100644 index 0000000..d1b0ce6 --- /dev/null +++ b/src/tdebluez-common/mimetypes/obex-objectpush-profile.desktop @@ -0,0 +1,32 @@ +[Desktop Entry] +Encoding=UTF-8 +Comment=OBEX Object Push Profile +Comment[bg]=Профил OBEX Object Push +Comment[ca]=Perfil d'enviament d'objectes OBEX +Comment[da]=OBEX objekt-skubbeprofil +Comment[de]=OBEX Object-Push-Profil +Comment[el]=Προφίλ αποστολής αντικειμένων OBEX +Comment[es]=Perfil de envío de objetos OBEX +Comment[et]=OBEX objekti saatmise profiil +Comment[fr]=Profil OBEX Object Push +Comment[gl]=Perfil de Envio de Obxectos OBEX +Comment[it]=Profilo di Oggetto Push OBEX +Comment[ja]=OBEX オブジェクトプッシュ プロファイル (OPP) +Comment[lt]=OBEX persiuntimo profilis +Comment[nl]=OBEX Object Push-profiel +Comment[pa]=OBEX Object Push ਪ੍ਰੋਫਾਇਲ +Comment[pl]=Profil OBEX Object Push +Comment[pt]=Perfil de Envio de Objectos OBEX +Comment[pt_BR]=Perfil de Envio de Objectos OBEX +Comment[sr]=Профил за OBEX гурање објеката +Comment[sr@Latn]=Profil za OBEX guranje objekata +Comment[sv]=OBEX-objektsändingsprofil +Comment[ta]=OBEX பொருள் விளக்கக்குறிப்பு +Comment[tr]=OBEX Nesne Ekleme Profili +Comment[xx]=xxOBEX Object Push Profilexx +Icon=mail_send +Type=MimeType +MimeType=bluetooth/obex-object-push-profile +Patterns= +NoDisplay=false +X-TDE-AutoEmbed=true diff --git a/src/tdebluez-common/mimetypes/peripheral-device-class.desktop b/src/tdebluez-common/mimetypes/peripheral-device-class.desktop new file mode 100644 index 0000000..55eaa3f --- /dev/null +++ b/src/tdebluez-common/mimetypes/peripheral-device-class.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/peripheral-device-class +Icon=joystick +Comment=Peripheral Bluetooth Device +Comment[bg]=Периферно Bluetooth устройство +Comment[ca]=Dispositiu Bluetooth perifèric +Comment[da]=Perifer Bluetooth-enhed +Comment[de]=Peripheriegerät für Bluetooth +Comment[el]=Περιφερειακή συσκευή Bluetooth +Comment[es]=Dispositivo Bluetooth periférico +Comment[et]=Väline Bluetoothi seade +Comment[fr]=Périphérique Bluetooth +Comment[gl]=Dispositivo Bluetooth Periférico +Comment[it]=Dispositivo Bluetooth periferico +Comment[ja]=周辺機器 Bluetooth デバイス +Comment[lt]=Periferinis Bluetooth įrenginys +Comment[nl]=Bluetooth randapparaat +Comment[pa]=ਪੈਰਾਫੀਰਲ ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Urządzenie peryferyjne Bluetooth +Comment[pt]=Dispositivo Bluetooth Periférico +Comment[pt_BR]=Dispositivo Bluetooth Periférico +Comment[sr]=Периферијски bluetooth уређај +Comment[sr@Latn]=Periferijski bluetooth uređaj +Comment[sv]=Extern Blåtandsenhet +Comment[ta]=புற புலுடுத் கருவி +Comment[tr]=Çevresel Bluetooth Aygıtı +Comment[xx]=xxPeripheral Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/phone-device-class.desktop b/src/tdebluez-common/mimetypes/phone-device-class.desktop new file mode 100644 index 0000000..b1b28f8 --- /dev/null +++ b/src/tdebluez-common/mimetypes/phone-device-class.desktop @@ -0,0 +1,32 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/phone-device-class +Icon=kaddressbook +X-TDE-IsAlso=inode/directory +Comment=Phone Bluetooth Device +Comment[ar]=جهاز هاتف Bluetooth +Comment[bg]=Телефонно Bluetooth устройство +Comment[ca]=Dispositiu Bluetooth telefònic +Comment[da]=Telefon Bluetooth-enhed +Comment[de]=Bluetooth-Gerät für Telefonie +Comment[el]=Τηλεφωνική συσκευή Bluetooth +Comment[es]=Dispositivo bluetooth telefónico +Comment[et]=Telefoni Bluetoothi seade +Comment[fr]=Téléphone Bluetooth +Comment[gl]=Teléfone con Bluetooth +Comment[it]=Dispositivo Bluetooth telefonico +Comment[ja]=電話 Bluetooth デバイス +Comment[lt]=Bluetooth telefono įrenginys +Comment[nl]=Bluetooth telefoon +Comment[pa]=ਫੋਨ ਬਲਿਊਟੁੱਥ ਜੰਤਰ +Comment[pl]=Urządzenie Bluetooth - telefon +Comment[pt]=Dispositivo Bluetooth Telefone +Comment[pt_BR]=Dispositivo Bluetooth Telefone +Comment[sr]=Телефонски bluetooth уређај +Comment[sr@Latn]=Telefonski bluetooth uređaj +Comment[sv]=Blåtandsenhet i telefon +Comment[ta]=தொலைபெசி புலுடுத் கருவி +Comment[tg]=Дастгоҳи телефони Bluetooth +Comment[tr]=Bluetooth Telefon Aygıtı +Comment[xx]=xxPhone Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/serial-port-profile.desktop b/src/tdebluez-common/mimetypes/serial-port-profile.desktop new file mode 100644 index 0000000..439de4a --- /dev/null +++ b/src/tdebluez-common/mimetypes/serial-port-profile.desktop @@ -0,0 +1,29 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/serial-port-profile +Icon=input_devices_settings +Comment=Bluetooth Serial Port Profile +Comment[bg]=Профил за сериен порт за Bluetooth +Comment[ca]=Perfil de port sèrie Bluetooth +Comment[da]=Bluetooth seriel port profil +Comment[de]=Serielles Bluetooth-Anschlussprofil +Comment[el]=Προφίλ σειριακής θύρας Bluetooth +Comment[es]=Perfil Bluetooth de puerto serie +Comment[et]=Bluetoothi jadapordi profiil +Comment[fr]=Profil de port série Bluetooth +Comment[gl]=Perfil Bluetooth de Porto Série +Comment[it]=Profilo di porta seriale Bluetooth +Comment[ja]=Bluetooth シリアルポート プロファイル (SPP) +Comment[lt]=Bluetooth nuoseklaus prievado profilis +Comment[nl]=Bluetooth seriële-poort-profiel +Comment[pa]=ਬਲਿਊਟੁੱਥ ਸੀਰੀਅਲ ਪੋਰਟ ਪ੍ਰੋਫਾਇਲ +Comment[pl]=Profil Bluetooth portu szeregowego +Comment[pt]=Perfil Bluetooth de Portal Série +Comment[pt_BR]=Perfil Bluetooth de Portal Série +Comment[sr]=Bluetooth профил серијског порта +Comment[sr@Latn]=Bluetooth profil serijskog porta +Comment[sv]=Blåtandsprofil för serieport +Comment[ta]=புலுடுத் தொடர் துரை பக்கநோக்கு +Comment[tr]=Bluetooth Seri Port Profili +Comment[xx]=xxBluetooth Serial Port Profilexx diff --git a/src/tdebluez-common/mimetypes/synchronization-profile.desktop b/src/tdebluez-common/mimetypes/synchronization-profile.desktop new file mode 100644 index 0000000..50efd3c --- /dev/null +++ b/src/tdebluez-common/mimetypes/synchronization-profile.desktop @@ -0,0 +1,31 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/synchronization-profile +Icon=pda_blue +Comment=Bluetooth Synchronization Profile +Comment[ar]=مواصفات مقارنة التزامن Bluetooth +Comment[bg]=Профил за синхронизиране на Bluetooth +Comment[ca]=Perfil de sincronització Bluetooth +Comment[da]=Bluetooth synkroniseringsprofil +Comment[de]=Bluetooth Synchronisationsprofil +Comment[el]=Προφίλ συγχρονισμού Bluetooth +Comment[en_GB]=Bluetooth Synchronisation Profile +Comment[es]=Perfil de sincronización Bluetooth +Comment[et]=Bluetoothi sünkroprofiil +Comment[fr]=Profil de Synchronisation Bluetooth +Comment[gl]=Perfil de Sincronizazón Bluetooth +Comment[it]=Profilo di sincronizzazione Bluetooth +Comment[ja]=Bluetooth 同期プロファイル (SYNC) +Comment[lt]=Bluetooth sinchronizacijos profilis +Comment[nl]=Bluetooth synchronisatieprofiel +Comment[pa]=ਬਲਿਊਟੁੱਥ ਸਮਕਾਲੀ ਪ੍ਰੋਫਾਇਲ +Comment[pl]=Profil Bluetooth synchronizacji +Comment[pt]=Perfil de Sincronização Bluetooth +Comment[pt_BR]=Perfil de Sincronização Bluetooth +Comment[sr]=Bluetooth профил синхронизације +Comment[sr@Latn]=Bluetooth profil sinhronizacije +Comment[sv]=Blåtandsprofil för synkronisering +Comment[ta]=புலுடுத் ஒத்திசை பக்கநோக்கு +Comment[tr]=Bluetooth Eşzamanlama Profili +Comment[xx]=xxBluetooth Synchronization Profilexx diff --git a/src/tdebluez-common/mimetypes/toy-device-class.desktop b/src/tdebluez-common/mimetypes/toy-device-class.desktop new file mode 100644 index 0000000..b2b40d3 --- /dev/null +++ b/src/tdebluez-common/mimetypes/toy-device-class.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/toy-device-class +Icon=package_toys +X-TDE-IsAlso=inode/directory +Comment=Toy Bluetooth Device +Comment[bg]=Играчка Bluetooth устройство +Comment[xx]=xxToy Bluetooth Devicexx diff --git a/src/tdebluez-common/mimetypes/unknown-device-class.desktop b/src/tdebluez-common/mimetypes/unknown-device-class.desktop new file mode 100644 index 0000000..5a05925 --- /dev/null +++ b/src/tdebluez-common/mimetypes/unknown-device-class.desktop @@ -0,0 +1,30 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/unknown-device-class +Icon=tdebluez +Comment=Unknown Bluetooth Device Class +Comment[ar]=فئة جهاز Bluetooth غير معروف +Comment[bg]=Неизвестен клас на Bluetooth устройство +Comment[ca]=Classe de dispositiu Bluetooth desconegut +Comment[da]=Ukendt Bluetooth enhedsklasse +Comment[de]=Unbekannte Bluetooth-Geräteklasse +Comment[el]=Άγνωστη κλάση συσκευής Bluetooth +Comment[es]=Clase de dispositivo Bluetooth desconocida +Comment[et]=Tundmatu Bluetoothi seadme klass +Comment[fr]=Classe du périphérique Bluetooth inconnue +Comment[gl]=Clase de dispositivo Bluetooth descoñecida +Comment[it]=Classe di dispositivo Bluetooth ignota +Comment[ja]=未知の Bluetooth デバイスクラス +Comment[lt]=Nežinoma Bluetooth įrenginio klasė +Comment[nl]=Onbekende Bluetooth apparaatklasse +Comment[pa]=ਅਣਜਾਣ ਬਲਿਊਟੁੱਥ ਜੰਤਰ ਕਲਾਸ +Comment[pl]=Nieznana klasa urządzenia Bluetooth +Comment[pt]=Classe de dispositivo Bluetooth desconhecida +Comment[pt_BR]=Classe de dispositivo Bluetooth desconhecida +Comment[sr]=Непозната класа bluetooth уређаја +Comment[sr@Latn]=Nepoznata klasa bluetooth uređaja +Comment[sv]=Okänd klass av Blåtandsenhet +Comment[ta]=தேரியாத புலுடுத் கருவி வகுப்புகள் +Comment[tr]=Bilinmeyen Bluetooth Aygıt Sınıfı +Comment[xx]=xxUnknown Bluetooth Device Classxx diff --git a/src/tdebluez-common/mimetypes/unknown-profile.desktop b/src/tdebluez-common/mimetypes/unknown-profile.desktop new file mode 100644 index 0000000..926c29e --- /dev/null +++ b/src/tdebluez-common/mimetypes/unknown-profile.desktop @@ -0,0 +1,33 @@ +[Desktop Entry] +Encoding=UTF-8 +Comment=Unknown Bluetooth Profile +Comment[ar]=مواصفات Bluetooth غير معروفة +Comment[bg]=Неизвестен профил на Bluetooth +Comment[br]=Profil Bluetooth dianav +Comment[ca]=Perfil Bluetooth desconegut +Comment[da]=Ukendt Bluetooth-profil +Comment[de]=Unkekanntes Bluetooth Profil +Comment[el]=Άγνωστο προφίλ Bluetooth +Comment[es]=Perfil Bluetooth desconocido +Comment[et]=Tundmatu Bluetoothi profiil +Comment[fr]=Profil Bluetooth inconnu +Comment[gl]=Perfil Bluetooth Descoñecido +Comment[it]=Profilo Bluetooth ignoto +Comment[ja]=未知の Bluetooth プロファイル +Comment[lt]=Nežinomas Bluetooth profilis +Comment[nl]=Onbekend Bluetooth-profiel +Comment[pa]=ਅਣਜਾਣ ਬਲਿਊਟੁੱਥ ਪ੍ਰੋਫਾਇਲ +Comment[pl]=Nieznany profil Bluetooth +Comment[pt]=Perfil Bluetooth Desconhecido +Comment[pt_BR]=Perfil Bluetooth Desconhecido +Comment[sr]=Непознати bluetooth профил +Comment[sr@Latn]=Nepoznati bluetooth profil +Comment[sv]=Okänd Blåtandsprofil +Comment[ta]=தெரியாத ப்ளூ டூத் விளக்கக்குறிப்பு +Comment[tg]=Профили Bluetooth номуайян +Comment[tr]=Bilinmeyen Bluetooth Profili +Comment[xx]=xxUnknown Bluetooth Profilexx +Icon=misc +Type=MimeType +MimeType=bluetooth/unknown-profile +Patterns= diff --git a/src/tdebluez-common/mimetypes/wearable-device-class.desktop b/src/tdebluez-common/mimetypes/wearable-device-class.desktop new file mode 100644 index 0000000..fe1f182 --- /dev/null +++ b/src/tdebluez-common/mimetypes/wearable-device-class.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=MimeType +MimeType=bluetooth/wearable-device-class +Icon=kaddressbook +X-TDE-IsAlso=inode/directory +Comment=Wearable Bluetooth Device +Comment[bg]=Преносимо Bluetooth устройство +Comment[xx]=xxWearable Bluetooth Devicexx diff --git a/src/tdebluez-common/org.trinitydesktop.tdebluez.conf b/src/tdebluez-common/org.trinitydesktop.tdebluez.conf new file mode 100644 index 0000000..fa48877 --- /dev/null +++ b/src/tdebluez-common/org.trinitydesktop.tdebluez.conf @@ -0,0 +1,42 @@ +<?xml version="1.0" encoding="UTF-8"?> <!-- -*- XML -*- --> +<!DOCTYPE busconfig PUBLIC + "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> +<busconfig> + <!-- Only root can own the service --> + <policy user="root"> + <allow own="org.trinitydesktop.tdebluez"/> + <allow send_destination="org.bluez"/> + <allow send_destination="org.trinitydesktop.tdebluez"/> + <allow send_path="/org/trinitydesktop/tdebluez" + send_interface="org.bluez.Agent1"/> + <allow send_path="/org/trinitydesktop/tdebluez" + send_interface="org.freedesktop.DBus.Introspectable"/> + </policy> + + <policy at_console="true"> + <!-- Users with physical access to the machine are allowed access --> + <allow send_destination="org.bluez"/> + <allow send_destination="org.trinitydesktop.tdebluez"/> + <allow send_path="/org/trinitydesktop/tdebluez" + send_interface="org.freedesktop.DBus.Introspectable"/> + <allow send_path="/org/trinitydesktop/tdebluez" + send_interface="org.bluez.Agent1"/> + </policy> + + <!-- allow users of bluetooth group to communicate --> + <policy group="bluetooth"> + <allow own="org.trinitydesktop.tdebluez"/> + <allow send_destination="org.bluez"/> + <allow send_destination="org.trinitydesktop.tdebluez"/> + <allow send_path="/org/trinitydesktop/tdebluez" + send_interface="org.freedesktop.DBus.Introspectable"/> + <allow send_path="/org/trinitydesktop/tdebluez" + send_interface="org.bluez.Agent1"/> + </policy> + + <policy context="default"> + <!-- Everyone else is denied access --> + <deny send_destination="org.trinitydesktop.tdebluez"/> + </policy> +</busconfig> diff --git a/src/tdebluez-common/org.trinitydesktop.tdebluez.service b/src/tdebluez-common/org.trinitydesktop.tdebluez.service new file mode 100644 index 0000000..9b0928a --- /dev/null +++ b/src/tdebluez-common/org.trinitydesktop.tdebluez.service @@ -0,0 +1,4 @@ +[D-BUS Service] +Name=org.trinitydesktop.tdebluez +Exec=/bin/false +User=root diff --git a/src/tdebluez-common/tde-settings-network-bluetooth.directory b/src/tdebluez-common/tde-settings-network-bluetooth.directory new file mode 100644 index 0000000..54636e7 --- /dev/null +++ b/src/tdebluez-common/tde-settings-network-bluetooth.directory @@ -0,0 +1,7 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Bluetooth +Name[pa]=ਬਲਿਊਟੁੱਥ +Name[sv]=Blåtand +Name[xx]=xxBluetoothxx +Icon=tdebluez diff --git a/src/tdebluez/CMakeLists.txt b/src/tdebluez/CMakeLists.txt new file mode 100644 index 0000000..8d1efcc --- /dev/null +++ b/src/tdebluez/CMakeLists.txt @@ -0,0 +1,48 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +project (tdebluez) + +include_directories( + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/src/libtdebluez + ${CMAKE_BINARY_DIR}/src/libtdebluez + ${CMAKE_SOURCE_DIR}/src/tdebluezauth +# ${DBUS_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### tdebluez (tdeinit) ###################### +tde_add_tdeinit_executable( tdebluez AUTOMOC + SOURCES + adapterconfig.cpp adapterdialog.ui application.cpp + devicedialog.ui devicedialog_ext.ui adapterconfigdialog.cpp + devicewizard.cpp devicesetupwizarddialog.ui devicesetupwizard.cpp + mediacontrol.cpp mediactl.ui trayicon.cpp main.cpp + LINK + ${DBUS_TQT_LIBRARIES} tdecore-shared tdeui-shared tdeio-shared tdebluez-shared bluezinterfaces-static + ${XEXT_LIBRARIES} ${XTST_LIBRARIES} ${XSCRNSAVER_LIBRARIES} + DESTINATION ${BIN_INSTALL_DIR} +) + +##### other data ################################ +# +install( FILES tdebluez.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) +install( FILES tdebluez.autostart.desktop DESTINATION ${AUTOSTART_INSTALL_DIR} ) +install( FILES eventsrc DESTINATION ${DATA_INSTALL_DIR}/tdebluez ) diff --git a/src/tdebluez/adapterconfig.cpp b/src/tdebluez/adapterconfig.cpp new file mode 100644 index 0000000..cf9470a --- /dev/null +++ b/src/tdebluez/adapterconfig.cpp @@ -0,0 +1,386 @@ +/* + * + * Adapter config dialog for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <kdebug.h> +#include "adapterconfig.h" +#include <devicemimeconverter.h> + +#include <btuuids.h> + +AdapterConfig::AdapterConfig(ObjectManagerImpl *mgr, AdapterImpl *a) +{ + adapterDialog = new AdapterDialog(); + manager = mgr; + adapter = a; + + TQT_DBusError dbuserr; + name = adapter->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Get alias for the adapter failed: %s", dbuserr.message().local8Bit().data()); + + adapterDialog->deviceModes->insertItem(i18n("Hidden")); + adapterDialog->deviceModes->insertItem(i18n("Always visible")); + adapterDialog->deviceModes->insertItem(i18n("Temporary visible")); + + adapterDialog->deviceClass->insertItem(i18n("Unknown")); + adapterDialog->deviceClass->insertItem(i18n("Computer")); + adapterDialog->deviceClass->setEnabled(false); + + adapterDialog->adapterName->setText(name); + + addAdapterDialogInfo(); + + // ADAPTER -> MANAGER -> DIALOG + connect(manager, SIGNAL(adapterNameChanged(const TQString&,const TQString&)), + this, TQT_SLOT(slotAdapterNameChanged(const TQString&, const TQString&))); + connect(manager, SIGNAL(adapterAliasChanged(const TQString&,const TQString&)), + this, TQT_SLOT(slotAdapterNameChanged(const TQString&, const TQString&))); + + connect(manager, SIGNAL(adapterDiscoverableTimeoutChanged(const TQString&, TQ_UINT32)), + this, TQT_SLOT(slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32))); + connect(manager, SIGNAL(adapterDiscoverableChanged(const TQString&, bool)), + this, TQT_SLOT(slotDiscoverableChanged(const TQString&, bool))); + connect(manager, SIGNAL(adapterPowerOnChanged(const TQString&, bool)), this, TQT_SLOT(slotPowerOnChanged(const TQString&, bool))); + + // DIALOG -> ADAPTER + connect(adapterDialog->adapterName, SIGNAL(textChanged(const TQString &)), + this, TQT_SLOT(slotChangeName(const TQString &))); + connect(adapterDialog->deviceModes, SIGNAL(activated(int)), + this, TQT_SLOT(slotSetMode(int))); +// connect(adapterDialog->deviceClass, SIGNAL(activated(const TQString &)), + // this, TQT_SLOT(slotSetClass(const TQString &))); + connect(adapterDialog->sliderTimeout, SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotChangeTimeout(int))); + + adapterDialog->setModal(false); +} + +AdapterConfig::~AdapterConfig() +{ + if (adapterDialog) + delete adapterDialog; +} + +void AdapterConfig::addAdapterDialogInfo() +{ + TQT_DBusError dbuserr; + bool disc = adapter->getDiscoverable(dbuserr); + int timeout = adapter->getDiscoverableTimeout(dbuserr); + if (disc) + { + if (timeout > 0) + { + adapterDialog->deviceModes->setCurrentItem(2); + adapterDialog->timeout->setNum(int(timeout) / 60); + adapterDialog->timeout->setText(adapterDialog->timeout->text().append(i18n("min"))); + adapterDialog->sliderTimeout->setValue(timeout); + + adapterDialog->sliderTimeout->setEnabled(true); + adapterDialog->timeout->setEnabled(true); + adapterDialog->textLabel9->setEnabled(true); + + } + else + { + adapterDialog->deviceModes->setCurrentItem(1); + adapterDialog->timeout->setNum(int(timeout) / 60); + adapterDialog->timeout->setText(adapterDialog->timeout->text().append(i18n("min"))); + adapterDialog->sliderTimeout->setValue(timeout); + + adapterDialog->sliderTimeout->setEnabled(false); + adapterDialog->timeout->setEnabled(false); + adapterDialog->textLabel9->setEnabled(false); + } + } + else + { + adapterDialog->deviceModes->setCurrentItem(0); + adapterDialog->timeout->setText(i18n("none")); + adapterDialog->sliderTimeout->setValue(0); + + adapterDialog->sliderTimeout->setEnabled(false); + adapterDialog->timeout->setEnabled(false); + adapterDialog->textLabel9->setEnabled(false); + } + + slotSetClass(DeviceMimeConverter::classToMimeType(adapter->getClass(dbuserr))); + if (dbuserr.isValid()) + tqDebug("Get class for the adapter failed: %s", dbuserr.message().local8Bit().data()); + + TQString address = adapter->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Get address for the adapter failed: %s", dbuserr.message().local8Bit().data()); + TQStringList uuids = adapter->getUUIDs(dbuserr); + if (dbuserr.isValid()) + tqDebug("Get uuids for the adapter failed: %s", dbuserr.message().local8Bit().data()); + TQVBoxLayout *infoLayout = new TQVBoxLayout(adapterDialog->groupBoxInfo->layout()); + // GridLayout *infoGrid = new TQGridLayout(adapterDialog->groupBoxInfo->layout()); + + if (!address.isNull()) + adapterDialog->macLabel->setText(i18n("MAC Address: <b>%1</b>").arg(address)); + + if (!uuids.isEmpty()) + { + TQString supported; + // DeviceList; + for (TQStringList::iterator it = uuids.begin(); it != uuids.end(); ++it) + { + supported += resolveUUID((*it)) + ", "; + } + adapterDialog->verLabel->setText(i18n("<p>Services:<br/><b>%1</b></p>").arg(supported.left(supported.length() - 2))); + } + +} + +//from adapter + +void AdapterConfig::slotAdapterNameChanged(const TQString &path, const TQString &n) +{ + if (path != adapter->getPath()) + return; + name = n; + disconnect(adapterDialog->adapterName, SIGNAL(textChanged(const TQString &)), + this, TQT_SLOT(slotChangeName(const TQString &))); + + adapterDialog->adapterName->setText(name); + + connect(adapterDialog->adapterName, SIGNAL(textChanged(const TQString &)), + this, TQT_SLOT(slotChangeName(const TQString &))); +} + +void AdapterConfig::slotPowerOnChanged(const TQString &path, bool state) +{ + if (path != adapter->getPath()) + return; + + addAdapterDialogInfo(); + + adapterDialog->setEnabled(state); +} + +void AdapterConfig::slotDiscoverableChanged(const TQString &path, bool changed) +{ + if (path != adapter->getPath()) + return; + + TQT_DBusError dbuserr; + TQ_UINT32 timeout = adapter->getDiscoverableTimeout(dbuserr); + if (dbuserr.isValid()) + tqDebug("Get discoverable timeout for the adapter failed: %s", dbuserr.message().local8Bit().data()); + disconnect(adapterDialog->deviceModes, SIGNAL(activated(int)), + this, TQT_SLOT(slotSetMode(int))); + disconnect(adapterDialog->sliderTimeout, SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotChangeTimeout(int))); + + if (changed) + { + if (timeout > 0) + { + adapterDialog->deviceModes->setCurrentItem(2); + adapterDialog->timeout->setNum(int(timeout) / 60); + adapterDialog->timeout->setText(adapterDialog->timeout->text().append(i18n("min"))); + adapterDialog->sliderTimeout->setValue(timeout); + adapterDialog->sliderTimeout->setEnabled(false); + adapterDialog->timeout->setEnabled(false); + adapterDialog->textLabel9->setEnabled(false); + } + else + { + adapterDialog->deviceModes->setCurrentItem(1); + adapterDialog->timeout->setNum(int(timeout) / 60); + adapterDialog->timeout->setText(adapterDialog->timeout->text().append(i18n("min"))); + adapterDialog->sliderTimeout->setValue(timeout); + adapterDialog->sliderTimeout->setEnabled(true); + adapterDialog->timeout->setEnabled(true); + adapterDialog->textLabel9->setEnabled(true); + } + } + else + { + adapterDialog->deviceModes->setCurrentItem(0); + adapterDialog->sliderTimeout->setValue(0); + adapterDialog->timeout->setText(i18n("none")); + adapterDialog->sliderTimeout->setEnabled(false); + adapterDialog->timeout->setEnabled(false); + adapterDialog->textLabel9->setEnabled(false); + } + connect(adapterDialog->deviceModes, SIGNAL(activated(int)), + this, TQT_SLOT(slotSetMode(int))); + connect(adapterDialog->sliderTimeout, SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotChangeTimeout(int))); +} + +void AdapterConfig::slotDiscoverableTimeoutChanged(const TQString &path, TQ_UINT32 timeout) +{ + if (path != adapter->getPath()) + return; + + disconnect(adapterDialog->sliderTimeout, SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotChangeTimeout(int))); + + if (timeout == 0) + { + adapterDialog->sliderTimeout->setValue(0); + adapterDialog->timeout->setText(i18n("none")); + adapterDialog->sliderTimeout->setEnabled(false); + adapterDialog->timeout->setEnabled(false); + adapterDialog->textLabel9->setEnabled(false); + } + else + { + adapterDialog->timeout->setNum(int(timeout) / 60); + adapterDialog->timeout->setText(adapterDialog->timeout->text().append(i18n("min"))); + adapterDialog->sliderTimeout->setValue(int(timeout)); + adapterDialog->sliderTimeout->setEnabled(true); + adapterDialog->timeout->setEnabled(true); + adapterDialog->textLabel9->setEnabled(true); + } + connect(adapterDialog->sliderTimeout, SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotChangeTimeout(int))); +} + +// from dialog +void AdapterConfig::slotChangeName(const TQString &n) +{ + name = n; + TQT_DBusError dbuserr; + if (adapterDialog->adapterName->text() != name) + { + //otherwise signal textchanged() from the dialog and slot nameChanged + //from the adapter will end in a endless loop. + disconnect(manager, SIGNAL(adapterNameChanged(const TQString&,const TQString&)), + this, TQT_SLOT(slotAdapterNameChanged(const TQString&, const TQString&))); + disconnect(manager, SIGNAL(adapterAliasChanged(const TQString&,const TQString&)), + this, TQT_SLOT(slotAdapterNameChanged(const TQString&, const TQString&))); + +// adapterDialog->adapterName->setText(name); + adapter->setAlias(name, dbuserr); + if (dbuserr.isValid()) + tqDebug("Set alias for the adapter failed: %s", dbuserr.message().local8Bit().data()); + + connect(manager, SIGNAL(adapterNameChanged(const TQString&,const TQString&)), + this, TQT_SLOT(slotAdapterNameChanged(const TQString&, const TQString&))); + connect(manager, SIGNAL(adapterAliasChanged(const TQString&,const TQString&)), + this, TQT_SLOT(slotAdapterNameChanged(const TQString&, const TQString&))); + } +} + +void AdapterConfig::slotChangeTimeout(int timeout) +{ + // Disconnect signal of valueChanged! + // D-Bus signal get emmited immeditaly .. + // and would trigger a endless loop of signals! + TQT_DBusError dbuserr; + disconnect(manager, SIGNAL(adapterDiscoverableChanged(const TQString&, bool)), + this, TQT_SLOT(slotDiscoverableChanged(const TQString&, bool))); + disconnect(manager, SIGNAL(adapterDiscoverableTimeoutChanged(const TQString&, TQ_UINT32)), + this, TQT_SLOT(slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32))); + + adapterDialog->timeout->setNum(int(timeout) / 60); + adapterDialog->sliderTimeout->setValue(int(timeout)); + adapterDialog->timeout->setText(adapterDialog->timeout->text().append(i18n("min"))); + adapter->setDiscoverableTimeout(timeout, dbuserr); + if (dbuserr.isValid()) + tqDebug("Set discoverable timeout for the adapter failed: %s", dbuserr.message().local8Bit().data()); + + connect(manager, SIGNAL(adapterDiscoverableChanged(const TQString&, bool)), + this, TQT_SLOT(slotDiscoverableChanged(const TQString&, bool))); + connect(manager, SIGNAL(adapterDiscoverableTimeoutChanged(const TQString&, TQ_UINT32)), + this, TQT_SLOT(slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32))); +} + +void AdapterConfig::slotSetMode(int modenr) +{ + + TQT_DBusError dbuserr; + int timeout = adapter->getDiscoverableTimeout(dbuserr); + if (dbuserr.isValid()) + tqDebug("Get discoverable timeout for the adapter failed: %s", dbuserr.message().local8Bit().data()); + + // Disconnect signal of valueChanged! + // D-Bus signal get emmited immeditaly .. + // and would trigger a endless loop of signals! + disconnect(adapterDialog->deviceModes, SIGNAL(activated(int)), + this, TQT_SLOT(slotSetMode(int))); + disconnect(adapterDialog->sliderTimeout, SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotChangeTimeout(int))); + disconnect(manager, SIGNAL(adapterDiscoverableChanged(const TQString&, bool)), + this, TQT_SLOT(slotDiscoverableChanged(const TQString&, bool))); + disconnect(manager, SIGNAL(adapterDiscoverableTimeoutChanged(const TQString&, TQ_UINT32)), + this, TQT_SLOT(slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32))); + + switch (modenr) + { + case 0: + case 1: + timeout = 0; + adapterDialog->timeout->setText(i18n("none")); + adapterDialog->sliderTimeout->setValue(timeout); + + adapterDialog->sliderTimeout->setEnabled(false); + adapterDialog->timeout->setEnabled(false); + adapterDialog->textLabel9->setEnabled(false); + break; + case 2: + if (timeout == 0) + timeout = 180; + adapterDialog->timeout->setNum(timeout / 60); + adapterDialog->timeout->setText(adapterDialog->timeout->text().append(i18n("min"))); + adapterDialog->sliderTimeout->setValue(timeout); + + adapterDialog->sliderTimeout->setEnabled(true); + adapterDialog->timeout->setEnabled(true); + adapterDialog->textLabel9->setEnabled(true); + break; + } + adapter->setDiscoverable(((modenr > 0) ? true : false), dbuserr); + adapter->setDiscoverableTimeout(timeout, dbuserr); + if (dbuserr.isValid()) + tqDebug("Get discoverable for the adapter failed: %s", dbuserr.message().local8Bit().data()); + + connect(adapterDialog->deviceModes, SIGNAL(activated(int)), + this, TQT_SLOT(slotSetMode(int))); + connect(adapterDialog->sliderTimeout, SIGNAL(valueChanged(int)), + this, TQT_SLOT(slotChangeTimeout(int))); + + connect(manager, SIGNAL(adapterDiscoverableChanged(const TQString&, bool)), + this, TQT_SLOT(slotDiscoverableChanged(const TQString&, bool))); + connect(manager, SIGNAL(adapterDiscoverableTimeoutChanged(const TQString&, TQ_UINT32)), + this, TQT_SLOT(slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32))); +} + +void AdapterConfig::slotSetClass(const TQString & deviceClass) +{ + if (deviceClass == "bluetooth/computer-device-class") + { + adapterDialog->deviceClass->setCurrentItem(1); + } + else + { + adapterDialog->deviceClass->setCurrentItem(0); + } +} + +#include "adapterconfig.moc" diff --git a/src/tdebluez/adapterconfig.h b/src/tdebluez/adapterconfig.h new file mode 100644 index 0000000..2936580 --- /dev/null +++ b/src/tdebluez/adapterconfig.h @@ -0,0 +1,83 @@ +/* + * + * Adapter config dialog for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef ADAPTERCONFIG_H_ +#define ADAPTERCONFIG_H_ + +#include <tqlabel.h> +#include <tqlineedit.h> +#include <tqtabwidget.h> +#include <tqlayout.h> +#include <tqgroupbox.h> +#include <tqcombobox.h> +#include <tqobject.h> +#include <tqslider.h> + +#include <adapterImpl.h> + +#include "adapterdialog.h" +#include "application.h" + +using namespace TDEBluetooth; + +class AdapterConfig: public TQObject +{ + Q_OBJECT + +public: + AdapterConfig(ObjectManagerImpl *mgr, AdapterImpl *adapter); + ~AdapterConfig(); + + AdapterDialog *dialog() const + { + return adapterDialog; + } + ; + TQString getName() + { + return name; + } + ; + +public slots: + // from adapter + void slotAdapterNameChanged(const TQString&, const TQString&); + void slotPowerOnChanged(const TQString&, bool); + void slotDiscoverableChanged(const TQString&, bool); + void slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32 timeout); + // from dialog + void slotChangeName(const TQString& name); + void slotSetMode(int); + void slotSetClass(const TQString& mime); + void slotChangeTimeout(int timeout); + +private: + AdapterDialog *adapterDialog; + AdapterImpl *adapter; + ObjectManagerImpl *manager; + TQString name; + void addAdapterDialogInfo(); +}; + +#endif // ADAPTERCONFIG_H_ diff --git a/src/tdebluez/adapterconfigdialog.cpp b/src/tdebluez/adapterconfigdialog.cpp new file mode 100644 index 0000000..750a4a3 --- /dev/null +++ b/src/tdebluez/adapterconfigdialog.cpp @@ -0,0 +1,141 @@ +/* + * + * Adapter Manager Gui for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "adapterconfig.h" +#include "adapterconfigdialog.h" + +AdapterConfigDialog::AdapterConfigDialog(TDEBluetoothApp *_app) : + KDialogBase(NULL, "AdapterConfigDialog", true, "Adapter Configuration", (Ok)), app(_app), manager(_app->manager) +{ + nodevice = NULL; + tabWidget = new TQTabWidget(this); + + ObjectManagerImpl::AdapterList list = manager->getAdapters(); + ObjectManagerImpl::AdapterList::iterator it; + for (it = list.begin(); it != list.end(); ++it) + addAdapter((*it)); + + if (list.count() == 0) + { + nodevice = new TQLabel(i18n("No Bluetooth adapter found!"), this); + tabWidget->addTab(nodevice, i18n("no adapter")); + tabWidget->setMinimumSize(250, 300); + } + + tabWidget->show(); + setMainWidget(tabWidget); + setModal(false); + + connect(this, SIGNAL(okClicked()), this, TQT_SLOT(hide())); + connect(manager, SIGNAL(adapterAdded(const TQString&)), TQT_SLOT(addAdapter(const TQString&))); + connect(manager, SIGNAL(adapterRemoved(const TQString&)), TQT_SLOT(removeAdapter(const TQString&))); + connect(tabWidget, SIGNAL(currentChanged(TQWidget *)), this, TQT_SLOT(slotCurrentChanged(TQWidget *))); +} + +AdapterConfigDialog::~AdapterConfigDialog() +{ + close(); + if (nodevice) + delete nodevice; + delete tabWidget; +// tabWidget = 0; +} + +void AdapterConfigDialog::addAdapter(const TQString &path) +{ + AdapterConfig *aconfig = new AdapterConfig(app->manager, app->adapters[path]); + tabWidget->addTab(aconfig->dialog(), aconfig->getName()); + + TQT_DBusError dbuserr; + bool powered = app->adapters[path]->getPowered(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + + aconfig->dialog()->setEnabled(powered); +// +// if (tabWidget->isTabEnabled(aconfig->dialog())) +// { + tabWidget->showPage(aconfig->dialog()); +// } + adapterList.insert(path, aconfig); + + connect(aconfig->dialog()->adapterName, SIGNAL(textChanged(const TQString &)), + this, TQT_SLOT(slotChangeName(const TQString &))); + connect(aconfig->dialog()->adapterName, SIGNAL(textChanged(const TQString &)), + app->adapters[path], TQT_SLOT(slotSetAlias(const TQString &))); + + if (nodevice) + { + tabWidget->removePage(nodevice); + nodevice = 0; + } +} + +void AdapterConfigDialog::removeAdapter(const TQString &path) +{ + AdapterConfig *aconfig = adapterList[path]; + if (!aconfig) + return; + + tabWidget->removePage(aconfig->dialog()); + delete adapterList[path]; + adapterList.remove(path); + + if (adapterList.count() == 0) + { + nodevice = new TQLabel(i18n("No Bluetooth device found!"), tabWidget); + tabWidget->addTab(nodevice, i18n("no device")); + if (tabWidget->isTabEnabled(nodevice)) + { + tabWidget->showPage(nodevice); + } + } +} + +void AdapterConfigDialog::slotChangeName(const TQString &name) +{ + tabWidget->changeTab(tabWidget->currentPage(), name); +} + +void AdapterConfigDialog::slotCurrentChanged(TQWidget *widget) +{ + TQMap<TQString,AdapterConfig *>::iterator it; + for (it = adapterList.begin(); it != adapterList.end(); ++it) + { + if (it.data()->dialog() == widget) + { + TQString path = it.key(); + TQT_DBusError dbuserr; + TQString name = app->adapters[path]->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); +// kdDebug() << "Adapter changed: " << it.data()->dialog()->macLabel->text() << endl; + emit signalAdapterSelected(path,name); + break; + } + } +} + +#include "adapterconfigdialog.moc" diff --git a/src/tdebluez/adapterconfigdialog.h b/src/tdebluez/adapterconfigdialog.h new file mode 100644 index 0000000..7cb0157 --- /dev/null +++ b/src/tdebluez/adapterconfigdialog.h @@ -0,0 +1,70 @@ +/* + * + * Adapter Manager Gui for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef ADAPTERCONFIGDIALOG_H_ +#define ADAPTERCONFIGDIALOG_H_ + +#include <tqmap.h> +#include <kdialogbase.h> + +#include <adapterImpl.h> + +#include "application.h" +#include "adapterconfig.h" + +using namespace TDEBluetooth; + +class AdapterConfigDialog: public KDialogBase +{ + Q_OBJECT + +public: + AdapterConfigDialog(TDEBluetoothApp *app); + ~AdapterConfigDialog(); + +public slots: + void addAdapter(const TQString&); + void removeAdapter(const TQString&); + void slotChangeName(const TQString&); + void slotCurrentChanged(TQWidget *); + +signals: + void signalAdapterSelected(const TQString&, const TQString&); + +private: + TQLabel *nodevice; + + TDEBluetoothApp *app; + ObjectManagerImpl *manager; + TQMap<TQString,AdapterConfig *> adapterList; + + void addAdapterDialog(AdapterImpl *adapter); + void addAdapterDialogInfo(AdapterImpl &adapater, + AdapterDialog *adapterDialog); + + TQTabWidget *tabWidget; +}; + +#endif // ADAPTERCONFIGDIALOG_H_ + diff --git a/src/tdebluez/adapterdialog.ui b/src/tdebluez/adapterdialog.ui new file mode 100644 index 0000000..c4789f7 --- /dev/null +++ b/src/tdebluez/adapterdialog.ui @@ -0,0 +1,346 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>AdapterDialog</class> +<widget class="TQDialog"> + <property name="name"> + <cstring>AdapterDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>404</width> + <height>385</height> + </rect> + </property> + <property name="caption"> + <string>AdapterDialog</string> + </property> + <vbox> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>groupBoxSettings</cstring> + </property> + <property name="geometry"> + <rect> + <x>21</x> + <y>21</y> + <width>360</width> + <height>218</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>360</width> + <height>0</height> + </size> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="title"> + <string>Device Settings</string> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout11</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout13</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layoutName</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>textLabel10</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="text"> + <string>Adapter Name:</string> + </property> + </widget> + <widget class="TQLineEdit"> + <property name="name"> + <cstring>adapterName</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout12</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="text"> + <string>Mode:</string> + </property> + </widget> + <widget class="TQComboBox"> + <property name="name"> + <cstring>deviceModes</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="currentItem"> + <number>0</number> + </property> + </widget> + </hbox> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout10</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>textLabel9</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="text"> + <string>Discoverable Timeout:</string> + </property> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>timeout</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="text"> + <string></string> + </property> + <property name="alignment"> + <set>AlignVCenter|AlignRight</set> + </property> + </widget> + </hbox> + </widget> + <widget class="TQSlider"> + <property name="name"> + <cstring>sliderTimeout</cstring> + </property> + <property name="paletteForegroundColor"> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </property> + <property name="minValue"> + <number>60</number> + </property> + <property name="maxValue"> + <number>900</number> + </property> + <property name="lineStep"> + <number>60</number> + </property> + <property name="pageStep"> + <number>120</number> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="tickmarks"> + <enum>NoMarks</enum> + </property> + <property name="toolTip" stdset="0"> + <string>Timeout after the adapter gets invisible</string> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="text"> + <string>Class of Device:</string> + </property> + </widget> + <widget class="TQComboBox"> + <item> + <property name="text"> + <string>Unspecified</string> + </property> + </item> + <item> + <property name="text"> + <string>Desktop</string> + </property> + </item> + <item> + <property name="text"> + <string>Laptop</string> + </property> + </item> + <property name="name"> + <cstring>deviceClass</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + </widget> + </hbox> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <widget class="TQGroupBox"> + <property name="name"> + <cstring>groupBoxInfo</cstring> + </property> + <property name="geometry"> + <rect> + <x>21</x> + <y>245</y> + <width>360</width> + <height>131</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>3</hsizetype> + <vsizetype>3</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>360</width> + <height>0</height> + </size> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="title"> + <string>Device Information</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout14</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>macLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>5</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="text"> + <string></string> + </property> + <property name="alignment"> + <set>AlignTop</set> + </property> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>verLabel</cstring> + </property> + <property name="font"> + <font> + </font> + </property> + <property name="text"> + <string></string> + </property> + </widget> + </vbox> + </widget> + </vbox> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/tdebluez/application.cpp b/src/tdebluez/application.cpp new file mode 100644 index 0000000..7ad5a27 --- /dev/null +++ b/src/tdebluez/application.cpp @@ -0,0 +1,372 @@ +/* + * + * New Bluetooth App for TDE and bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#include <dcopclient.h> +#include <kuser.h> +#include <tqregexp.h> + +#include <errno.h> + +#include <sys/types.h> +#include <signal.h> + +#include "trayicon.h" +#include "application.h" + +#define WAIT_BEFORE_KILL 5000 // 5sec +#define CONFIGURATION_FILE "tdebluezrc" +#define TDEBLUEZAUTH_EXE "tdebluezauth" +#define OBEX_EXE "/usr/lib/bluetooth/obexd" +#define OBEX_EXE_ALT "/usr/libexec/bluetooth/obexd" +#define BLUEZ_DN "org.bluez" +#define DOWNLOAD_DIRECTORY "Downloads" + +TDEBluetoothApp::TDEBluetoothApp() : + KUniqueApplication() +{ + // set default config file + m_config = new TDEConfig(CONFIGURATION_FILE); + m_config->setGroup("General"); + bool autostart = m_config->readBoolEntry("autoStart", false); + m_waitBeforeKill = m_config->readNumEntry("waitBeforeKill", WAIT_BEFORE_KILL); + TQString authAgentExe = m_config->readEntry("authAgentExe", TDEBLUEZAUTH_EXE); + TQString obexSrvExe = m_config->readEntry("obexSrvExe", OBEX_EXE); + TQString downloadDir = m_config->readPathEntry("downloadDir", ""); + + if (!autostart) + disableSessionManagement(); + + if (m_waitBeforeKill == 0) + { + m_waitBeforeKill = WAIT_BEFORE_KILL; + m_config->writeEntry("waitBeforeKill", m_waitBeforeKill); + } + + if (obexSrvExe.isEmpty()) + { + obexSrvExe=TQString(OBEX_EXE); + } + + if (authAgentExe.isEmpty()) + { + authAgentExe = TDEBLUEZAUTH_EXE; + m_config->writePathEntry("authAgentExe", authAgentExe); + } + + if (downloadDir.isEmpty()) + { + downloadDir = DOWNLOAD_DIRECTORY; + m_config->writePathEntry("downloadDir", downloadDir); + } + + manager = new ObjectManagerImpl(BLUEZ_DN, "/", this, "ObjectManager"); + if (!manager->isConnectedToDBUS()) + { + tqDebug("ObjectManager is not connected to DBus"); + return; + } + + ObjectManagerImpl::AdapterList al = manager->getAdapters(); + ObjectManagerImpl::AdapterList::Iterator ait = al.begin(); + for (ait; ait != al.end(); ++ait) + { + AdapterImpl *a = new AdapterImpl(BLUEZ_DN, (*ait)); + a->setConnection((*(manager->getConnection()))); + adapters.insert((*ait), a); + } + + ObjectManagerImpl::DeviceList dl = manager->getDevices(); + ObjectManagerImpl::DeviceList::Iterator dit = dl.begin(); + for (dit; dit != dl.end(); ++dit) + { + DeviceImpl *d = new DeviceImpl(BLUEZ_DN, (*dit)); + d->setConnection((*(manager->getConnection()))); + devices.insert((*dit), d); + } + + authAgent = new TQProcess(authAgentExe, this); + authAgent->addArgument("--nofork"); + + TQFileInfo obexSrvExeFile( obexSrvExe ); + if (!obexSrvExeFile.exists()) + { + obexSrvExeFile.setFile(OBEX_EXE_ALT); + if (obexSrvExeFile.exists()) + { + m_config->writePathEntry("obexSrvExe", obexSrvExeFile.filePath()); + } + else + { + tqWarning( "obexd executable was not found\nSet path in configuration file \"%s\"\nVariable: obexSrvExe=<path to obexd>", CONFIGURATION_FILE); + m_config->writeEntry("obexSrv", false); + } + } + + obexServer = new TQProcess(obexSrvExeFile.filePath(), this); + obexServer->addArgument("-n"); + obexServer->addArgument("-a"); + obexServer->addArgument("-l"); + obexServer->addArgument("-r"); + obexServer->addArgument(downloadDir); + + //stop tdebluezauth or obexd daemon to regain control + KUser user; + long uid = user.uid(); + + TQDir d("/proc"); + d.setFilter(TQDir::Dirs); + + TQRegExp rx( "^\\d+$" ); + for (int i = 0; i < d.count(); i++) + { + if ( ! rx.exactMatch(d[i]) ) + continue; + + TQFile f("/proc/" + d[i] + "/status"); + if ( ! f.open( IO_ReadOnly ) ) + { + tqDebug( "Failed to open file for reading: %s", f.name().local8Bit().data() ); + continue; + } + + TQTextStream stream( &f ); + TQString pid; + bool tokill = false; + while ( !stream.atEnd() ) { + TQString line = stream.readLine(); // line of text excluding '\n' + if (line.startsWith("Name:") && + ( line.endsWith("tdebluezauth") || line.endsWith("obexd") )) + { + pid = d[i]; + } + if (line.find(TQRegExp(TQString("Uid:\\s+%1").arg(uid))) != -1) + { + tokill = true; + } + } + f.close(); + + if (tokill && ! pid.isEmpty()) + { + if ( kill( (pid_t) pid.toLong(), SIGKILL ) == -1 ) + { + switch ( errno ) + { + case EINVAL: + tqDebug( "4\t%s", pid.local8Bit().data() ); + break; + case ESRCH: + tqDebug( "3\t%s", pid.local8Bit().data() ); + break; + case EPERM: + tqDebug( "2\t%s", pid.local8Bit().data() ); + break; + default: /* unknown error */ + tqDebug( "1\t%s", pid.local8Bit().data() ); + break; + } + } else { + tqWarning( "Cleanup pid\t%s", pid.local8Bit().data() ); + } + } + } + + // connect to manager signals + connect(manager, SIGNAL(adapterAdded(const TQString&)), TQT_SLOT(slotAdapterAdded(const TQString&))); + connect(manager, SIGNAL(adapterRemoved(const TQString&)), TQT_SLOT(slotAdapterRemoved(const TQString&))); + connect(manager, SIGNAL(deviceAdded(const TQString&)), TQT_SLOT(slotDeviceAdded(const TQString&))); + connect(manager, SIGNAL(deviceRemoved(const TQString&)), TQT_SLOT(slotDeviceRemoved(const TQString&))); +// connect(manager, SIGNAL(adapterPowerOnChanged(const TQString&, bool)), SLOT(slotPowerOnChanged(const TQString&, bool))); + + trayIcon = new TrayIcon(this); + setMainWidget(trayIcon); +} + +TDEBluetoothApp::~TDEBluetoothApp() +{ + + if (obexServer) + { + if (obexServer->isRunning()) + obexServer->kill(); + delete obexServer; + } + if (authAgent) + { + if (authAgent->isRunning()) + authAgent->kill(); + delete authAgent; + } + delete trayIcon; + + if (manager->isConnectedToDBUS()) + { + DevicesMap::Iterator dit = devices.begin(); + for (dit; dit != devices.end(); ++dit) + { + DeviceImpl *d = dit.data(); + if (d) + delete d; + } + devices.clear(); + + AdaptersMap::Iterator ait = adapters.begin(); + for (ait; ait != adapters.end(); ++ait) + { + AdapterImpl *a = ait.data(); + if (a) + { + TQT_DBusError error; + if (a->getDiscovering(error)) + a->StopDiscovery(error); + if (error.isValid()) + tqDebug("Stop discoverable for the adapter failed: %s", error.message().local8Bit().data()); + delete a; + } + } + adapters.clear(); + } + delete manager; + + if (m_config->isDirty()) + m_config->sync(); + + delete m_config; +} + +bool TDEBluetoothApp::startAuthAgent() +{ + if (!authAgent->isRunning()) + { + if (!authAgent->start()) + return false; + } + return true; +} + +bool TDEBluetoothApp::stopAuthAgent() +{ + if (authAgent->isRunning()) + { + authAgent->tryTerminate(); + TQTimer::singleShot(m_waitBeforeKill, authAgent, SLOT(kill())); + } + return true; +} + +bool TDEBluetoothApp::startObexSrv() +{ + if (!obexServer->isRunning()) + { + if (!obexServer->start()) + return false; + } + return true; +} + +bool TDEBluetoothApp::stopObexSrv() +{ + if (obexServer->isRunning()) + { + obexServer->tryTerminate(); + TQTimer::singleShot(m_waitBeforeKill, obexServer, SLOT(kill())); + } + return true; +} + +bool TDEBluetoothApp::isConnected() +{ + return manager->isConnectedToDBUS(); +} + +void TDEBluetoothApp::setAutoStart(bool val) +{ + if (val) + enableSessionManagement(); + else + disableSessionManagement(); + + m_config->setGroup("General"); + m_config->writeEntry("autoStart", val); +} + +void TDEBluetoothApp::setStartObex(bool val) +{ + m_config->setGroup("General"); + m_config->writeEntry("obexSrv", val); +} + +void TDEBluetoothApp::setStartAuthAgent(bool val) +{ + m_config->setGroup("General"); + m_config->writeEntry("authAgent", val); +} + +bool TDEBluetoothApp::getAutoStart() +{ + m_config->setGroup("General"); + return m_config->readBoolEntry("autoStart"); +} + +bool TDEBluetoothApp::getStartObex() +{ + m_config->setGroup("General"); + return m_config->readBoolEntry("obexSrv"); +} + +bool TDEBluetoothApp::getStartAuthAgent() +{ + m_config->setGroup("General"); + return m_config->readBoolEntry("authAgent"); +} + +void TDEBluetoothApp::slotAdapterAdded(const TQString &adapter) +{ + AdapterImpl *a = new AdapterImpl(BLUEZ_DN, adapter); + a->setConnection((*(manager->getConnection()))); + adapters.insert(adapter, a); + emit signalAdapterAdded(adapter); +} + +void TDEBluetoothApp::slotAdapterRemoved(const TQString &adapter) +{ + delete adapters[adapter]; + adapters.remove(adapter); + emit signalAdapterRemoved(adapter); +} + +void TDEBluetoothApp::slotDeviceAdded(const TQString &device) +{ + DeviceImpl *d = new DeviceImpl(BLUEZ_DN, device); + d->setConnection((*(manager->getConnection()))); + devices.insert(device, d); +} + +void TDEBluetoothApp::slotDeviceRemoved(const TQString &device) +{ + delete devices[device]; + devices.remove(device); +} + +#include "application.moc" diff --git a/src/tdebluez/application.h b/src/tdebluez/application.h new file mode 100644 index 0000000..84411ad --- /dev/null +++ b/src/tdebluez/application.h @@ -0,0 +1,97 @@ +/* + * + * New Bluetooth App for TDE and bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef APPLICATION_H_ +#define APPLICATION_H_ + +#include <kuniqueapplication.h> +#include <tdemessagebox.h> +#include <tqprocess.h> + +#include <objectmanagerImpl.h> + +class TDEConfig; +class TrayIcon; +class AdapterConfig; +class AdapterConfigDialog; +class DeviceWizard; + +using namespace TDEBluetooth; + +class TDEBluetoothApp: public KUniqueApplication +{ + Q_OBJECT + +public: + TDEBluetoothApp(); + ~TDEBluetoothApp(); + + typedef TQMap<TQString,AdapterImpl*> AdaptersMap; + typedef TQMap<TQString,DeviceImpl*> DevicesMap; + + bool startAuthAgent(); + bool stopAuthAgent(); + + bool startObexSrv(); + bool stopObexSrv(); + + bool isConnected(); + +protected: + ObjectManagerImpl *manager; + AdaptersMap adapters; + DevicesMap devices; + void setAutoStart(bool val); + void setStartObex(bool val); + void setStartAuthAgent(bool val); + bool getAutoStart(); + bool getStartObex(); + bool getStartAuthAgent(); + +private: + TQProcess *obexServer; + TQProcess *authAgent; + TrayIcon *trayIcon; + TDEConfig *m_config; + int m_waitBeforeKill; + + friend class TrayIcon; + friend class AdapterConfig; + friend class AdapterConfigDialog; + friend class DeviceWizard; + +public slots: + void slotAdapterAdded(const TQString& adapter); + void slotAdapterRemoved(const TQString& adapter); + // void slotPowerOnChanged(const TQString&, bool); + void slotDeviceAdded(const TQString& device); + void slotDeviceRemoved(const TQString& device); + +signals: + void signalAdapterAdded(const TQString &adapter); + void signalAdapterRemoved(const TQString &adapter); +}; + +#endif // APPLICATION_H_ diff --git a/src/tdebluez/devicedialog.ui b/src/tdebluez/devicedialog.ui new file mode 100644 index 0000000..cd640ef --- /dev/null +++ b/src/tdebluez/devicedialog.ui @@ -0,0 +1,335 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>DeviceDialog</class> +<include location="global">kseparator.h</include> +<widget class="TQDialog"> + <property name="name"> + <cstring>DeviceDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>550</width> + <height>190</height> + </rect> + </property> + <property name="caption"> + <string>Devices</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>textLabel1_2</cstring> + </property> + <property name="paletteForegroundColor"> + <color> + <red>0</red> + <green>0</green> + <blue>0</blue> + </color> + </property> + <property name="text"> + <string><font size="+1">Configured Devices:</font></string> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout6</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQListView"> + <column> + <property name="text"> + <string>1</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>2</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>3</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>4</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>deviceBox</cstring> + </property> + <property name="frameShape"> + <enum>GroupBoxPanel</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="lineWidth"> + <number>2</number> + </property> + <property name="selectionMode"> + <enum>Single</enum> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + <property name="showSortIndicator"> + <bool>false</bool> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout9</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout8</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <spacer> + <property name="name"> + <cstring>spacer5</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>pixmapLabel</cstring> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>0</hsizetype> + <vsizetype>0</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>48</width> + <height>50</height> + </size> + </property> + <property name="text"> + <string></string> + </property> + <property name="alignment"> + <set>AlignCenter</set> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </vbox> + </widget> + <spacer> + <property name="name"> + <cstring>spacer6</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Fixed</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="TQToolButton"> + <property name="name"> + <cstring>configureButton</cstring> + </property> + <property name="minimumSize"> + <size> + <width>130</width> + <height>28</height> + </size> + </property> + <property name="text"> + <string>Co&nfigure</string> + </property> + <property name="accel"> + <string>Alt+N</string> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>connectButton</cstring> + </property> + <property name="minimumSize"> + <size> + <width>130</width> + <height>28</height> + </size> + </property> + <property name="text"> + <string>C&onnect</string> + </property> + <property name="accel"> + <string>Alt+O</string> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>deleteButton</cstring> + </property> + <property name="minimumSize"> + <size> + <width>130</width> + <height>28</height> + </size> + </property> + <property name="text"> + <string>&Delete</string> + </property> + <property name="accel"> + <string>Alt+D</string> + </property> + </widget> + </vbox> + </widget> + </hbox> + </widget> + <widget class="KSeparator"> + <property name="name"> + <cstring>kSeparator1</cstring> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>lastLayout</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQPushButton"> + <property name="name"> + <cstring>addButton</cstring> + </property> + <property name="text"> + <string>&Start Discovery <<</string> + </property> + <property name="accel"> + <string>Alt+S</string> + </property> + <property name="toggleButton"> + <bool>true</bool> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>okButton</cstring> + </property> + <property name="text"> + <string>&Close</string> + </property> + <property name="accel"> + <string>Alt+C</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer1</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>410</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +<includehints> + +</includehints> +</UI> diff --git a/src/tdebluez/devicedialog_ext.ui b/src/tdebluez/devicedialog_ext.ui new file mode 100644 index 0000000..e251d09 --- /dev/null +++ b/src/tdebluez/devicedialog_ext.ui @@ -0,0 +1,155 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>DeviceDialog_Ext</class> +<widget class="TQDialog"> + <property name="name"> + <cstring>DeviceDialog_Ext</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>550</width> + <height>190</height> + </rect> + </property> + <property name="caption"> + <string>New Device</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQFrame"> + <property name="name"> + <cstring>newDevFrame</cstring> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Plain</enum> + </property> + <property name="lineWidth"> + <number>0</number> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout7</cstring> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>textLabel1</cstring> + </property> + <property name="text"> + <string><b>New Device:</b></string> + </property> + </widget> + <widget class="TQListView"> + <column> + <property name="text"> + <string>Name</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>Address</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <column> + <property name="text"> + <string>3</string> + </property> + <property name="clickable"> + <bool>false</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <property name="name"> + <cstring>newdevList</cstring> + </property> + <property name="allColumnsShowFocus"> + <bool>true</bool> + </property> + </widget> + </vbox> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout4</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQPushButton"> + <property name="name"> + <cstring>setupButton</cstring> + </property> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="text"> + <string>&Setup</string> + </property> + <property name="accel"> + <string>Alt+S</string> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>statusbar</cstring> + </property> + <property name="text"> + <string></string> + </property> + </widget> + </vbox> + </widget> + </vbox> +</widget> +<includes> + <include location="local" impldecl="in implementation">devicedialog_ext.ui.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/tdebluez/devicesetupwizard.cpp b/src/tdebluez/devicesetupwizard.cpp new file mode 100644 index 0000000..77f88cf --- /dev/null +++ b/src/tdebluez/devicesetupwizard.cpp @@ -0,0 +1,662 @@ +/* + * + * Dialogs for tdebluez device configuration + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <tqradiobutton.h> +#include <tqpushbutton.h> +#include <tqprogressbar.h> +#include <tqcheckbox.h> +#include <tdeconfig.h> +#include <knotifydialog.h> +#include <knotifyclient.h> + +#include <interfaces/device1Proxy.h> +#include <btuuids.h> +#include <devicemimeconverter.h> + +#include "application.h" +#include "devicesetupwizard.h" + +#define LOGOTIMEOUT 100 //100 msec +#define ASYNC_TIMEOUT 15000 //15 sec +#define CONNECT_TIMEOUT 5000 // 5 sec +#define PROGRESS_TIMEOUT 50 // 50 msec + +DeviceSetupWizard::DeviceSetupWizard(ObjectManagerImpl* _manager) : + DeviceSetupWizardDialog(), manager(_manager) +{ + device = 0; + address = TQString(); + + pairpage = page(0); + setHelpEnabled(pairpage, false); + + pairingpage = page(1); + setHelpEnabled(pairingpage, false); + + connectpage = page(2); + setHelpEnabled(connectpage, false); + + connectingpage = page(3); + setHelpEnabled(connectingpage, false); + + donepage = page(4); + setHelpEnabled(donepage, false); + setFinishEnabled(donepage, true); + cancelButton()->setText(i18n("S&kip Wizard")); + + setModal(true); + + m_config = TDEGlobal::config(); + + // create the first ListView + tQListViewSrc->setRootIsDecorated(TRUE); + tQListViewSrc->setSelectionMode(TQListView::Multi); + tQListViewSrc->clear(); + + // create the second ListView + tQListViewDst->setRootIsDecorated(TRUE); + tQListViewDst->setSelectionMode(TQListView::Multi); + tQListViewDst->clear(); + + // progress bars + pairingProgressBar->setProgress(0,ASYNC_TIMEOUT); + pairingProgressBar->setPercentageVisible(false); + connectingProgressBar->setProgress(0,ASYNC_TIMEOUT); + connectingProgressBar->setPercentageVisible(false); + + pairingTimer = new TQTimer(this); + connectTimer = new TQTimer(this); + connect(pairingTimer, SIGNAL(timeout()), this, TQT_SLOT(slotAdvancePairingProgressBar())); + connect(connectTimer, SIGNAL(timeout()), this, TQT_SLOT(slotAdvanceConnectProgressBar())); + + connect(manager, SIGNAL(deviceServicesResolvedChanged(const TQString&, bool)), + this, TQT_SLOT(slotDeviceServicesResolvedChanged(const TQString&, bool))); + + connect(buttonSrc2Dst, SIGNAL(clicked()), this, SLOT(slotCopySrc2Dst())); + connect(buttonDst2Src, SIGNAL(clicked()), this, SLOT(slotCopyDst2Src())); + connect(cancelPairingButton, SIGNAL(clicked()), this, SLOT(slotCancelPairing())); + connect(cancelConnectButton, SIGNAL(clicked()), this, SLOT(slotCancelConnecting())); +} + +DeviceSetupWizard::~DeviceSetupWizard() +{ +} + +void DeviceSetupWizard::next() +{ + if (pairingTimer->isActive()) + { + pairingTimer->stop(); + } + if (connectTimer->isActive()) + { + connectTimer->stop(); + } + + if (currentPage() == pairpage) + { + if (pairingRadioButton1->isChecked()) + { + pairingProgressBar->setProgress(0,ASYNC_TIMEOUT); + pairingTimer->start(PROGRESS_TIMEOUT); + setNextEnabled(pairpage, false); + setNextEnabled(pairingpage, false); + TQWizard::showPage(pairingpage); + startPairing(); + } + else + TQWizard::showPage(donepage); + } + else if (currentPage() == connectpage) + { + preferredProfiles.clear(); + TQListViewItemIterator it2(tQListViewDst); + while (it2.current()) + { + TQString selText = it2.current()->text(0); + for (TQStringList::iterator it3 = uuids.begin(); it3 != uuids.end(); + ++it3) + { + TQString u = (*it3); + if (selText == resolveUUID(u)) + { + kdDebug() << "REQUESTED UUID: " << u << endl; + preferredProfiles.append(u); + } + } + ++it2; + } + + m_config->setGroup(address); + m_config->writeEntry("profile", preferredProfiles); + m_config->sync(); + + // set the progress bar depending on the number of profiles to be connected + // and CONNECT_TIMEOUT value +// connectingProgressBar->setProgress(0, (ASYNC_TIMEOUT + CONNECT_TIMEOUT) * preferredProfiles.count()); + connectingProgressBar->setProgress(0,ASYNC_TIMEOUT); + + connectTimer->start(PROGRESS_TIMEOUT); + TQWizard::showPage(connectingpage); + + slotConnectNextProfile(); + } +// else if (currentPage() == connectingpage) +// { +// TQT_DBusError error; +// if (!device->getConnected(error)) +// { +// int asyncCallId=0; +// device->ConnectAsync(asyncCallId, error); +// manager->getConnection()->scheduleDispatch(); +// } +// else +// { +// TQWizard::next(); +// } +// if (error.isValid()) +// tqDebug("Failed in connecting device: %s", error.message().local8Bit().data()); +// } + else if (currentPage() == donepage) + { + if (trustedCheckBox->isChecked()) + { + finishButton()->setFocus(); + } + else + { + trustedCheckBox->setFocus(); + } + } +} + +void DeviceSetupWizard::back() +{ + TQWizard::back(); +} + +void DeviceSetupWizard::setDevice(DeviceImpl *_device) +{ + kdDebug() << "New device: " << _device << endl; + + if (device == _device) + return; + + if (device) + closeDevice(); + + device = _device; + + TQWizard::showPage(pairpage); + setNextEnabled(pairpage, true); + + TQT_DBusError error; + address = device->getAddress(error); + if (error.isValid()) + tqDebug("Failed to get address for the new device: %s", error.message().local8Bit().data()); + + if (device->getPaired(error)) + { + updateServiceList(); + preferredProfiles.clear(); + tQListViewDst->clear(); + m_config->setGroup(address); + preferredProfiles = m_config->readListEntry("profile"); + TQStringList::iterator it = preferredProfiles.begin(); + for (it; it != preferredProfiles.end(); ++it) + { + (void) new TQListViewItem(tQListViewDst, resolveUUID(*it)); + } + setAppropriate(pairpage, false); + if (tQListViewDst->childCount() > 0) + setNextEnabled(connectpage, true); + TQWizard::showPage(connectpage); + } else { + tQListViewDst->clear(); + } + if (error.isValid()) + tqDebug("Failed to get paired status for the new device: %s", error.message().local8Bit().data()); + + if (device->getConnected(error)) + { + setAppropriate(pairpage, false); + setAppropriate(pairingpage, false); + setAppropriate(connectpage, false); + setAppropriate(connectingpage, false); + TQWizard::showPage(donepage); + } + if (error.isValid()) + tqDebug("Failed to get connecting status of the new device: %s", error.message().local8Bit().data()); + + if (device->getTrusted(error)) + trustedCheckBox->setChecked(true); + if (error.isValid()) + tqDebug("Failed to get trusted status of the new device: %s", error.message().local8Bit().data()); + + connect(device, SIGNAL(PairAsyncReply(int /*asyncCallId*/)), + this, TQT_SLOT(slotPairAsyncReply(int /*asyncCallId*/))); + connect(device, SIGNAL(CancelPairingAsyncReply(int /*asyncCallId*/)), + this, TQT_SLOT(slotCancelPairingAsyncReply(int /*asyncCallId*/))); + connect(device, SIGNAL(AsyncErrorResponseDetected(int /*asyncCallId*/, const TQT_DBusError)), + this, TQT_SLOT(slotAsyncErrorResponseDetected(int /*asyncCallId*/, const TQT_DBusError))); + connect(device, SIGNAL(ConnectAsyncReply(int /*asyncCallId*/)), + this, TQT_SLOT(slotConnectAsyncReply(int /*asyncCallId*/))); +// connect(device, SIGNAL(DisonnectAsyncReply(int /*asyncCallId*/)), +// this, TQT_SLOT(slotDisconnectAsyncReply(int /*asyncCallId*/))); + connect(device, SIGNAL(ConnectProfileAsyncReply(int /*asyncCallId*/)), + this, TQT_SLOT(slotConnectProfileAsyncReply(int /*asyncCallId*/))); +// connect(device, SIGNAL(DisconnectProfileAsyncReply(int /*asyncCallId*/)), +// this, TQT_SLOT(slotDisconnectProfileAsyncReply(int /*asyncCallId*/))); +} + +void DeviceSetupWizard::updateServiceList() +{ + TQT_DBusError error; + uuids.clear(); + uuids = device->getUUIDs(error); + if (error.isValid()) + tqDebug("Failed to get uuids: %s", error.message().local8Bit().data()); + + tQListViewSrc->clear(); + for (TQStringList::iterator it = uuids.begin(); it != uuids.end(); ++it) + { + if ( + ((*it) == "00001203-0000-1000-8000-00805f9b34fb") || //Generic Audio + ((*it) == "00001108-0000-1000-8000-00805f9b34fb") || //Headset + ((*it) == "0000111e-0000-1000-8000-00805f9b34fb") || //Handsfree + ((*it) == "0000111f-0000-1000-8000-00805f9b34fb") || //Handsfree AG + ((*it) == "0000110a-0000-1000-8000-00805f9b34fb") || //A2DP Source + ((*it) == "0000110b-0000-1000-8000-00805f9b34fb") || //A2DP Sink + ((*it) == "00001103-0000-1000-8000-00805f9b34fb") || //DUN Gateway + ((*it) == "00001800-0000-1000-8000-00805f9b34fb") //GAP + ) + { + (void) new TQListViewItem(tQListViewSrc, resolveUUID((*it))); + } + } +} + +void DeviceSetupWizard::startPairing() +{ + TQT_DBusError error; + int asyncCallId = 0; + if (!device->PairAsync(asyncCallId, error)) + { + if (error.isValid()) + tqDebug("Failed to get paired status for the new device: %s", error.message().local8Bit().data()); + } + manager->getConnection()->scheduleDispatch(); +} + +void DeviceSetupWizard::slotPairingTimeOut() +{ + if(pairingTimer->isActive()) + pairingTimer->stop(); + + if (!device) + return; + + TQT_DBusError error; + if (!device->getPaired(error)) + { + if (!error.isValid()) + { + TQWizard::showPage(pairpage); + setNextEnabled(pairpage, true); + } + else + tqDebug("Failed pairing the new device: %s", error.message().local8Bit().data()); + } + else + { + if (tQListViewDst->childCount() > 0) + setNextEnabled(connectpage, true); + TQWizard::showPage(connectpage); + } +} + +void DeviceSetupWizard::slotConnectTimeOut() +{ + if(connectTimer->isActive()) + connectTimer->stop(); + + if (!device) + return; + + TQT_DBusError error; + if (!device->getConnected(error)) + { + if (!error.isValid()) + { + TQWizard::showPage(connectpage); + if (tQListViewDst->childCount() > 0) + setNextEnabled(connectpage, true); + setNextEnabled(connectpage, true); + } + else + tqDebug("Failed connecting the new device: %s", error.message().local8Bit().data()); + } + else + { + setNextEnabled(connectingpage, false); + setBackEnabled(donepage, false); + TQWizard::showPage(donepage); + } +} + +/** the cancel button is connected to the reject() slot of TQDialog, + * so we have to reimplement this here to add a dialogbox to ask if we + * really want to quit the wizard. + */ +void DeviceSetupWizard::reject() +{ + close(); // this will trigger the close event caught below +} + +void DeviceSetupWizard::closeEvent(TQCloseEvent* e) +{ + if (askClose()) + { + hide(); + closeDevice(); + } + else + { + e->ignore(); + } +} + +/** maybe call a dialog that the wizard has finished. */ +void DeviceSetupWizard::accept() +{ + TQT_DBusError error; + if (trustedCheckBox->isChecked()) + { + if (!device->getTrusted(error)) + { + device->setTrusted(true, error); + } + if (error.isValid()) + tqDebug("Could not set trusted for %s\nError: %s", + address.latin1(), error.message().local8Bit().data()); + } + + hide(); + closeDevice(); +} + +void DeviceSetupWizard::closeDevice() +{ +// make sure timers go down + if (pairingTimer->isActive()) + { + pairingTimer->stop(); + } + if (connectTimer->isActive()) + { + connectTimer->stop(); + } + + if (!device) + return; + + disconnect(device, SIGNAL(PairAsyncReply(int /*asyncCallId*/)), + this, TQT_SLOT(slotPairAsyncReply(int /*asyncCallId*/))); + disconnect(device, SIGNAL(CancelPairingAsyncReply(int /*asyncCallId*/)), + this, TQT_SLOT(slotCancelPairingAsyncReply(int /*asyncCallId*/))); + disconnect(device, SIGNAL(AsyncErrorResponseDetected(int /*asyncCallId*/, const TQT_DBusError)), + this, TQT_SLOT(slotAsyncErrorResponseDetected(int /*asyncCallId*/, const TQT_DBusError))); + disconnect(device, SIGNAL(ConnectAsyncReply(int /*asyncCallId*/)), + this, TQT_SLOT(slotConnectAsyncReply(int /*asyncCallId*/))); +// disconnect(device, SIGNAL(DisonnectAsyncReply(int /*asyncCallId*/)), +// this, TQT_SLOT(slotDisconnectAsyncReply(int /*asyncCallId*/))); + disconnect(device, SIGNAL(ConnectProfileAsyncReply(int /*asyncCallId*/)), + this, TQT_SLOT(slotConnectProfileAsyncReply(int /*asyncCallId*/))); +// connect(device, SIGNAL(DisconnectProfileAsyncReply(int /*asyncCallId*/)), +// this, TQT_SLOT(slotDisconnectProfileAsyncReply(int /*asyncCallId*/))); + + preferredProfiles.clear(); + address = TQString(); + device = 0; +} + +void DeviceSetupWizard::slotDeviceServicesResolvedChanged(const TQString &path, bool resolved) +{ + if (!device) + return; + + if (path != device->getPath()) + return; + + updateServiceList(); +} + +void DeviceSetupWizard::slotConnectNextProfile() +{ + if (preferredProfiles.isEmpty()) + { + slotConnectTimeOut(); + } + else + { + TQString connect = preferredProfiles.first(); + //disable next button while profiles are being handled + setBackEnabled(connectpage, false); + setNextEnabled(connectpage, false); + setBackEnabled(connectingpage, false); + setNextEnabled(connectingpage, false); + int asyncCallId = 0; + TQT_DBusError error; + if (!device->ConnectProfileAsync(asyncCallId, connect, error)) + { + if (error.isValid()) + tqDebug("Failed to call DBus ConnectProfileAsync: %s", error.message().local8Bit().data()); + } + manager->getConnection()->scheduleDispatch(); + } +} + +void DeviceSetupWizard::slotAsyncErrorResponseDetected(int asyncCallId, const TQT_DBusError error) +{ + tqDebug("AsyncErrorResponseDetected: %i %s %s", error.type(), error.name().local8Bit().data(), error.message().local8Bit().data()); + + if(pairingTimer->isActive()) + pairingTimer->stop(); + + if(connectTimer->isActive()) + connectTimer->stop(); + + switch (error.type()) + { + case 5: //org.freedesktop.DBus.Error.NoReply + case 22: // org.bluez.Error.InProgress, org.bluez.Error.Failed Host is down + default: + if (currentPage() == pairingpage) + { + slotPairingTimeOut(); + } + if (currentPage() == connectingpage) + { + slotConnectTimeOut(); + } + } +// TQMessageBox::critical( 0, "Device Setup Wizard", +// TQString("AsyncErrorResponseDetected: %1\n%2\n%3") +// .arg(error.type()) +// .arg(error.name().local8Bit().data()) +// .arg(error.message().local8Bit().data()), +// TQMessageBox::Ok, TQMessageBox::NoButton, TQMessageBox::NoButton); + + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "ConnectionError", tr("AsyncErrorResponseDetected: %1\n%2\n%3") + .arg(error.type()) + .arg(error.name().local8Bit().data()) + .arg(error.message().local8Bit().data())); +} + +void DeviceSetupWizard::slotConnectAsyncReply(int asyncCallId) +{ + slotConnectTimeOut(); +} + +//void DeviceSetupWizard::slotDisconnectAsyncReply(int asyncCallId) +//{ +// slotConnectNextProfile(); +//} + +void DeviceSetupWizard::slotConnectProfileAsyncReply(int asyncCallId) +{ + kdDebug() << __func__ << endl; + if (!preferredProfiles.isEmpty()) + preferredProfiles.pop_front(); + + if (!preferredProfiles.isEmpty() && connectTimer->isActive()) + // delay connecting next profile to prevent error InProgress + TQTimer::singleShot(CONNECT_TIMEOUT, this, TQT_SLOT(slotConnectNextProfile())); + else + slotConnectTimeOut(); +} + +//void DeviceSetupWizard::slotDisconnectProfileAsyncReply(int asyncCallId) +//{ +// slotConnectTimeOut(); +//} + +void DeviceSetupWizard::slotPairAsyncReply(int asyncCallId) +{ + slotPairingTimeOut(); +} + +void DeviceSetupWizard::slotCancelPairingAsyncReply(int asyncCallId) +{ + slotPairingTimeOut(); +} + +void DeviceSetupWizard::slotCancelPairing() +{ + int asyncCallId = 0; + TQT_DBusError error; + if (!device->CancelPairingAsync(asyncCallId, error)) + { + if (error.isValid()) + tqDebug("Failed to call DBus CancelPairingAsync: %s", error.message().local8Bit().data()); + } + + if(pairingTimer->isActive()) + pairingTimer->stop(); +} + +void DeviceSetupWizard::slotCancelConnecting() +{ + int asyncCallId = 0; + TQT_DBusError error; + if (device->getConnected(error)) + { + if (!device->DisconnectAsync(asyncCallId, error)) + tqDebug("Failed to call DisconnectAsync: %s", error.message().local8Bit().data()); + } + if (error.isValid()) + tqDebug("Failed in slotCancelConnecting: %s", error.message().local8Bit().data()); + + if(connectTimer->isActive()) + connectTimer->stop(); +} + +void DeviceSetupWizard::slotAdvancePairingProgressBar() +{ + if (pairingProgressBar->progress() < pairingProgressBar->totalSteps()) + { + pairingProgressBar->setProgress(pairingProgressBar->progress() + ASYNC_TIMEOUT/PROGRESS_TIMEOUT); + } + else + pairingProgressBar->setProgress(0,ASYNC_TIMEOUT); +} + +void DeviceSetupWizard::slotAdvanceConnectProgressBar() +{ + if (connectingProgressBar->progress() < connectingProgressBar->totalSteps()) + { + connectingProgressBar->setProgress(connectingProgressBar->progress() + ASYNC_TIMEOUT/PROGRESS_TIMEOUT); + } + else + connectingProgressBar->setProgress(0,ASYNC_TIMEOUT); +} + +void DeviceSetupWizard::slotNext() +{ + TQWizard::next(); +} + +bool DeviceSetupWizard::askClose() +{ + TQString text; + if (currentPage() == page(0)) + { + text = i18n("<p>Are you sure you want to quit the Device Settings Wizard?</p>" + "<p>The Device Settings Wizard helps you to configure the BT device and use it later.</p>" + "<p>Click <b>Cancel</b> to return and finish your setup.</p>"); + } + else + { + text = i18n("<p>Are you sure you want to quit the Device Settings Wizard?</p>" + "<p>If yes, click <b>Quit</b> and all changes will be lost." + "<br>If not, click <b>Cancel</b> to return and finish your setup.</p>"); + } + int status = KMessageBox::warningContinueCancel(this, text, i18n("All Changes Will Be Lost"), KStdGuiItem::quit()); + if (status == KMessageBox::Continue) + return true; + else + return false; +} + +void DeviceSetupWizard::slotCopySrc2Dst() +{ + tQListViewDst->clear(); + // iterate through the first ListView... + TQListViewItemIterator it(tQListViewSrc, TQListViewItemIterator::Selected); + while (it.current()) + { + (void) new TQListViewItem(tQListViewDst, it.current()->text(0)); + ++it; + } + if (tQListViewDst->childCount() > 0) + setNextEnabled(connectpage, true); +} + +void DeviceSetupWizard::slotCopyDst2Src() +{ + // iterate through the first ListView... + TQListViewItemIterator it(tQListViewDst, TQListViewItemIterator::Selected); + while (it.current()) + { + TQListViewItem *item = it.current(); + ++it; + delete item; + } + if (tQListViewDst->childCount() == 0) + setNextEnabled(connectpage, false); +} + +#include "devicesetupwizard.moc" diff --git a/src/tdebluez/devicesetupwizard.h b/src/tdebluez/devicesetupwizard.h new file mode 100644 index 0000000..c75e839 --- /dev/null +++ b/src/tdebluez/devicesetupwizard.h @@ -0,0 +1,119 @@ +/* + * + * Dialogs for tdebluez devices + * + * Copyright (C) 2007 Tom Patzig <[email protected]> + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * kbluetooth 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 2 of the License, or + * (at your option) any later version. + * + * kbluetooth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef DEVICESETUPWIZARD_H +#define DEVICESETUPWIZARD_H + +#include <tqtimer.h> + +#include "devicesetupwizarddialog.h" + +using namespace TDEBluetooth; + +class DeviceSetupWizard: public DeviceSetupWizardDialog +{ + Q_OBJECT + +public: + DeviceSetupWizard(ObjectManagerImpl *manager); + ~DeviceSetupWizard(); + + virtual void next(); + virtual void back(); + void setDevice(DeviceImpl *device); + +private: + void updateServiceList(); + void startPairing(); + +public slots: // Public slots + /** the cancel button is connected to the reject() slot of TQDialog, + * so we have to reimplement this here to add a dialogbox to + * ask if we really want to quit the wizard. + */ + void reject(); + /** maybe call a dialog that the wizard has finished. + * Calls applySettings() to save the current selection. + */ + void accept(); + void closeDevice(); + + /** We need this to use it in a TQTimer */ + void slotNext(); + +private slots: + // from object manager + void slotDeviceServicesResolvedChanged(const TQString &path, bool resolved); + + // local + void slotPairingTimeOut(); + void slotConnectTimeOut(); + void slotConnectNextProfile(); + + // from device1Proxy + void slotAsyncErrorResponseDetected(int asyncCallId, const TQT_DBusError error); + void slotConnectAsyncReply(int asyncCallId); +// void slotDisconnectAsyncReply(int asyncCallId); + void slotConnectProfileAsyncReply(int asyncCallId); +// void slotDisconnectProfileAsyncReply(int asyncCallId); + void slotPairAsyncReply(int asyncCallId); + void slotCancelPairingAsyncReply(int asyncCallId); + void slotCancelPairing(); + void slotCancelConnecting(); + void slotAdvancePairingProgressBar(); + void slotAdvanceConnectProgressBar(); + +protected slots: + void slotCopySrc2Dst(); + void slotCopyDst2Src(); + +protected: + // Protected methods + // the close button on the titlebar sets e->accept() which we don't want. + virtual void closeEvent(TQCloseEvent*); + bool askClose(); + +private: + ObjectManagerImpl *manager; +// AdapterImpl *adapter; + DeviceImpl *device; + TQString address; + TQStringList uuids; + + TQWidget* pairpage; + TQWidget* pairingpage; + TQWidget* connectpage; + TQWidget* connectingpage; + TQWidget* donepage; + TQTimer* pairingTimer; + TQTimer* connectTimer; + +// TQMap<int, TQString> asyncCalls; + + TQStringList preferredProfiles; + TDEConfig* m_config; +}; + +#endif diff --git a/src/tdebluez/devicesetupwizarddialog.ui b/src/tdebluez/devicesetupwizarddialog.ui new file mode 100644 index 0000000..dfaa00b --- /dev/null +++ b/src/tdebluez/devicesetupwizarddialog.ui @@ -0,0 +1,403 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>DeviceSetupWizardDialog</class> +<widget class="TQWizard"> + <property name="name"> + <cstring>DeviceSetupWizardDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>515</width> + <height>368</height> + </rect> + </property> + <property name="caption"> + <string>Device Setup Wizard</string> + </property> + <widget class="TQWidget"> + <property name="name"> + <cstring>WizardPage</cstring> + </property> + <attribute name="title"> + <string>Pair</string> + </attribute> + <widget class="TQButtonGroup"> + <property name="name"> + <cstring>pairingButtonGroup</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + <property name="geometry"> + <rect> + <x>30</x> + <y>60</y> + <width>350</width> + <height>110</height> + </rect> + </property> + <property name="title"> + <string>Device pairing</string> + </property> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>pairingRadioButton2</cstring> + </property> + <property name="geometry"> + <rect> + <x>10</x> + <y>70</y> + <width>220</width> + <height>31</height> + </rect> + </property> + <property name="text"> + <string>Pair &device later</string> + </property> + <property name="accel"> + <string>Alt+D</string> + </property> + </widget> + <widget class="TQRadioButton"> + <property name="name"> + <cstring>pairingRadioButton1</cstring> + </property> + <property name="geometry"> + <rect> + <x>10</x> + <y>30</y> + <width>210</width> + <height>30</height> + </rect> + </property> + <property name="text"> + <string>Pair de&vice now</string> + </property> + <property name="accel"> + <string>Alt+V</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + </widget> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>pairingTextLabel</cstring> + </property> + <property name="geometry"> + <rect> + <x>30</x> + <y>20</y> + <width>350</width> + <height>30</height> + </rect> + </property> + <property name="text"> + <string>Do you want to pair device now or later?</string> + </property> + </widget> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>WizardPage</cstring> + </property> + <attribute name="title"> + <string>Pairing</string> + </attribute> + <widget class="TQFrame"> + <property name="name"> + <cstring>progressBarFrame1</cstring> + </property> + <property name="geometry"> + <rect> + <x>30</x> + <y>10</y> + <width>420</width> + <height>50</height> + </rect> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <widget class="TQProgressBar"> + <property name="name"> + <cstring>pairingProgressBar</cstring> + </property> + <property name="geometry"> + <rect> + <x>5</x> + <y>9</y> + <width>300</width> + <height>29</height> + </rect> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>cancelPairingButton</cstring> + </property> + <property name="geometry"> + <rect> + <x>315</x> + <y>9</y> + <width>91</width> + <height>31</height> + </rect> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="accel"> + <string>Alt+C</string> + </property> + </widget> + </widget> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>WizardPage</cstring> + </property> + <attribute name="title"> + <string>Connect</string> + </attribute> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonSrc2Dst</cstring> + </property> + <property name="geometry"> + <rect> + <x>204</x> + <y>62</y> + <width>51</width> + <height>31</height> + </rect> + </property> + <property name="text"> + <string>&>></string> + </property> + <property name="accel"> + <string>Alt+></string> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>buttonDst2Src</cstring> + </property> + <property name="geometry"> + <rect> + <x>204</x> + <y>102</y> + <width>51</width> + <height>31</height> + </rect> + </property> + <property name="focusPolicy"> + <enum>NoFocus</enum> + </property> + <property name="text"> + <string>&<<</string> + </property> + <property name="accel"> + <string>Alt+<</string> + </property> + </widget> + <widget class="TQListView"> + <column> + <property name="text"> + <string>Service</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <item> + <property name="text"> + <string>Neuer Eintrag</string> + </property> + <property name="pixmap"> + <pixmap></pixmap> + </property> + </item> + <property name="name"> + <cstring>tQListViewSrc</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>30</y> + <width>190</width> + <height>240</height> + </rect> + </property> + </widget> + <widget class="TQListView"> + <column> + <property name="text"> + <string>Service</string> + </property> + <property name="clickable"> + <bool>true</bool> + </property> + <property name="resizable"> + <bool>true</bool> + </property> + </column> + <item> + <property name="text"> + <string>Neuer Eintrag</string> + </property> + <property name="pixmap"> + <pixmap></pixmap> + </property> + </item> + <property name="name"> + <cstring>tQListViewDst</cstring> + </property> + <property name="geometry"> + <rect> + <x>270</x> + <y>30</y> + <width>201</width> + <height>240</height> + </rect> + </property> + </widget> + <widget class="TQLabel"> + <property name="name"> + <cstring>connectTextLabel</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>270</width> + <height>30</height> + </rect> + </property> + <property name="text"> + <string>Select service to connect:</string> + </property> + </widget> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>WizardPage</cstring> + </property> + <attribute name="title"> + <string>Connecting</string> + </attribute> + <widget class="TQFrame"> + <property name="name"> + <cstring>progressBarFrame2</cstring> + </property> + <property name="geometry"> + <rect> + <x>40</x> + <y>20</y> + <width>420</width> + <height>50</height> + </rect> + </property> + <property name="frameShape"> + <enum>StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>Raised</enum> + </property> + <widget class="TQProgressBar"> + <property name="name"> + <cstring>connectingProgressBar</cstring> + </property> + <property name="geometry"> + <rect> + <x>5</x> + <y>9</y> + <width>300</width> + <height>29</height> + </rect> + </property> + </widget> + <widget class="TQPushButton"> + <property name="name"> + <cstring>cancelConnectButton</cstring> + </property> + <property name="geometry"> + <rect> + <x>315</x> + <y>9</y> + <width>91</width> + <height>31</height> + </rect> + </property> + <property name="text"> + <string>&Cancel</string> + </property> + <property name="accel"> + <string>Alt+C</string> + </property> + </widget> + </widget> + </widget> + <widget class="TQWidget"> + <property name="name"> + <cstring>WizardPage</cstring> + </property> + <attribute name="title"> + <string>Done</string> + </attribute> + <widget class="TQLabel"> + <property name="name"> + <cstring>doneTextLabel</cstring> + </property> + <property name="geometry"> + <rect> + <x>30</x> + <y>20</y> + <width>261</width> + <height>31</height> + </rect> + </property> + <property name="backgroundMode"> + <enum>PaletteBackground</enum> + </property> + <property name="backgroundOrigin"> + <enum>WidgetOrigin</enum> + </property> + <property name="text"> + <string>Done setup device</string> + </property> + </widget> + <widget class="TQCheckBox"> + <property name="name"> + <cstring>trustedCheckBox</cstring> + </property> + <property name="geometry"> + <rect> + <x>30</x> + <y>60</y> + <width>270</width> + <height>31</height> + </rect> + </property> + <property name="text"> + <string>Trust the &device</string> + </property> + <property name="accel"> + <string>Alt+D</string> + </property> + </widget> + </widget> +</widget> +<includes> + <include location="global" impldecl="in declaration">kcombobox.h</include> +</includes> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/tdebluez/devicewizard.cpp b/src/tdebluez/devicewizard.cpp new file mode 100644 index 0000000..51be413 --- /dev/null +++ b/src/tdebluez/devicewizard.cpp @@ -0,0 +1,866 @@ +/* + * + * Device Manager Gui for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <tqdbusobjectpath.h> +#include <tdeconfig.h> +#include <tqpushbutton.h> +#include <knotifydialog.h> +#include <knotifyclient.h> + +#include <devicemimeconverter.h> +#include <btuuids.h> + +#include "application.h" +#include "devicewizard.h" + +#define LOGOTIMEOUT 80 //80 msec +#define CONTIMEOUT 5000 //5 sec + +DeviceWizard::DeviceWizard(TDEBluetoothApp* a) : + DeviceDialog(), app(a) +{ + // use the first powered adapter + TQMap<TQString, AdapterImpl*>::Iterator ait = app->adapters.begin(); + for (ait; ait != app->adapters.end(); ++ait) + { + AdapterImpl *adptr = ait.data(); + if (adptr) + { + TQT_DBusError dbuserr; + if (adptr->getPowered(dbuserr)) + { + adapter = ait.data(); + break; + } + if (dbuserr.isValid()) + tqDebug("Get powered for active adapter failed: %s", dbuserr.message().local8Bit().data()); + } + } + + // else use the first available + if (!adapter) + adapter = (app->adapters).begin().data(); + + devicesetupwizard = new DeviceSetupWizard(app->manager); + + devicedlg_ext = new DeviceDialog_Ext(this); + setExtension(devicedlg_ext->newDevFrame); + setOrientation(TQt::Vertical); + + mainlogo = TDEGlobal::iconLoader()->loadIcon("tdebluez", TDEIcon::Small, 16); + setIcon(mainlogo); + + connectingDevice = {ConState::IDLE, TQString(), TQStringList()}; + + pix = TDEGlobal::iconLoader()->loadIcon("bluetooth", TDEIcon::Small, 48); + pixmapLabel->setPixmap(pix); + pixmapLabel->show(); + + logoBlend = pix; + KPixmapEffect::blend(logoBlend, -1, red, KPixmapEffect::DiagonalGradient); + + deviceBox->header()->hide(); + + // add devices + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + kdDebug() << "device path: " << dit.key() << endl; + slotInsertDevice(dit.key()); + } + + int colSize = deviceBox->columnWidth(1); + deviceBox->setColumnWidth(1, colSize + 20); + + /* disable button by default */ + setStateDeviceButtons(false); + + devicedlg_ext->newdevList->header()->hide(); + devicedlg_ext->newdevList->setColumnAlignment(2, TQt::AlignVCenter); + devicedlg_ext->setupButton->setEnabled(false); + + // connect signals + // devicedlg_ext + connect(devicedlg_ext->setupButton, SIGNAL(clicked()), + this, TQT_SLOT(slotSetupNewDevice())); + connect(devicedlg_ext->newdevList, SIGNAL(clicked(TQListViewItem*)), + this, TQT_SLOT(slotChangeSetupButton(TQListViewItem*))); + + // deviceBox + connect(deviceBox, SIGNAL(clicked(TQListViewItem*)), + this, TQT_SLOT(slotDeviceBoxClicked(TQListViewItem*))); + + // this wizard + connect(addButton, SIGNAL(toggled(bool)), + this, TQT_SLOT(showExtension(bool))); + connect(addButton, SIGNAL(toggled(bool)), + this, TQT_SLOT(slotSearch(bool))); + + connect(okButton, SIGNAL(clicked()), + this, SLOT(slotCloseDialog())); + + connect(configureButton, SIGNAL(clicked()), + this, TQT_SLOT(slotConfigDevice())); + connect(connectButton, SIGNAL(clicked()), + this, TQT_SLOT(slotConnectButton())); + connect(deleteButton, SIGNAL(clicked()), + this, TQT_SLOT(slotDeleteDevice())); + + // ADAPTER -> DIALOG + connect(app->manager, SIGNAL(adapterDiscoveringChanged(const TQString&, bool)), + this, TQT_SLOT(slotAdapterDiscoveringChanged(const TQString&, bool))); + + // DEVICE -> DIALOG + connect(app->manager, SIGNAL(deviceConnectedChanged(const TQString&, bool)), + this, TQT_SLOT(slotDeviceConnectedChanged(const TQString&, bool))); + connect(app->manager, SIGNAL(deviceAdded(const TQString&)), + this, TQT_SLOT(slotInsertDevice(const TQString&))); + connect(app->manager, SIGNAL(deviceRemoved(const TQString&)), + this, TQT_SLOT(slotDeviceRemoved(const TQString&))); + connect(app->manager, SIGNAL(deviceNameChanged(const TQString&, const TQString&)), + this, TQT_SLOT(slotDeviceNameChanged(const TQString&, const TQString&))); + connect(app->manager, SIGNAL(deviceAliasChanged(const TQString&, const TQString&)), + this, TQT_SLOT(slotDeviceNameChanged(const TQString&, const TQString&))); + connect(app->manager, SIGNAL(devicePairedChanged(const TQString&,bool)), + this, TQT_SLOT(slotDevicePairedChanged(const TQString&,bool))); + + // connect(app->manager, SIGNAL(mediaControlConnectedChanged(const TQString&,bool)), + // TQT_SLOT(slotMediaControlConnectedChanged(const TQString&,bool))); + + chgLogoTimer = new TQTimer(this); + TQObject::connect(chgLogoTimer, SIGNAL(timeout()), this, SLOT(slotUpdateLogo())); + timer = false; +} + +DeviceWizard::~DeviceWizard() +{ +// if (mediaCtlDialog) +// delete mediaCtlDialog; + delete devicedlg_ext; + delete devicesetupwizard; +} + +void DeviceWizard::slotCloseDialog() +{ + close(); +} + +void DeviceWizard::slotDeviceBoxClicked(TQListViewItem *dev) +{ + if (!dev) + { + setStateDeviceButtons(true); + return; + } + + TQString selAddr = dev->text(2); + if (connectingDevice.state == ConState::CONNECTING) + { + if (selAddr == connectingDevice.address) + { + connectButton->setText(i18n("&Disconnect")); + connectButton->setEnabled(true); + } + else + { + setStateDeviceButtons(false); + TQMessageBox::information(this, + i18n("Trying to connect device: ") + connectingDevice.address, + i18n("Either wait or try disconnecting first"), + TQMessageBox::Ok | TQMessageBox::Default, + TQMessageBox::NoButton, + TQMessageBox::NoButton); + } + return; + } + + + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQT_DBusError dbuserr; + TQString addr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (selAddr == addr) + { + bool connected = dit.data()->getConnected(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getConnected failed: %s", dbuserr.message().local8Bit().data()); + if (connected) + { + connectButton->setText(i18n("&Disconnect")); + } + else + { + connectButton->setText(i18n("C&onnect")); + } + break; + } + } + setStateDeviceButtons(true); +} + +void DeviceWizard::slotChangeSetupButton(TQListViewItem *dev) +{ + devicedlg_ext->setupButton->setEnabled(true); +} + +void DeviceWizard::slotConnectButton() +{ + TQListViewItem *sel = deviceBox->selectedItem(); + + if (!sel) + return; + + setStateDeviceButtons(false); + + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQT_DBusError dbuserr; + TQString addr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (sel->text(2) == addr) + { + if (connectButton->text() == "C&onnect") + { + connectingDevice.state = ConState::CONNECTING; + connectingDevice.address = addr; + + app->m_config->setGroup(addr); + TQStringList profiles = app->m_config->readListEntry("profile"); + connectingDevice.profiles = profiles; + + if (connectingDevice.profiles.isEmpty()) + { + devicesetupwizard->setDevice(dit.data()); + devicesetupwizard->show(); + devicesetupwizard->raise(); + devicedlg_ext->setupButton->setEnabled(false); + } + else + { + slotConnectNextProfile(); + } + } + else + { + int asyncCallId = 0; + if (dit.data()->DisconnectAsync(asyncCallId, dbuserr)) + { + app->manager->getConnection()->scheduleDispatch(); + connectingDevice.state = ConState::DISCONNECTING; + connectingDevice.profiles.clear(); + } + if (dbuserr.isValid()) + { + tqDebug("DisconnectAsync failed: %s", dbuserr.message().local8Bit().data()); + } + } + break; + } + } +} + +void DeviceWizard::slotConnectNextProfile() +{ + TQString profile = connectingDevice.profiles.first(); + if (profile.isEmpty()) + { + connectingDevice = {ConState::IDLE, TQString(), TQStringList()}; + return; + } + + TQT_DBusError dbuserr; + TQString path; + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQString addr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (addr == connectingDevice.address) + { + path = dit.key(); + break; + } + } + + if (path.isEmpty()) + { + connectingDevice = {ConState::IDLE, TQString(), TQStringList()}; + return; + } + + int asyncCallId = 0; + if (app->devices[path]->ConnectProfileAsync(asyncCallId, profile, dbuserr)) + { + app->manager->getConnection()->scheduleDispatch(); + + connectingDevice.profiles.pop_front(); + if (!connectingDevice.profiles.isEmpty()) + TQTimer::singleShot(CONTIMEOUT, this, TQT_SLOT(slotConnectNextProfile())); + } + else + { + if (dbuserr.isValid()) + tqDebug("ConnectProfileAsync failed: %s", dbuserr.message().local8Bit().data()); + + TQString text = i18n("<p>Attempt to start connection with the device failed</p>" + "<p>You can retry to connect or click <b>Cancel</b> to stop.</p>"); + int status = KMessageBox::warningContinueCancel(this, + text, + i18n("Connection attempts will be interrupted"), + KStdGuiItem::quit()); + if (status == KMessageBox::Continue) + TQTimer::singleShot(CONTIMEOUT, this, TQT_SLOT(slotConnectNextProfile())); + else + connectingDevice = {ConState::IDLE, TQString(), TQStringList()}; + } +} + +void DeviceWizard::slotSetAdapter(const TQString &path, const TQString &name) +{ + adapter = app->adapters[path]; +} + +void DeviceWizard::setStateDeviceButtons(bool state) +{ + connectButton->setEnabled(state); + deleteButton->setEnabled(state); + configureButton->setEnabled(state); +} + +void DeviceWizard::slotDeviceConnectedChanged(const TQString &path, bool connect) +{ + TQT_DBusError dbuserr; + TQString addr = app->devices[path]->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + + TQListViewItem *devItem = deviceBox->findItem(addr, 2, TQt::ExactMatch); + if (!devItem) + return; // may be it was already deleted + + //this is the selected item + if (devItem == deviceBox->selectedItem()) + { + if (connect) + connectButton->setText(i18n("&Disconnect")); + else + connectButton->setText(i18n("C&onnect")); + setStateDeviceButtons(true); + } + + if (connect) + { + KPixmap pix = TDEGlobal::iconLoader()->loadIcon("bookmark", TDEIcon::Small, 16); + devItem->setPixmap(0, pix); + } + else + { + devItem->setPixmap(0, TQPixmap()); + } + + // If we initiated the connection request, set state + if (addr == connectingDevice.address) + { + switch (connectingDevice.state) + { + case ConState::CONNECTING: + if (connectingDevice.profiles.isEmpty()) + connectingDevice = {ConState::IDLE, TQString(), TQStringList()}; + break; + case ConState::DISCONNECTING: + connectingDevice = {ConState::IDLE, TQString(), TQStringList()}; + break; + } + } +} + +void DeviceWizard::slotDeleteDevice() +{ + TQListViewItem *sel = deviceBox->selectedItem(); + /* No device selected */ + if (!sel) + return; + + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQT_DBusError dbuserr; + TQString addr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (sel->text(2) == addr) + { + if (!adapter->RemoveDevice(TQT_DBusObjectPath(dit.key()), dbuserr)) + { + TQString err = (dbuserr.isValid()) ? dbuserr.message() : i18n("No error message"); + TQMessageBox::information(this, + i18n("Remove failed"), + i18n("Device ") + addr + i18n(" could not be removed!\nReason: ") + err, + TQMessageBox::Ok | TQMessageBox::Default, + TQMessageBox::NoButton, + TQMessageBox::NoButton); + } + + app->m_config->deleteGroup(addr); + app->m_config->sync(); + + break; + } + } + // fix for not emitting signal after device was remove + // this results in not updating the device wizard and + // leaving the device in the list, while the device is + // removed from the adapter list + app->manager->getConnection()->scheduleDispatch(); + // selection is to be removed + setStateDeviceButtons(false); +} + +void DeviceWizard::slotDeviceRemoved(const TQString& path) +{ + kdDebug() << __func__ << endl; + // because device was already deleted from the devicemap + // we need to find out which view item it is + TQStringList addrList1 = TQStringList(); + TQStringList addrList2 = TQStringList(); + + TQListViewItemIterator it1(deviceBox); + while (it1.current()) + { + TQString addr = it1.current()->text(2); + addrList1.append(addr); + ++it1; + } + + TQListViewItemIterator it2(devicedlg_ext->newdevList); + while (it2.current()) + { + TQString addr = it2.current()->text(1); + addrList2.append(addr); + ++it2; + } + + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQT_DBusError dbuserr; + TQString addr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (addrList1.grep(addr).size() == 1) + addrList1.remove(addr); + if (addrList2.grep(addr).size() == 1) + addrList2.remove(addr); + } + for (TQStringList::Iterator it = addrList1.begin(); it != addrList1.end(); + ++it) + { + TQListViewItem *item = deviceBox->findItem((*it), 2, TQt::ExactMatch); + if (item) + delete item; + } + for (TQStringList::Iterator it = addrList2.begin(); it != addrList2.end(); + ++it) + { + TQListViewItem *item = devicedlg_ext->newdevList->findItem((*it), 1, TQt::ExactMatch); + if (item) + delete item; + } + + devicedlg_ext->setupButton->setEnabled(false); + setStateDeviceButtons(false); +} + +void DeviceWizard::slotConfigDevice() +{ + TQListViewItem *sel = deviceBox->selectedItem(); + // No device selected + if (!sel) + return; + + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQT_DBusError dbuserr; + TQString addr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (sel->text(2) == addr) + { + // device to be configured + setStateDeviceButtons(false); + devicesetupwizard->setDevice(dit.data()); + devicesetupwizard->show(); + devicesetupwizard->raise(); + devicedlg_ext->setupButton->setEnabled(false); + kdDebug() << "address: _____________" << addr << endl; + break; + } + } +} + +void DeviceWizard::slotSearch(bool state) +{ + // Discovering can be enabled and disabled only from + // the one and the same application + TQT_DBusError dbuserr; + if (state) + { + adapter->StartDiscovery(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device StartDiscovery failed: %s", dbuserr.message().local8Bit().data()); + addButton->setText(i18n("&Stop Discovery >>")); + } + else + { + adapter->StopDiscovery(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device StopDiscovery failed: %s", dbuserr.message().local8Bit().data()); + addButton->setText(i18n("&Start Discovery <<")); + } +} + +void DeviceWizard::slotAdapterDiscoveringChanged(const TQString& path, bool state) +{ + timer = state; + + if (state) + { +// new device list should be empty when starting search/discovery +// but also the device should be removed from the bluetooth cache +// this means iterate over devicedlg_ext->newdevList and call +// adapter->RemoveDevice(object_path, error) on the device + disconnect(app->manager, SIGNAL(deviceRemoved(const TQString&)), + this, TQT_SLOT(slotDeviceRemoved(const TQString&))); + TQListViewItemIterator it2(devicedlg_ext->newdevList); + while (it2.current()) + { + TQString addr = it2.current()->text(1); + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQT_DBusError dbuserr; + TQString thepath = dit.data()->getPath(); + TQString theaddr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (addr == theaddr) + { + adapter->RemoveDevice(thepath, dbuserr); + if (dbuserr.isValid()) + tqDebug("Remove Device failed: %s", dbuserr.message().local8Bit().data()); + break; + } + } + ++it2; + } + devicedlg_ext->newdevList->clear(); + connect(app->manager, SIGNAL(deviceRemoved(const TQString&)), + this, TQT_SLOT(slotDeviceRemoved(const TQString&))); + devicedlg_ext->statusbar->setText(i18n("Device Discovery started")); + chgLogoTimer->start(LOGOTIMEOUT); + } + else + { + chgLogoTimer->stop(); + pixmapLabel->setPixmap(pix); + } +} + +void DeviceWizard::slotInsertDevice(const TQString& path) +{ + TQT_DBusError dbuserr; + TQString addr = app->devices[path]->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + TQString name = app->devices[path]->getName(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getName failed: %s", dbuserr.message().local8Bit().data()); + bool paired = app->devices[path]->getPaired(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getPaired failed: %s", dbuserr.message().local8Bit().data()); + TQ_UINT32 devclass = app->devices[path]->getClass(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getClass failed: %s", dbuserr.message().local8Bit().data()); + bool connected = app->devices[path]->getConnected(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getConnected failed: %s", dbuserr.message().local8Bit().data()); + + + connect(app->devices[path], SIGNAL(AsyncErrorResponseDetected(int /*asyncCallId*/, const TQT_DBusError)), + this, TQT_SLOT(slotAsyncErrorResponseDetected(int /*asyncCallId*/, const TQT_DBusError))); +// connect(app->devices[path], SIGNAL(ConnectAsyncReply(int /*asyncCallId*/)), +// this, TQT_SLOT(slotConnectAsyncReply(int /*asyncCallId*/))); +// connect(app->devices[path], SIGNAL(DisonnectAsyncReply(int /*asyncCallId*/)), +// this, TQT_SLOT(slotDisconnectAsyncReply(int /*asyncCallId*/))); +// connect(app->devices[path], SIGNAL(ConnectProfileAsyncReply(int /*asyncCallId*/)), +// this, TQT_SLOT(slotConnectProfileAsyncReply(int /*asyncCallId*/))); + + + TQListViewItem *devItem = deviceBox->findItem(addr, 2, TQt::ExactMatch); + //device was already setup but is not in the deviceBox + if (paired && !devItem) + { + TQListViewItem *toAddDev = new TQListViewItem(deviceBox); + toAddDev->setText(1, name); + toAddDev->setText(2, addr); + TQString iconName = DeviceMimeConverter::classToIconName(devclass); + KPixmap pix2 = TDEGlobal::iconLoader()->loadIcon(iconName, TDEIcon::Small, 16); + toAddDev->setPixmap(3, pix2); + + KPixmap pix3 = TDEGlobal::iconLoader()->loadIcon("bookmark", TDEIcon::Small, 16); + + if (connected) + toAddDev->setPixmap(0, pix3); + deviceBox->insertItem(toAddDev); + return; + } + + //device was not setup it belongs to the new device list + TQString mimeType = DeviceMimeConverter::classToMimeType(devclass); + TQString type; + if (mimeType == "bluetooth/peripheral-device-class") + { + type = i18n("peripheral"); + } + else if (mimeType == "bluetooth/av-device-class") + { + type = i18n("A/V"); + } + else if (mimeType == "bluetooth/phone-device-class") + { + type = i18n("phone"); + } + else if (mimeType == "bluetooth/wearable-device-class") + { + type = i18n("wearable"); + } + else if (mimeType == "bluetooth/toy-device-class") + { + type = i18n("toy"); + } + else if (mimeType == "bluetooth/health-device-class") + { + type = i18n("toy"); + } + else if (mimeType == "bluetooth/computer-device-class") + { + return; + } + else + { + type = i18n("unknown"); + } + + TQListViewItem *ndevlist = new TQListViewItem(devicedlg_ext->newdevList, name, addr); + + TQString iconName = DeviceMimeConverter::classToIconName(devclass); + KPixmap pix2 = TDEGlobal::iconLoader()->loadIcon(iconName, TDEIcon::Small, 32); + ndevlist->setPixmap(2, pix2); + + devicedlg_ext->newdevList->insertItem(ndevlist); + + int size1 = devicedlg_ext->newdevList->columnWidth(0); + devicedlg_ext->newdevList->setColumnWidth(0, size1 + 15); + + int size2 = devicedlg_ext->newdevList->columnWidth(1); + devicedlg_ext->newdevList->setColumnWidth(1, size2 + 15); + + devicedlg_ext->statusbar->setText(i18n("Found new %1 device.").arg(type)); +} + +void DeviceWizard::slotDeviceNameChanged(const TQString& path, const TQString& newname) +{ + TQT_DBusError dbuserr; + TQString addr = app->devices[path]->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + + TQListViewItem *tmp = devicedlg_ext->newdevList->findItem(addr, 1, TQt::ExactMatch); + if (tmp) { + if (tmp->text(0) == "") + { + const TQPixmap *ico = tmp->pixmap(2); + devicedlg_ext->newdevList->takeItem(tmp); + TQListViewItem *ndevlist = new TQListViewItem(devicedlg_ext->newdevList, newname, addr); + if (ndevlist) + { + ndevlist->setPixmap(2, (*ico)); + devicedlg_ext->newdevList->insertItem(ndevlist); + } + } + return; + } + + tmp = deviceBox->findItem(addr, 2, TQt::ExactMatch); + if (tmp) { + if (tmp->text(0) == "") + { + const TQPixmap *ico = tmp->pixmap(2); + deviceBox->takeItem(tmp); + TQListViewItem *devlist = new TQListViewItem(deviceBox, newname, addr); + if (devlist) + { + devlist->setPixmap(2, (*ico)); + deviceBox->insertItem(devlist); + } + } + } +} + +void DeviceWizard::slotAsyncErrorResponseDetected(int asyncCallId, const TQT_DBusError dbuserr) +{ + tqDebug("AsyncErrorResponseDetected (%i): %i %s %s", asyncCallId, dbuserr.type(), dbuserr.name().local8Bit().data(), dbuserr.message().local8Bit().data()); + + connectingDevice = {ConState::IDLE, TQString(), TQStringList()}; + connectButton->setText(i18n("C&onnect")); + setStateDeviceButtons(true); + + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "ConnectionError", tr("AsyncErrorResponseDetected: %1\n%2\n%3") + .arg(dbuserr.type()) + .arg(dbuserr.name().local8Bit().data()) + .arg(dbuserr.message().local8Bit().data())); +} + +void DeviceWizard::slotSetupNewDevice() +{ + TQListViewItem *confSel = devicedlg_ext->newdevList->currentItem(); + if (!confSel) + { + TQMessageBox::information(this, + i18n("Setup device"), + i18n("You have to select a remote Device to setup!"), + TQMessageBox::Ok | TQMessageBox::Default, + TQMessageBox::NoButton, + TQMessageBox::NoButton); + return; + } + + TQString selAddr = confSel->text(1); + DeviceImpl *newdev; + + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQT_DBusError dbuserr; + TQString addr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (selAddr == addr) + { + newdev = dit.data(); + break; + } + } + + if (!newdev) + { + TQMessageBox::information(this, + i18n("Setup device"), + i18n("No device matching selection was found!"), + TQMessageBox::Ok | TQMessageBox::Default, + TQMessageBox::NoButton, + TQMessageBox::NoButton); + return; + } + + setStateDeviceButtons(false); + devicesetupwizard->setDevice(newdev); + devicesetupwizard->show(); + devicesetupwizard->raise(); + devicedlg_ext->setupButton->setEnabled(false); + + kdDebug() << "address: _____________" << selAddr << endl; +} + +void DeviceWizard::slotDevicePairedChanged(const TQString& path, bool) +{ + TQListViewItem *confSel = devicedlg_ext->newdevList->currentItem(); + if (!confSel) + return; + + TQString selAddr = confSel->text(1); + TQListViewItem* newDeviceBoxItem = new TQListViewItem(deviceBox); + newDeviceBoxItem->setText(1, confSel->text(0)); + newDeviceBoxItem->setText(2, selAddr); + + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + TQT_DBusError dbuserr; + TQString addr = dit.data()->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (addr == selAddr) + { + TQString iconName = DeviceMimeConverter::classToIconName(dit.data()->getClass(dbuserr)); + KPixmap pix4 = TDEGlobal::iconLoader()->loadIcon(iconName, TDEIcon::Small, 16); + newDeviceBoxItem->setPixmap(3, pix4); + break; + } + } + + deviceBox->insertItem(newDeviceBoxItem); + delete confSel; +} + +//void DeviceWizard::slotMediaControlConnectedChanged(const TQString &path, +// bool connect) +//{ +// if (connect) +// mediaCtlDialog = new MediaControl(path, app->manager->getConnection()); +// else +// mediaCtlDialog->close(); +//} + +void DeviceWizard::slotUpdateLogo() +{ + if (!addButton->isOn()) { + timer = false; + pixmapLabel->setPixmap(pix); + return; + } + + if (timer == false) + { + pixmapLabel->setPixmap(logoBlend); + timer = true; + } + else + { + pixmapLabel->setPixmap(pix); + timer = false; + } +} + +#include "devicewizard.moc" + diff --git a/src/tdebluez/devicewizard.h b/src/tdebluez/devicewizard.h new file mode 100644 index 0000000..dae8fe5 --- /dev/null +++ b/src/tdebluez/devicewizard.h @@ -0,0 +1,123 @@ +/* + * + * Device Manager Gui for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef DEVICEWIZARD_H +#define DEVICEWIZARD_H + +#include <tqheader.h> +#include <tqtoolbutton.h> +#include <tqlabel.h> +// +#include <tqlistview.h> +#include <kpixmap.h> +#include <kiconloader.h> +#include <kpixmapeffect.h> + +#include <objectmanagerImpl.h> +#include <adapterImpl.h> +#include <deviceImpl.h> + +#include "devicedialog.h" +#include "devicedialog_ext.h" +#include "devicesetupwizard.h" +//#include "mediacontrol.h" + +using namespace TDEBluetooth; + +class DeviceWizard: public DeviceDialog +{ + Q_OBJECT + +public: + DeviceWizard(TDEBluetoothApp* app); + ~DeviceWizard(); + +private: + void setStateDeviceButtons(bool state); + +private slots: + // device wizard ui + void slotDeviceBoxClicked(TQListViewItem*); + void slotChangeSetupButton(TQListViewItem*); + void slotConnectButton(); + void slotCloseDialog(); + void slotSearch(bool state); + void slotUpdateLogo(); + void slotInsertDevice(const TQString& path); + void slotSetupNewDevice(); + void slotDeleteDevice(); + void slotConfigDevice(); + + // supportive + void slotConnectNextProfile(); + void slotSetAdapter(const TQString& path, const TQString& name); + + // MANAGER -> device wizard + // adapter related + void slotAdapterDiscoveringChanged(const TQString&, bool); + // void slotMediaControlConnectedChanged(const TQString&, bool); + // device related +// void slotSetConnectedIcon(const TQString&); +// void slotSetDisconnectedIcon(const TQString&); + void slotDeviceConnectedChanged(const TQString&, bool); + void slotDeviceRemoved(const TQString& path); + void slotDevicePairedChanged(const TQString&, bool); + void slotDeviceNameChanged(const TQString&, const TQString&); + + void slotAsyncErrorResponseDetected(int asyncCallId, const TQT_DBusError dbuserr); +// void slotConnectAsyncReply(int asyncCallId); +// void slotConnectProfileAsyncReply(int asyncCallId); + + + +private: + TDEBluetoothApp *app; + AdapterImpl *adapter; + + DeviceDialog_Ext *devicedlg_ext; + DeviceSetupWizard *devicesetupwizard; + // MediaControl *mediaCtlDialog; + + enum ConState + { + IDLE = 0, CONNECTING, DISCONNECTING + }; + + struct ConnectDevice { + ConState state; + TQString address; + TQStringList profiles; // when multiple profiles are to be connected + }; + + KPixmap logoBlend; + KPixmap pix; + KPixmap mainlogo; + + TQTimer* chgLogoTimer; + bool timer; + + ConnectDevice connectingDevice; +}; + +#endif diff --git a/src/tdebluez/eventsrc b/src/tdebluez/eventsrc new file mode 100644 index 0000000..c4fb1a2 --- /dev/null +++ b/src/tdebluez/eventsrc @@ -0,0 +1,397 @@ +[!Global!] +IconName=tdebluez +Comment=TDEBluetooth +Comment[sv]=TDEBluetooth +Comment[tr]=TDEBluetooth + +[AdapterAttached] +Name=AdapterAttached +Name[bg]=Прикачен адаптер +Comment=Adapter attached +Comment[bg]=Адаптер за блутут беше прикачен към системата +default_presentation=20 + +[AdapterDetached] +Name=AdapterDetached +Name[bg]=Отстранен адаптер +Comment=Adapter detached +Comment[bg]=Адаптер за блутут беше отстранен от системата +default_presentation=20 + +[AdapterAvailable] +Name=AdapterAvailable +Name[bg]=Адаптер на разположение +Comment=Adapter available +Comment[bg]=Адаптер за блутут е на разположение +default_presentation=20 + +[IncomingConnection] +Name=IncomingConnection +Name[bg]=Входяща връзка +Name[br]=Kevreadenn resev +Name[cy]=CysylltiadCyrraedd +Name[da]=Indgående forbindelse +Name[de]=EingehendeVerbindung +Name[el]=Εισερχόμενη σύνδεση +Name[es]=Conexión entrante +Name[et]=Sisenev ühendus +Name[fr]=Connexion entrante +Name[ga]=CeangalIsteach +Name[gl]=Chamada Entrante +Name[it]=ConnessioneInArrivo +Name[lt]=Įeinantis ryšys +Name[nl]=Inkomende verbinding +Name[pl]=Połączenie przychodzące +Name[pt]=Ligação Recebida +Name[pt_BR]=Ligação Recebida +Name[sr]=Долазна веза +Name[sr@Latn]=Долазна веза +Name[sv]=Inkommande anslutning +Name[ta]=உள் வரும் இனைப்பு +Name[tg]=Пайвастшавии даромад +Name[tr]=Gelen Bağlandı +Comment=Received incoming connection +Comment[bg]=Получаване на входяща връзка +Comment[bs]=Primljena dolazeća konekcija +Comment[ca]=S'ha rebut una connexió entrant +Comment[cs]=Obdrženo příchozí spojení +Comment[cy]=Derbynwyd cysylltiad a gyrhaeddodd +Comment[da]=Modtog indkommende forbindelse +Comment[de]=Empfangene eingehende Verbindung +Comment[el]=Λήψη εισερχόμενης σύνδεσης +Comment[es]=Se ha recibido una conexión entrante +Comment[et]=Saadi sisenev ühendus +Comment[fr]=Connexion rentrante reçue +Comment[gl]=Foi recebida unha chamada +Comment[it]=Connessione in arrivo ricevuta +Comment[ja]=着信接続がありました +Comment[lt]=Priimtas įeinantis ryšys +Comment[nl]=Ontving een inkomende verbinding +Comment[pl]=Otrzymano połączenie przychodzące +Comment[pt]=Foi recebida uma ligação +Comment[pt_BR]=Foi recebida uma ligação +Comment[sr]=Примљена је долазећа веза +Comment[sr@Latn]=Примљена је долазећа веза +Comment[sv]=Tog emot inkommande anslutning +Comment[ta]=உள் வரும் இனைப்பை பேற்றுள்ளது +Comment[tg]=Пайвастшавии даромад қабул шуд +default_presentation=20 + +[ProcessStderr] +Name=ProcessStderr +Name[de]=ProzessStderr +Name[el]=Διεργασία Stderr +Name[es]=Error estándar de proceso +Name[fr]=Stdett du processus +Name[gl]=ProcesStderr +Name[it]=StderrDelProcesso +Name[pl]=Wyjście diagnostyczne procesu +Name[pt]=Processamento do STDERR +Name[pt_BR]=Processamento do STDERR +Name[sr]=Stderr процеса +Name[sr@Latn]=Stderr процеса +Name[sv]=Processens standardfelutmatning +Comment=Output of search job on stderr +Comment[bg]=Изходни данни за търсене на работа на stderr +Comment[ca]=Resultat del treball de cerca en stderr +Comment[da]=Uddata fra søgejob til stderr +Comment[de]=Ausgabe des Suchauftrags auf stderr +Comment[el]=Έξοδος της εργασίας αναζήτησης στο stderr +Comment[es]=Salida del trabajo de búsqueda de error +Comment[et]=Otsingutöö väljund stderri +Comment[fr]=Sortie de la tâche de recherche sur stderr +Comment[gl]=Resultado do traballo de procura en stderr +Comment[it]=Output del processo di ricerca su stderr +Comment[ja]=検索ジョブの stderr への出力 +Comment[lt]=Paieškos rezultato išvedimas į stderr +Comment[nl]=Uitvoer van zoektaak op stderr +Comment[pl]=Wyjście zadania wyszukiwania na standardowe wyjście diagnostyczne +Comment[pt]=Resultado da tarefa de pestquisa no 'stderr' +Comment[pt_BR]=Resultado da tarefa de pestquisa no 'stderr' +Comment[sr]=Излаз посла тражења на stderr +Comment[sr@Latn]=Излаз посла тражења на stderr +Comment[sv]=Utmatning från sökjobb på standardfelutmatningen +Comment[ta]=stderr இல் தேடும் பணியின் வெளியீடு +Comment[tg]=Натиҷаи ҷустуҷӯи корҳои stderr +default_presentation=28 +default_sound=KDE_Critical_Error.wav + +[ProcessStdout] +Name=ProcessStdout +Name[de]=ProzessStdout +Name[el]=Διεργασία Stdout +Name[es]=Salida estándar de proceso +Name[fr]=Stdout du processus +Name[gl]=ProcesStdout +Name[it]=StdoutProcesso +Name[pl]=Wyjście standardowe procesu +Name[pt]=Processamento do STDOUT +Name[pt_BR]=Processamento do STDOUT +Name[sr]=Stdout процеса +Name[sr@Latn]=Stdout процеса +Name[sv]=Processens standardutmatning +Comment=Output of search job on stdout +Comment[bg]=Изходни данни за търсене на работа на stdout +Comment[ca]=Resultat del treball de cerca en stdout +Comment[da]=Uddata fra søgejob til stdout +Comment[de]=Ausgabe des Suchauftrags auf stdout +Comment[el]=Έξοδος της εργασίας αναζήτησης στο stdout +Comment[es]=Salida del trabajo de búsqueda en la salida estándar +Comment[et]=Otsingutöö väljund stdouti +Comment[fr]=Sortie de la tâche de recherche sur stdout +Comment[gl]=Resultado do traballo de procura en stdout +Comment[it]=Output del processo di ricerca su stdout +Comment[ja]=検索ジョブの stdout への出力 +Comment[lt]=Paieškos rezultato išvedimas į stdout +Comment[nl]=Uitvoer van zoektaak op stdout +Comment[pl]=Wyjście zadania wyszukiwania na standardowe wyjście procesu +Comment[pt]=Resultado da tarefa de pestquisa no 'stdout' +Comment[pt_BR]=Resultado da tarefa de pestquisa no 'stdout' +Comment[sr]=Излаз посла тражења на stdout +Comment[sr@Latn]=Излаз посла тражења на stdout +Comment[sv]=Utmatning från sökjobb på standardutmatningen +Comment[ta]=stdout இல் தேடும் பணியின் வெளியீடு +default_presentation=8 + +[ProcessFailed] +Name=ProcessFailed +Name[bg]=Грешка при изпълнение +Name[cs]=Proces selhal +Name[cy]=MethoddProses +Name[de]=ProzessFehlgeschlagen +Name[el]=Η διεργασία απέτυχε +Name[es]=Proceso fallido +Name[et]=Protsess nurjus +Name[fr]=Échec du processus +Name[ga]=PróiseasTeipthe +Name[gl]=ProcesFailed +Name[it]=ProcessoNonRiuscito +Name[lt]=Procesas baigėsi klaida +Name[nl]=Proces mislukt +Name[pa]=ਕਾਰਜ ਫੇਲ +Name[pl]=Błąd procesu +Name[pt]=Processo Mal-Sucedido +Name[pt_BR]=Processo Mal-Sucedido +Name[sr]=Неуспео процес +Name[sr@Latn]=Неуспео процес +Name[sv]=Processen misslyckades +Name[ta]=சேயல் இயந்தது +Name[tg]=Амалиёт қатъ шуд +Name[tr]=Süreç Hatası +Comment=Could not call process to handle connection +Comment[bg]=Грешка при изпълнение на процес за обработка на връзка +Comment[bs]=Nisam mogao pozvati proces koji rukuje konekcijom +Comment[ca]=No s'ha pogut cridar al procés per a manejar la connexió +Comment[cs]=Nelze spustit proces k obsluze spojení +Comment[cy]=Methu galw proses i drin y cysylltiad +Comment[da]=Kunne ikke kalde proces til at håndtere forbindelse +Comment[de]=Prozess zum Behandeln der Verbindung konnte nicht aufgerufen werden +Comment[el]=Αδυναμία κλήσης της διεργασίας για τον έλεγχο της σύνδεσης +Comment[es]=No se pudo llamar al proceso que maneja la conexión +Comment[et]=Ei suuda käivitada protsessi ühenduse käsitlemiseks +Comment[fr]=Impossible d'appeler le processus pour ouvrir la connexion +Comment[gl]=Non foi posíbel chamar o proceso de xestión da conexón +Comment[it]=Impossibile chiamare processo per gestire la connessione +Comment[ja]=接続を扱うプロセスを呼び出せませんでした +Comment[lt]=Nepavyko iškviesti proceso prisijungimui apdoroti +Comment[nl]=Het proces om de verbinding af te handelen kon niet worden aangeroepen +Comment[pl]=Nie można wywołać procesu do obsługi połączenia +Comment[pt]=Não foi possível invocar o processo para tratar da ligação +Comment[pt_BR]=Não foi possível invocar o processo para tratar da ligação +Comment[sr]=Нисам могао да позовем процес за руковање везом +Comment[sr@Latn]=Нисам могао да позовем процес за руковање везом +Comment[sv]=Kunde inte anropa process för att hantera anslutningen +Comment[ta]=இனைப்பை கையாள செயல் எதுவும் இல்லை +Comment[tg]=Амалиёт барои пайвастшавӣ фаъол карда натавонист +default_presentation=15 +default_sound=KDE_Critical_Error.wav + +[BluetoothDeviceLost] +Name=BluetoothDeviceLost +Name[bg]=Връзката с Bluetooth устройството е изгубена +Name[de]=BluetoothGerätVerloren +Name[el]=Η συσκευή Bluetooth χάθηκε +Name[es]=Dispositivos bluetooth perdidos +Name[et]=Bluetooth seade kadunud +Name[fr]=Périphérique Bluetooth Perdu +Name[it]=DispositivoBluetoothPerso +Name[lt]=Ryšys su bluetooth įrenginiu nutrūko +Name[nl]=Bluetooth-apparaat verloren +Name[pl]=Utracono urządzenie +Name[pt]=Dispositivo Bluetooth Perdido +Name[pt_BR]=Dispositivo Bluetooth Perdido +Name[sr]=Bluetooth уређај је изгубљен +Name[sr@Latn]=Bluetooth уређај је изгубљен +Name[sv]=Blåtandsenhet förlorad +Name[ta]=புலுடுத் கருவி தொலைந்தது +Name[tg]=Дастгоҳи Bluetooth гум шуд +Name[tr]=Bluetooth Aygıtı Kaybedildi +Comment=The Bluetooth device failed or was unplugged +Comment[bg]=Bluetooth устройство се повреди или е било изключено +Comment[bs]=Bluetooth uređaj je izazvao grešku ili je iskopčan +Comment[ca]=El dispositiu Bluetooth ha fallat o ha estat desendollat +Comment[da]=Bluetooth-enheden mislykkedes eller var ikke sat til +Comment[de]=Das Bluetooth-Gerät meldet einen Fehler oder wurde entfernt +Comment[el]=Η συσκευή Bluetooth απέτυχε ή δεν είναι συνδεδεμένη +Comment[es]=Falló el dispositivo bluetooth o se desconectó +Comment[et]=Bluetooth seade tõrkus või ei ole ühendatud +Comment[fr]=Le périphérique Bluetooth a planté ou a été débranché +Comment[gl]=O dispositivo Bluetooth fallou ou foi desconectado +Comment[it]=Il dispositivo Bluetooth è in errore o è stato scollegato +Comment[ja]=Bluetooth デバイスに問題があるか、取り外されました +Comment[lt]=Bluetooth įrenginys nesuveikė arba buvo atjungtas +Comment[nl]=Het Bluetooth-apparaat faalde of is niet aangesloten +Comment[pl]=Urządzenie Bluetooth zostało odłączone lub wystąpił w nim błąd +Comment[pt]=O dispositivo Bluetooth falhou ou foi desligado +Comment[pt_BR]=O dispositivo Bluetooth falhou ou foi desligado +Comment[sr]=Bluetooth уређај није у реду или је искључен +Comment[sr@Latn]=Bluetooth уређај није у реду или је искључен +Comment[sv]=Blåtandsenheten slutade fungera eller kopplades bort +Comment[ta]=புலுடுத் கருவி சேயல் இயந்தது அல்லது இனைப்பு துண்டிக்க பட்டது +Comment[tg]=Дастгоҳи Bluetooth қатъ шуд ё ҷудо карда шуд +Comment[tr]=Bluetooth aygıtı başarısız oldu ya da çıkartıldı +default_presentation=21 +default_sound=KDE_Dialog_Disappear.wav + +[BluetoothDeviceFound] +Name=BluetoothDeviceFound +Name[bg]=Открито е устройство Bluetooth +Name[de]=BluetoothGerätGefunden +Name[el]=Βρέθηκε συσκευή Bluetooth +Name[es]=Dispositivo bluetooth encontrado +Name[et]=Bluetooth seade leitud +Name[fr]=Périphérique Bluetooth Trouvé +Name[it]=DispositivoBluetoothTrovato +Name[lt]=Aptiktas bluetooth įrenginys +Name[nl]=Bluetooth-apparaat gevonden +Name[pl]=Znaleziono urządzenie Bluetooth +Name[pt]=Dispositivo Bluetooth Encontrado +Name[pt_BR]=Dispositivo Bluetooth Encontrado +Name[sr]=Нађен Bluetooth уређај +Name[sr@Latn]=Нађен Bluetooth уређај +Name[sv]=Blåtandsenhet hittades +Name[ta]=புலுடுத் கருவி கிடைத்தது +Name[tg]=Дастгоҳи Bluetooth ёфт нашуд +Name[tr]=Bluetooth Aygıtı Bulundu +Comment=The Bluetooth device was detected +Comment[ar]=تم اكتشلف جهاز Bluetooth +Comment[bg]=Открито е устройство Bluetooth +Comment[bs]=Bluetooth uređaj je detektovan +Comment[ca]=El dispositiu Bluetooth ha estat detectat +Comment[da]=Bluetooth-enheden blev detekteret +Comment[de]=Das Bluetooth-Gerät wurde erkannt +Comment[el]=Η συσκευή Bluetooth εντοπίστηκε +Comment[es]=Se detectó el dispositivo bluetooth +Comment[et]=Tuvastati Bluetooth seade +Comment[fr]=Le périphérique Bluetooth a été détecté +Comment[gl]=O dispositivo Bluetooth foi detectado +Comment[it]=Il dispositivo Bluetooth è stato rilevato +Comment[ja]=Bluetooth デバイスを検出しました +Comment[lt]=Aptiktas naujas bluetooth įrenginys +Comment[nl]=Het Bluetooth-apparaat is gevonden +Comment[pa]=ਬਲਿਊਟੁੱਥ ਜੰਤਰ ਨਹੀਂ ਮਿਲਿਆ ਹੈ +Comment[pl]=Znaleziono urządzenie Bluetooth +Comment[pt]=Foi detectado um dispositivo Bluetooth +Comment[pt_BR]=Foi detectado um dispositivo Bluetooth +Comment[sr]=Bluetooth уређај је пронађен +Comment[sr@Latn]=Bluetooth уређај је пронађен +Comment[sv]=Blåtandsenheten detekterades +Comment[ta]=புலுடுத் கருவி கண்டறிய பட்டது +Comment[tg]=Дастгоҳи Bluetooth пайдо шуд +Comment[tr]=Bluetooth aygıtı bulundu +default_presentation=21 +default_sound=KDE_Dialog_Appear.wav + +[NoChannelFound] +Name=NoChannelFound +Name[bg]=Не е открит канал +Name[de]=KeinKanalGefunden +Name[el]=Δε βρέθηκε κανάλι +Name[es]=No se encontró el canal +Name[et]=Kanaleid pole +Name[fr]=Aucun Canal trouvé +Name[it]=NessunCanaleTrovato +Name[lt]=Neaptiktas joks kanalas +Name[nl]=Geen kanaal gevonden +Name[pl]=Kanał nie odnaleziony +Name[pt]=Nenhum Canal Encontrado +Name[pt_BR]=Nenhum Canal Encontrado +Name[sr]=Није нађен канал +Name[sr@Latn]=Није нађен канал +Name[sv]=Ingen kanal hittades +Name[ta]=அலைவரிசை எதுவும் கிடைக்கவில்லை +Name[tg]=Ягон канал ёфт нашуд +Comment=No channel could be assigned to a service +Comment[ar]=لم اتمكن من تعيين قناة للخدمة +Comment[bg]=Не е открит канал за услуга +Comment[bs]=Nisam mogao pridružiti kanal usluzi +Comment[ca]=No s'ha pogut assignar cap canal a un servei +Comment[da]=Ingen kanal kunne tilknyttes en tjeneste +Comment[de]=Es konnte dem Dienst kein Kanal zugeordnet werden +Comment[el]=Δε βρέθηκε κανάλι για την αντιστοίχηση με μια υπηρεσία +Comment[es]=No se pudo asignar ningún canal al servicio +Comment[et]=Teenusele pole võimalik kanalit eraldada +Comment[fr]=Aucun canal n'a pu être assigné au service +Comment[gl]=Non foi posíbel atribuir un canal ao servizo +Comment[it]=Nessun canale ha potuto essere assegnato a un servizio +Comment[ja]=サービスにチャネルを割り当てられませんでした +Comment[lt]=Tarnybai nepavyko priskirti jokio kanalo +Comment[nl]=Er kon geen kanaal worden toegewezen aan een dienst +Comment[pl]=Żaden kanał nie mógł zostać przypisany do urządzenia +Comment[pt]=Não foi possível atribuir um canal a um serviço +Comment[pt_BR]=Não foi possível atribuir um canal a um serviço +Comment[sr]=Нема канала који се може доделити услузи +Comment[sr@Latn]=Нема канала који се може доделити услузи +Comment[sv]=Någon kanal kunde inte tilldelas till en tjänst +Comment[ta]=சேவைக்கு எந்த ஒரு அலைவரிசையும் கோடுக்கபட வில்லை +default_presentation=15 +default_sound=KDE_Critical_Error.wav + +[ConnectionError] +Name=ConnectionError +Name[ar]=خطأ عند الاتصال +Name[bg]=Грешка при връзка +Name[br]=Fazi Kevreadur +Name[de]=Verbindungsfehler +Name[el]=Σφάλμα σύνδεσης +Name[es]=Error de conexión +Name[et]=Ühenduse viga +Name[fr]=Erreur de Connexion +Name[it]=ErroreDiConnessione +Name[lt]=Prisijungimo klaida +Name[nl]=Verbindingsfout +Name[pl]=Błąd połączenia +Name[pt]=Erro de Ligação +Name[pt_BR]=Erro de Ligação +Name[sr]=Грешка везе +Name[sr@Latn]=Грешка везе +Name[sv]=Anslutningsfel +Name[ta]=இனைப்பு பிழை +Name[tg]=Хатои пайвастшавӣ +Comment=Error while setting up a connection +Comment[ar]=خطأ عند أعداد الاتصال +Comment[bg]=Грешка при установяване на връзка +Comment[bs]=Greška prilikom podešavanja konekcije +Comment[ca]=Error mentre s'establia una connexió +Comment[da]=Fejl ved opsætning af en forbindelse +Comment[de]=Fehler beim Aufbauen einer Verbindung +Comment[el]=Σφάλμα κατά την εγκαθίδρυση μιας σύνδεσης +Comment[es]=Error durante la configuración de una conexión +Comment[et]=Viga ühenduse loomisel +Comment[fr]=Erreur lors de la mise en place de la connexion +Comment[gl]=Erro ao configurar unha conexón +Comment[it]=Errore durante l'impostazione di una connessione +Comment[ja]=接続のセットアップ中にエラーが発生しました +Comment[lt]=Klaida užmezgant ryšį +Comment[nl]=Fout bij het opzetten van een verbinding +Comment[pa]=ਕੁਨੈਕਸ਼ਨ ਬਣਾਉਣ ਦੌਰਾਨ ਗਲਤੀ ਆਈ ਹੈ +Comment[pl]=Błąd w trakcie przygotowywania połączenia +Comment[pt]=Ocorreu um erro ao configurar uma ligação +Comment[pt_BR]=Ocorreu um erro ao configurar uma ligação +Comment[sr]=Грешка при подешавању везе +Comment[sr@Latn]=Грешка при подешавању везе +Comment[sv]=Fel när en anslutning skulle upprättas +Comment[ta]=இனைப்பை அமைக்கையில் பிழை +Comment[tg]=Ҳангоми танзими пайвастшавӣ хато пайдо шуд +default_presentation=21 +default_sound=KDE_Error.wav diff --git a/src/tdebluez/main.cpp b/src/tdebluez/main.cpp new file mode 100644 index 0000000..6ef0336 --- /dev/null +++ b/src/tdebluez/main.cpp @@ -0,0 +1,83 @@ +/* + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <tdecmdlineargs.h> +#include <tdeaboutdata.h> +#include <iostream> + +#include "application.h" +static const char *description = I18N_NOOP( + "TDEBluetooth is a bluetooth manager\nfor the Trinity Desktop."); + +static TDECmdLineOptions options[] = +{ + { + "dontforceshow", + I18N_NOOP("Show the tray icon if it was disabled before."), + 0 + }, + { 0, 0, 0 } +}; + +extern "C" KDE_EXPORT int kdemain(int argc, char **argv) +{ + TDELocale::setMainCatalogue("tdebluez"); + TDEAboutData aboutData( "tdebluez", + I18N_NOOP("TDEBluetooth"), + 0, + description, + TDEAboutData::License_GPL, + "(c) 2018-, Emanoil Kotsev\n(c) 2003-2004, Fred Schaettgen", + 0, + "http://trinitydesktop.org"); + aboutData.addAuthor( "Emanoil Kotsev", + I18N_NOOP("Port to TDE and fundamental rework with Bluez5"), + "[email protected]"); + TDECmdLineArgs::init(argc, argv, &aboutData); + TDECmdLineArgs::addCmdLineOptions(options); + KUniqueApplication::addCmdLineOptions(); + + if (!KUniqueApplication::start()) + { + std::cerr << i18n("TDEBluetooth is already running.\n").local8Bit(); + return 0; + } + + TDEBluetoothApp a; + + if (!a.isConnected()) + { + KMessageBox::error(NULL, i18n("Can't connect to DBus!\nUnable to start tdebluez. \n\n \ + Restart dbus and the bluetooth service")); + // debug message for testing + std::cerr << i18n("Can't connect to DBus!\n").local8Bit(); + KUniqueApplication::kApplication()->quit(); + return 0; + } + else + { + return a.exec(); + } + +} + diff --git a/src/tdebluez/mediacontrol.cpp b/src/tdebluez/mediacontrol.cpp new file mode 100644 index 0000000..6d9afac --- /dev/null +++ b/src/tdebluez/mediacontrol.cpp @@ -0,0 +1,181 @@ +/* + * + * MediaControl for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <kdebug.h> + +#include <tqpushbutton.h> +#include <tqslider.h> +#include <kiconloader.h> +#include "mediacontrol.h" + +MediaControl::MediaControl(TQString path, TQT_DBusConnection *conn) : + MediaCtlDlg() +{ + pixStart = TDEGlobal::iconLoader()->loadIcon("media-playback-start", TDEIcon::Small, 22); + pixPause = TDEGlobal::iconLoader()->loadIcon("media-playback-pause", TDEIcon::Small, 22); + + tQPushButtonPlay->setPixmap(pixStart); + tQPushButtonSeekForward->setPixmap(TDEGlobal::iconLoader()->loadIcon("media-seek-forward", TDEIcon::Small, 22)); + tQPushButtonSeekBackward->setPixmap(TDEGlobal::iconLoader()->loadIcon("media-seek-backward", TDEIcon::Small, 22)); + tQPushButtonForward->setPixmap(TDEGlobal::iconLoader()->loadIcon("media-skip-forward", TDEIcon::Small, 22)); + tQPushButtonBackward->setPixmap(TDEGlobal::iconLoader()->loadIcon("media-skip-backward", TDEIcon::Small, 22)); + tQPushButtonStop->setPixmap(TDEGlobal::iconLoader()->loadIcon("media-playback-stop", TDEIcon::Small, 22)); + + tQVolumeSlider->setTracking(false); + tQVolumeSlider->setRange(0, 100); + volume = 50; + tQVolumeSlider->setValue(volume); + + mPath = path; + mediaCtlProxy = new org::bluez::MediaControl1Proxy("org.bluez", path); + mediaCtlProxy->setConnection((*(conn))); + + connect((TQObject*) tQPushButtonPlay, SIGNAL(clicked()), this, TQT_SLOT(slotPlay())); + connect((TQObject*) tQPushButtonPlay, SIGNAL(toggled(bool)), this, TQT_SLOT(slotPlayToggled(bool))); + connect((TQObject*) tQPushButtonSeekForward, SIGNAL(clicked()), this, TQT_SLOT(slotFastForward())); + connect((TQObject*) tQPushButtonSeekBackward, SIGNAL(clicked()), this, TQT_SLOT(slotRewind())); + connect((TQObject*) tQPushButtonForward, SIGNAL(clicked()), this, TQT_SLOT(slotNext())); + connect((TQObject*) tQPushButtonBackward, SIGNAL(clicked()), this, TQT_SLOT(slotPrevious())); + connect((TQObject*) tQPushButtonStop, SIGNAL(clicked()), this, TQT_SLOT(slotStop())); + // tQProgressSlider + connect((TQObject*) tQVolumeSlider, SIGNAL(valueChanged(int)), this, TQT_SLOT(slotVolumeValueChanged(int))); + // tQPushButtonRepeat + show(); +} + +MediaControl::~MediaControl() +{ + if (mediaCtlProxy) + delete mediaCtlProxy; +} + +//void MediaControl::closeMediaControl() +//{ +// +//} + +void MediaControl::slotPlay() +{ + kdDebug() << k_funcinfo << endl; + TQT_DBusError error; + mediaCtlProxy->Play(error); + if (error.isValid()) + tqDebug("Media Play failed: %s", error.message().local8Bit().data()); +} + +void MediaControl::slotPlayToggled(bool state) +{ + kdDebug() << k_funcinfo << endl; + if (state) + { + tQPushButtonPlay->setPixmap(pixPause); + } + else + { + slotPause(); + tQPushButtonPlay->setPixmap(pixStart); + } +} + +void MediaControl::slotStop() +{ + kdDebug() << k_funcinfo << endl; + TQT_DBusError error; + if (mediaCtlProxy->Stop(error)) + { + if (tQPushButtonPlay->isOn()) + tQPushButtonPlay->toggle(); + } + + if (error.isValid()) + tqDebug("Media Stop failed: %s", error.message().local8Bit().data()); +} + +void MediaControl::slotPause() +{ + kdDebug() << k_funcinfo << endl; + TQT_DBusError error; + mediaCtlProxy->Pause(error); + if (error.isValid()) + tqDebug("Media Pause failed: %s", error.message().local8Bit().data()); +} + +void MediaControl::slotNext() +{ + kdDebug() << k_funcinfo << endl; + TQT_DBusError error; + mediaCtlProxy->Next(error); + if (error.isValid()) + tqDebug("Media Next failed: %s", error.message().local8Bit().data()); +} + +void MediaControl::slotPrevious() +{ + kdDebug() << k_funcinfo << endl; + TQT_DBusError error; + mediaCtlProxy->Previous(error); + if (error.isValid()) + tqDebug("Media Previous failed: %s", error.message().local8Bit().data()); +} + +void MediaControl::slotFastForward() +{ + kdDebug() << k_funcinfo << endl; + TQT_DBusError error; + mediaCtlProxy->FastForward(error); + if (error.isValid()) + tqDebug("Media FastForward failed: %s", error.message().local8Bit().data()); +} + +void MediaControl::slotRewind() +{ + kdDebug() << k_funcinfo << endl; + TQT_DBusError error; + mediaCtlProxy->Rewind(error); + if (error.isValid()) + tqDebug("Media Rewind failed: %s", error.message().local8Bit().data()); +} + +void MediaControl::slotVolumeValueChanged(int val) +{ + kdDebug() << k_funcinfo << endl; + TQT_DBusError error; + if (val > volume) + { + TQT_DBusError error; + mediaCtlProxy->VolumeUp(error); + if (error.isValid()) + tqDebug("Media VolumeUp getPowered failed: %s", error.message().local8Bit().data()); + } + if (val < volume) + { + mediaCtlProxy->VolumeDown(error); + if (error.isValid()) + tqDebug("Media VolumeDown getPowered failed: %s", error.message().local8Bit().data()); + } + volume = val; +} + +#include "mediacontrol.moc" diff --git a/src/tdebluez/mediacontrol.h b/src/tdebluez/mediacontrol.h new file mode 100644 index 0000000..b096045 --- /dev/null +++ b/src/tdebluez/mediacontrol.h @@ -0,0 +1,66 @@ +/* + * + * MediaControl for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef MEDIACONTROL_H_INCLUDED +#define MEDIACONTROL_H_INCLUDED + +#include <kdialogbase.h> +#include <tqobject.h> + +#include <interfaces/mediacontrol1Proxy.h> +#include "mediactl.h" + +class MediaControl: public MediaCtlDlg +{ + Q_OBJECT + +public: + MediaControl(TQString path, TQT_DBusConnection* conn); + ~MediaControl(); +// void closeMediaControl(); + +public slots: + void slotPlay(); + void slotPlayToggled(bool); + void slotStop(); + void slotPause(); + void slotNext(); + void slotPrevious(); + void slotFastForward(); + void slotRewind(); + void slotVolumeValueChanged(int); + +private: + TQString mPath; + int volume; + org::bluez::MediaControl1Proxy *mediaCtlProxy; + TQPixmap pixStart; + TQPixmap pixPause; + +}; + +#endif //MEDIACONTROL_H_INCLUDED + +// End of File diff --git a/src/tdebluez/mediactl.ui b/src/tdebluez/mediactl.ui new file mode 100644 index 0000000..877969e --- /dev/null +++ b/src/tdebluez/mediactl.ui @@ -0,0 +1,265 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>MediaCtlDlg</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>MediaCtlDlg</cstring> + </property> + <property name="geometry"> + <rect> + <x>1</x> + <y>0</y> + <width>140</width> + <height>140</height> + </rect> + </property> + <property name="minimumSize"> + <size> + <width>140</width> + <height>140</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>140</width> + <height>140</height> + </size> + </property> + <property name="caption"> + <string>Media Control</string> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>10</y> + <width>120</width> + <height>120</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQSlider" row="1" column="1"> + <property name="name"> + <cstring>tQVolumeSlider</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="tickmarks"> + <enum>NoMarks</enum> + </property> + </widget> + <widget class="TQSlider" row="2" column="0"> + <property name="name"> + <cstring>tQProgressSlider</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="tickmarks"> + <enum>Below</enum> + </property> + </widget> + <widget class="TQLabel" row="0" column="1"> + <property name="name"> + <cstring>pixmapAudio</cstring> + </property> + <property name="pixmap"> + <pixmap>image0</pixmap> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + </widget> + <widget class="TQLayoutWidget" row="0" column="0" rowspan="2" colspan="1"> + <property name="name"> + <cstring>layoutButtons</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQPushButton" row="0" column="1"> + <property name="name"> + <cstring>tQPushButtonPlay</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string>></string> + <comment>Play</comment> + </property> + <property name="accel"> + <string></string> + </property> + <property name="toggleButton"> + <bool>true</bool> + </property> + </widget> + <widget class="TQPushButton" row="1" column="2"> + <property name="name"> + <cstring>tQPushButtonSeekForward</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string>>></string> + <comment>Seek Forward</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + <widget class="TQPushButton" row="0" column="2"> + <property name="name"> + <cstring>tQPushButtonForward</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string>>|</string> + <comment>Next</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + <widget class="TQPushButton" row="1" column="0"> + <property name="name"> + <cstring>tQPushButtonSeekBackward</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string><<</string> + <comment>Seek Back</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + <widget class="TQPushButton" row="0" column="0"> + <property name="name"> + <cstring>tQPushButtonBackward</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string>|<</string> + <comment>Previous</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + <widget class="TQPushButton" row="1" column="1"> + <property name="name"> + <cstring>tQPushButtonStop</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="text"> + <string>-</string> + <comment>Stop</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + </grid> + </widget> + <widget class="TQPushButton" row="2" column="1"> + <property name="name"> + <cstring>tQPushButtonRepeat</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image1</pixmap> + </property> + <property name="accel"> + <string></string> + </property> + <property name="toggleButton"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> +</widget> +<images> + <image name="image0"> + <data format="PNG" length="389">89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af40000000473424954080808087c0864880000013c494441545885edd44d8a22311887f19f3078010fe6091457e2815c097e5d4711575e4010541475a1961f65f52a3da4a9699a1eed81a1febba4429ee74dbd09458a1429f28f53fa415696c7fef553e06ab50a2a958a5eaff7fef1950219349b4dd06eb741abd58a16bd42208346a3118167b359eee2670a6450abd540a7d389c0cbe5f2650211b8dbed82d3e91481e7f3f9d30572c1c7e3118cc7e308bc5eaf9f26108187c321381c0e60341a81cd66f329f83b0219d4eb7530180cc07ebfc7ef8ac378b55a7d69d3af084415f7fbfd08349d4ea3f162b10097cbe5af05a2eb14ba3a1c750087a30ef301fc783cbe2d900bfed85ca1e200de6eb7e07ebf835229ff954fd3f453812cfce38fe0d05cb7db0dec76bb77709aa6cee7b324496459e67abd4a922457205ccf3f09984c26a05c2ee76e50a4489122ff5dde0051dcb85173c955470000000049454e44ae426082</data> + </image> + <image name="image1"> + <data format="PNG" length="854">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000000473424954080808087c0864880000030d49444154388dedd55b4814511807f0ff9999bdccec2415ae9bb8ed206e51b151490f5eb6d8cca8a7e862659715840a89ae04fa20928291866117e8c5a790a82028eaa17a88322c82a848964d0da92ca4a0dad471e7d4ceecd743bab86169906f7df03d9c0bbf73f8387c871111a623846951ffc3e3431a3f608c89001c00c4291e9a046001f84644d6843063cc595357332fb422d862936c45494aaa93a982200c9b09abf3c1fd7bd58cb13e2232d2e0402060afae3e12280d85eecef5fa94acac3992ec94c1184b4b207dccb931a3fffddb3562a9f0c834ad924020d0158944bea7e0bcbcbcccc260715376768ea2aa19e2d3e74f74ce8d496f2c3b157de18245ae2cb7472e0c16357577f755001848c19aa6cdb49256414e768ef4f071a76e18c69eb28ddb2e4f065fbd76a5fcd98ba76df94b97abaffa7a0b344d9b39060b00e0f57a338c78dce574ca88c5bea8534101a06ce3b6cb5f6331d566b3c1881b2eafd79b91aa3f00f8fd7e99733e5a373e1533159c735856029c73f8fd7e796c5e02009fcf270f3ce907f067f8fcf9b34126b23b8c61b86aef813963b0699ae09cc3b7d897820500d0340d969534e2c608ec36bbded2da5cfe2b7aea54739089ecd6d62ddb157d64c403002dadcde5a228ea834383304dd3d0340d69b0dbedd615598946225d66c9aa5297c36e6f6b3c514f4d271b3f00c0f1e686a060136f55842b55d929431004de78a29e24496a5bb62cdfd5dbdb6329b21275bbdd7a5a290044d7ac5ed77ef1d285854585c58e1de56175d6acd938d650eb01b0548070a96cd3565512258cc475ecda59e14c9809c4625fd4972fa3564f77f7f75d3b2adb0144c76036ae1f075ebfee5b77e3e6f5f0a7cf9fe673ce9d8aac0c35d41f3ffaa0f3bebfa3a3e3f0a183471cc9a489b3e75a13c3c3bacd6e77189999993d1bd66fbe989b9b7b1b4024550b221a9f1e225a4b446122aa22a2dd44944f44a17b1d775b6aeb6a78ffbb37b4ff60158dae8747f77b7e71d29b10808f00ee4cf020586865892832493c7da6759fa2b8bee167036affdd0b627ff1353100c500960020009d00bafe05fc57316d8dfe07fa3155dcf5eed88b0000000049454e44ae426082</data> + </image> +</images> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/tdebluez/mediaplayer.ui b/src/tdebluez/mediaplayer.ui new file mode 100644 index 0000000..f3c796b --- /dev/null +++ b/src/tdebluez/mediaplayer.ui @@ -0,0 +1,253 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>MediaCtlDlg</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>MediaCtlDlg</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>257</width> + <height>178</height> + </rect> + </property> + <property name="caption"> + <string>Media Control</string> + </property> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>10</y> + <width>247</width> + <height>159</height> + </rect> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQSlider" row="1" column="1"> + <property name="name"> + <cstring>tQVolumeSlider</cstring> + </property> + <property name="orientation"> + <enum>Vertical</enum> + </property> + <property name="tickmarks"> + <enum>NoMarks</enum> + </property> + </widget> + <widget class="TQSlider" row="2" column="0"> + <property name="name"> + <cstring>tQProgressSlider</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="tickmarks"> + <enum>Below</enum> + </property> + </widget> + <widget class="TQLabel" row="0" column="1"> + <property name="name"> + <cstring>pixmapAudio</cstring> + </property> + <property name="pixmap"> + <pixmap>image0</pixmap> + </property> + <property name="scaledContents"> + <bool>true</bool> + </property> + </widget> + <widget class="TQLayoutWidget" row="0" column="0" rowspan="2" colspan="1"> + <property name="name"> + <cstring>layoutButtons</cstring> + </property> + <grid> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQPushButton" row="0" column="1"> + <property name="name"> + <cstring>tQPushButtonPlay</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="text"> + <string>></string> + <comment>Play</comment> + </property> + <property name="accel"> + <string></string> + </property> + <property name="toggleButton"> + <bool>true</bool> + </property> + </widget> + <widget class="TQPushButton" row="1" column="2"> + <property name="name"> + <cstring>tQPushButtonSeekForward</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>31</width> + <height>32</height> + </size> + </property> + <property name="text"> + <string>>></string> + <comment>Seek Forward</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + <widget class="TQPushButton" row="0" column="2"> + <property name="name"> + <cstring>tQPushButtonForward</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="text"> + <string>>|</string> + <comment>Next</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + <widget class="TQPushButton" row="1" column="0"> + <property name="name"> + <cstring>tQPushButtonSeekBackward</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="text"> + <string><<</string> + <comment>Seek Back</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + <widget class="TQPushButton" row="0" column="0"> + <property name="name"> + <cstring>tQPushButtonBackward</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="text"> + <string>|<</string> + <comment>Previous</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + <widget class="TQPushButton" row="1" column="1"> + <property name="name"> + <cstring>tQPushButtonStop</cstring> + </property> + <property name="minimumSize"> + <size> + <width>22</width> + <height>22</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>32</width> + <height>32</height> + </size> + </property> + <property name="text"> + <string>-</string> + <comment>Stop</comment> + </property> + <property name="accel"> + <string></string> + </property> + </widget> + </grid> + </widget> + <widget class="TQPushButton" row="2" column="1"> + <property name="name"> + <cstring>tQPushButtonRepeat</cstring> + </property> + <property name="text"> + <string></string> + </property> + <property name="pixmap"> + <pixmap>image1</pixmap> + </property> + <property name="accel"> + <string></string> + </property> + <property name="toggleButton"> + <bool>true</bool> + </property> + </widget> + </grid> + </widget> +</widget> +<images> + <image name="image0"> + <data format="PNG" length="389">89504e470d0a1a0a0000000d4948445200000020000000200806000000737a7af40000000473424954080808087c0864880000013c494441545885edd44d8a22311887f19f3078010fe6091457e2815c097e5d4711575e4010541475a1961f65f52a3da4a9699a1eed81a1febba4429ee74dbd09458a1429f28f53fa415696c7fef553e06ab50a2a958a5eaff7fef1950219349b4dd06eb741abd58a16bd42208346a3118167b359eee2670a6450abd540a7d389c0cbe5f2650211b8dbed82d3e91481e7f3f9d30572c1c7e3118cc7e308bc5eaf9f26108187c321381c0e60341a81cd66f329f83b0219d4eb7530180cc07ebfc7ef8ac378b55a7d69d3af084415f7fbfd08349d4ea3f162b10097cbe5af05a2eb14ba3a1c750087a30ef301fc783cbe2d900bfed85ca1e200de6eb7e07ebf835229ff954fd3f453812cfce38fe0d05cb7db0dec76bb77709aa6cee7b324496459e67abd4a922457205ccf3f09984c26a05c2ee76e50a4489122ff5dde0051dcb85173c955470000000049454e44ae426082</data> + </image> + <image name="image1"> + <data format="PNG" length="854">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000000473424954080808087c0864880000030d49444154388dedd55b4814511807f0ff9999bdccec2415ae9bb8ed206e51b151490f5eb6d8cca8a7e862659715840a89ae04fa20928291866117e8c5a790a82028eaa17a88322c82a848964d0da92ca4a0dad471e7d4ceecd743bab86169906f7df03d9c0bbf73f8387c871111a623846951ffc3e3431a3f608c89001c00c4291e9a046001f84644d6843063cc595357332fb422d862936c45494aaa93a982200c9b09abf3c1fd7bd58cb13e2232d2e0402060afae3e12280d85eecef5fa94acac3992ec94c1184b4b207dccb931a3fffddb3562a9f0c834ad924020d0158944bea7e0bcbcbcccc260715376768ea2aa19e2d3e74f74ce8d496f2c3b157de18245ae2cb7472e0c16357577f755001848c19aa6cdb49256414e768ef4f071a76e18c69eb28ddb2e4f065fbd76a5fcd98ba76df94b97abaffa7a0b344d9b39060b00e0f57a338c78dce574ca88c5bea8534101a06ce3b6cb5f6331d566b3c1881b2eafd79b91aa3f00f8fd7e99733e5a373e1533159c735856029c73f8fd7e796c5e02009fcf270f3ce907f067f8fcf9b34126b23b8c61b86aef813963b0699ae09cc3b7d897820500d0340d969534e2c608ec36bbded2da5cfe2b7aea54739089ecd6d62ddb157d64c403002dadcde5a228ea834383304dd3d0340d69b0dbedd615598946225d66c9aa5297c36e6f6b3c514f4d271b3f00c0f1e686a060136f55842b55d929431004de78a29e24496a5bb62cdfd5dbdb6329b21275bbdd7a5a290044d7ac5ed77ef1d285854585c58e1de56175d6acd938d650eb01b0548070a96cd3565512258cc475ecda59e14c9809c4625fd4972fa3564f77f7f75d3b2adb0144c76036ae1f075ebfee5b77e3e6f5f0a7cf9fe673ce9d8aac0c35d41f3ffaa0f3bebfa3a3e3f0a183471cc9a489b3e75a13c3c3bacd6e77189999993d1bd66fbe989b9b7b1b4024550b221a9f1e225a4b446122aa22a2dd44944f44a17b1d775b6aeb6a78ffbb37b4ff60158dae8747f77b7e71d29b10808f00ee4cf020586865892832493c7da6759fa2b8bee167036affdd0b627ff1353100c500960020009d00bafe05fc57316d8dfe07fa3155dcf5eed88b0000000049454e44ae426082</data> + </image> +</images> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/tdebluez/tdebluez.autostart.desktop b/src/tdebluez/tdebluez.autostart.desktop new file mode 100644 index 0000000..4ac8608 --- /dev/null +++ b/src/tdebluez/tdebluez.autostart.desktop @@ -0,0 +1,44 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=TDEBluetooth +Name[sv]=TDEBluetooth +GenericName=TDE Bluetooth Daemon +GenericName[ar]=مراقب TDE Bluetooth +GenericName[bg]=Демон за Bluetooth в TDE +GenericName[br]=Diaoul TDE Bluetooth +GenericName[bs]=TDE Bluetooth daemon +GenericName[ca]=Dimoni Bluetooth de TDE +GenericName[cs]=Bluetooth démon pro TDE +GenericName[da]=TDE Bluetooth-dæmon +GenericName[de]=TDE Bluetooth-Daemon +GenericName[el]=Ο δαίμονας Bluetooth του TDE +GenericName[es]=Daemon Bluetooth de TDE +GenericName[et]=TDE Bluetoothi deemon +GenericName[fr]=Démon TDE Bluetooth +GenericName[gl]=Servizo Bluetooth de TDE +GenericName[it]=Demone Bluetooth di TDE +GenericName[ja]=TDE Bluetooth デーモン +GenericName[lt]=TDE Bluetooth tarnyba +GenericName[nl]=TDE Bluetooth-daemon +GenericName[pa]=TDE ਬਲਿਊਟੁੱਥ ਡਾਈਮੋਨ +GenericName[pl]=Demon Bluetooth dla TDE +GenericName[pt]=Serviço Bluetooth do TDE +GenericName[pt_BR]=Serviço Bluetooth do TDE +GenericName[ru]=Служба TDE Bluetooth +GenericName[sr]=Bluetooth демон за TDE +GenericName[sr@Latn]=Bluetooth demon za TDE +GenericName[sv]=TDE-Blåtandsdemon +GenericName[ta]=TDE புலுடுத் டேமொன் +GenericName[tg]=Даймони TDE Bluetooth +GenericName[tr]=TDE Bluetooth Servisi +Exec=tdebluez +Icon=tdebluez +Type=Application +X-DocPath=tdebluez/index.html +Terminal=false +X-TDE-autostart-after=panel +X-TDE-StartupNotify=false +X-DCOP-ServiceType=Unique +#X-TDE-Library=klipper_panelapplet +#X-TDE-UniqueApplet=true +X-TDE-autostart-condition=tdebluezrc:General:AutoStart:false diff --git a/src/tdebluez/tdebluez.desktop b/src/tdebluez/tdebluez.desktop new file mode 100644 index 0000000..10c037f --- /dev/null +++ b/src/tdebluez/tdebluez.desktop @@ -0,0 +1,61 @@ +[Desktop Entry] +Encoding=UTF-8 +Exec=tdebluez +Icon=tdebluez +Type=Application +Name=tdebluez +Name[en]=tdebluez +GenericName=Bluetooth Server +GenericName[ar]=خادم Bluetooth +GenericName[bg]=Сървър за Bluetooth +GenericName[br]=Servijer Bluetooth +GenericName[ca]=Servidor Bluetooth +GenericName[cs]=Bluetooth server +GenericName[da]=Bluetooth-server +GenericName[de]=Bluetooth-Server +GenericName[el]=Εξυπηρετητής Bluetooth +GenericName[es]=Servidor Bluetooth +GenericName[et]=Bluetoothi server +GenericName[fr]=Services Bluetooth +GenericName[ga]=Freastalaí Bluetooth +GenericName[gl]=Servidor Bluetooth +GenericName[it]=Server Bluetooth +GenericName[ja]=Bluetooth サーバ +GenericName[lt]=Bluetooth serveris +GenericName[nl]=Bluetooth-dienst +GenericName[pa]=ਬਲਿਊਟੁੱਥ ਸਰਵਰ +GenericName[pl]=Serwer Bluetooth +GenericName[pt]=Servidor Bluetooth +GenericName[pt_BR]=Servidor Bluetooth +GenericName[sr]=Bluetooth сервер +GenericName[sr@Latn]=Bluetooth server +GenericName[sv]=Blåtandserver +GenericName[tg]=Хидматгоҳи Bluetooth +GenericName[tr]=Bluetooth Sunucusu +GenericName[xx]=xxBluetooth Serverxx +Categories=Qt;TDE;System;Monitor; +OnlyShowIn=TDE; +Comment=TDE Bluetooth Framework Metaserver +Comment[bg]=Мета сървър за Bluetooth Framework +Comment[bs]=TDE Bluetooth framework metaserver +Comment[ca]=Meta-servidor de l'estructura Bluetooth de TDE +Comment[da]=TDE Bluetooth-skelet metaserver +Comment[de]=TDE Bluetooth-Framework Metaserver +Comment[el]=Πλαίσιο στήριξης εξυπηρετητή Bluetooth του TDE +Comment[es]=Metaservidor del marco de trabajo Bluetooth de TDE +Comment[et]=TDE Bluetooth raamistiku metaserver +Comment[fr]=Méta-serveur de l'interface TDE Bluetooth +Comment[gl]=Meta-servidor da Infra-estrutura Bluetooth de TDE +Comment[it]=Metaserver dell'infrastruttura Bluetooth di TDE +Comment[ja]=TDE Bluetooth フレームワーク メタサーバ +Comment[lt]=TDE Bluetooth aplinkos meta serveris +Comment[pl]=Metaserwer szkieletu TDE Bluetooth +Comment[pt]=Meta-servidor da Infra-estrutura Bluetooth do TDE +Comment[pt_BR]=Meta-servidor da Infra-estrutura Bluetooth do TDE +Comment[sr]=Bluetooth оквирни метасервер за TDE +Comment[sr@Latn]=Bluetooth okvirni metaserver za TDE +Comment[sv]=Metaserver för TDE:s Blåtandsramverk +Comment[ta]=TDE புலுடுத் சட்ட வேலை மேட்டா சேவகன் +Comment[tr]=TDE Bluetooth Ortamı Meta Sunucusu +Comment[xx]=xxTDE Bluetooth Framework Metaserverxx + diff --git a/src/tdebluez/trayicon.cpp b/src/tdebluez/trayicon.cpp new file mode 100644 index 0000000..3f56194 --- /dev/null +++ b/src/tdebluez/trayicon.cpp @@ -0,0 +1,806 @@ +/* + * + * TrayIcon for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <objectmanagerImpl.h> +#include <adapterImpl.h> + +#include "application.h" + +#include "trayicon.h" + +#define PIXMAP_LOGO "tdebluez" +#define HELP_DOCUMENT "tdebluez/components.html#components.TDEBluetooth" +#define PROCESS_KINPUTWIZARD "kinputwizard" +#define PROCESS_KBLUEMON "kbluemon" +#define PROCESS_KBLUELOCK "kbluelock" + + +using namespace TDEBluetooth; + +TrayIcon::TrayIcon(TDEBluetoothApp* _app) +{ + app = _app; + + iconConnectingBlinkState = false; + helpMenu = new KHelpMenu(this, TDEApplication::kApplication()->aboutData()); + + adapterConfigDialog = new AdapterConfigDialog(app); + deviceWizard = new DeviceWizard(app); + +// alwaysVisible was part of the old code and is to be decided if we need it in the future +// the idea is that the tray icon may be invisible if desired +// config->setGroup("UI"); +// alwaysVisible = config->readBoolEntry("alwaysVisible", true); + + bool agentstate = app->getStartAuthAgent(); + bool obexserver = app->getStartObex(); + bool autostart = app->getAutoStart(); + +// blinkTimer = new TQTimer(this); +// connect(blinkTimer, SIGNAL(timeout()), this, TQT_SLOT(slotSearchIcon())); + +// This following commented out lines are also part of the old code +// They represent features that were not migrated to Bluez5 +// KBlueMon +//// kbluemonAction = new TDEAction(tr("KBlue&Mon"), +//// TDEGlobal::iconLoader()->loadIcon("info", TDEIcon::Small, 16), +//// TDEShortcut::null(), this, "kbluemon"); +//// connect(kbluemonAction, SIGNAL(activated()), this, SLOT(slotkbluemonitor())); +//// +//// // KBlueLock +//// kbluelockAction = new TDEAction(tr("KBlue&Lock"), +//// TDEGlobal::iconLoader()->loadIcon("kbluelock", TDEIcon::Small, 16), +//// TDEShortcut::null(), this, "kbluelock"); +//// connect(kbluelockAction, SIGNAL(activated()), this, SLOT(slotkbluelock())); +//// +//// // KBtobexclient +//// kbtobexclientAction = new TDEAction(tr("&Send File..."), +//// TDEGlobal::iconLoader()->loadIcon("attach", TDEIcon::Small, 16), +//// TDEShortcut::null(), this, "kbtobexclient"); +//// connect(kbtobexclientAction, SIGNAL(activated()), this, SLOT(slotkbtobexclient())); +//// +// // BT switch + bool anyPowered = false; + TDEBluetoothApp::AdaptersMap::iterator it = app->adapters.begin(); + for (it; it != app->adapters.end(); ++it) + { + // slotAddAdapter(it.key()); + TQT_DBusError dbuserr; + bool powered = app->adapters[it.key()]->getPowered(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + TQString name = app->adapters[it.key()]->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); + + TQString msg; + if (powered) { + anyPowered = powered; + msg = tr("Power off [%1]").arg(name); + } + else + { + msg = tr("Power on [%1]").arg(name); + } + + TDEToggleAction *ad_a = new TDEToggleAction(this, name.utf8()); + ad_a->setText(msg); + ad_a->setChecked(powered); + + showPowerOnActionMap.insert(it.key(), ad_a); + connect(ad_a, SIGNAL(toggled(bool)), this, TQT_SLOT(slotPowerOn(bool))); + + } + + // Configuration menu + configActionMenu = new TDEActionMenu(tr("&Configuration"), TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), this, "config_menu"); + + // Help menu + helpActionMenu = new TDEActionMenu(tr("&Help"), TDEGlobal::iconLoader()->loadIcon("help", TDEIcon::Small, 16), this, "help_menu"); + + // show documentation + showHelpAction = KStdAction::help(this, TQT_SLOT(slotShowHelp()), actionCollection()); + + // "About" menu item + aboutAction = KStdAction::aboutApp(this, TQT_SLOT(slotAbout()), actionCollection()); + +// // Inputdevice configuration +// inputConfigAction = new TDEAction(tr("&Input Devices..."), +// TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), +// TDEShortcut::null(), this, "input_config"); +// connect(inputConfigAction, SIGNAL(activated()), this, SLOT(slotInputConfig())); + + // Bluetooth Device configuration + // from 06_rev748007.patch + deviceConfigAction = new TDEAction(tr("&Devices..."), TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), TDEShortcut::null(), this, "device_config"); + connect(deviceConfigAction, SIGNAL(activated()), this, TQT_SLOT(slotDeviceConfig())); + + // Bluetooth Adapter configuration + adapterConfigAction = new TDEAction(tr("&Adapters..."), TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), TDEShortcut::null(), this, "adapter_config"); + connect(adapterConfigAction, SIGNAL(activated()), this, TQT_SLOT(slotAdapterConfig())); + +// // Paired device configuration +// pairedConfigAction = new TDEAction(tr("&Paired/Trusted Devices..."), +// TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), +// TDEShortcut::null(), this, "paired_config"); +// connect(pairedConfigAction, SIGNAL(activated()), this, SLOT(slotPairedConfig())); + + // Autostart switch + autostartIconAction = new TDEToggleAction(this, "autostart"); + connect(autostartIconAction, SIGNAL(toggled(bool)), this, TQT_SLOT(slotIconAutostartToggled(bool))); + autostartIconAction->setChecked(autostart); + autostartIconAction->setText(tr("&Auto Start")); + + // Agent switch + agentIconAction = new TDEToggleAction(this, "tdeauthagent"); + connect(agentIconAction, SIGNAL(toggled(bool)), this, TQT_SLOT(slotIconAgentToggled(bool))); + agentIconAction->setChecked(agentstate); + agentIconAction->setText(tr("Auth A&gent")); + + // Obexsrv switch + obexIconAction = new TDEToggleAction(this, "tdebtobexsrv"); + connect(obexIconAction, SIGNAL(toggled(bool)), this, TQT_SLOT(slotIconObexToggled(bool))); + obexIconAction->setChecked(obexserver); + obexIconAction->setText(tr("&Obex Server")); + + slotIconAgentToggled(agentstate); + slotIconObexToggled(obexserver); + +// // Always-visible switch +// showIconAction = new TDEToggleAction(this, "always_visible"); +// connect(showIconAction, SIGNAL(toggled(bool)), this, SLOT(slotShowIconToggled(bool))); +// showIconAction->setChecked(alwaysVisible); +// showIconAction->setText(tr("Always &Visible")); +// configActionMenu->insert(showIconAction); + + KPixmap logoPixmap = TDEGlobal::iconLoader()->loadIcon(PIXMAP_LOGO, TDEIcon::Small, 22); + iconIdle = logoPixmap; + iconOff = logoPixmap; + iconConnected = logoPixmap; + iconNoAdapter = logoPixmap; + KPixmapEffect::toGray(iconOff); + KPixmapEffect::fade(iconOff, 0.3, TQColor(255, 255, 255)); + KPixmapEffect::fade(iconConnected, 0.5, TQColor(255, 0, 0)); + KPixmapEffect::toGray(iconNoAdapter); + KPixmapEffect::fade(iconNoAdapter, 0.5, TQColor(128, 128, 128)); + + setupTray(anyPowered); + + connect(app, SIGNAL(signalAdapterAdded(const TQString&)), this, TQT_SLOT(slotAddAdapter(const TQString&))); + connect(app, SIGNAL(signalAdapterRemoved(const TQString&)), this, TQT_SLOT(slotRemoveAdapter(const TQString&))); + + connect(app->manager, SIGNAL(adapterPowerOnChanged(const TQString&, bool)), this, TQT_SLOT(slotPowerOnChanged(const TQString&, bool))); + connect(app->manager, SIGNAL(adapterNameChanged(const TQString&, const TQString&)), this, TQT_SLOT(slotUpdateToolTip(const TQString&, const TQString&))); + connect(app->manager, SIGNAL(adapterAliasChanged(const TQString&, const TQString&)), this, TQT_SLOT(slotUpdateToolTip(const TQString&, const TQString&))); + connect(app->manager, SIGNAL(adapterNameChanged(const TQString&, const TQString&)), this, TQT_SLOT(slotAdapterAliasChanged(const TQString&, const TQString&))); + connect(app->manager, SIGNAL(adapterAliasChanged(const TQString&, const TQString&)), this, TQT_SLOT(slotAdapterAliasChanged(const TQString&, const TQString&))); + +// connect(app->manager, SIGNAL(adapterModeChanged(const TQString&, const TQString&)), this, TQT_SLOT(slotUpdateToolTip(const TQString&, const TQString&))); +// connect(app->manager, SIGNAL(adapterPowerOnChanged(const TQString&, bool)), this, TQT_SLOT(slotPowerOnChanged(const TQString&, bool))); + connect(app->manager, SIGNAL(adapterDiscoverableTimeoutChanged(const TQString&, TQ_UINT32)), + this, TQT_SLOT(slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32))); + connect(app->manager, SIGNAL(adapterDiscoverableChanged(const TQString&, bool)), + this, TQT_SLOT(slotDiscoverableChanged(const TQString&, bool))); +// connect(app->manager, SIGNAL(adapterDiscoveringChanged(const TQString&, bool)), this, TQT_SLOT(slotDiscoveringChanged(const TQString&, bool))); + connect(app->manager, SIGNAL(deviceConnectedChanged(const TQString&, bool)), this, TQT_SLOT(slotDeviceConnectedChanged(const TQString&, bool))); + + connect(adapterConfigDialog, SIGNAL(signalAdapterSelected(const TQString&, const TQString&)), + deviceWizard, TQT_SLOT(slotSetAdapter(const TQString&, const TQString&))); + connect(adapterConfigDialog, SIGNAL(signalAdapterSelected(const TQString&, const TQString&)), + this, TQT_SLOT(slotUpdateToolTip(const TQString&, const TQString&))); + + connect(this, SIGNAL(quitSelected()), this, SLOT(slotQuitSelected())); + +} + +TrayIcon::~TrayIcon() +{ + +// disconnect(app->manager, SIGNAL(deviceConnectedChanged(const TQString&, bool)), this, TQT_SLOT(slotDeviceConnectedChanged(const TQString&, bool))); +// disconnect(app->manager, SIGNAL(adapterNameChanged(const TQString&, const TQString&)), this, TQT_SLOT(slotUpdateToolTip(const TQString&, const TQString&))); +// disconnect(app->manager, SIGNAL(adapterAliasChanged(const TQString&, const TQString&)), this, TQT_SLOT(slotUpdateToolTip(const TQString&, const TQString&))); +//// disconnect(app->manager, SIGNAL(adapterModeChanged(const TQString&, const TQString&)), this, SLOT(slotUpdateToolTip(const TQString&, const TQString&))); +//// disconnect(app->manager, SIGNAL(adapterPowerOnChanged(const TQString&, bool)), this, TQT_SLOT(slotPowerOnChanged(const TQString&, bool))); +// disconnect(app->manager, SIGNAL(adapterDiscoverableTimeoutChanged(const TQString&, TQ_UINT32)), +// this, SLOT(slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32))); +// disconnect(app->manager, SIGNAL(adapterDiscoverableChanged(const TQString&, bool)), +// this, SLOT(slotDiscoverableChanged(const TQString&, bool))); +//// disconnect(app->manager, SIGNAL(adapterDiscoveringChanged(const TQString&, bool)), this, SLOT(slotDiscoveringChanged(const TQString&, bool))); + + if (deviceWizard) + delete deviceWizard; + if (adapterConfigDialog) + delete adapterConfigDialog; + + delete obexIconAction; + delete agentIconAction; + delete autostartIconAction; + delete adapterConfigAction; + delete deviceConfigAction; + delete helpActionMenu; + delete configActionMenu; + delete helpMenu; +} + +void TrayIcon::setupTray(bool enable) +{ + + // CONTEXT MENU + + // if (!kbluemonAction->isPlugged()) + // kbluemonAction->plug(contextMenu()); + // kbluemonAction->setEnabled(enable); + // + // if (!kbluelockAction->isPlugged()) + // kbluelockAction->plug(contextMenu()); + // kbluelockAction->setEnabled(enable); + // + // if (!kbtobexclientAction->isPlugged()) + // kbtobexclientAction->plug(contextMenu()); + // kbtobexclientAction->setEnabled(enable); + + TQMap<TQString, TDEToggleAction *>::iterator it = showPowerOnActionMap.begin(); + for (it; it != showPowerOnActionMap.end(); ++it) + { + if (!it.data()->isPlugged()) + it.data()->plug(contextMenu(), 1); + // The toggle should always be active in order to power on and off + it.data()->setEnabled(true); + } + + // device wizard + if (!deviceConfigAction->isPlugged()) + deviceConfigAction->plug(contextMenu()); + deviceConfigAction->setEnabled(enable); + + // adapter configuration + if (!adapterConfigAction->isPlugged()) + adapterConfigAction->plug(contextMenu()); + adapterConfigAction->setEnabled(enable); + + // the config menu + if (!configActionMenu->isPlugged()) + configActionMenu->plug(contextMenu()); + if (!showPowerOnActionMap.isEmpty()) + configActionMenu->setEnabled(true); + else + configActionMenu->setEnabled(false); + + // the help menu + if (!helpActionMenu->isPlugged()) + helpActionMenu->plug(contextMenu()); + + // the help sub menu + if (!showHelpAction->isPlugged()) + showHelpAction->plug(helpActionMenu->popupMenu()); + + // Report bug menu item + /* + TDEAction* reportBugAction = KStdAction::reportBug(this, + SLOT(slotReportBug()), actionCollection()); + helpActionMenu->insert(reportBugAction); + */ + + // ABOUT MENU + if (!aboutAction->isPlugged()) + aboutAction->plug(helpActionMenu->popupMenu()); + + // Menu entries: + // ------------- + + // // CONFIG MENU + // if (!inputConfigAction->isPlugged()) + // inputConfigAction->plug(configActionMenu->popupMenu()); + + // Service configuration + /* TODO: create BlueZ service UI + serviceConfigAction = new TDEAction(tr("Configure &Services..."), + TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), + TDEShortcut::null(), this, "service_config"); + connect(serviceConfigAction, SIGNAL(activated()), this, SLOT(slotServiceConfig())); + configActionMenu->insert(serviceConfigAction); + */ + + // if (!pairedConfigAction->isPlugged()) + // pairedConfigAction->plug(configActionMenu->popupMenu()); + // configure notifications + /* + TDEAction* notificationAction = KStdAction::configureNotifications(this, + SLOT(slotConfigureNotifications()), actionCollection()); + configActionMenu->insert(notificationAction); + */ + + // Autostart option + if (!autostartIconAction->isPlugged()) + autostartIconAction->plug(configActionMenu->popupMenu()); + + // Agent option + if (!agentIconAction->isPlugged()) + agentIconAction->plug(configActionMenu->popupMenu()); + + //Obex option + if (!obexIconAction->isPlugged()) + obexIconAction->plug(configActionMenu->popupMenu()); + + // if (!showIconAction->isPlugged()) + // showIconAction->plug(configActionMenu->popupMenu()); + + updateIcon(); + show(); +} + +void TrayIcon::updateIcon() +{ + TQString oldText = TQToolTip::textFor(this); + if (showPowerOnActionMap.isEmpty()) + { + setPixmap(iconNoAdapter); + updateTooltip(tr("No BT adapter")); + if (!this->isHidden()) + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "AdapterDetached", tr("<b>No BT adapter available.</b><br/>(BT adapter removed)")); + + adapterConfigAction->setEnabled(false); + deviceConfigAction->setEnabled(false); + return; + } + + TQT_DBusError dbuserr; + bool anyPowered = false; + TQString name; + TQString path; + TQMap<TQString, TDEToggleAction *>::iterator it = showPowerOnActionMap.begin(); + for (it; it != showPowerOnActionMap.end(); ++it) + { + anyPowered = app->adapters[it.key()]->getPowered(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + // know if any adapter is powered + if (anyPowered) + { + path = app->adapters[it.key()]->getPath(); + name = app->adapters[it.key()]->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); + break; + } + } + + if (anyPowered) + { + bool anyConnected = false; + TDEBluetoothApp::DevicesMap::Iterator dit = app->devices.begin(); + for (dit; dit != app->devices.end(); ++dit) + { + anyConnected = dit.data()->getConnected(dbuserr); + if (dbuserr.isValid()) + tqDebug("Check for connected device failed: %s", dbuserr.message().local8Bit().data()); + if (anyConnected) + break; + } + + if (anyConnected) + setPixmap(iconConnected); + else + setPixmap(iconIdle); + } + else + { + if (deviceWizard) + deviceWizard->hide(); + + if (adapterConfigDialog) + adapterConfigDialog->hide(); + + //if no other adapter was powered, use the first one for the tooltip + path = app->adapters.begin().data()->getPath(); + name = app->adapters.begin().data()->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); + + setPixmap(iconOff); + } + + slotUpdateToolTip(path, name); + + adapterConfigAction->setEnabled(anyPowered); + deviceConfigAction->setEnabled(anyPowered); +} + +void TrayIcon::slotIconAutostartToggled(bool state) +{ + app->setAutoStart(state); +} + +void TrayIcon::slotServiceConfig() +{ + kdDebug() << k_funcinfo << endl; +} + +void TrayIcon::slotAdapterConfig() +{ + adapterConfigDialog->show(); + adapterConfigDialog->raise(); +} + +void TrayIcon::slotDeviceConfig() +{ + deviceWizard->show(); + deviceWizard->raise(); + deviceWizard->setFocus(); +} + +void TrayIcon::slotInputConfig() +{ + TDEProcess process(0); + + process << PROCESS_KINPUTWIZARD; + if (!process.start(TDEProcess::DontCare)) + { + KMessageBox::information(this, tr("Could not execute kinputwizard."), tr("TDEBluetooth")); + } +} + +void TrayIcon::slotkbluemonitor() +{ + TDEProcess process(0); + process << PROCESS_KBLUEMON; + + if (!process.start(TDEProcess::DontCare)) + { + KMessageBox::information(this, tr("Could not execute KBlueMon."), tr("TDEBluetooth")); + } +} + +void TrayIcon::slotkbluelock() +{ + TDEProcess process(0); + process << PROCESS_KBLUELOCK; + + if (!process.start(TDEProcess::DontCare)) + { + KMessageBox::information(this, tr("Could not execute KBlueLock."), tr("TDEBluetooth")); + } +} + +void TrayIcon::slotIconObexToggled(bool state) +{ + app->setStartObex(state); + + if (state) + { + if (!app->startObexSrv()) + { + KMessageBox::information(this, tr("Could not start OBEX server."), tr("TDEBluetooth")); + } + } + else + { + if (!app->stopObexSrv()) + { + KMessageBox::information(this, tr("Could not stop OBEX server."), tr("TDEBluetooth")); + } + } +} + +void TrayIcon::slotIconAgentToggled(bool state) +{ + app->setStartAuthAgent(state); + + if (state) + { + if (!app->startAuthAgent()) + { + KMessageBox::information(this, tr("Could not start TDEBluez Authentication Agent."), tr("TDEBluetooth")); + } + } + else + { + if (!app->stopAuthAgent()) + { + KMessageBox::information(this, tr("Could not stop TDEBluez Authentication Agent."), tr("TDEBluetooth")); + } + } +} + +void TrayIcon::slotPowerOn(bool state) +{ + // who send the signal ? + const TQObject * o = TQObject::sender(); + const TDEToggleAction* obj = const_cast<TDEToggleAction*>(reinterpret_cast<const TDEToggleAction*>(o)); + TQMap<TQString, TDEToggleAction *>::Iterator it = showPowerOnActionMap.begin(); + + TQString path; + for (it; it != showPowerOnActionMap.end(); ++it) + { + if (obj == it.data()) + { + path = it.key(); + break; + } + } + + app->adapters[path]->powerOn(state); +} + +void TrayIcon::slotPowerOnChanged(const TQString &adapter, bool state) +{ + TQT_DBusError dbuserr; + TQString name = app->adapters[adapter]->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); + + TQString addr = app->adapters[adapter]->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAddress failed: %s", dbuserr.message().local8Bit().data()); + + if (name.isEmpty() && addr.isEmpty()) // adapter was removed + return; + + TQString msg; + if (state) + { + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "AdapterAvailable", tr("BT adapter <b>%1</b> is on<br/>(<b>%2</b>)").arg(name).arg(addr)); + msg = tr("Power off [%1]").arg(name); + } + else + { + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "AdapterAvailable", tr("BT adapter <b>%1</b> is off<br/>(<b>%2</b>)").arg(name).arg(addr)); + msg = tr("Power on [%1]").arg(name); + } + + showPowerOnActionMap[adapter]->setText(msg); + showPowerOnActionMap[adapter]->setChecked(state); + slotUpdateToolTip(adapter, name); + updateIcon(); +} + +void TrayIcon::slotDeviceConnectedChanged(const TQString& path, bool state) +{ + TQT_DBusError dbuserr; + TQString name = app->devices[path]->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Device getAlias failed: %s", dbuserr.message().local8Bit().data()); + TQString address = app->devices[path]->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAddress failed: %s", dbuserr.message().local8Bit().data()); + if (state) + { + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "IncomingConnection", tr("Connected to <b>%1</b> (<b>%2</b>)").arg(name).arg(address)); + } + else + { + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "IncomingConnection", tr("Disconnected from <b>%1</b> (<b>%2</b>)").arg(name).arg(address)); + } + updateIcon(); +} + +TQString TrayIcon::localAndEnglish(const TQCString& s) +{ + if (TQString(s) != tr(s)) + return TQString("%1 (\"%2\")").arg(tr(s)).arg(s); + else + return s; +} + +void TrayIcon::mousePressEvent(TQMouseEvent *e) +{ + if (e->button() == TQMouseEvent::LeftButton) + { +// TQMessageBox::information(this, +// tr("Use right click to open the menu"), +// tr("Left click is reserved for ObexFTP browsing.\n" +// "ObexFTP is subject of development.")); + e->accept(); + TDEProcess proc; + proc << "kfmclient" << "openURL" << "bluetooth:/"; + proc.start(TDEProcess::DontCare); + } + else + { + KSystemTray::mousePressEvent(e); + } +} + +void TrayIcon::slotQuitSelected() +{ + // Ask if the user want to simply quit or disable + // automatic start of TDEBluetooth + if (!autostartIconAction->isChecked()) + { + int autoStart = KMessageBox::questionYesNoCancel(0, + tr("Should TDEBluetooth still be restarted when you login?"), + tr("Automatically Start TDEBluetooth?"), + tr("Start"), + tr("Do Not Start")); + + if (autoStart == KMessageBox::Yes) + app->setAutoStart(true); + else if (autoStart == KMessageBox::No) + app->setAutoStart(false); + } +} + +void TrayIcon::slotShowHelp() +{ + // TODO: This is surely not the correct way to jump to the + // right chapter. Do I really have to mention the html-file, + // or is the id enough? + TDEApplication::kApplication()->invokeHelp("", HELP_DOCUMENT); +} + +void TrayIcon::slotAddAdapter(const TQString& path) +{ + kdDebug() << k_funcinfo << endl; // for debugging MicheleC report + TQT_DBusError dbuserr; + + bool powered = app->adapters[path]->getPowered(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + + TQString name = app->adapters[path]->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); + + TQString addr = app->adapters[path]->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getAddress failed: %s", dbuserr.message().local8Bit().data()); + + TQString msg; + if (powered) + msg = tr("Power off [%1]").arg(name); + else + msg = tr("Power on [%1]").arg(name); + + TDEToggleAction *ad_a = new TDEToggleAction(this, name.utf8()); + ad_a->setText(msg); + ad_a->setChecked(powered); + + showPowerOnActionMap.insert(path, ad_a); + connect(ad_a, SIGNAL(toggled(bool)), this, SLOT(slotPowerOn(bool))); + + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "AdapterAttached", tr("BT adapter <b>%1</b> attached<br/>(<b>%2</b>)").arg(name).arg(addr)); + + if(!powered) // find out if we have some powered adapter + { + TQMap<TQString, TDEToggleAction *>::iterator it = showPowerOnActionMap.begin(); + for (it; it != showPowerOnActionMap.end(); ++it) + { + powered = app->adapters[it.key()]->getPowered(dbuserr); + if (dbuserr.isValid()) + tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + // know if any adapter is powered + if (powered) + break; + } + } + + if (obexIconAction->isChecked()) + { + if (!app->obexServer->isRunning()) + app->startObexSrv(); + } + + if (agentIconAction->isChecked()) + { + if (!app->authAgent->isRunning()) + app->startAuthAgent(); + } + + setupTray(powered); +} + +void TrayIcon::slotRemoveAdapter(const TQString& path) +{ + kdDebug() << k_funcinfo << endl; // for debugging MicheleC report + disconnect(showPowerOnActionMap[path], SIGNAL(toggled(bool)), this, SLOT(slotPowerOn(bool))); + + if (showPowerOnActionMap[path]->isPlugged()) + showPowerOnActionMap[path]->unplug(contextMenu()); + showPowerOnActionMap.remove(path); + + KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), + "AdapterDetached", tr("BT adapter detached")); + + if (showPowerOnActionMap.isEmpty()) + { + if (deviceWizard) + deviceWizard->hide(); + if (adapterConfigDialog) + adapterConfigDialog->hide(); + if (app->obexServer->isRunning()) + app->stopObexSrv(); + if (app->authAgent->isRunning()) + app->stopAuthAgent(); + setupTray(false); + } + else + { + setupTray(true); + } +} + +void TrayIcon::slotAdapterAliasChanged(const TQString &path, const TQString &alias) +{ + // slotAddAdapter(it.key()); + TQT_DBusError dbuserr; + bool powered = showPowerOnActionMap[path]->isChecked(); + TQString msg; + if (powered) + msg = tr("Power off [%1]").arg(alias); + else + msg = tr("Power on [%1]").arg(alias); + showPowerOnActionMap[path]->setText(msg); +} + +void TrayIcon::slotDiscoverableTimeoutChanged(const TQString &path, TQ_UINT32 timeout) +{ + TQT_DBusError dbuserr; + TQString name = app->adapters[path]->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Error: %s", dbuserr.message().local8Bit().data()); + slotUpdateToolTip(path, name); +} + +void TrayIcon::slotDiscoverableChanged(const TQString &path, bool state) +{ + TQT_DBusError dbuserr; + TQString name = app->adapters[path]->getAlias(dbuserr); + if (dbuserr.isValid()) + tqDebug("Error: %s", dbuserr.message().local8Bit().data()); + slotUpdateToolTip(path, name); +} + +void TrayIcon::slotUpdateToolTip(const TQString& adapter, const TQString& name) +{ + TQT_DBusError dbuserr; + TQString addr = app->adapters[adapter]->getAddress(dbuserr); + if (dbuserr.isValid()) + tqDebug("Error: %s", dbuserr.message().local8Bit().data()); + TQString disc = + (app->adapters[adapter]->getDiscoverable(dbuserr)) ? "discoverable" : "hidden"; + if (dbuserr.isValid()) + tqDebug("Error: %s", dbuserr.message().local8Bit().data()); + + TQString newText = tr("Adapter: %1\nAddress: %2\nMode: %3\n").arg(name, addr, disc); + updateTooltip(newText); +} + +void TrayIcon::updateTooltip(const TQString &text) +{ + TQString oldText = TQToolTip::textFor(this); + if (oldText != text) + { + TQToolTip::remove(this); + TQToolTip::add(this, text); + } +} + +#include "trayicon.moc" diff --git a/src/tdebluez/trayicon.h b/src/tdebluez/trayicon.h new file mode 100644 index 0000000..b77b918 --- /dev/null +++ b/src/tdebluez/trayicon.h @@ -0,0 +1,160 @@ +/* + * + * TrayIcon for tdebluez + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluez. + * + * tdebluez 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 2 of the License, or + * (at your option) any later version. + * + * tdebluez is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef TRAYICON_H +#define TRAYICON_H + + +#include <tqtooltip.h> +#include <tdeconfig.h> +#include <tdepopupmenu.h> +#include <tdeactionclasses.h> + +#include <ksystemtray.h> +#include <khelpmenu.h> +#include <knotifydialog.h> +#include <knotifyclient.h> +#include <kprocess.h> + +#include "adapterconfigdialog.h" +#include "devicewizard.h" + +class TQTimer; +class TDEToggleAction; +class TDEAction; +class TDEActionMenu; +class TDEPopupMenu; +class KHelpMenu; +class TDEBluetoothApp; + +/** + @author Fred Schaettgen + */ +class TrayIcon: public KSystemTray +{ + Q_OBJECT + +public: + TrayIcon(TDEBluetoothApp* app); + ~TrayIcon(); + // void setAlwaysShowIcon(bool state); + +private slots: + // void slotQuitSelected(); + // void slotShowIconToggled(bool); + void slotServiceConfig(); + // void slotPairedConfig(); + void slotDeviceConfig(); + void slotAdapterConfig(); + void slotInputConfig(); + void slotkbluemonitor(); + void slotkbluelock(); + // void slotkbtobexclient(); + void slotConfigureNotifications() + { + KNotifyDialog::configure(this); + } + ; + void slotQuitSelected(); + void slotReportBug() + { + helpMenu->reportBug(); + } + ; + void slotAbout() + { + helpMenu->aboutApplication(); + } + ; + void slotShowHelp(); +// void slotSearchIcon(); + void slotIconAutostartToggled(bool state); + void slotIconAgentToggled(bool state); + void slotIconObexToggled(bool state); + // gui -> manager + void slotPowerOn(bool state); + // manager -> gui + void slotPowerOnChanged(const TQString&, bool); + void slotDeviceConnectedChanged(const TQString&, bool); + void slotAddAdapter(const TQString&); + void slotRemoveAdapter(const TQString&); + void slotDiscoverableTimeoutChanged(const TQString&, TQ_UINT32 timeout); + void slotDiscoverableChanged(const TQString&, bool state); + // void slotDiscoveringChanged(const TQString&, bool state); + void slotUpdateToolTip(const TQString& adapter, const TQString& name); + void slotAdapterAliasChanged(const TQString&, const TQString&); + +protected: + void mousePressEvent(TQMouseEvent *e); + +private: +// TQTimer *blinkTimer; + bool iconConnectingBlinkState; + + KHelpMenu *helpMenu; + TDEBluetoothApp* app; + + AdapterConfigDialog *adapterConfigDialog; // for BT Adapters + DeviceWizard *deviceWizard; // for BT Devices + + bool acceptClose; + KPixmap iconIdle; + KPixmap iconConnected; + KPixmap iconNoAdapter; + KPixmap iconOff; + + TDEToggleAction *agentIconAction; + TDEToggleAction *obexIconAction; + // TDEToggleAction *showIconAction; + TDEToggleAction *autostartIconAction; + TQMap<TQString, TDEToggleAction *> showPowerOnActionMap; + + TDEAction *serviceConfigAction; + // TDEAction *pairedConfigAction; + TDEAction *adapterConfigAction; + TDEAction *deviceConfigAction; + // TDEAction *inputConfigAction; + TDEAction *showHelpAction; + TDEAction *kbluemonAction; + TDEAction *kbluelockAction; + TDEAction *kbtobexclientAction; + TDEAction *aboutAction; + TDEActionMenu *configActionMenu; + TDEActionMenu *helpActionMenu; + + void setupTray(bool); + void updateIcon(); + + void updateTooltip(const TQString &text); + + TQString localAndEnglish(const TQCString& s); + +signals: + // void setObexSrv(bool); + void setPowerOn(bool); + +}; + +#endif diff --git a/src/tdebluezauth/CMakeLists.txt b/src/tdebluezauth/CMakeLists.txt new file mode 100644 index 0000000..055779d --- /dev/null +++ b/src/tdebluezauth/CMakeLists.txt @@ -0,0 +1,47 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +project( tdebluezauth ) + +# import required +#tde_import( lib... ) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR}/src/libtdebluez + ${CMAKE_BINARY_DIR}/src/libtdebluez + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +# ${DBUS_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### tdebluezauth (tdeinit) ###################### + +tde_add_executable( tdebluezauth AUTOMOC + SOURCES + authorize.cpp authdialog.ui + pindialog.cpp pindefdialog.ui + authservice.cpp application.cpp main.cpp + LINK + ${DBUS_TQT_LIBRARIES} tdebluez-shared bluezinterfaces-static + DESTINATION ${BIN_INSTALL_DIR} +) + +##### other data ################################ +#tde_install_icons( tdebluezauth ) +install( FILES tdebluezauth.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} ) diff --git a/src/tdebluezauth/application.cpp b/src/tdebluezauth/application.cpp new file mode 100644 index 0000000..3b1dec8 --- /dev/null +++ b/src/tdebluezauth/application.cpp @@ -0,0 +1,156 @@ +/* + * + * Authorization Agent implementation of bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluezauth. + * + * tdebluezauth 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 2 of the License, or + * (at your option) any later version. + * + * tdebluezauth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#include <tqdbusobjectpath.h> +#include <tdecmdlineargs.h> +#include <tdemessagebox.h> + +#include <adapterImpl.h> +#include "application.h" +#include "authservice.h" + +#define DBUS_AUTH_SERVICE "TDEBluezAuth" +#define DBUS_AUTH_SERVICE_NAME "org.trinitydesktop.tdebluez" + +TDEBluezAuth::TDEBluezAuth() : + KUniqueApplication() +{ + m_connection = TQT_DBusConnection::addConnection(TQT_DBusConnection::SystemBus, DBUS_AUTH_SERVICE); + + if (!m_connection.isConnected()) + { + kdError() << "Failed to open connection to system message bus: " << m_connection.lastError().message() << endl; + exit(-1); + } + + // try to get a specific service name + if (!m_connection.requestName(DBUS_AUTH_SERVICE_NAME)) + { + tqWarning("Requesting name %s failed. " + "The object will only be addressable through unique name '%s'", + DBUS_AUTH_SERVICE_NAME, m_connection.uniqueName().local8Bit().data()); + exit(-2); + } + + manager = new TDEBluetooth::ObjectManagerImpl("org.bluez", "/", this, "ObjectManager"); + if (!manager->isConnectedToDBUS()) + { + tqDebug("ObjectManager is not connected to DBus"); + exit(-3); + } + + rootService = new RootNodeService(m_connection); + orgService = new OrgNodeService(m_connection); + tdeNodeService = new TrinityDekstopNodeService(m_connection); + authService = new AuthService(m_connection); + agentManager = 0; + if (!configureAgent()) + { + tqDebug("Failed to configure the auth agent"); + } + disableSessionManagement(); + +// connect to manager signals +// connect(manager, SIGNAL(adapterAdded(const TQString&)), SLOT(slotAdapterAdded(const TQString&))); +// connect(manager, SIGNAL(adapterRemoved(const TQString&)), SLOT(slotAdapterRemoved(const TQString&))); + connect(manager, SIGNAL(adapterPowerOnChanged(const TQString&, bool)), + this, SLOT(slotPowerOnChanged(const TQString&, bool))); +} + +TDEBluezAuth::~TDEBluezAuth() +{ + disconnect(manager, SIGNAL(adapterPowerOnChanged(const TQString&, bool)), + this, SLOT(slotPowerOnChanged(const TQString&, bool))); + // close D-Bus connection + unconfigureAgent(); + + m_connection.closeConnection(DBUS_AUTH_SERVICE); + + delete authService; + delete tdeNodeService; + delete orgService; + delete rootService; + + delete manager; + agentManager = 0; +} + +bool TDEBluezAuth::isConnectedToDBUS() +{ + return m_connection.isConnected(); +} + +bool TDEBluezAuth::configureAgent() +{ + if (!agentManager) + agentManager = manager->getAgentManager(); + + if (manager->isAgentRegistered() && manager->isAgentDefaultAgent()) + { + return true; + } + + if (!manager->isAgentRegistered()) + { + if (!manager->registerAgent()) + { + tqWarning("org.bluez.Agent1 registering FAILED"); + return false; + } + } + if (!manager->isAgentDefaultAgent()) + { + if (!manager->requestDefaultAgent()) + { + tqWarning("org.bluez.Agent1 registering FAILED"); + return false; + } + } + + kdDebug() << "org.bluez.Agent1 registering OK" << endl; + + return true; +} + +bool TDEBluezAuth::unconfigureAgent() +{ + if (manager->isAgentRegistered()) + { + if (manager->unregisterAgent()) + kdDebug() << "Agent unregistered OK" << endl; + else + kdDebug() << "Agent unregistered FAILED" << endl; + } + return true; +} + +void TDEBluezAuth::slotPowerOnChanged(const TQString& adapter, bool state) +{ + if (state) + configureAgent(); + else + unconfigureAgent(); +} + +#include "application.moc" diff --git a/src/tdebluezauth/application.h b/src/tdebluezauth/application.h new file mode 100644 index 0000000..499418a --- /dev/null +++ b/src/tdebluezauth/application.h @@ -0,0 +1,79 @@ +/* + * + * Authorization Agent implementation of bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluezauth. + * + * tdebluezauth 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 2 of the License, or + * (at your option) any later version. + * + * tdebluezauth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef TDEAUTHAPP_H_ +#define TDEAUTHAPP_H_ + +#include <kuniqueapplication.h> + +#include <objectmanagerImpl.h> +#include "authservice.h" + +class TDEBluezAuth: public KUniqueApplication +{ + Q_OBJECT + +public: + TDEBluezAuth(); + virtual ~TDEBluezAuth(); + + /*! + * This function return information about connection status to the DBUS daemon. + * \return boolean with the state of the connection to D-Bus + * \retval true if connected + * \retval false if disconnected + */ + bool isConnectedToDBUS(); + +private: + /*! + * This function initialise the connection to the D-Bus daemon. + * \return boolean with the result of the operation + * \retval true if successful initialised D-Bus connection + * \retval false if unsuccessful + */ + bool configureAgent(); + //! to close the connection to D-Bus + bool unconfigureAgent(); + +private: + TQT_DBusConnection m_connection; + + AgentManager1Proxy* agentManager; + RootNodeService *rootService; + OrgNodeService *orgService; + TrinityDekstopNodeService *tdeNodeService; + AuthService *authService; + +public: + TDEBluetooth::ObjectManagerImpl *manager; + +public slots: + // void slotAdapterAdded(const TQString& adapter); + // void slotAdapterRemoved(const TQString& adapter); + void slotPowerOnChanged(const TQString&, bool); + +}; + +#endif // TDEAUTHAPP_H_ diff --git a/src/tdebluezauth/authdialog.ui b/src/tdebluezauth/authdialog.ui new file mode 100644 index 0000000..8b0efcf --- /dev/null +++ b/src/tdebluezauth/authdialog.ui @@ -0,0 +1,52 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>AuthDialog</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>AuthDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>425</width> + <height>300</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>400</width> + <height>300</height> + </size> + </property> + <property name="caption"> + <string>AuthenticationDialog</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>messageLabel</cstring> + </property> + <property name="text"> + <string><font size="+2">Bluetooth Authorization Request</font> +<p><b>%1</b> (device address <b>%2</b>) %3.</p> + +<p> +If you aren't sure about the identity of the other party, then reject +this authorization request.</p></string> + </property> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/tdebluezauth/authorize.cpp b/src/tdebluezauth/authorize.cpp new file mode 100644 index 0000000..26aa813 --- /dev/null +++ b/src/tdebluezauth/authorize.cpp @@ -0,0 +1,52 @@ +/* + * + * Authorization dialog for kbluetooth + * + * Copyright (C) 2006 Daniel Gollub <[email protected]> + * + * + * This file is part of kbluetooth. + * + * kbluetooth 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 2 of the License, or + * (at your option) any later version. + * + * libkbluetooth is distributed 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 libkbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "authorize.h" +#include "authdialog.h" + +AuthorizeDialog::AuthorizeDialog(const TQString &addr, const TQString &devName, const TQString &service) : + KDialogBase(NULL, "authrequest", true, "Bluetooth Authorization Request", + (Ok | Cancel), Ok, false, + KGuiItem(i18n("Accept"), "accept"), + KGuiItem(i18n("Reject"), "reject")) +{ + TQString action(i18n("wants to act as Input Device")); + + if (!service.isEmpty()) + action.append(" for " + service); + + authDlg = new AuthDialog(this); + authDlg->messageLabel->setText(authDlg->messageLabel->text().arg(devName).arg(addr).arg(action)); + connect(this, SIGNAL(okClicked()), SLOT(close())); + + setMainWidget(authDlg); +} + +AuthorizeDialog::~AuthorizeDialog() +{ + delete authDlg; +} + +#include "authorize.moc" diff --git a/src/tdebluezauth/authorize.h b/src/tdebluezauth/authorize.h new file mode 100644 index 0000000..ff9e9b3 --- /dev/null +++ b/src/tdebluezauth/authorize.h @@ -0,0 +1,47 @@ +/* + * + * Authorization Agent implementation of bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluezauth. + * + * tdebluezauth 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 2 of the License, or + * (at your option) any later version. + * + * tdebluezauth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef AUTHORIZE_H +#define AUTHORIZE_H + +#include <tqlabel.h> + +#include <kdialogbase.h> + +#include "application.h" +#include "authdialog.h" + +class AuthorizeDialog : public KDialogBase +{ + + Q_OBJECT + +public: + AuthorizeDialog(const TQString &addr, const TQString &devName, const TQString &service); + ~AuthorizeDialog(); + AuthDialog *authDlg; +}; + +#endif diff --git a/src/tdebluezauth/authservice.cpp b/src/tdebluezauth/authservice.cpp new file mode 100644 index 0000000..419e3e1 --- /dev/null +++ b/src/tdebluezauth/authservice.cpp @@ -0,0 +1,294 @@ +/* + * + * Authorization Agent implementation of bluez5 + * + * Copyright (C) 2019 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluezauth. + * + * tdebluezauth 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 2 of the License, or + * (at your option) any later version. + * + * tdebluezauth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +// TQt includes +#include <tqdbusobjectpath.h> +#include <deviceImpl.h> +#include <btuuids.h> + +#include "authservice.h" +#include "pindialog.h" +#include "authorize.h" + +#define DBUS_AUTH_SERVICE_PATH "/org/trinitydesktop/tdebluez" + +Agent1InterfaceImpl::Agent1InterfaceImpl(TQT_DBusConnection &conn) : + m_connection(&conn) +{ +} + +Agent1InterfaceImpl::~Agent1InterfaceImpl() +{ +} + + +/*! + * Implement virtual methods + * + */ + +void Agent1InterfaceImpl::handleMethodReply(const TQT_DBusMessage& reply) +{ + m_connection->send(reply); +} + +bool Agent1InterfaceImpl::Release(TQT_DBusError& error) +{ + // do something + return true; +} + +void Agent1InterfaceImpl::RequestPinCodeAsync(int asyncCallId, const TQT_DBusObjectPath& device) +{ + TQT_DBusError error; + TDEBluetooth::DeviceImpl *devImpl = new TDEBluetooth::DeviceImpl("org.bluez", device); + devImpl->setConnection((*m_connection)); + TQString addr = devImpl->getAddress(error); + TQString name = devImpl->getAlias(error); + delete devImpl; + PinDialog *pinDialog = new PinDialog(addr, name); + pinDialog->pinDlg->pinEdit->setText(TQString()); + pinDialog->pinDlg->pinEdit->setEnabled(true); + KDialogBase::centerOnScreen(pinDialog); + pinDialog->setActiveWindow(); + pinDialog->show(); + pinDialog->raise(); + + if (pinDialog->exec() == TQDialog::Accepted) + RequestPinCodeAsyncReply(asyncCallId, pinDialog->pinDlg->pinEdit->text()); + else + RequestPinCodeAsyncError(asyncCallId, TQT_DBusError::stdFailed("Request canceled")); + delete pinDialog; +} + +void Agent1InterfaceImpl::DisplayPinCodeAsync(int asyncCallId, const TQT_DBusObjectPath& device, const TQString& pincode) +{ + TQT_DBusError error; + TDEBluetooth::DeviceImpl *devImpl = new TDEBluetooth::DeviceImpl("org.bluez", device); + devImpl->setConnection((*m_connection)); + TQString addr = devImpl->getAddress(error); + TQString name = devImpl->getAlias(error); + kdDebug() << addr << " " << name << endl; + delete devImpl; + PinDialog *pinDialog = new PinDialog(addr, name); + pinDialog->pinDlg->pinEdit->setText(TQString("%1").arg(pincode)); + pinDialog->pinDlg->pinEdit->setEnabled(false); + KDialogBase::centerOnScreen(pinDialog); + pinDialog->setActiveWindow(); + pinDialog->show(); + pinDialog->raise(); + + if (pinDialog->exec() == TQDialog::Accepted) + DisplayPinCodeAsyncReply(asyncCallId); + else + DisplayPinCodeAsyncError(asyncCallId, TQT_DBusError::stdFailed("Request not accepted")); + delete pinDialog; +} + +void Agent1InterfaceImpl::RequestPasskeyAsync(int asyncCallId, const TQT_DBusObjectPath& device) +{ + TQT_DBusError error; + TDEBluetooth::DeviceImpl *devImpl = new TDEBluetooth::DeviceImpl("org.bluez", device); + devImpl->setConnection((*m_connection)); + TQString addr = devImpl->getAddress(error); + TQString name = devImpl->getAlias(error); + delete devImpl; + PinDialog *pinDialog = new PinDialog(addr, name); + pinDialog->pinDlg->pinEdit->setText(TQString()); + pinDialog->pinDlg->pinEdit->setEnabled(true); + KDialogBase::centerOnScreen(pinDialog); + pinDialog->setActiveWindow(); + pinDialog->show(); + pinDialog->raise(); + + if (pinDialog->exec() == TQDialog::Accepted) + RequestPasskeyAsyncReply(asyncCallId, pinDialog->pinDlg->pinEdit->text().toUInt()); + else + RequestPasskeyAsyncError(asyncCallId, TQT_DBusError::stdFailed("Request not accepted")); + delete pinDialog; +} + +void Agent1InterfaceImpl::DisplayPasskeyAsync(int asyncCallId, const TQT_DBusObjectPath& device, TQ_UINT32 passkey, TQ_UINT16 entered) +{ + TQT_DBusError error; + TDEBluetooth::DeviceImpl *devImpl = new TDEBluetooth::DeviceImpl("org.bluez", device); + devImpl->setConnection((*m_connection)); + TQString addr = devImpl->getAddress(error); + TQString name = devImpl->getAlias(error); + delete devImpl; + PinDialog *pinDialog = new PinDialog(addr, name); + pinDialog->pinDlg->pinEdit->setText(TQString("%1").arg(passkey)); + pinDialog->pinDlg->pinEdit->setEnabled(false); + KDialogBase::centerOnScreen(pinDialog); + pinDialog->setActiveWindow(); + pinDialog->show(); + pinDialog->raise(); + + if (pinDialog->exec() == TQDialog::Accepted) + DisplayPasskeyAsyncReply(asyncCallId); + else + DisplayPasskeyAsyncError(asyncCallId, TQT_DBusError::stdFailed("Request not accepted")); + delete pinDialog; +} + +void Agent1InterfaceImpl::RequestConfirmationAsync(int asyncCallId, const TQT_DBusObjectPath& device, TQ_UINT32 passkey) +{ + TQT_DBusError error; + TDEBluetooth::DeviceImpl *devImpl = new TDEBluetooth::DeviceImpl("org.bluez", device); + devImpl->setConnection((*m_connection)); + TQString addr = devImpl->getAddress(error); + TQString name = devImpl->getAlias(error); + delete devImpl; + PinDialog *pinDialog = new PinDialog(addr, name); + pinDialog->pinDlg->pinEdit->setText(TQString("%3").arg(passkey)); + pinDialog->pinDlg->pinEdit->setEnabled(false); + KDialogBase::centerOnScreen(pinDialog); + pinDialog->setActiveWindow(); + pinDialog->show(); + pinDialog->raise(); + + if (pinDialog->exec() == TQDialog::Accepted) + RequestConfirmationAsyncReply(asyncCallId); + else + RequestConfirmationAsyncError(asyncCallId, TQT_DBusError::stdFailed("Request not accepted")); + delete pinDialog; +} + +void Agent1InterfaceImpl::RequestAuthorizationAsync(int asyncCallId, const TQT_DBusObjectPath& device) +{ + TQT_DBusError error; + TDEBluetooth::DeviceImpl *devImpl = new TDEBluetooth::DeviceImpl("org.bluez", device); + devImpl->setConnection((*m_connection)); + TQString addr = devImpl->getAddress(error); + TQString name = devImpl->getAlias(error); + delete devImpl; + AuthorizeDialog *authDialog = new AuthorizeDialog(addr, name, TQString()); + KDialogBase::centerOnScreen(authDialog); + authDialog->setActiveWindow(); + authDialog->show(); + authDialog->raise(); + + if (authDialog->exec() == TQDialog::Accepted) + RequestAuthorizationAsyncReply(asyncCallId); + else + RequestAuthorizationAsyncError(asyncCallId, TQT_DBusError::stdFailed("Request not authorized")); + delete authDialog; +} + +void Agent1InterfaceImpl::AuthorizeServiceAsync(int asyncCallId, const TQT_DBusObjectPath& device, const TQString& uuid) +{ + kdDebug() << __func__ << "()" << endl; + + TQT_DBusError error; + TDEBluetooth::DeviceImpl *devImpl = new TDEBluetooth::DeviceImpl("org.bluez", device); + devImpl->setConnection((*m_connection)); + TQString addr = devImpl->getAddress(error); + TQString name = devImpl->getAlias(error); + delete devImpl; + AuthorizeDialog *authDialog = new AuthorizeDialog(addr, name, resolveUUID(uuid)); + KDialogBase::centerOnScreen(authDialog); + authDialog->setActiveWindow(); + authDialog->show(); + authDialog->raise(); + + if (authDialog->exec() == TQDialog::Accepted) + AuthorizeServiceAsyncReply(asyncCallId); + else + AuthorizeServiceAsyncError(asyncCallId, TQT_DBusError::stdFailed("Request not accepted")); + delete authDialog; +} + +bool Agent1InterfaceImpl::Cancel(TQT_DBusError& error) +{ + kdDebug() << __func__ << "()" << endl; + + // do something + return true; +} + +RootNodeService::RootNodeService(TQT_DBusConnection &connection) : + DBusBaseNode(), m_connection(connection) +{ + addChildNode("org"); + registerObject(m_connection, "/"); +} + +RootNodeService::~RootNodeService() +{ +} + +TQT_DBusObjectBase* RootNodeService::createInterface(const TQString& interfaceName) +{ + return (TQT_DBusObjectBase*) m_interfaces[interfaceName]; +} + +OrgNodeService::OrgNodeService(TQT_DBusConnection &connection) : + DBusBaseNode(), m_connection(connection) +{ + addChildNode("trinitydesktop"); + registerObject(m_connection, "/org"); +} + +OrgNodeService::~OrgNodeService() +{ +} + +TQT_DBusObjectBase* OrgNodeService::createInterface(const TQString& interfaceName) +{ + return (TQT_DBusObjectBase*) m_interfaces[interfaceName]; +} + +TrinityDekstopNodeService::TrinityDekstopNodeService(TQT_DBusConnection &connection) : + DBusBaseNode(), m_connection(connection) +{ + addChildNode("tdebluez"); + registerObject(m_connection, "/org/trinitydesktop"); +} + +TrinityDekstopNodeService::~TrinityDekstopNodeService() +{ +} + +TQT_DBusObjectBase* TrinityDekstopNodeService::createInterface(const TQString& interfaceName) +{ + return (TQT_DBusObjectBase*) m_interfaces[interfaceName]; +} + +AuthService::AuthService(TQT_DBusConnection &conn) : + org::trinitydesktop::tdebluezNode(), m_connection(conn) +{ + m_interfaces.insert("org.freedesktop.DBus.Introspectable", this); + m_interfaces.insert("org.bluez.Agent1", new Agent1InterfaceImpl(m_connection)); + registerObject(m_connection, DBUS_AUTH_SERVICE_PATH); +} + +AuthService::~AuthService() +{ +} + +TQT_DBusObjectBase* AuthService::createInterface(const TQString& interfaceName) +{ + return (TQT_DBusObjectBase*) m_interfaces[interfaceName]; +} diff --git a/src/tdebluezauth/authservice.h b/src/tdebluezauth/authservice.h new file mode 100644 index 0000000..187d4a0 --- /dev/null +++ b/src/tdebluezauth/authservice.h @@ -0,0 +1,230 @@ +/* + * + * Authorization Agent implementation of bluez5 + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluezauth. + * + * tdebluezauth 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 2 of the License, or + * (at your option) any later version. + * + * tdebluezauth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ +#ifndef AGENTIMPL_H +#define AGENTIMPL_H + +#include <tqdbusconnection.h> + +#include <interfaces/agent1Interface.h> +#include <interfaces/tdebluezNode.h> +#include <interfaces/dbusbaseNode.h> + +class Agent1InterfaceImpl : public org::bluez::Agent1Interface +{ + +public: + Agent1InterfaceImpl(TQT_DBusConnection&); + virtual ~Agent1InterfaceImpl(); +protected: + /** + * void Release() + * This method gets called when the service daemon + * unregisters the agent. An agent can use it to do + * cleanup tasks. There is no need to unregister the + * agent, because when this method gets called it has + * already been unregistered. + */ + virtual bool Release(TQT_DBusError& error); + /** + * string RequestPinCode(object device) + * + * This method gets called when the service daemon + * needs to get the passkey for an authentication. + * + * The return value should be a string of 1-16 characters + * length. The string can be alphanumeric. + * + * Possible errors: org.bluez.Error.Rejected + * org.bluez.Error.Canceled + */ + virtual void RequestPinCodeAsync(int asyncCallId, const TQT_DBusObjectPath& device); + /** + * void DisplayPinCode(object device, string pincode) + + This method gets called when the service daemon + needs to display a pincode for an authentication. + + An empty reply should be returned. When the pincode + needs no longer to be displayed, the Cancel method + of the agent will be called. + + This is used during the pairing process of keyboards + that don't support Bluetooth 2.1 Secure Simple Pairing, + in contrast to DisplayPasskey which is used for those + that do. + + This method will only ever be called once since + older keyboards do not support typing notification. + + Note that the PIN will always be a 6-digit number, + zero-padded to 6 digits. This is for harmony with + the later specification. + + Possible errors: org.bluez.Error.Rejected + org.bluez.Error.Canceled + */ + virtual void DisplayPinCodeAsync(int asyncCallId, const TQT_DBusObjectPath& device, const TQString& pincode); + /** + * uint32 RequestPasskey(object device) + + This method gets called when the service daemon + needs to get the passkey for an authentication. + + The return value should be a numeric value + between 0-999999. + + Possible errors: org.bluez.Error.Rejected + org.bluez.Error.Canceled + */ + virtual void RequestPasskeyAsync(int asyncCallId, const TQT_DBusObjectPath& device); + /** + * void DisplayPasskey(object device, uint32 passkey, + uint16 entered) + + This method gets called when the service daemon + needs to display a passkey for an authentication. + + The entered parameter indicates the number of already + typed keys on the remote side. + + An empty reply should be returned. When the passkey + needs no longer to be displayed, the Cancel method + of the agent will be called. + + During the pairing process this method might be + called multiple times to update the entered value. + + Note that the passkey will always be a 6-digit number, + so the display should be zero-padded at the start if + the value contains less than 6 digits. + */ + virtual void DisplayPasskeyAsync(int asyncCallId, const TQT_DBusObjectPath& device, TQ_UINT32 passkey, TQ_UINT16 entered); + /** + * void RequestConfirmation(object device, uint32 passkey) + + This method gets called when the service daemon + needs to confirm a passkey for an authentication. + + To confirm the value it should return an empty reply + or an error in case the passkey is invalid. + + Note that the passkey will always be a 6-digit number, + so the display should be zero-padded at the start if + the value contains less than 6 digits. + + Possible errors: org.bluez.Error.Rejected + org.bluez.Error.Canceled + */ + virtual void RequestConfirmationAsync(int asyncCallId, const TQT_DBusObjectPath& device, TQ_UINT32 passkey); + /** + * void RequestAuthorization(object device) + + This method gets called to request the user to + authorize an incoming pairing attempt which + would in other circumstances trigger the just-works + model, or when the user plugged in a device that + implements cable pairing. In the latter case, the + device would not be connected to the adapter via + Bluetooth yet. + + Possible errors: org.bluez.Error.Rejected + org.bluez.Error.Canceled + */ + virtual void RequestAuthorizationAsync(int asyncCallId, const TQT_DBusObjectPath& device); + /** + * void AuthorizeService(object device, string uuid) + + This method gets called when the service daemon + needs to authorize a connection/service request. + + Possible errors: org.bluez.Error.Rejected + org.bluez.Error.Canceled + */ + virtual void AuthorizeServiceAsync(int asyncCallId, const TQT_DBusObjectPath& device, const TQString& uuid); + /** + * void Cancel() + + This method gets called to indicate that the agent + request failed before a reply was returned. + */ + virtual bool Cancel(TQT_DBusError& error); + + virtual void handleMethodReply(const TQT_DBusMessage& reply); + +private: + TQT_DBusConnection *m_connection; +}; + +class AuthService: public org::trinitydesktop::tdebluezNode +{ +public: + AuthService(TQT_DBusConnection&); + ~AuthService(); + +protected: + virtual TQT_DBusObjectBase* createInterface(const TQString&); + +private: + TQMap<TQString, TQT_DBusObjectBase*> m_interfaces; + TQT_DBusConnection m_connection; +}; + +class RootNodeService: public DBusBaseNode +{ +public: + RootNodeService(TQT_DBusConnection&); + ~RootNodeService(); +protected: + virtual TQT_DBusObjectBase* createInterface(const TQString&); +private: + TQMap<TQString, TQT_DBusObjectBase*> m_interfaces; + TQT_DBusConnection m_connection; +}; + +class OrgNodeService: public DBusBaseNode +{ +public: + OrgNodeService(TQT_DBusConnection&); + ~OrgNodeService(); +protected: + virtual TQT_DBusObjectBase* createInterface(const TQString&); +private: + TQMap<TQString, TQT_DBusObjectBase*> m_interfaces; + TQT_DBusConnection m_connection; +}; + +class TrinityDekstopNodeService: public DBusBaseNode +{ +public: + TrinityDekstopNodeService(TQT_DBusConnection&); + ~TrinityDekstopNodeService(); +protected: + virtual TQT_DBusObjectBase* createInterface(const TQString&); +private: + TQMap<TQString, TQT_DBusObjectBase*> m_interfaces; + TQT_DBusConnection m_connection; +}; + +#endif // AGENTIMPL_H diff --git a/src/tdebluezauth/main.cpp b/src/tdebluezauth/main.cpp new file mode 100644 index 0000000..98ca19e --- /dev/null +++ b/src/tdebluezauth/main.cpp @@ -0,0 +1,77 @@ +/* + * + * Adapter config dialog for tdebluez authentication + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluezauth. + * + * tdebluezauth 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 2 of the License, or + * (at your option) any later version. + * + * tdebluezauth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + + +#include <tdecmdlineargs.h> +#include <tdeaboutdata.h> +#include <tdemessagebox.h> +#include <kuniqueapplication.h> +#include <iostream> + +#include "application.h" + +static const char *description = I18N_NOOP("TDEBluezAuth"); +static const char *copy = I18N_NOOP("Copyright (C) 2018 Emanoil."); + +static TDECmdLineOptions options[] = +{ + { 0, 0, 0 } +}; + +int main(int argc, char *argv[]) +{ + TDELocale::setMainCatalogue("tdebluetooth"); + TDEAboutData aboutData("tdebluezauth", + I18N_NOOP("TDEBluezAuth"), + 0, + description, TDEAboutData::License_GPL, + copy,0, "http://trinitydesktop.org"); + aboutData.addAuthor("Tom Patzig", I18N_NOOP("Author"), "[email protected]"); + aboutData.addAuthor("Emanoil Kotsev", I18N_NOOP("Bluez5 and port to TDE"), "[email protected]"); + TDECmdLineArgs::init( argc, argv, &aboutData ); + TDECmdLineArgs::addCmdLineOptions( options ); + KUniqueApplication::addCmdLineOptions(); + + if (!KUniqueApplication::start()) + { + std::cerr << i18n("TDEBluezAuth is already running.\n").local8Bit(); + return 0; + } + + TDEBluezAuth a; + + if (!a.isConnectedToDBUS()) + { + KMessageBox::error(NULL,i18n("Can't connect to DBus!\nUnable to start tdebluezauth. \n\n \ + Restart dbus and the bluetooth service")); + KUniqueApplication::kApplication()->quit(); + return -1; + } + else + { + return a.exec(); + } + +} diff --git a/src/tdebluezauth/pindefdialog.ui b/src/tdebluezauth/pindefdialog.ui new file mode 100644 index 0000000..4ebc8d4 --- /dev/null +++ b/src/tdebluezauth/pindefdialog.ui @@ -0,0 +1,87 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>PinDefaultDialog</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>PinDefaultDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>738</width> + <height>300</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>400</width> + <height>300</height> + </size> + </property> + <property name="caption"> + <string>PinDefaultDialog</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>messageLabel</cstring> + </property> + <property name="text"> + <string><font size="+2">Bluetooth Pairing Request</font> +<p><b>%1</b> (device address <b>%2</b>) wants to pair with your +Bluetooth device, which is needed for authenticated and secure connections. +</p><p> +If you are sure about the identity of the other party, then please enter +the same PIN below as was used by the other device.</p></string> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLineEdit"> + <property name="name"> + <cstring>pinEdit</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>197</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/tdebluezauth/pindefdialog2.ui b/src/tdebluezauth/pindefdialog2.ui new file mode 100644 index 0000000..4ebc8d4 --- /dev/null +++ b/src/tdebluezauth/pindefdialog2.ui @@ -0,0 +1,87 @@ +<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> +<class>PinDefaultDialog</class> +<widget class="TQWidget"> + <property name="name"> + <cstring>PinDefaultDialog</cstring> + </property> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>738</width> + <height>300</height> + </rect> + </property> + <property name="sizePolicy"> + <sizepolicy> + <hsizetype>1</hsizetype> + <vsizetype>1</vsizetype> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>400</width> + <height>300</height> + </size> + </property> + <property name="caption"> + <string>PinDefaultDialog</string> + </property> + <vbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLabel"> + <property name="name"> + <cstring>messageLabel</cstring> + </property> + <property name="text"> + <string><font size="+2">Bluetooth Pairing Request</font> +<p><b>%1</b> (device address <b>%2</b>) wants to pair with your +Bluetooth device, which is needed for authenticated and secure connections. +</p><p> +If you are sure about the identity of the other party, then please enter +the same PIN below as was used by the other device.</p></string> + </property> + </widget> + <widget class="TQLayoutWidget"> + <property name="name"> + <cstring>layout3</cstring> + </property> + <hbox> + <property name="name"> + <cstring>unnamed</cstring> + </property> + <widget class="TQLineEdit"> + <property name="name"> + <cstring>pinEdit</cstring> + </property> + <property name="enabled"> + <bool>true</bool> + </property> + </widget> + <spacer> + <property name="name"> + <cstring>spacer2</cstring> + </property> + <property name="orientation"> + <enum>Horizontal</enum> + </property> + <property name="sizeType"> + <enum>Expanding</enum> + </property> + <property name="sizeHint"> + <size> + <width>197</width> + <height>20</height> + </size> + </property> + </spacer> + </hbox> + </widget> + </vbox> +</widget> +<layoutdefaults spacing="6" margin="11"/> +</UI> diff --git a/src/tdebluezauth/pindialog.cpp b/src/tdebluezauth/pindialog.cpp new file mode 100644 index 0000000..7f31b89 --- /dev/null +++ b/src/tdebluezauth/pindialog.cpp @@ -0,0 +1,58 @@ +/* + * + * PIN Dialog dialog for tdebluez authentication + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluezauth. + * + * tdebluezauth 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 2 of the License, or + * (at your option) any later version. + * + * tdebluezauth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "pindialog.h" +#include "pindefdialog.h" + +PinDialog::PinDialog(const TQString &addr, const TQString &devName) : + KDialogBase(NULL, "pinrequest", true, "Pin Request", (Ok | Cancel)) +{ + + pinDlg = new PinDefaultDialog(this); + pinDlg->messageLabel->setText(pinDlg->messageLabel->text().arg(devName).arg(addr)); + + pinDlg->pinEdit->setFocus(); + + connect(this, TQT_SIGNAL(okClicked()), TQT_SLOT(setPin())); + + setMainWidget(pinDlg); +} + +PinDialog::~PinDialog() +{ + delete pinDlg; +} + +void PinDialog::setPin() +{ + pin = pinDlg->pinEdit->text(); +} + +const TQString PinDialog::getPin() +{ + return pin; +} + +#include "pindialog.moc" diff --git a/src/tdebluezauth/pindialog.h b/src/tdebluezauth/pindialog.h new file mode 100644 index 0000000..f99fd1f --- /dev/null +++ b/src/tdebluezauth/pindialog.h @@ -0,0 +1,58 @@ +/* + * + * PIN Dialog dialog for tdebluez authentication + * + * Copyright (C) 2018 Emanoil Kotsev <[email protected]> + * + * + * This file is part of tdebluezauth. + * + * tdebluezauth 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 2 of the License, or + * (at your option) any later version. + * + * tdebluezauth is distributed 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 kbluetooth; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#ifndef PINDIALOG_H +#define PINDIALOG_H + +#include <tqlineedit.h> +#include <tqlabel.h> +#include <kdialogbase.h> +#include "application.h" +#include "pindefdialog.h" + +/** +@author Fred Schaettgen + */ + +class PinDialog : public KDialogBase +{ + + Q_OBJECT + +public: + PinDialog(const TQString &addr, const TQString &devName); + ~PinDialog(); + PinDefaultDialog *pinDlg; + const TQString getPin(); + +private: + TQString pin; + +private slots: + void setPin(); + +}; + +#endif diff --git a/src/tdebluezauth/tdebluezauth.desktop b/src/tdebluezauth/tdebluezauth.desktop new file mode 100644 index 0000000..efdeaf4 --- /dev/null +++ b/src/tdebluezauth/tdebluezauth.desktop @@ -0,0 +1,36 @@ +[Desktop Entry] +Encoding=UTF-8 +Exec=tdebluezauth +Icon=tdebluez +Type=Application +Name=tdebluezauth +GenericName=Bluetooth Wizard +GenericName[de]=Bluetooth-Assistent +GenericName[es]=Asistente de bluetooth +GenericName[et]=Bluetoothi nõustaja +GenericName[it]=Assistente per Bluetooth +GenericName[ja]=Bluetooth ウィザード +GenericName[nl]=Bluetooth-assistent +GenericName[pt]=Assistente de Bluetooth +GenericName[pt_BR]=Assistente de Bluetooth +GenericName[sr]=Bluetooth чаробњак +GenericName[sr@Latn]=Bluetooth čarobnjak +GenericName[sv]=Blåtandsguide +GenericName[tg]=Устоди Bluetooth +GenericName[tr]=Bluetooth Sihirbazı +GenericName[xx]=xxBluetooth Wizardxx +Categories=Qt;TDE;System;Monitor; +Comment=TDE Bluetooth Wizard +Comment[de]=TDE Bluetooth-Assistent +Comment[es]=Asistente de bluetooth para TDE +Comment[et]=TDE Bluetoothi nõustaja +Comment[it]=Assistente per Bluetooth di TDE +Comment[ja]=TDE Bluetooth ウィザード +Comment[nl]=TDE Bluetooth-assistent +Comment[pt]=Assistente de Bluetooth do TDE +Comment[pt_BR]=Assistente de Bluetooth do TDE +Comment[sr]=TDE чаробњак за Bluetooth +Comment[sr@Latn]=TDE čarobnjak za Bluetooth +Comment[sv]=TDE:s Blåtandsguide +Comment[tg]=Устоди TDE Bluetooth +Comment[tr]=TDE Bluetooth Sihirbazı diff --git a/src/tdeioclient/CMakeLists.txt b/src/tdeioclient/CMakeLists.txt new file mode 100644 index 0000000..19cc86d --- /dev/null +++ b/src/tdeioclient/CMakeLists.txt @@ -0,0 +1,40 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +project (tdeioclient) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src/libtdebluez + ${CMAKE_SOURCE_DIR}/src/tdeioclient + ${CMAKE_BINARY_DIR}/src + ${CMAKE_BINARY_DIR}/src/tdeioclient + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### tdeioclient (tdeinit) ###################### + +tde_add_executable ( tdeioclient AUTOMOC + SOURCES + commandhandler.cpp main.cpp + LINK + ${DBUS_TQT_LIBRARIES} tdecore-shared tdebluez-shared tdeio-shared + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/src/tdeioclient/commandhandler.cpp b/src/tdeioclient/commandhandler.cpp new file mode 100644 index 0000000..4a24716 --- /dev/null +++ b/src/tdeioclient/commandhandler.cpp @@ -0,0 +1,407 @@ +/*************************************************************************** + * Copyright (C) 2004 by Fred Schaettgen <[email protected]>* + * * + * 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 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#include "commandhandler.h" +#include <tdecmdlineargs.h> +#include <tdeapplication.h> +#include <tdelocale.h> +#include <iostream> +#include <kdebug.h> +#include <tqdatetime.h> +#include <tqtimer.h> +#include <tdeio/job.h> + +CommandHandler::CommandHandler(TDECmdLineArgs *a) +{ + this->iterate = false; + this->args = a; + returnValue = 0; + if (args->count() < 2) + { + exitPrintUsage(i18n("Arguments missing.")); + } + origCommand = args->arg(0); + for (int n = 1; n < args->count() - 1; ++n) + { + sources.append(args->arg(n)); + } + target = args->arg(args->count() - 1); + targets = sources; + targets.append(target); + + if (args->isSet("outfile")) + { + outFile.setName(args->getOption("outfile")); + outFile.open(IO_WriteOnly); + } + else + { + // Open stdout + outFile.open(IO_WriteOnly, 1); + } + + if (args->isSet("infile")) + { + inFile.setName(args->getOption("infile")); + inFile.open(IO_ReadOnly); + } + else + { + // Open stdin + inFile.open(IO_ReadOnly, 0); + } + + showProgressWindow = args->isSet("progresswindow"); + overwrite = args->isSet("overwrite"); +} + +CommandHandler::~CommandHandler() +{ +} + +void CommandHandler::start() +{ + if (origCommand == "ls") + { + command = "ls"; + list(target); + } + else if (origCommand == "get" || origCommand == "cat" || origCommand == "read") + { + command = "get"; + get(target); + } + else if (origCommand == "put" || origCommand == "write") + { + command = "put"; + put(target); + } + else if (origCommand == "mkdir") + { + command = "mkdir"; + mkdir(target); + } + else if (origCommand == "rmdir") + { + command = "rmdir"; + rmdir(target); + } + else if (origCommand == "rm" || origCommand == "del") + { + command = "del"; + del(targets); + } + else if (origCommand == "cp" || origCommand == "copy") + { + command = "copy"; + copy(sources, target); + } + else + { + command = origCommand; + exitPrintUsage(i18n("unknown command: %1").arg(command)); + } +} + +void CommandHandler::commonConnect(TDEIO::Job* job) +{ + connect(job, SIGNAL(infoMessage(TDEIO::Job*,const TQString&)), + this, SLOT(slotInfoMessage(TDEIO::Job*,const TQString&))); + connect(job, SIGNAL(percent (TDEIO::Job*, unsigned long)), + this, SLOT(slotPercent(TDEIO::Job*, unsigned long))); + connect(job, SIGNAL(result(TDEIO::Job*)), this, SLOT(slotFinished(TDEIO::Job*))); +} + +KURL::List CommandHandler::urlList(const TQStringList& sources) +{ + KURL::List ret; + for (size_t n = 0; n < sources.size(); ++n) + { + ret.append(KURL(sources[n])); + } + return ret; +} + +// Commands --------------------------------------------------- + +void CommandHandler::list(const TQString& target) +{ + bool showHidden = true; + TDEIO::ListJob* job = TDEIO::listDir(KURL(target), showProgressWindow, showHidden); + this->job = job; + commonConnect(job); + connect(job, SIGNAL(entries(TDEIO::Job*, const TDEIO::UDSEntryList&)), + this, SLOT(slotEntries(TDEIO::Job*, const TDEIO::UDSEntryList&))); +} + +void CommandHandler::get(const TQString& target) +{ + bool reload = false; + TDEIO::TransferJob* job = TDEIO::get(KURL(target), reload, showProgressWindow); + this->job = job; + commonConnect(job); + connect(job, SIGNAL(data(TDEIO::Job*,const TQByteArray&)), + this, SLOT(slotData(TDEIO::Job*,const TQByteArray&))); +} + +void CommandHandler::put(const TQString& target) +{ + int permissions = -1; + bool resume = false; + TDEIO::TransferJob* job = TDEIO::put(KURL(target), permissions, + overwrite, resume, showProgressWindow); + this->job = job; + commonConnect(job); + connect(job, SIGNAL(dataReq(TDEIO::Job*,TQByteArray&)), + this, SLOT(slotDataReq(TDEIO::Job*,TQByteArray&))); +} + +void CommandHandler::mkdir(const TQString& target) +{ + int permissions = -1; + TDEIO::SimpleJob* job = TDEIO::mkdir(KURL(target), permissions); + this->job = job; + commonConnect(job); +} + +void CommandHandler::rmdir(const TQString& target) +{ + TDEIO::SimpleJob* job = TDEIO::rmdir(KURL(target)); + this->job = job; + commonConnect(job); +} + +void CommandHandler::del(const TQStringList& targets) +{ + bool shred = false; + TDEIO::DeleteJob* job = TDEIO::del(urlList(targets), shred, showProgressWindow); + this->job = job; + commonConnect(job); +} + +void CommandHandler::copy(const TQStringList& sources, const TQString& target) +{ + TDEIO::CopyJob *job = TDEIO::copy(urlList(sources), KURL(target), + showProgressWindow); + this->job = job; + commonConnect(job); +} + +// Signal handlers -------------------------------------------- + +void CommandHandler::slotEntries(TDEIO::Job* /*job*/, const TDEIO::UDSEntryList& list) +{ + if (command == "ls") + { + for (size_t n = 0; n < list.size(); ++n) + { + TDEIO::UDSEntry entry = list[n]; + + TQDateTime date = TQDateTime::currentDateTime(); + TQString user = "n/a"; + TQString iconName = "unknown"; + TQString group = "n/a"; + TQString extra = "n/a"; + TQString name = "n/a"; + TQDateTime mTime = TQDateTime::currentDateTime(); + TQDateTime aTime = TQDateTime::currentDateTime(); + TQDateTime cTime = TQDateTime::currentDateTime(); + int fileType = 0; + TQString linkDest = "n/a"; + TQString url = "n/a"; + TQString mimeType = "n/a"; + TQString guessedMimeType = "n/a"; + TQString xmlProperties = "n/a"; + long long size = -1; + int access = 0; + + for (size_t m = 0; m < entry.size(); ++m) + { + TDEIO::UDSAtom atom = entry[m]; + switch (atom.m_uds) + { + case TDEIO::UDS_TIME: + date.setTime_t(atom.m_long); + break; + case TDEIO::UDS_SIZE: + size = atom.m_long; + break; + case TDEIO::UDS_USER: + user = atom.m_str; + break; + case TDEIO::UDS_ICON_NAME: + iconName = atom.m_str; + break; + case TDEIO::UDS_GROUP: + group = atom.m_str; + break; + case TDEIO::UDS_EXTRA: + extra = atom.m_str; + break; + case TDEIO::UDS_NAME: + name = atom.m_str; + break; + case TDEIO::UDS_ACCESS: + access = atom.m_long; + break; + case TDEIO::UDS_MODIFICATION_TIME: + mTime.setTime_t(atom.m_long); + break; + case TDEIO::UDS_ACCESS_TIME: + aTime.setTime_t(atom.m_long); + break; + case TDEIO::UDS_CREATION_TIME: + cTime.setTime_t(atom.m_long); + break; + case TDEIO::UDS_FILE_TYPE: + fileType = atom.m_long; + break; + case TDEIO::UDS_LINK_DEST: + linkDest = atom.m_str; + break; + case TDEIO::UDS_URL: + url = atom.m_str; + break; + case TDEIO::UDS_MIME_TYPE: + mimeType = atom.m_str; + break; + case TDEIO::UDS_GUESSED_MIME_TYPE: + guessedMimeType = atom.m_str; + break; + case TDEIO::UDS_XML_PROPERTIES: + xmlProperties = atom.m_str; + break; + }; + } + + if (args->isSet("access")) + { + std::cout << TQString::number(access, 8).local8Bit() << " "; + } + if (args->isSet("filetype")) + { + std::cout << TQString::number(fileType).rightJustify(4).local8Bit() << " "; + } + if (args->isSet("user")) + { + std::cout << user.rightJustify(8).local8Bit() << " "; + } + if (args->isSet("group")) + { + std::cout << group.rightJustify(8).local8Bit() << " "; + } + if (args->isSet("size")) + { + std::cout << TQString::number(size).rightJustify(9).local8Bit() << " "; + } + if (args->isSet("date")) + { + std::cout << date.toString("yyyy-MM-dd hh:mm:ss").local8Bit() << " "; + } + if (args->isSet("mtime")) + { + std::cout << mTime.toString("yyyy-MM-dd hh:mm:ss").local8Bit() << " "; + } + if (args->isSet("atime")) + { + std::cout << aTime.toString("yyyy-MM-dd hh:mm:ss").local8Bit() << " "; + } + if (args->isSet("ctime")) + { + std::cout << cTime.toString("yyyy-MM-dd hh:mm:ss").local8Bit() << " "; + } + if (args->isSet("iconName")) + { + std::cout << iconName.local8Bit() << " "; + } + if (args->isSet("mimetype")) + { + std::cout << mimeType.local8Bit() << " "; + } + if (args->isSet("guessedmimetype")) + { + std::cout << guessedMimeType.local8Bit() << " "; + } + if (args->isSet("linkdest")) + { + std::cout << linkDest.local8Bit() << " "; + } + if (args->isSet("url")) + { + std::cout << url.local8Bit() << " "; + } + if (args->isSet("name")) + { + std::cout << name.local8Bit() << " "; + } + if (args->isSet("xmlproperties")) + { + std::cout << xmlProperties.local8Bit() << " "; + } + if (args->isSet("extra")) + { + std::cout << extra.local8Bit() << " "; + } + std::cout << std::endl; + } + } +} + +void CommandHandler::slotData(TDEIO::Job* /*job*/, const TQByteArray &data) +{ + outFile.writeBlock(data); +} + +void CommandHandler::slotDataReq(TDEIO::Job* /*job*/, TQByteArray &data) +{ + data.resize(65536); + data.resize(inFile.readBlock(data.data(), data.size())); +} + +void CommandHandler::slotInfoMessage(TDEIO::Job* /*job*/, const TQString& msg) +{ + if (msg != lastMessage && args->isSet("messages")) + { + std::cerr << " >" << msg.local8Bit() << std::endl; + lastMessage = msg; + } +} + +void CommandHandler::slotPercent(TDEIO::Job* /*job*/, unsigned long /*percent*/) +{ + +} + +void CommandHandler::slotFinished(TDEIO::Job* job) +{ + if (job->error() != 0) + { + std::cerr << job->errorString().local8Bit() << std::endl; + iterate = false; + } + else + { + if (iterate) + { + start(); + } + } + + if (!iterate) + { + TDEApplication::kApplication()->exit(job->error()); + } +} + +void CommandHandler::exitPrintUsage(const TQString& message) +{ + std::cout << message.local8Bit() << std::endl; + TDECmdLineArgs::usage(); +} + +#include "commandhandler.moc" diff --git a/src/tdeioclient/commandhandler.h b/src/tdeioclient/commandhandler.h new file mode 100644 index 0000000..29fb552 --- /dev/null +++ b/src/tdeioclient/commandhandler.h @@ -0,0 +1,60 @@ +//-*-c++-*- +/*************************************************************************** + * Copyright (C) 2004 by Fred Schaettgen <[email protected]>* + * * + * 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 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ +#ifndef COMMANDHANDLER_H +#define COMMANDHANDLER_H + +#include <tqobject.h> +#include <tqstringlist.h> +#include <tdeio/jobclasses.h> +#include <tqfile.h> +#include <kurl.h> + +class TDECmdLineArgs; +namespace TDEIO { class Job; } + +class CommandHandler : public TQObject +{ + Q_OBJECT + +public: + CommandHandler(TDECmdLineArgs *args); + ~CommandHandler(); + void start(); + +private: + KURL::List urlList(const TQStringList& list); + void exitPrintUsage(const TQString& message); + void list(const TQString& target); + void get(const TQString& target); + void put(const TQString& target); + void mkdir(const TQString& target); + void rmdir(const TQString& target); + void del(const TQStringList& targets); + void copy(const TQStringList& sources, const TQString& target); + void commonConnect(TDEIO::Job* job); + + TQString command, origCommand, target, lastMessage; + TQStringList targets, sources; + TDEIO::Job* job; + int returnValue; + TDECmdLineArgs *args; + TQFile outFile, inFile; + bool showProgressWindow, overwrite, iterate; + +private slots: + void slotFinished(TDEIO::Job *job); + void slotEntries(TDEIO::Job* job, const TDEIO::UDSEntryList& list); + void slotData(TDEIO::Job *, const TQByteArray &data); + void slotDataReq(TDEIO::Job *, TQByteArray &data); + void slotInfoMessage(TDEIO::Job* job,const TQString& msg); + void slotPercent(TDEIO::Job* job, unsigned long percent); +}; + +#endif diff --git a/src/tdeioclient/main.cpp b/src/tdeioclient/main.cpp new file mode 100644 index 0000000..59762b7 --- /dev/null +++ b/src/tdeioclient/main.cpp @@ -0,0 +1,73 @@ +//-*-c++-*- +/*************************************************************************** + * Copyright (C) 2003 by Fred Schaettgen * + * [email protected] * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include <tdeapplication.h> +#include <tdeaboutdata.h> +#include <tdecmdlineargs.h> +#include <tdelocale.h> +#include <kurl.h> +#include <tqwidget.h> + +#include "commandhandler.h" + +static const char description[] = + I18N_NOOP("TDEIO command line client for tdebluez"); + +//FIXME static const char* version = TDEBluetoothConfig::version; + +static const char* version = "0.0.1"; + +static TDECmdLineOptions options[] = +{ + {"d", 0, 0}, {"date", I18N_NOOP("List date"), 0}, + {"u", 0, 0}, {"user", I18N_NOOP("List user"), 0}, + {"i", 0, 0}, {"iconName", I18N_NOOP("List icon name"), 0}, + {"g", 0, 0}, {"group", I18N_NOOP("List group"), 0}, + {"extra", I18N_NOOP("List extra"), 0}, + {"noname", I18N_NOOP("Do not list name"), 0}, + {"p", 0, 0}, {"access", I18N_NOOP("List access permissions"), 0}, + {"m", 0, 0}, {"mtime", I18N_NOOP("List modification time"), 0}, + {"a", 0, 0}, {"atime", I18N_NOOP("List access time"), 0}, + {"c", 0, 0}, {"ctime", I18N_NOOP("List creation time"), 0}, + {"f", 0, 0}, {"filetype", I18N_NOOP("List file type"), 0}, + {"D", 0, 0}, {"linkdest", I18N_NOOP("List link destination"), 0}, + {"U", 0, 0}, {"url", I18N_NOOP("List URL"), 0}, + {"M", 0, 0}, {"mimetype", I18N_NOOP("List mime type"), 0}, + {"G", 0, 0}, {"guessedmimetype", I18N_NOOP("List guessed mime type"), 0}, + {"X", 0, 0}, {"xmlproperties", I18N_NOOP("List XML properties"), 0}, + {"s", 0, 0}, {"size", I18N_NOOP("List size"), 0}, + {"outfile [filename]", I18N_NOOP("Output file. Defaults to stdout"), 0}, + {"infile [filename]", I18N_NOOP("Input file. Defaults to stdin"), 0}, + {"progresswindow", I18N_NOOP("Show a progress window"), 0}, + {"nooverwrite", I18N_NOOP("Ask (graphically) before overwriting files"), 0}, + {"messages", I18N_NOOP("Show messages from the tdeioslave"), 0}, + {"+[cmd]", I18N_NOOP("Command (ls, cat, put, cp, rm, mv, mkdir, rmdir)"), 0 }, + TDECmdLineLastOption +}; + +int main(int argc, char **argv) +{ + TDEAboutData about("tdeioclient", + I18N_NOOP("tdeio client"), + version, description, + TDEAboutData::License_GPL, + "(C) 2004 Fred Schaettgen", 0, 0, + "[email protected]"); + about.addAuthor("Emanoil Kotsev", I18N_NOOP("Bluez5 and port to TDE"), "[email protected]"); + TDECmdLineArgs::init(argc, argv, &about); + TDECmdLineArgs::addCmdLineOptions(options); + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + TDEApplication app; + + CommandHandler commandHandler(args); + commandHandler.start(); + return app.exec(); +} diff --git a/src/tdeioslave/CMakeLists.txt b/src/tdeioslave/CMakeLists.txt new file mode 100644 index 0000000..11b6614 --- /dev/null +++ b/src/tdeioslave/CMakeLists.txt @@ -0,0 +1,13 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( bluetooth ) +add_subdirectory( obex ) diff --git a/src/tdeioslave/bluetooth/CMakeLists.txt b/src/tdeioslave/bluetooth/CMakeLists.txt new file mode 100644 index 0000000..f74af27 --- /dev/null +++ b/src/tdeioslave/bluetooth/CMakeLists.txt @@ -0,0 +1,40 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src/libtdebluez + ${CMAKE_BINARY_DIR}/src/libtdebluez + ${CMAKE_SOURCE_DIR}/src/tdeioslave/bluetooth + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) +##### tdeio_bluetooth (static) ############################# +set( target tdeio_bluetooth ) + +tde_add_kpart( ${target} AUTOMOC + SOURCES tdeiobluetooth.cpp + LINK ${DBUS_TQT_LIBRARIES} tdeio-shared tdebluez-shared bluezinterfaces-static + DESTINATION ${PLUGIN_INSTALL_DIR} +) + +# konqueror sidebar entry +install( + FILES bluetooth.protocol + DESTINATION ${SERVICES_INSTALL_DIR} ) +install( + FILES bluetooth_sidebarentry.desktop + DESTINATION ${DATA_INSTALL_DIR}/konqsidebartng/virtual_folders/services +) diff --git a/src/tdeioslave/bluetooth/bluetooth.protocol b/src/tdeioslave/bluetooth/bluetooth.protocol new file mode 100644 index 0000000..b99a1f5 --- /dev/null +++ b/src/tdeioslave/bluetooth/bluetooth.protocol @@ -0,0 +1,33 @@ +[Protocol] +exec=tdeio_bluetooth +protocol=bluetooth +input=none +output=filesystem +reading=true +listing=Name,Type +Icon=tdebluez +Description=Bluetooth inquiry protocol +Description[bg]=Протокол за заявка към Bluetooth +Description[ca]=Protocol de recerca Bluetooth +Description[da]=Bluetooth forespørgselsprotokol +Description[de]=Bluetooth-Anfrageprotokoll +Description[el]=Πρωτόκολλο έρευνας Bluetooth +Description[es]=Protocolo de búsqueda Bluetooth +Description[et]=Bluetoothi päringuprotokoll +Description[fr]=Protocole de Demande de renseignements Bluetooth +Description[gl]=Protocolo de pestquisa Bluetooth +Description[it]=Protocollo di richiesta Bluetooth +Description[ja]=Bluetooth 問い合わせプロトコル +Description[lt]=Bluetooth užklausų protokolas +Description[nl]=Bluetooth inquiry-protocol +Description[pl]=Protokół wyszukiwania Bluetooth +Description[pt]=Protocolo de intquisição Bluetooth +Description[pt_BR]=Protocolo de intquisição Bluetooth +Description[sr]=Протокол испитивања Bluetooth-а +Description[sr@Latn]=Protokol ispitivanja Bluetooth-a +Description[sv]=Blåtand frågeprotokoll +Description[ta]=புளூடூத்தை உள்ளிடும் நெறிமுறை +Description[tr]=Bluetooth sorgulama protokolü +Description[xx]=xxBluetooth inquiry protocolxx +maxInstances=3 +DocPath=tdebluez/components.tdeio_sdp.html diff --git a/src/tdeioslave/bluetooth/bluetooth_sidebarentry.desktop b/src/tdeioslave/bluetooth/bluetooth_sidebarentry.desktop new file mode 100644 index 0000000..79306e0 --- /dev/null +++ b/src/tdeioslave/bluetooth/bluetooth_sidebarentry.desktop @@ -0,0 +1,35 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Link +URL=bluetooth:/ +Icon=tdebluez +Name=Bluetooth Browser +Name[ar]= متصفح Bluetooth +Name[bg]=Браузър за Bluetooth +Name[br]=Furcher Bluetooth +Name[ca]=Fullejador Bluetooth +Name[da]=Bluetooth-browser +Name[de]=Bluetooth-Browser +Name[el]=Περιηγητής Bluetooth +Name[es]=Navegador Bluetooth +Name[et]=Bluetoothi brauser +Name[fr]=Navigateur Bluetooth +Name[ga]=Brabhsálaí Bluetooth +Name[gl]=Navegador Bluetooth +Name[it]=Navigatore Bluetooth +Name[ja]=Bluetooth ブラウザ +Name[lt]=Bluetooth naršyklė +Name[pa]=ਬਲਿਊਟੁੱਥ ਝਲਕਾਰਾ +Name[pl]=Przeglądarka Bluetooth +Name[pt]=Navegador Bluetooth +Name[pt_BR]=Navegador Bluetooth +Name[ru]=Обозреватель Bluetooth +Name[sr]=Bluetooth прегледач +Name[sr@Latn]=Bluetooth pregledač +Name[sv]=Blåtandsbläddrare +Name[ta]=புலுடுத் உலாவி +Name[tr]=Bluetooth Tarayıcısı +Name[xx]=xxBluetooth Browserxx +Open=false +X-TDE-TreeModule=Directory +X-TDE-KonqSidebarModule=konqsidebar_tree diff --git a/src/tdeioslave/bluetooth/tdeiobluetooth.cpp b/src/tdeioslave/bluetooth/tdeiobluetooth.cpp new file mode 100644 index 0000000..d2268a7 --- /dev/null +++ b/src/tdeioslave/bluetooth/tdeiobluetooth.cpp @@ -0,0 +1,464 @@ +//-*-c++-*- +/*************************************************************************** + * Copyright (C) 2003 by Fred Schaettgen * + * [email protected] * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#include "tdeiobluetooth.h" + +#include <sys/stat.h> +#include <dcopclient.h> +#include <tdeapplication.h> +#include <tdecmdlineargs.h> +#include <tqregexp.h> + +#include <devicemimeconverter.h> +#include <deviceImpl.h> +#include <btuuids.h> + +using namespace TDEBluetooth; + +static const TDECmdLineOptions options[] = +{ + { "+protocol", I18N_NOOP( "Protocol name" ), 0 }, + { "+pool", I18N_NOOP( "Socket name" ), 0 }, + { "+app", I18N_NOOP( "Socket name" ), 0 }, + TDECmdLineLastOption +}; + +extern "C" +{ + int kdemain(int argc, char **argv) { + TDEInstance instance( "tdeio_bluetooth" ); + kdDebug() << "*** Starting tdeio_bluetooth " << endl; + if (argc != 4) { + kdDebug() << "Usage: tdeio_bluetooth protocol domain-socket1 domain-socket2" << endl; + exit(-1); + } + + putenv(strdup("SESSION_MANAGER=")); + TDECmdLineArgs::init(argc, argv, "tdeio_bluetooth", 0, 0, 0, 0); + TDECmdLineArgs::addCmdLineOptions( options ); + + TDEApplication app( false, false, false ); + app.dcopClient()->attach(); + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + TDEioBluetooth slave( args->arg(0), args->arg(1), args->arg(2) ); + kdDebug() << "*** protocol " << args->arg(0) << endl; + kdDebug() << "*** pool socket " << args->arg(1) << endl; + kdDebug() << "*** app socket " << args->arg(2) << endl; + slave.dispatchLoop(); + kdDebug() << "*** tdeio_bluetooth Done" << endl; + return 0; + } +} + + +TDEioBluetooth::TDEioBluetooth(const TQCString &protocol, const TQCString &pool_socket, const TQCString &app_socket) : + ForwardingSlaveBase(protocol, pool_socket, app_socket) +{ + kdDebug() << k_funcinfo << endl; + + TDELocale::setMainCatalogue("tdebluez"); + TQT_DBusError error; + adapter = 0; + + manager = new TDEBluetooth::ObjectManagerImpl("org.bluez", "/"/*, this, "ObexObjectManager"*/); + + if (!manager) + { + ForwardingSlaveBase::error(TDEIO::ERR_SERVICE_NOT_AVAILABLE, i18n("Bluetooth Manager not found")); + closeConnection(); + } + else + { + if (!manager->getAdapters().isEmpty()) + { + TDEBluetooth::ObjectManagerImpl::AdapterList al = manager->getAdapters(); + TDEBluetooth::ObjectManagerImpl::AdapterList::Iterator ait = al.begin(); + for (ait; ait != al.end(); ++ait) + { + TDEBluetooth::AdapterImpl *ad = new TDEBluetooth::AdapterImpl("org.bluez", (*ait)); + ad->setConnection((*(manager->getConnection()))); + // FIXME implement multiple adapters + if (ad->getPowered(error)) + { + adapter = ad; + break; + } + } + connect(manager, SIGNAL(deviceAdded(const TQString &)), + this, SLOT(slotAddDevice(const TQString &))); + connect(manager, SIGNAL(deviceRemoved(const TQString &)), + this, SLOT(slotRemoveDevice(const TQString &))); + connect(manager, SIGNAL(adapterPowerOnChanged(const TQString&, bool )), + this, SLOT(slotAdapterPowerOnChanged(const TQString &, bool ))); + } + else + { + ForwardingSlaveBase::error(TDEIO::ERR_SERVICE_NOT_AVAILABLE, i18n("No adapter found")); + closeConnection(); + } + } +} + +TDEioBluetooth::~TDEioBluetooth() +{ + kdDebug() << k_funcinfo << endl; + if (manager) delete manager; + if (adapter) delete adapter; +} + +void TDEioBluetooth::closeConnection() +{ + kdDebug() << k_funcinfo << endl; + exit(); +} + +void TDEioBluetooth::stat(const KURL &url) +{ + kdDebug() << __func__ << "(" << url.prettyURL() << ")" << endl; + + TDEIO::UDSEntry entry; + + if (!adapter) + { +// ForwardingSlaveBase::warning(i18n("Bluetooth Adapter not found")); +// ForwardingSlaveBase::error(TDEIO::ERR_SERVICE_NOT_AVAILABLE, i18n("Bluetooth Adapter not found")); + TQString name = "No device found"; + TQ_UINT32 devClass = 0; + + addAtom(entry, TDEIO::UDS_NAME, name); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_ACCESS, 0555); + addAtom(entry, TDEIO::UDS_MIME_TYPE, DeviceMimeConverter::classToMimeType(devClass)); + addAtom(entry, TDEIO::UDS_ICON_NAME, DeviceMimeConverter::classToIconName(devClass)); + + return; + } + + TQT_DBusError dbuserror; + TQString path = url.path(); + if (path.isEmpty() || path == "/") + { + // The root is "virtual" - it's not a single physical directory + createTopLevelEntry(entry); + } + else if (path.find(TQRegExp("/\\[([0-9A-F]{2}:){5}[0-9A-F]{2}\\]"), 0) != -1) + { + createDirEntry(entry, path, path); + } + else + { + ForwardingSlaveBase::error(TDEIO::ERR_MALFORMED_URL, i18n("Could not stat %1.").arg(url.prettyURL())); + } + statEntry(entry); + finished(); +} + +void TDEioBluetooth::listDir(const KURL &url) +{ + kdDebug() << k_funcinfo << endl; + + if (!adapter) + { + ForwardingSlaveBase::error(TDEIO::ERR_SERVICE_NOT_AVAILABLE, i18n("Bluetooth Adapter not found")); + return; + } + + TDEIO::UDSEntry entry; + TQValueList<TDEIO::UDSEntry> list; + TQT_DBusError error; + TDEIO::UDSEntryList entries; + + TQString path = url.path(); + TQString name = adapter->getName(error); + + kdDebug() << __func__ << "(" << path << ")" << endl; + + TQRegExp rx("/" + name + "/\\[([0-9A-F]{2}:){5}[0-9A-F]{2}\\]"); + kdDebug() << "Regex: " << rx.search(path) << endl; + + if (rx.search(path) == 0) + { + listServices(list, url); + } + else if (path == "/" + name) + { + listDevices(list, url); + } + else if (path == "/") + { + createTopLevelEntry(entry); + listEntry(entry, false); + } + else + { + ForwardingSlaveBase::listDir(url); + } + + if (list.count() > 0) + { + kdDebug() << __func__ << "(" << path << ")" << endl; + totalSize(list.count() + 1); + + TDEIO::UDSEntryListIterator it = list.begin(); + TDEIO::UDSEntryListIterator end = list.end(); + for (; it != end; ++it) + { + entries.append(*it); + } + listEntries(entries); + } + listEntry(entry, true); + + finished(); + return; +} + +bool TDEioBluetooth::rewriteURL(const KURL &url, KURL &newUrl) +{ + kdDebug() << k_funcinfo << endl; + + TQString path = url.path(); + TQString protocol = url.protocol(); + + if (protocol == "obexopp" || protocol == "obexftp") + { + newUrl = url; + return true; + } + else + { + ForwardingSlaveBase::error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + return false; + } +} + +void TDEioBluetooth::createTopLevelEntry(TDEIO::UDSEntry &entry) +{ + kdDebug() << k_funcinfo << endl; + + TQT_DBusError error; + TQString name = adapter->getName(error); + TQ_UINT32 devClass = adapter->getClass(error); + + addAtom(entry, TDEIO::UDS_NAME, name); + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, TDEIO::UDS_ACCESS, 0555); + addAtom(entry, TDEIO::UDS_MIME_TYPE, DeviceMimeConverter::classToMimeType(devClass)); + addAtom(entry, TDEIO::UDS_ICON_NAME, DeviceMimeConverter::classToIconName(devClass)); +} + +bool TDEioBluetooth::listDevice(TDEIO::UDSEntry &entry, const TQString &path, const KURL &url) +{ + kdDebug() << __func__ << "(" << url << ")" << endl; + TQT_DBusError error; + + TDEBluetooth::DeviceImpl *dev = new TDEBluetooth::DeviceImpl("org.bluez", path); + dev->setConnection((*(manager->getConnection()))); + + const TQString addr = dev->getAddress(error); + TQString name = dev->getName(error); + TQString alias = dev->getAlias(error); + const int devClass = dev->getClass(error); + TQString aname = adapter->getName(error); + + delete dev; + + entry.clear(); + + if (!alias.isEmpty()) + name = alias; + else + name = alias = addr; + + createDirEntry(entry, name, TQString("bluetooth:/%1/[%2]").arg(aname).arg(addr), + DeviceMimeConverter::classToMimeType(devClass)); + + return true; +} + +bool TDEioBluetooth::listDevices(TQValueList<TDEIO::UDSEntry> &list, const KURL &url) +{ + kdDebug() << __func__ << "(" << url << ")" << endl; + + TDEIO::UDSEntry entry; + TDEBluetooth::ObjectManagerImpl::DeviceList dl = manager->getDevices(); + TDEBluetooth::ObjectManagerImpl::DeviceList::Iterator dit = dl.begin(); + for (dit; dit != dl.end(); ++dit) + { + entry.clear(); + listDevice(entry, (*dit), url); + list.append(entry); + } + + return true; +} + +bool TDEioBluetooth::listServices(TQValueList<TDEIO::UDSEntry> &list, const KURL &url) +{ + kdDebug() << __func__ << "url: " << url << endl; + + TDEIO::UDSEntry entry; + TQString path = url.path(); + + kdDebug() << __func__ << "path: " << path << endl; + + int pos = path.find(TQRegExp("/\\[([0-9A-F]{2}:){5}[0-9A-F]{2}\\]"), 0); + if (pos != -1) + { + + TQString address = path.remove(0, pos + 2).remove(17, path.length()); + kdDebug() << __func__ << "address: " << address << endl; + + TDEBluetooth::ObjectManagerImpl::DeviceList dl = manager->getDevices(); + TDEBluetooth::ObjectManagerImpl::DeviceList::Iterator dit = dl.begin(); + for (dit; dit != dl.end(); ++dit) + { + TDEBluetooth::DeviceImpl *d = new TDEBluetooth::DeviceImpl("org.bluez", (*dit)); + d->setConnection((*(manager->getConnection()))); + + TQT_DBusError dbuserror; + TQString addr = d->getAddress(dbuserror); + if (addr == address) + { + TQStringList uuids = d->getUUIDs(dbuserror); + for (TQStringList::Iterator it = uuids.begin(); + it != uuids.end(); ++it) + { + entry.clear(); + // accepted services OBEX OPP, PCE, FTP + //FIXME temporary disabled +// if ((*it) == "00001105-0000-1000-8000-00805f9b34fb") +// { +// createDirEntry(entry, resolveUUID((*it)), TQString("obexopp:/[%1]/").arg(address), "bluetooth/obex-objectpush-profile"); +// addAtom(entry, TDEIO::UDS_NAME, "obexopp"); +// list.append(entry); +// } +// else if ((*it) == "00001106-0000-1000-8000-00805f9b34fb") +// { +// createDirEntry(entry, resolveUUID((*it)), TQString("obexftp:/[%1]/").arg(address), "bluetooth/obex-ftp-profile"); +// addAtom(entry, TDEIO::UDS_NAME, "obexftp"); +// list.append(entry); +// } + } + break; + } + delete d; + } + } + else + { + ForwardingSlaveBase::error(TDEIO::ERR_MALFORMED_URL, url.url()); + } + + return true; +} + +bool TDEioBluetooth::createDirEntry(TDEIO::UDSEntry &entry, const TQString &name, const TQString &dir, const TQString &mimeType) +{ + kdDebug() << k_funcinfo << endl; + + addAtom(entry, TDEIO::UDS_NAME, name); + if (dir != TQString::null) + { + addAtom(entry, TDEIO::UDS_URL, dir); + } + addAtom(entry, TDEIO::UDS_MIME_TYPE, mimeType); + + if (mimeType == "inode/directory") + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IFDIR); + else + addAtom(entry, TDEIO::UDS_FILE_TYPE, S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH); + + return true; +} + +void TDEioBluetooth::slotAddDevice(const TQString &path) +{ + kdDebug() << k_funcinfo << endl; + listDir("bluetooth:/"); +} + +void TDEioBluetooth::slotRemoveDevice(const TQString &path) +{ + kdDebug() << __func__ << "(" << path << ")" << endl; + listDir("bluetooth:/"); + +// TQT_DBusError error; +// TDEBluetooth::DeviceImpl *d= new TDEBluetooth::DeviceImpl("org.bluez",path); +// d->setConnection((*(manager->getConnection()))); +// const TQString address = d->getAddress(error); +// delete d; +// +// listDevice(address); +// listEntry(TDEIO::UDSEntry(), true); + +} + +void TDEioBluetooth::slotAddService(const KURL &url, const TQString uuid) +{ + kdDebug() << __func__ << "(URL=" << url << ", UUID=" << uuid << ")" << endl; + +// TQT_DBusError error; +// TDEBluetooth::DeviceImpl *d= new TDEBluetooth::DeviceImpl("org.bluez",path); +// d->setConnection((*(manager->getConnection()))); +// const TQString address = d->getAddress(error); +// TQ_UINT32 devclass = d->getClass(error); +// const TQString devicon = DeviceMimeConverter::classToIconName(devclass); +// delete d; +// +// TQMap<TQString,int>::iterator f=qDevicesList.find(address); +// if(f!=qDevicesList.end() && f.data() == devclass) return; + +// listEntry(UDSEntry(), true); + +} + +void TDEioBluetooth::slotAdapterPowerOnChanged(TQString const& path, bool state) +{ + kdDebug() << __func__ << "(" << path << ")" << endl; +// +// TQT_DBusError error; +// TDEBluetooth::DeviceImpl *d= new TDEBluetooth::DeviceImpl("org.bluez",path); +// d->setConnection((*(manager->getConnection()))); +// const TQString address = d->getAddress(error); +// TQ_UINT32 devclass = d->getClass(error); +// const TQString devicon = DeviceMimeConverter::classToIconName(devclass); +// delete d; +// +// TQMap<TQString,int>::iterator f=qDevicesList.find(address); +// if(f!=qDevicesList.end() && f.data() == devclass) return; +// qDevicesList.insert(address, devclass); +// +// listDevice(address); +// listEntry(UDSEntry(), true); + +} + +void TDEioBluetooth::addAtom(TDEIO::UDSEntry &entry, TDEIO::UDSAtomTypes type, TQString s) +{ + kdDebug() << k_funcinfo << endl; + TDEIO::UDSAtom atom; + atom.m_uds = type; + atom.m_str = s; + entry.append(atom); +} + +void TDEioBluetooth::addAtom(TDEIO::UDSEntry &entry, TDEIO::UDSAtomTypes type, long l) +{ + kdDebug() << k_funcinfo << endl; + TDEIO::UDSAtom atom; + atom.m_uds = type; + atom.m_long = l; + entry.append(atom); +} + +#include "tdeiobluetooth.moc" diff --git a/src/tdeioslave/bluetooth/tdeiobluetooth.h b/src/tdeioslave/bluetooth/tdeiobluetooth.h new file mode 100644 index 0000000..7b881f2 --- /dev/null +++ b/src/tdeioslave/bluetooth/tdeiobluetooth.h @@ -0,0 +1,56 @@ +//-*-c++-*- +/*************************************************************************** + * Copyright (C) 2003 by Fred Schaettgen * + * [email protected] * + * * + * 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 2 of the License, or * + * (at your option) any later version. * + ***************************************************************************/ + +#ifndef _TDEIOBT_H_ +#define _TDEIOBT_H_ + +#include <tdeio/forwardingslavebase.h> +#include <vector> + +#include <adapterImpl.h> +#include <objectmanagerImpl.h> + +class TDEioBluetooth : public TDEIO::ForwardingSlaveBase +{ + Q_OBJECT + +public: + TDEioBluetooth(const TQCString &protocol, const TQCString &pool_socket, const TQCString &app_socket); + virtual ~TDEioBluetooth(); + virtual void closeConnection(); + virtual void stat(const KURL &url); + virtual void listDir(const KURL &url); + +protected: + virtual bool rewriteURL(const KURL &url, KURL &newUrl); + +private: + void createTopLevelEntry(TDEIO::UDSEntry& entry); + bool listDevice(TDEIO::UDSEntry &entry, const TQString &path, const KURL &url); + bool listDevices(TQValueList<TDEIO::UDSEntry> &list, const KURL &url); + bool listServices(TQValueList<TDEIO::UDSEntry> &list, const KURL &url); + bool createDirEntry(TDEIO::UDSEntry &entry, const TQString &title, + const TQString &dir = TQString::null, const TQString &mimeType = "inode/directory"); + void addAtom(TDEIO::UDSEntry &entry, TDEIO::UDSAtomTypes type, TQString s); + void addAtom(TDEIO::UDSEntry &entry, TDEIO::UDSAtomTypes type, long l); + + TDEBluetooth::AdapterImpl *adapter; + TDEBluetooth::ObjectManagerImpl *manager; + +private slots: + void slotAddDevice(const TQString &address); + void slotAddService(const KURL &url, const TQString uuid); + void slotRemoveDevice(const TQString &address); + void slotAdapterPowerOnChanged(const TQString & path, bool state) ; + +}; + +#endif //TDEIOBT diff --git a/src/tdeioslave/obex/CMakeLists.txt b/src/tdeioslave/obex/CMakeLists.txt new file mode 100644 index 0000000..d31aa6f --- /dev/null +++ b/src/tdeioslave/obex/CMakeLists.txt @@ -0,0 +1,38 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src/libtdeobex + ${CMAKE_BINARY_DIR}/src/libtdeobex + ${CMAKE_SOURCE_DIR}/src/tdeioslave/obex + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) +##### tdeio_bluetooth (static) ############################# +set( target tdeio_obex ) + +tde_add_kpart( ${target} AUTOMOC + SOURCES tdeio_obex.cpp obex.cpp + LINK ${DBUS_TQT_LIBRARIES} tdeio-shared tdeobex-shared obexinterfaces-static + DESTINATION ${PLUGIN_INSTALL_DIR} +) + +install( FILES obexftp.protocol + DESTINATION ${SERVICES_INSTALL_DIR} ) +install( FILES obexopp.protocol + DESTINATION ${SERVICES_INSTALL_DIR} ) +install( FILES obex_sidebarentry.desktop + DESTINATION ${DATA_INSTALL_DIR}/konqsidebartng/virtual_folders/services )
\ No newline at end of file diff --git a/src/tdeioslave/obex/README b/src/tdeioslave/obex/README new file mode 100644 index 0000000..a44d55f --- /dev/null +++ b/src/tdeioslave/obex/README @@ -0,0 +1,91 @@ + +OBEX tdeio slave. +--------------- + +At the moment it is mostly working with ober IP, IrDA and the Siemens BFB +transport protocol. The slave ues url's of the form + +obex://hostname:port/path + +for IP connections. It will use the standard OBEX port 650 if the port +argument is omitted. The IP transport also queries for the nss/netdb entry + +obex 650/tcp + +if registered in the services database. (see getent(1) or nsswitch.conf(5)) +The IP transport also tries the port 29650. This one is used in case of +a server running without root privileges. + +The IrDA Transport is accessed via the url format + +obex://irda/path + +In this case device discovery is done and the first device offering +the OBEX hint bit is connected. + +The Bluetooth Transport is accessed via the url format + +obex://bluetooth/path + +In this case device discovery is done and the first device offering +the filesystem browsing profile is connected. + +There exist serial transports for Siemens mobiles. It is currently untested. +In theory it should work. + +A serial transport for the ericcson mobiles is also in the works. It should be +easy to do. It is also difficult to test because I don't know anyone with an +ericsson phone ... + +I have removed the old url format using '!' to separate transport options. +There is now a kcontrol module for configuration. Using this module one can +define 'OBEX hosts' which can be used for hostnames in OBEX url's. Since there +are many configuration options i think this is the best method to access +specific devices. If you know the hardware addresses of your bluetooth or +irda device you can use url's of the form: + +obex://[ef:01:23:45]/ + +if your irda device has the address ef:01:23:45 or + +obex://[ab:cd:ef:01:23:45]/ + +if your bluetooth device has the hardware address ab:cd:ef:01:23:45. +For bluetooth you can also include the rfcomm channel of the folderbrowsing +profile in the usual port field. + +OBEX authentication is currently supported in url's. +More complete authentication configutation will come. + +DEVICE COMPATIBILITY + +The NOKIA 3650 mobile has a firmware bug in some versions. +Mobiles with this bug return invalid XML files for folder listings. This +leads to empty directories. Thie bug is reported to be in at least firmware +version 2.50. The firmware version 3.16 fixed this bug. +Thanks to Fred Schaettgen <[email protected]> for testing. + +My Siemens S45i works well with this implementation. + +Connections from and to openobex driven clients or servers will be refused, +since openobex uses a wrong protocol version value in connect +requests/responses. + +DOCUMENTATION + +Hmm, can someone tell me how to write kdehelp documentation? + +DEMO SERVER + +There is an example folderbowsing server in the subfolder +libqobex/qobexfbssrv/. This server and the server api is currently under +heavy development. It listens by default on localhost. You can change the +transport where it listens with -t <whatever>. It is also password protected +by the password 'fbsserver' For more information think of the wisdom of +the yedi: + +Use the source Luke + +:) + +Have fun! diff --git a/src/tdeioslave/obex/obex.cpp b/src/tdeioslave/obex/obex.cpp new file mode 100644 index 0000000..fb1d81b --- /dev/null +++ b/src/tdeioslave/obex/obex.cpp @@ -0,0 +1,312 @@ +/* + This file is part of tdeio_obex. + + Copyright (c) 2003 Mathias Froehlich <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +#include "obex.h" + +#include <kdebug.h> +#include <tqapplication.h> +#include <tqeventloop.h> +#include <tqregexp.h> + +#include <sys/stat.h> + +#include <tqdbusvariant.h> + +#define MINIMUM_UID 500 + +Obex::Obex(TQString &protocol) : + mProtocol(protocol) +{ + kdDebug() << k_funcinfo << endl; + KUser user; + m_effectiveUid = user.uid(); +} + +Obex::~Obex() +{ + kdDebug() << k_funcinfo << endl; +} + +bool Obex::parseURL(const KURL &url, TQString &address, TQString &name, TQString &path) const +{ + kdDebug() << k_funcinfo << endl; + TQString url_path = url.path(+1); + + if (url_path.find(TQRegExp("/\\[([0-9A-F]{2}:){5}[0-9A-F]{2}\\]"), 0) != -1) + { + address = url_path.remove(0, 2); + address = address.remove(17, url_path.length()); + url_path = url_path.remove(0, 18); + kdDebug() << "Obex::parseURL address : " << address << endl; + kdDebug() << "Obex::parseURL url_path : " << url_path << endl; + } + else + return false; + + int i = url_path.find('/', 1); + if (i > 0) + { + name = url_path.mid(1, i - 1); + } + else + { + name = url_path.mid(1); + } + path = url_path; + kdDebug() << "Obex::parseURL path : " << path << endl; + kdDebug() << "Obex::parseURL name : " << name << endl; + + return true; +} + +void Obex::addAtom(UDSEntry &entry, UDSAtomTypes type, const TQString &s) +{ + kdDebug() << k_funcinfo << endl; + UDSAtom atom; + atom.m_uds = type; + atom.m_str = s; + entry.append(atom); +} + +void Obex::addAtom(UDSEntry &entry, UDSAtomTypes type, const long l) +{ + kdDebug() << k_funcinfo << endl; + UDSAtom atom; + atom.m_uds = type; + atom.m_long = l; + entry.append(atom); +} + +void Obex::createTopLevelEntry(UDSEntry &entry) +{ + kdDebug() << k_funcinfo << endl; + + entry.clear(); + addAtom(entry, UDS_NAME, "."); + addAtom(entry, UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, UDS_ACCESS, 0555); + addAtom(entry, UDS_MIME_TYPE, "inode/directory"); + addAtom(entry, UDS_ICON_NAME, "pda_blue"); + addAtom(entry, UDS_USER, "root"); + addAtom(entry, UDS_GROUP, "root"); +} + +void Obex::createDirEntry(UDSEntry &entry, const TQString dir) +{ + kdDebug() << k_funcinfo << endl; + entry.clear(); + addAtom(entry, UDS_NAME, "/" + dir); + addAtom(entry, UDS_FILE_TYPE, S_IFDIR); + addAtom(entry, UDS_ACCESS, 0755); + addAtom(entry, UDS_MIME_TYPE, "inode/directory"); + addAtom(entry, UDS_ICON_NAME, "pda_blue"); + addAtom(entry, UDS_USER, "root"); + addAtom(entry, UDS_GROUP, "root"); +} + +void Obex::slotStatResult(Job *job) +{ + kdDebug() << k_funcinfo << endl; + if (job->error() == 0) + { + StatJob *stat_job = static_cast<StatJob *>(job); + m_entryBuffer = stat_job->statResult(); + } + + tqApp->eventLoop()->exitLoop(); +} + +UDSEntry Obex::createUDSEntry(const TQMap<TQString, TQT_DBusData> &map) +{ + kdDebug() << k_funcinfo << endl; + + UDSEntry entry; + long mode; + uint isFile = 0; + + TQMap<TQString, TQT_DBusData>::const_iterator mit = map.begin(); + for (mit; mit != map.end(); ++mit) + { + + UDSAtom atom; + if (mit.key() == "Accessed") + { + TQString v = mit.data().toVariant().value.toString(); + atom.m_uds = UDS_ACCESS_TIME; + atom.m_long = stringToTime_t(v); + entry.append(atom); + } + if (mit.key() == "Created") + { + TQString v = mit.data().toVariant().value.toString(); + atom.m_uds = UDS_CREATION_TIME; + atom.m_long = stringToTime_t(v); + entry.append(atom); + } + if (mit.key() == "Group-perm") + { + TQString v = mit.data().toVariant().value.toString(); + if (v.contains('R', FALSE)) + mode |= S_IRGRP; + if (v.contains('W', FALSE)) + mode |= S_IWGRP; + } + if (mit.key() == "Modified") + { + TQString v = mit.data().toVariant().value.toString(); + atom.m_uds = UDS_MODIFICATION_TIME; + atom.m_long = stringToTime_t(v); + entry.append(atom); + } + if (mit.key() == "Size") + { + TQ_UINT64 v = mit.data().toVariant().value.toUInt64(); + atom.m_uds = UDS_SIZE; + atom.m_long = v; + entry.append(atom); + } + if (mit.key() == "Name") + { + TQString v = mit.data().toVariant().value.toString(); + atom.m_uds = UDS_NAME; + atom.m_str = v; + entry.append(atom); + } + if (mit.key() == "Other-perm") + { + TQString v = mit.data().toVariant().value.toString(); + if (v.contains('R', FALSE)) + mode |= S_IROTH; + if (v.contains('W', FALSE)) + mode |= S_IWOTH; + } + if (mit.key() == "Type") + { + TQString v = mit.data().toVariant().value.toString(); + if (v == "folder") + { + isFile = 1; + } + if (v == "file") + { + TQString v = mit.data().toVariant().value.toString(); + isFile = 2; + } + } + if (mit.key() == "User-perm") + { + TQString v = mit.data().toVariant().value.toString(); + if (v.contains('R', FALSE)) + mode |= S_IRUSR; + if (v.contains('W', FALSE)) + mode |= S_IWUSR; + } + } + + if (isFile == 1) + { + if (mode & S_IRUSR) + mode |= S_IXUSR; + if (mode & S_IRGRP) + mode |= S_IXGRP; + if (mode & S_IROTH) + mode |= S_IXOTH; + + UDSAtom atom; + atom.m_uds = UDS_ACCESS; + atom.m_long = mode; + entry.append(atom); + + // set the file type + atom.m_uds = UDS_FILE_TYPE; + atom.m_long = S_IFDIR; + entry.append(atom); + } + else if (isFile == 2) + { + UDSAtom atom; + atom.m_uds = UDS_ACCESS; + atom.m_long = mode; + entry.append(atom); + + // set the file type + atom.m_uds = UDS_FILE_TYPE; + atom.m_long = S_IFREG; + entry.append(atom); + } + else + { + //FIXME fall back + } + return entry; +} + +time_t Obex::stringToTime_t(TQString str) +{ + kdDebug() << k_funcinfo << endl; + + str.insert(13, ':'); + str.insert(11, ':'); + str.insert(6, '-'); + str.insert(4, '-'); + TQDateTime time = TQDateTime::fromString(str, TQt::ISODate); + + return time.toTime_t(); +} + +UDSEntry Obex::extractUrlInfos(const KURL &url) +{ + kdDebug() << k_funcinfo << endl; + + m_entryBuffer.clear(); + + StatJob *job = stat(url, false); + connect(job, TQT_SIGNAL(result(Job *)), this, TQT_SLOT(slotStatResult(Job *))); + tqApp->eventLoop()->enterLoop(); + + UDSEntry::iterator it = m_entryBuffer.begin(); + UDSEntry::iterator end = m_entryBuffer.end(); + + UDSEntry infos; + + for (; it != end; ++it) + { + switch ((*it).m_uds) + { + case UDS_ACCESS: + case UDS_USER: + case UDS_GROUP: + case UDS_CREATION_TIME: + case UDS_MODIFICATION_TIME: + case UDS_ACCESS_TIME: + infos.append(*it); + break; + default: + break; + } + } + + addAtom(infos, UDS_LOCAL_PATH, url.path()); + + return infos; +} + +#include "obex.moc" diff --git a/src/tdeioslave/obex/obex.h b/src/tdeioslave/obex/obex.h new file mode 100644 index 0000000..bc6d3cc --- /dev/null +++ b/src/tdeioslave/obex/obex.h @@ -0,0 +1,66 @@ +/* + This file is part of tdeio_obex. + + Copyright (c) 2003 Mathias Froehlich <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef OBEX_H +#define OBEX_H + + +#include <tdeio/global.h> +#include <tdeio/job.h> +#include <kurl.h> +#include <kuser.h> + +#include <tqdbusdata.h> + +#include <tqstring.h> + +using namespace TDEIO; + +class Obex : public TQObject +{ + Q_OBJECT + +public: + Obex(TQString & mProtocol); + virtual ~Obex(); + bool parseURL(const KURL &url, TQString &address, TQString &name, TQString &path) const; + void createTopLevelEntry(UDSEntry &entry); + void createDirEntry(UDSEntry &entry, const TQString dir); + UDSEntry createUDSEntry( const TQMap< TQString, TQT_DBusData > &map ); + bool changeWorkingDirectory( const TQString& to ); + +private slots: + void slotStatResult(Job *job); + +private: + + UDSEntry extractUrlInfos(const KURL &url); + UDSEntry m_entryBuffer; + void addAtom(UDSEntry &entry, UDSAtomTypes type, const TQString &s); + void addAtom(UDSEntry &entry, UDSAtomTypes type, const long l); + + time_t stringToTime_t( TQString ); + + long m_effectiveUid; + TQString mProtocol; +}; + +#endif diff --git a/src/tdeioslave/obex/obex_sidebarentry.desktop b/src/tdeioslave/obex/obex_sidebarentry.desktop new file mode 100644 index 0000000..9bc0178 --- /dev/null +++ b/src/tdeioslave/obex/obex_sidebarentry.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Encoding=UTF-8 +Type=Link +URL=obexftp:/ +Icon=tdebluez +Name=Bluetooth Browser +Name[et]=Bluetoothi brauser +Open=false +X-TDE-TreeModule=Directory +X-TDE-KonqSidebarModule=konqsidebar_tree diff --git a/src/tdeioslave/obex/obexftp.protocol b/src/tdeioslave/obex/obexftp.protocol new file mode 100644 index 0000000..3262d4b --- /dev/null +++ b/src/tdeioslave/obex/obexftp.protocol @@ -0,0 +1,52 @@ +[Protocol] +# The executable +exec=tdeio_obex +# This protocol name +protocol=obexftp +Parent=system:/ + +# input/output can be one of: filesystem, stream, none +input=none +output=filesystem +maxInstances=1 + +# capabilities for this protocol +reading=true +writing=true +makedir=true +deleting=true +moving=false +linking=false + +# What to list ... FIXME work out how ... +listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group + +# Can be source protocol +source=false + +Description=A tdeioslave for OBEX connections +Description[bg]=tdeioslave за OBEX връзки +Description[br]=Ur c'hioslave evit ar c'hevreadennoù OBEX +Description[ca]=Un tdeioslave per a les connexions OBEX +Description[da]=En tdeioslave til OBEX-forbindelser +Description[de]=Ein tdeioslave für OBEX-Verbindungen +Description[el]=Ένας υπηρέτης tdeio για συνδέσεις OBEX +Description[es]=Un 'tdeioslave' para conexiones OBEX +Description[et]=OBEX-ühenduste I/O-moodul +Description[fr]=Un tdeioslave pour les connexions OBEX +Description[it]=Un tdeioslave per connessioni OBEX +Description[ja]=OBEX 接続のための tdeioslave +Description[ka]=tdeioslave OBEX კავშირებისთვის +Description[nl]=Een tdeioslave for OBEX-verbindingen +Description[pl]=Wtyczka protokołu dla połączeń OBEX +Description[pt]=Um 'tdeioslave' para ligações OBEX +Description[pt_BR]=Um 'tdeioslave' para ligações OBEX +Description[sr]=tdeioslave за OBEX везе +Description[sr@Latn]=tdeioslave za OBEX veze +Description[sv]=En I/O-slav för OBEX-anslutningar +Description[ta]=ஒரு OBEX இணைப்பிற்க்காண tdeioslave. +Description[tr]=OBEX bağlantıları için bir tdeioslave +Description[xx]=xxA tdeioslave for OBEX connectionsxx +Icon=remote + +DocPath=tdebluez/components.tdeio_obex.html diff --git a/src/tdeioslave/obex/obexopp.protocol b/src/tdeioslave/obex/obexopp.protocol new file mode 100644 index 0000000..964bab9 --- /dev/null +++ b/src/tdeioslave/obex/obexopp.protocol @@ -0,0 +1,52 @@ +[Protocol] +# The executable +exec=tdeio_obex +# This protocol name +protocol=obexopp +Parent=system:/ + +# input/output can be one of: filesystem, stream, none +input=none +output=none +maxInstances=1 + +# capabilities for this protocol +reading=false +writing=true +makedir=false +deleting=false +moving=false +linking=false + +# What to list ... FIXME work out how ... +listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group + +# Can be source protocol +source=false + +Description=A tdeioslave for OBEX connections +Description[bg]=tdeioslave за OBEX връзки +Description[br]=Ur c'hioslave evit ar c'hevreadennoù OBEX +Description[ca]=Un tdeioslave per a les connexions OBEX +Description[da]=En tdeioslave til OBEX-forbindelser +Description[de]=Ein tdeioslave für OBEX-Verbindungen +Description[el]=Ένας υπηρέτης tdeio για συνδέσεις OBEX +Description[es]=Un 'tdeioslave' para conexiones OBEX +Description[et]=OBEX-ühenduste I/O-moodul +Description[fr]=Un tdeioslave pour les connexions OBEX +Description[it]=Un tdeioslave per connessioni OBEX +Description[ja]=OBEX 接続のための tdeioslave +Description[ka]=tdeioslave OBEX კავშირებისთვის +Description[nl]=Een tdeioslave for OBEX-verbindingen +Description[pl]=Wtyczka protokołu dla połączeń OBEX +Description[pt]=Um 'tdeioslave' para ligações OBEX +Description[pt_BR]=Um 'tdeioslave' para ligações OBEX +Description[sr]=tdeioslave за OBEX везе +Description[sr@Latn]=tdeioslave za OBEX veze +Description[sv]=En I/O-slav för OBEX-anslutningar +Description[ta]=ஒரு OBEX இணைப்பிற்க்காண tdeioslave. +Description[tr]=OBEX bağlantıları için bir tdeioslave +Description[xx]=xxA tdeioslave for OBEX connectionsxx +Icon=remote + +DocPath=tdebluez/components.tdeio_obex.html diff --git a/src/tdeioslave/obex/tdeio_obex.cpp b/src/tdeioslave/obex/tdeio_obex.cpp new file mode 100644 index 0000000..fbd2fb5 --- /dev/null +++ b/src/tdeioslave/obex/tdeio_obex.cpp @@ -0,0 +1,548 @@ +/* + This file is part of tdeio_obex. + + Copyright (c) 2003 Mathias Froehlich <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +#include <stdlib.h> +#include <unistd.h> +//#include <sys/stat.h> +#include <pwd.h> +#include <grp.h> + +#include <kdebug.h> + +#include <tdeapplication.h> +#include <dcopclient.h> +#include <tdecmdlineargs.h> + +#include <tqdbusvariant.h> +#include <tqdbusdatalist.h> +#include <tqdbusdatamap.h> + +#include "tdeio_obex.h" + +static const TDECmdLineOptions options[] = { { "+protocol", I18N_NOOP( + "Protocol name"), 0 }, { "+pool", I18N_NOOP("Socket name"), 0 }, { + "+app", I18N_NOOP("Socket name"), 0 }, TDECmdLineLastOption }; + +extern "C" { + int KDE_EXPORT kdemain( int argc, char **argv ) + { + // TDEApplication is necessary to use other ioslaves + putenv(strdup("SESSION_MANAGER=")); + TDECmdLineArgs::init(argc, argv, "tdeio_obex", 0, 0, 0, 0); + TDECmdLineArgs::addCmdLineOptions( options ); + TDEApplication app( false, false, false ); + // We want to be anonymous even if we use DCOP + app.dcopClient()->attach(); + + TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs(); + ObexProtocol slave( args->arg(0), args->arg(1), args->arg(2) ); + slave.dispatchLoop(); + return 0; + } +} + +ObexProtocol::ObexProtocol(const TQCString &protocol, const TQCString &pool_socket, const TQCString &app_socket) : + SlaveBase(protocol, pool_socket, app_socket) +{ + kdDebug() << k_funcinfo << endl; + mChannel = 0; + mAddress = TQString::null; + mSessionPath = TQString(); + mFileTransfer = 0; + mSessionProperties = 0; + mSession = 0; + mClient = 0; + mProtocol = protocol; + mHost = TQString::null; + mConnected = false; + + mManager = new TDEObex::ObexObjectManagerImpl("org.bluez.obex", "/"); + if (!mManager->isConnectedToDBUS()) + { + TQString err = "ObexObjectManager is not connected to DBus"; + tqDebug(err); + // infoMessage(i18n("Error")); + TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT, err); + exit(); + } + + kdDebug() << "ObexProtocol::ObexProtocol DBus connection: " << (*(mManager->getConnection())).uniqueName() << endl; + + if (mProtocol == "obexftp" || mProtocol == "obexopp") + { + obex = new Obex(mProtocol); + // mConnected = connectObex(); + } + else + exit(); + + if (!mClient) + mClient = mManager->getClient(); + if (!mClient) + { + TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT, "ObexClient was not created"); + exit(); + } + +} + +ObexProtocol::~ObexProtocol() +{ + kdDebug() << k_funcinfo << endl; + if (mConnected) + closeObex(); + if (obex) + delete obex; + if (mManager) + delete mManager; +} + +void ObexProtocol::closeConnection() +{ + kdDebug() << k_funcinfo << endl; + closeObex(); +} + +void ObexProtocol::closeObex() +{ + kdDebug() << k_funcinfo << endl; + + TQT_DBusError dbuserror; + if (mConnected && !mSessionPath.isEmpty()) + { + // infoMessage(i18n("Disconnecting")); + if (!mClient->RemoveSession(mSessionPath, dbuserror)) + { + if (dbuserror.isValid()) + TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT, dbuserror.message()); + } + // infoMessage(i18n("Disconnected")); + } + + if (mFileTransfer) + delete mFileTransfer; + if (mSessionProperties) + delete mSessionProperties; + if (mSession) + delete mSession; + if (mClient) + delete mClient; + mConnected = false; + + exit(); +} + +//void ObexProtocol::openConnection() +//{ +// kdDebug() << k_funcinfo << endl; +// +//} + +bool ObexProtocol::connectObex() +{ + kdDebug() << k_funcinfo << endl; + + TQT_DBusError dbuserror; + + TQT_DBusVariant obexprot; + if (mProtocol == "obexftp") + obexprot.value = TQT_DBusData::fromString("00001106-0000-1000-8000-00805f9b34fb"); + else if (mProtocol == "obexopp") + obexprot.value = TQT_DBusData::fromString("00001105-0000-1000-8000-00805f9b34fb"); + else if (mProtocol == "obexmap") + obexprot.value = TQT_DBusData::fromString("00001134-0000-1000-8000-00805f9b34fb"); + else if (mProtocol == "obexpbap") + obexprot.value = TQT_DBusData::fromString("00001130-0000-1000-8000-00805f9b34fb"); + else if (mProtocol == "obexsync") + obexprot.value = TQT_DBusData::fromString("00001104-0000-1000-8000-00805f9b34fb"); + obexprot.signature = obexprot.value.buildDBusSignature(); + TQMap<TQString, TQT_DBusVariant> args; + args.insert(TQString("Target"), obexprot); + + if (mSessionPath.isEmpty()) + { + kdDebug() << "ObexProtocol::connectObex : trying to create session" << endl; + if (!mClient->CreateSession(mAddress, args, mSessionPath, dbuserror)) + { + TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT, i18n("Could not create session for %1.").arg(mAddress)); + return false; + } + } + + kdDebug() << "ObexProtocol::connectObex mSessionPath: " << mSessionPath << endl; + if (!mSession) + { + mSession = new org::bluez::obex::Session1Proxy("org.bluez.obex", mSessionPath); + mSession->setConnection((*(mManager->getConnection()))); + + mSessionProperties = new org::freedesktop::DBus::PropertiesProxy("org.bluez", mSessionPath); + mSessionProperties->setConnection((*(mManager->getConnection()))); + + connect(mSessionProperties, SIGNAL(PropertiesChanged ( const TQString&, const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& )), + this, SLOT(slotPropertiesChanged ( const TQString& , const TQMap< TQString, TQT_DBusVariant >&, const TQStringList& ))); + + mFileTransfer = new org::bluez::obex::FileTransfer1Proxy("org.bluez.obex", mSessionPath); + mFileTransfer->setConnection((*(mManager->getConnection()))); + + } + if (mClient != 0 && mSession != 0 && mFileTransfer != 0) + mConnected = true; + return mConnected; +} + +void ObexProtocol::listDir(const KURL &url) +{ + kdDebug() << k_funcinfo << endl; + kdDebug() << "utl: " << url.url() << endl; + kdDebug() << "path: " << url.path() << endl; + + if (url.path().length() <= 1) + { + TDEIO::SlaveBase::error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + finished(); + return; + } + + TQString address, name, path; + bool ok = obex->parseURL(url, address, name, path); + + if (!ok || address.isEmpty()) + { + TDEIO::SlaveBase::error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + finished(); + return; + } + mAddress = address; + + kdDebug() << k_funcinfo << " address " << mAddress << endl; + kdDebug() << k_funcinfo << " name " << name << endl; + kdDebug() << k_funcinfo << " path " << path << endl; + kdDebug() << k_funcinfo << " at line " << __LINE__ << endl; + + if (!mConnected) + { + if (!connectObex()) + { + finished(); + return; + } + } + + if (!path.isEmpty()) + { + if (!changeWorkingDirectory(path)) + { + TDEIO::SlaveBase::error(TDEIO::ERR_CANNOT_OPEN_FOR_READING, path); + + finished(); + closeObex(); + return; + } + } + + kdDebug() << k_funcinfo << " at line " << __LINE__ << endl; + TQT_DBusDataList folderinfo; + TQT_DBusError dbuserror; + if (!mFileTransfer->ListFolder(folderinfo, dbuserror)) + { + if (dbuserror.isValid()) + { + TDEIO::SlaveBase::error(TDEIO::ERR_CANNOT_OPEN_FOR_READING, i18n("%1.\n%2").arg(url.prettyURL()).arg(dbuserror.message())); + } + else + { + TDEIO::SlaveBase::error(TDEIO::ERR_CANNOT_OPEN_FOR_READING, url.prettyURL()); + } + + finished(); + closeObex(); + return; + } + + TDEIO::UDSEntryList entries; + entries.clear(); + + TQValueList<TQT_DBusData> vl = folderinfo.toTQValueList(); + TQValueList<TQT_DBusData>::Iterator dit = vl.begin(); + for (dit; dit != vl.end(); ++dit) + { + bool ok = false; + TQMap<TQString, TQT_DBusData> map = (*dit).toStringKeyMap(&ok).toTQMap(); + if (!ok) + { + kdDebug() << k_funcinfo << " failed " << endl; + continue; + } + TDEIO::UDSEntry entry = obex->createUDSEntry(map); + entries.append(entry); + kdDebug() << k_funcinfo << " at line " << __LINE__ << endl; + } + + listEntries(entries); + listEntry(UDSEntry(), true); // ready + + finished(); + closeObex(); +} + +void ObexProtocol::stat(const KURL &url) +{ + kdDebug() << k_funcinfo << " url: " << url << endl; + + TQString address, name, path; + bool ok = obex->parseURL(url, address, name, path); + kdDebug() << k_funcinfo << " addr: " << address << endl; + kdDebug() << k_funcinfo << " name: " << name << endl; + kdDebug() << k_funcinfo << " path: " << path << endl; + + if (!ok || address.isEmpty()) + { + error(TDEIO::ERR_MALFORMED_URL, url.prettyURL()); + return; + } + + TDEIO::UDSEntry entry; + if (path.isEmpty() || path == "/") + { + // The root is "virtual" - it's not a single physical directory + obex->createTopLevelEntry(entry); + } + else + { + obex->createDirEntry(entry, url.url()); + } + statEntry(entry); + finished(); +} + +void ObexProtocol::get(const KURL& url) +{ + kdDebug() << k_funcinfo << endl; + + if (!mFileTransfer) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not get file: %1. No file transport").arg(url.prettyURL())); + return; + } + if (!mConnected) + { + if (!connectObex()) + { + finished(); + return; + } + } +// TQT_DBusError dbuserror; +// if (!mFileTransfer->GetFile(url.url(), dbuserror)) { +// TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not get file: %1.").arg(dbuserror.message())); +// } +} + +void ObexProtocol::copy(const KURL &src, const KURL &dest, int permissions, bool overwrite) +{ + kdDebug() << k_funcinfo << endl; + // obex->copy(src, dest, permissions, overwrite); + if (!mConnected) + { + if (!connectObex()) + { + finished(); + return; + } + } +} + +void ObexProtocol::put(const KURL& url, int permissions, bool overwrite, bool resume) +{ + kdDebug() << k_funcinfo << endl; + if (!mConnected) + { + if (!connectObex()) + { + finished(); + return; + } + } + if (!mFileTransfer) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not put file: %1. No file transport").arg(url.prettyURL())); + return; + } + +// +// TQT_DBusError dbuserror; +// if (!mFileTransfer->PutFile(url.url(), dbuserror)) { +// TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not put file: %1.").arg(dbuserror.message())); +// } + +} + +void ObexProtocol::del(const KURL &url, bool isfile) +{ + kdDebug() << k_funcinfo << endl; + + if (!isfile) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Only files can be deleted. Request to delete: %1").arg(url.prettyURL())); + return; + } + if (!mConnected) + { + if (!connectObex()) + { + finished(); + return; + } + } + if (!mFileTransfer) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not delete file: %1. No file transport").arg(url.prettyURL())); + return; + } + + TQT_DBusError dbuserror; + if (!mFileTransfer->Delete(url.url(), dbuserror)) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not delete file: %1.").arg(dbuserror.message())); + } + +} + +//void ObexProtocol::rename(const KURL& src, const KURL& dest, bool overwrite) +//{ +// kdDebug() << k_funcinfo << endl; +// // obex->rename(src, dest, overwrite); +// +//} + +void ObexProtocol::mkdir(const KURL&url, int permissions) +{ + kdDebug() << k_funcinfo << endl; + if (!mConnected) + { + if (!connectObex()) + { + finished(); + return; + } + } + if (!mFileTransfer) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not create directory: %1. No file transport").arg(url.prettyURL())); + return; + } + + TQT_DBusError dbuserror; + if (!mFileTransfer->CreateFolder(url.url(), dbuserror)) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not create directory: %1.").arg(dbuserror.message())); + } + +} + +bool ObexProtocol::changeWorkingDirectory(const TQString& dir) +{ + kdDebug() << "ObexProtocol::changeWorkingDirectory( " << dir << " )" << endl; + if (!dir.startsWith("/")) + { + TDEIO::SlaveBase::error(TDEIO::ERR_MALFORMED_URL, i18n("Could not change directory: %1. Directory should start with \"/\"").arg(dir)); + return false; + } + if (!mConnected) + { + if (!connectObex()) + { + finished(); + return false; + } + } + if (!mFileTransfer) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not change directory: %1. No file transport").arg(dir)); + return false; + } + + TQT_DBusError dbuserror; + if (!mFileTransfer->ChangeFolder(dir, dbuserror)) + { + TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not change directory: %1.").arg(dbuserror.message())); + return false; + } + + return true; +} + +void ObexProtocol::slotPropertiesChanged(const TQString& interface, const TQMap< + TQString, TQT_DBusVariant>& changed_properties, const TQStringList& invalidated_properties) +{ + kdDebug() << k_funcinfo << endl; + kdDebug() << interface << endl; + + if (interface == "org.bluez.obex.Session1") + { + TQMap<TQString, TQT_DBusVariant>::const_iterator it; + for (it = changed_properties.begin(); it != changed_properties.end(); + ++it) + { + bool ok = false; + if (it.key() == "Source") + emit sessionSourceChanged(mSessionPath, it.data().value.toBool(&ok)); + else if (it.key() == "Destination") + emit sessionDestinationChanged(mSessionPath, it.data().value.toString(&ok)); + else if (it.key() == "Channel") + emit sessionChannelChanged(mSessionPath, it.data().value.toByte(&ok)); + else if (it.key() == "Target") + emit sessionTargetChanged(mSessionPath, it.data().value.toString(&ok)); + else if (it.key() == "Root") + emit sessionRootChanged(mSessionPath, it.data().value.toString(&ok)); + else + continue; + if (!ok) + tqDebug("ObjectManagerImpl::slotPropertiesChanged conversion failed"); + } + } + + if (interface == "org.bluez.obex.FileTransfer1" || interface == "org.bluez.obex.Transfer1") + { + TQMap<TQString, TQT_DBusVariant>::const_iterator it; + for (it = changed_properties.begin(); it != changed_properties.end(); + ++it) + { + bool ok = false; + if (it.key() == "Size") + emit transferSizeChanged(mSessionPath, it.data().value.toUInt64(&ok)); + else if (it.key() == "Status") + emit transferStatusChanged(mSessionPath, it.data().value.toString(&ok)); + else if (it.key() == "Transferred") + emit transferTransferredChanged(mSessionPath, it.data().value.toUInt64(&ok)); + else if (it.key() == "Time") + emit transferTimeChanged(mSessionPath, it.data().value.toUInt64(&ok)); + else if (it.key() == "Filename") + emit transferFilenameChanged(mSessionPath, it.data().value.toString(&ok)); + else + continue; + if (!ok) + tqDebug("ObjectManagerImpl::slotPropertiesChanged conversion failed"); + } + } +} + +#include "tdeio_obex.moc" diff --git a/src/tdeioslave/obex/tdeio_obex.h b/src/tdeioslave/obex/tdeio_obex.h new file mode 100644 index 0000000..afa4b2e --- /dev/null +++ b/src/tdeioslave/obex/tdeio_obex.h @@ -0,0 +1,135 @@ +/* + This file is part of tdeio_obex. + + Copyright (c) 2003 Mathias Froehlich <[email protected]> + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed 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 + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor, + Boston, MA 02110-1301, USA. + */ + +#ifndef TDEIO_OBEX_H +#define TDEIO_OBEX_H + +#include <tdeio/global.h> +#include <tdeio/job.h> +#include <tdeio/slavebase.h> + +#include <tqdbusobjectpath.h> + +#include <interfaces/client1Proxy.h> +#include <interfaces/session1Proxy.h> +#include <interfaces/propertiesProxy.h> +#include <obexobjectmanagerImpl.h> + +#include "obex.h" + +class ObexProtocol: public TQObject, public TDEIO::SlaveBase { + + Q_OBJECT + +public: + ObexProtocol(const TQCString &protcol, const TQCString &pool_socket, + const TQCString &app_socket); + virtual ~ObexProtocol(); +// virtual void openConnection(); + virtual void closeConnection(); + virtual void stat(const KURL& url); + virtual void listDir(const KURL& url); + virtual void get(const KURL& url); + virtual void copy(const KURL &src, const KURL &dest, int permissions, + bool overwrite); + virtual void put(const KURL& url, int permissions, bool overwrite, + bool resume); + virtual void del(const KURL &url, bool isfile); + // virtual void chmod(const KURL& url, int permissions); +// virtual void rename(const KURL& src, const KURL& dest, bool overwrite); + virtual void mkdir(const KURL&url, int permissions); + +private: + // Private variables + /** True if ioslave is connected to server. */ + bool mConnected; + + /** Host we are connected to. */ + TQString mHost; + + /** + The protocol to be used. + */ + TQString mProtocol; + + /** + Pointer to the obex obejct. + */ + Obex *obex; + + /** + Pointer to the obex client class. + */ + org::bluez::obex::Client1Proxy* mClient; + + /** + Pointer to the obex session class. + */ + org::bluez::obex::Session1Proxy* mSession; + org::freedesktop::DBus::PropertiesProxy* mSessionProperties; + org::bluez::obex::FileTransfer1Proxy* mFileTransfer; + TQT_DBusObjectPath mSessionPath; + TQString mAddress; + + /** + Pointer to the obex agent manager class. + */ + TDEObex::ObexObjectManagerImpl* mManager; + + /** Channel we are connected to. */ + int mChannel; + + struct Status { + int code; + TDEIO::filesize_t size; + TQString text; + }; + +private: + // private methods + + /** + Helper functions. + */ + bool connectObex(); + void closeObex(); + bool changeWorkingDirectory(const TQString& to); + +private slots: + void slotPropertiesChanged(const TQString& interface, + const TQMap<TQString, TQT_DBusVariant>& changed_properties, + const TQStringList& invalidated_properties); + +signals: + void sessionSourceChanged(TQT_DBusObjectPath &path,bool ok); + void sessionDestinationChanged(TQT_DBusObjectPath &path, TQString value); + void sessionChannelChanged(TQT_DBusObjectPath &path, TQ_UINT8 value); + void sessionTargetChanged(TQT_DBusObjectPath &path, TQString value); + void sessionRootChanged(TQT_DBusObjectPath &path, TQString value); + + void transferSizeChanged(TQT_DBusObjectPath &path, TQ_UINT64 value); + void transferStatusChanged(TQT_DBusObjectPath &path, TQString value); + void transferTransferredChanged(TQT_DBusObjectPath &path, TQ_UINT64 value); + void transferTimeChanged(TQT_DBusObjectPath &path, TQ_UINT64 value); + void transferFilenameChanged(TQT_DBusObjectPath &path, TQString value); +}; + +#endif |