From c95a42982628b4b06ceed0c01cada10806c9b53c Mon Sep 17 00:00:00 2001 From: Emanoil Kotsev Date: Mon, 13 Mar 2023 20:31:19 +0000 Subject: i18n and some minor corrections Signed-off-by: Emanoil Kotsev --- src/libtdebluez/adapterImpl.cpp | 25 +- src/libtdebluez/objectmanagerImpl.cpp | 44 +- src/libtdeobex/obexobjectmanagerImpl.cpp | 20 +- src/tdebluez/adapterconfig.cpp | 18 +- src/tdebluez/adapterconfigdialog.cpp | 4 +- src/tdebluez/application.cpp | 18 +- src/tdebluez/devicesetupwizard.cpp | 41 +- src/tdebluez/devicewizard.cpp | 52 +- src/tdebluez/mediacontrol.cpp | 73 +-- src/tdebluez/trayicon.cpp | 128 ++--- src/tdebluezauth/application.cpp | 8 +- src/tdebluezioclient/CMakeLists.txt | 39 ++ src/tdebluezioclient/commandhandler.cpp | 408 +++++++++++++++ src/tdebluezioclient/commandhandler.h | 60 +++ src/tdebluezioclient/main.cpp | 74 +++ src/tdebluezioslave/CMakeLists.txt | 13 + src/tdebluezioslave/bluetooth/CMakeLists.txt | 43 ++ src/tdebluezioslave/bluetooth/bluetooth.protocol | 12 + .../bluetooth/bluetooth_sidebarentry.desktop | 9 + src/tdebluezioslave/bluetooth/tdeiobluetooth.cpp | 464 +++++++++++++++++ src/tdebluezioslave/bluetooth/tdeiobluetooth.h | 56 +++ src/tdebluezioslave/obex/CMakeLists.txt | 46 ++ src/tdebluezioslave/obex/README | 91 ++++ src/tdebluezioslave/obex/obex.cpp | 312 ++++++++++++ src/tdebluezioslave/obex/obex.h | 66 +++ src/tdebluezioslave/obex/obex_sidebarentry.desktop | 9 + src/tdebluezioslave/obex/obexftp.protocol | 19 + src/tdebluezioslave/obex/obexopp.protocol | 19 + src/tdebluezioslave/obex/tdeio_obex.cpp | 550 +++++++++++++++++++++ src/tdebluezioslave/obex/tdeio_obex.h | 135 +++++ src/tdeioclient/CMakeLists.txt | 39 -- src/tdeioclient/commandhandler.cpp | 407 --------------- src/tdeioclient/commandhandler.h | 60 --- src/tdeioclient/main.cpp | 74 --- src/tdeioslave/CMakeLists.txt | 13 - src/tdeioslave/bluetooth/CMakeLists.txt | 43 -- src/tdeioslave/bluetooth/bluetooth.protocol | 12 - .../bluetooth/bluetooth_sidebarentry.desktop | 9 - src/tdeioslave/bluetooth/tdeiobluetooth.cpp | 464 ----------------- src/tdeioslave/bluetooth/tdeiobluetooth.h | 56 --- src/tdeioslave/obex/CMakeLists.txt | 46 -- src/tdeioslave/obex/README | 91 ---- src/tdeioslave/obex/obex.cpp | 312 ------------ src/tdeioslave/obex/obex.h | 66 --- src/tdeioslave/obex/obex_sidebarentry.desktop | 9 - src/tdeioslave/obex/obexftp.protocol | 19 - src/tdeioslave/obex/obexopp.protocol | 19 - src/tdeioslave/obex/tdeio_obex.cpp | 550 --------------------- src/tdeioslave/obex/tdeio_obex.h | 135 ----- 49 files changed, 2641 insertions(+), 2639 deletions(-) create mode 100644 src/tdebluezioclient/CMakeLists.txt create mode 100644 src/tdebluezioclient/commandhandler.cpp create mode 100644 src/tdebluezioclient/commandhandler.h create mode 100644 src/tdebluezioclient/main.cpp create mode 100644 src/tdebluezioslave/CMakeLists.txt create mode 100644 src/tdebluezioslave/bluetooth/CMakeLists.txt create mode 100644 src/tdebluezioslave/bluetooth/bluetooth.protocol create mode 100644 src/tdebluezioslave/bluetooth/bluetooth_sidebarentry.desktop create mode 100644 src/tdebluezioslave/bluetooth/tdeiobluetooth.cpp create mode 100644 src/tdebluezioslave/bluetooth/tdeiobluetooth.h create mode 100644 src/tdebluezioslave/obex/CMakeLists.txt create mode 100644 src/tdebluezioslave/obex/README create mode 100644 src/tdebluezioslave/obex/obex.cpp create mode 100644 src/tdebluezioslave/obex/obex.h create mode 100644 src/tdebluezioslave/obex/obex_sidebarentry.desktop create mode 100644 src/tdebluezioslave/obex/obexftp.protocol create mode 100644 src/tdebluezioslave/obex/obexopp.protocol create mode 100644 src/tdebluezioslave/obex/tdeio_obex.cpp create mode 100644 src/tdebluezioslave/obex/tdeio_obex.h delete mode 100644 src/tdeioclient/CMakeLists.txt delete mode 100644 src/tdeioclient/commandhandler.cpp delete mode 100644 src/tdeioclient/commandhandler.h delete mode 100644 src/tdeioclient/main.cpp delete mode 100644 src/tdeioslave/CMakeLists.txt delete mode 100644 src/tdeioslave/bluetooth/CMakeLists.txt delete mode 100644 src/tdeioslave/bluetooth/bluetooth.protocol delete mode 100644 src/tdeioslave/bluetooth/bluetooth_sidebarentry.desktop delete mode 100644 src/tdeioslave/bluetooth/tdeiobluetooth.cpp delete mode 100644 src/tdeioslave/bluetooth/tdeiobluetooth.h delete mode 100644 src/tdeioslave/obex/CMakeLists.txt delete mode 100644 src/tdeioslave/obex/README delete mode 100644 src/tdeioslave/obex/obex.cpp delete mode 100644 src/tdeioslave/obex/obex.h delete mode 100644 src/tdeioslave/obex/obex_sidebarentry.desktop delete mode 100644 src/tdeioslave/obex/obexftp.protocol delete mode 100644 src/tdeioslave/obex/obexopp.protocol delete mode 100644 src/tdeioslave/obex/tdeio_obex.cpp delete mode 100644 src/tdeioslave/obex/tdeio_obex.h (limited to 'src') diff --git a/src/libtdebluez/adapterImpl.cpp b/src/libtdebluez/adapterImpl.cpp index 703f06f..adf4388 100644 --- a/src/libtdebluez/adapterImpl.cpp +++ b/src/libtdebluez/adapterImpl.cpp @@ -32,6 +32,7 @@ #include #include +#include #include "adapterImpl.h" @@ -90,7 +91,7 @@ void AdapterImpl::powerOn(bool state) if (hcidx < 0) { // error handling - tqDebug("Index for the device %s not found", device.local8Bit().data()); + tqDebug(i18n("Index for the device %1 not found").arg(device)); return; } @@ -99,7 +100,7 @@ void AdapterImpl::powerOn(bool state) TQFile file("/dev/rfkill"); if (!file.open(IO_ReadWrite)) { - tqDebug("Failed to open %s", file.name().utf8().data()); + tqDebug(i18n("Failed to open %1").arg(file.name())); return; } @@ -110,10 +111,10 @@ void AdapterImpl::powerOn(bool state) else event.soft = 1; - tqDebug("Bluetooth device %s switches: idx(%i), soft(%d).", device.local8Bit().data(), event.idx, event.soft); + tqDebug(i18n("Bluetooth device %1 switches: idx(%2), soft(%3).").arg(device).arg(event.idx).arg(event.soft)); if (write(file.handle(), &event, sizeof(event)) < 0) - tqDebug("Failed to write to %s", file.name().utf8().data()); + tqDebug(i18n("Failed to write to %1").arg(file.name())); file.close(); } @@ -124,18 +125,18 @@ TQString AdapterImpl::getPath() 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()); + TQT_DBusError dbuserror; + setAlias(alias, dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("AdapterImpl::slotSetAlias(%1) failed: %2").arg(alias).arg(dbuserror.message())); } 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()); + TQT_DBusError dbuserror; + setDiscoverableTimeout(timeout, dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("AdapterImpl::slotSetTimeout(%1) failed: %2").arg(timeout).arg(dbuserror.message())); } } // namespace TDEBluetooth diff --git a/src/libtdebluez/objectmanagerImpl.cpp b/src/libtdebluez/objectmanagerImpl.cpp index 789e221..96cb83e 100644 --- a/src/libtdebluez/objectmanagerImpl.cpp +++ b/src/libtdebluez/objectmanagerImpl.cpp @@ -191,12 +191,12 @@ bool ObjectManagerImpl::registerAgent() { if (!agentRegisteredStatus) { - TQT_DBusError error; + TQT_DBusError dbuserror; agentManager->RegisterAgent( - TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), DEVICE_PIN_CAPABILITY, error); - if (error.isValid()) + TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), DEVICE_PIN_CAPABILITY, dbuserror); + if (dbuserror.isValid()) { - tqDebug("Could not register agent: %s", error.message().local8Bit().data()); + tqDebug(i18n("Could not register agent: %1").arg(dbuserror.message())); return false; } agentRegisteredStatus = true; @@ -209,12 +209,12 @@ bool ObjectManagerImpl::unregisterAgent() kdDebug() << k_funcinfo << endl; if (agentRegisteredStatus) { - TQT_DBusError error; + TQT_DBusError dbuserror; getAgentManager()->UnregisterAgent( - TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), error); - if (error.isValid()) + TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), dbuserror); + if (dbuserror.isValid()) { - tqDebug("Could not unregister agent"); + tqDebug(i18n("Could not unregister agent")); return false; } agentRegisteredStatus = false; @@ -225,12 +225,12 @@ bool ObjectManagerImpl::unregisterAgent() bool ObjectManagerImpl::requestDefaultAgent() { - TQT_DBusError error; + TQT_DBusError dbuserror; agentManager->RequestDefaultAgent( - TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), error); - if (error.isValid()) + TQT_DBusObjectPath(TQCString(DBUS_AUTH_SERVICE_PATH)), dbuserror); + if (dbuserror.isValid()) { - tqDebug("Could not request default agent: %s", error.message().local8Bit().data()); + tqDebug(i18n("Could not request default agent: %1").arg(dbuserror.message())); return false; } agentIsDefaultAgent = true; @@ -258,17 +258,17 @@ 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()); + tqDebug(i18n("Failed to open connection to system message bus: %1").arg(dBusConn.lastError().message())); TQTimer::singleShot(4000, this, TQT_SLOT(reconnect())); return false; } setConnection(dBusConn); TQT_DBusDataMap objects; - TQT_DBusError error; - if (!GetManagedObjects(objects, error)) + TQT_DBusError dbuserror; + if (!GetManagedObjects(objects, dbuserror)) { - tqDebug("GetManagedObjects(objects,error) FAILED:\n%s\n", error.message().latin1()); + tqDebug(i18n("GetManagedObjects(objects,error) failed: %1").arg(dbuserror.message())); return false; } @@ -278,7 +278,7 @@ bool ObjectManagerImpl::initDBUS() 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()); + tqWarning(i18n("Failed to convert dbus data to string map: %1").arg(it.key())); } connect(this, SIGNAL(InterfacesAdded(const TQT_DBusObjectPath&, const TQT_DBusDataMap< TQString >&)), @@ -313,7 +313,7 @@ void ObjectManagerImpl::adapterPropertiesChanged(TQString path, const TQMap< else continue; if (!ok) - tqDebug("ObjectManagerImpl::adapterPropertiesChanged conversion failed"); + tqDebug(i18n("ObjectManagerImpl::adapterPropertiesChanged conversion failed")); } } @@ -367,7 +367,7 @@ void ObjectManagerImpl::devicePropertiesChanged(TQString path, const TQMap objects; - TQT_DBusError error; - if (!GetManagedObjects(objects, error)) + TQT_DBusError dbuserror; + if (!GetManagedObjects(objects, dbuserror)) { - tqDebug("GetManagedObjects(objects,error) FAILED\n"); + tqDebug(i18n("GetManagedObjects(objects, dbuserror) failed: %1").arg(dbuserror.message())); return false; } @@ -150,7 +150,7 @@ bool ObexObjectManagerImpl::initDBUS() TQT_DBusDataMap tqMap1 = it.data().toStringKeyMap(&ok); if (!ok) { - tqWarning("Failed to convert dbus data to string map: %s", it.key().latin1()); + tqWarning(i18n("Failed to convert dbus data to string map: %1").arg(it.key())); return false; } slotInterfacesAdded(it.key(), tqMap1); @@ -198,7 +198,7 @@ void ObexObjectManagerImpl::slotInterfacesAdded(const TQT_DBusObjectPath& object } else { - tqDebug("org.bluez.obex.AgentManager1 initialization failed\n"); + tqDebug(i18n("org.bluez.obex.AgentManager1 initialization failed")); } } else if (interface == "org.bluez.obex.Client1") @@ -210,7 +210,7 @@ void ObexObjectManagerImpl::slotInterfacesAdded(const TQT_DBusObjectPath& object } else { - tqDebug("org.bluez.obex.Client1 initialization failed\n"); + tqDebug(i18n("org.bluez.obex.Client1 initialization failed")); } } else if (interface == "org.bluez.obex.Session1") @@ -222,7 +222,7 @@ void ObexObjectManagerImpl::slotInterfacesAdded(const TQT_DBusObjectPath& object } else { - tqDebug("org.bluez.obex.Session1 initialization failed\n"); + tqDebug(i18n("org.bluez.obex.Session1 initialization failed")); } } else if (interface == "org.bluez.obex.FileTransfer1") @@ -234,7 +234,7 @@ void ObexObjectManagerImpl::slotInterfacesAdded(const TQT_DBusObjectPath& object } else { - tqDebug("org.bluez.obex.FileTransfer1 initialization failed\n"); + tqDebug(i18n("org.bluez.obex.FileTransfer1 initialization failed")); } } else if (interface == "org.freedesktop.DBus.Introspectable") @@ -243,7 +243,7 @@ void ObexObjectManagerImpl::slotInterfacesAdded(const TQT_DBusObjectPath& object } else { - tqWarning("Interface not implemented: %s", interface.local8Bit().data()); + tqWarning(i18n("Interface not implemented: %1").arg(interface)); } } } @@ -273,7 +273,7 @@ void ObexObjectManagerImpl::slotInterfacesRemoved(const TQT_DBusObjectPath& obje } else { - tqWarning("Interface not implemented: %s", (*it).local8Bit().data()); + tqWarning(i18n("Interface not implemented: %1").arg((*it))); } } } diff --git a/src/tdebluez/adapterconfig.cpp b/src/tdebluez/adapterconfig.cpp index cf9470a..c0e354a 100644 --- a/src/tdebluez/adapterconfig.cpp +++ b/src/tdebluez/adapterconfig.cpp @@ -38,7 +38,7 @@ AdapterConfig::AdapterConfig(ObjectManagerImpl *mgr, AdapterImpl *a) TQT_DBusError dbuserr; name = adapter->getAlias(dbuserr); if (dbuserr.isValid()) - tqDebug("Get alias for the adapter failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Get alias for the adapter failed: %1").arg(dbuserr.message())); adapterDialog->deviceModes->insertItem(i18n("Hidden")); adapterDialog->deviceModes->insertItem(i18n("Always visible")); @@ -127,14 +127,14 @@ void AdapterConfig::addAdapterDialogInfo() slotSetClass(DeviceMimeConverter::classToMimeType(adapter->getClass(dbuserr))); if (dbuserr.isValid()) - tqDebug("Get class for the adapter failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Get class for the adapter failed: %1").arg(dbuserr.message())); TQString address = adapter->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Get address for the adapter failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Get address for the adapter failed: %1").arg(dbuserr.message())); TQStringList uuids = adapter->getUUIDs(dbuserr); if (dbuserr.isValid()) - tqDebug("Get uuids for the adapter failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Get uuids for the adapter failed: %1").arg(dbuserr.message())); TQVBoxLayout *infoLayout = new TQVBoxLayout(adapterDialog->groupBoxInfo->layout()); // GridLayout *infoGrid = new TQGridLayout(adapterDialog->groupBoxInfo->layout()); @@ -188,7 +188,7 @@ void AdapterConfig::slotDiscoverableChanged(const TQString &path, bool changed) 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()); + tqDebug(i18n("Get discoverable timeout for the adapter failed: %1").arg(dbuserr.message())); disconnect(adapterDialog->deviceModes, SIGNAL(activated(int)), this, TQT_SLOT(slotSetMode(int))); disconnect(adapterDialog->sliderTimeout, SIGNAL(valueChanged(int)), @@ -278,7 +278,7 @@ void AdapterConfig::slotChangeName(const TQString &n) // adapterDialog->adapterName->setText(name); adapter->setAlias(name, dbuserr); if (dbuserr.isValid()) - tqDebug("Set alias for the adapter failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Set alias for the adapter failed: %1").arg(dbuserr.message())); connect(manager, SIGNAL(adapterNameChanged(const TQString&,const TQString&)), this, TQT_SLOT(slotAdapterNameChanged(const TQString&, const TQString&))); @@ -303,7 +303,7 @@ void AdapterConfig::slotChangeTimeout(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()); + tqDebug(i18n("Set discoverable timeout for the adapter failed: %1").arg(dbuserr.message())); connect(manager, SIGNAL(adapterDiscoverableChanged(const TQString&, bool)), this, TQT_SLOT(slotDiscoverableChanged(const TQString&, bool))); @@ -317,7 +317,7 @@ 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()); + tqDebug(i18n("Get discoverable timeout for the adapter failed: %1").arg(dbuserr.message())); // Disconnect signal of valueChanged! // D-Bus signal get emmited immeditaly .. @@ -358,7 +358,7 @@ void AdapterConfig::slotSetMode(int modenr) 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()); + tqDebug(i18n("Get discoverable for the adapter failed: %1").arg(dbuserr.message())); connect(adapterDialog->deviceModes, SIGNAL(activated(int)), this, TQT_SLOT(slotSetMode(int))); diff --git a/src/tdebluez/adapterconfigdialog.cpp b/src/tdebluez/adapterconfigdialog.cpp index 750a4a3..31caa27 100644 --- a/src/tdebluez/adapterconfigdialog.cpp +++ b/src/tdebluez/adapterconfigdialog.cpp @@ -71,7 +71,7 @@ void AdapterConfigDialog::addAdapter(const TQString &path) TQT_DBusError dbuserr; bool powered = app->adapters[path]->getPowered(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getPowered failed: %1").arg(dbuserr.message())); aconfig->dialog()->setEnabled(powered); // @@ -130,7 +130,7 @@ void AdapterConfigDialog::slotCurrentChanged(TQWidget *widget) TQT_DBusError dbuserr; TQString name = app->adapters[path]->getAlias(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getAlias failed: %1").arg(dbuserr.message())); // kdDebug() << "Adapter changed: " << it.data()->dialog()->macLabel->text() << endl; emit signalAdapterSelected(path,name); break; diff --git a/src/tdebluez/application.cpp b/src/tdebluez/application.cpp index 7ad5a27..bd08437 100644 --- a/src/tdebluez/application.cpp +++ b/src/tdebluez/application.cpp @@ -83,7 +83,7 @@ TDEBluetoothApp::TDEBluetoothApp() : manager = new ObjectManagerImpl(BLUEZ_DN, "/", this, "ObjectManager"); if (!manager->isConnectedToDBUS()) { - tqDebug("ObjectManager is not connected to DBus"); + tqDebug(i18n("ObjectManager is not connected to DBus")); return; } @@ -118,7 +118,7 @@ TDEBluetoothApp::TDEBluetoothApp() : } else { - tqWarning( "obexd executable was not found\nSet path in configuration file \"%s\"\nVariable: obexSrvExe=", CONFIGURATION_FILE); + tqWarning(i18n("obexd executable was not found\nSet path in configuration file \"%1\"\nVariable: obexSrvExe=").arg(CONFIGURATION_FILE)); m_config->writeEntry("obexSrv", false); } } @@ -146,7 +146,7 @@ TDEBluetoothApp::TDEBluetoothApp() : TQFile f("/proc/" + d[i] + "/status"); if ( ! f.open( IO_ReadOnly ) ) { - tqDebug( "Failed to open file for reading: %s", f.name().local8Bit().data() ); + tqDebug(i18n("Failed to open file for reading: %1").arg(f.name())); continue; } @@ -174,20 +174,20 @@ TDEBluetoothApp::TDEBluetoothApp() : switch ( errno ) { case EINVAL: - tqDebug( "4\t%s", pid.local8Bit().data() ); + tqDebug(i18n("4\t%1").arg(pid) ); break; case ESRCH: - tqDebug( "3\t%s", pid.local8Bit().data() ); + tqDebug(i18n("3\t%1").arg(pid) ); break; case EPERM: - tqDebug( "2\t%s", pid.local8Bit().data() ); + tqDebug(i18n("2\t%1").arg(pid) ); break; default: /* unknown error */ - tqDebug( "1\t%s", pid.local8Bit().data() ); + tqDebug(i18n("1\t%1").arg(pid) ); break; } } else { - tqWarning( "Cleanup pid\t%s", pid.local8Bit().data() ); + tqWarning(i18n("Cleanup pid\t%1").arg(pid) ); } } } @@ -241,7 +241,7 @@ TDEBluetoothApp::~TDEBluetoothApp() if (a->getDiscovering(error)) a->StopDiscovery(error); if (error.isValid()) - tqDebug("Stop discoverable for the adapter failed: %s", error.message().local8Bit().data()); + tqDebug(i18n("Stop discoverable for the adapter failed: %1").arg(error.message())); delete a; } } diff --git a/src/tdebluez/devicesetupwizard.cpp b/src/tdebluez/devicesetupwizard.cpp index 77f88cf..521214d 100644 --- a/src/tdebluez/devicesetupwizard.cpp +++ b/src/tdebluez/devicesetupwizard.cpp @@ -177,7 +177,7 @@ void DeviceSetupWizard::next() // TQWizard::next(); // } // if (error.isValid()) -// tqDebug("Failed in connecting device: %s", error.message().local8Bit().data()); +// tqDebug(i18n("Failed in connecting device: %1").arg(error.message())); // } else if (currentPage() == donepage) { @@ -215,7 +215,7 @@ void DeviceSetupWizard::setDevice(DeviceImpl *_device) TQT_DBusError error; address = device->getAddress(error); if (error.isValid()) - tqDebug("Failed to get address for the new device: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed to get address for the new device: %1").arg(error.message())); if (device->getPaired(error)) { @@ -237,7 +237,7 @@ void DeviceSetupWizard::setDevice(DeviceImpl *_device) tQListViewDst->clear(); } if (error.isValid()) - tqDebug("Failed to get paired status for the new device: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed to get paired status for the new device: %1").arg(error.message())); if (device->getConnected(error)) { @@ -248,12 +248,12 @@ void DeviceSetupWizard::setDevice(DeviceImpl *_device) TQWizard::showPage(donepage); } if (error.isValid()) - tqDebug("Failed to get connecting status of the new device: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed to get connecting status of the new device: %1").arg(error.message())); 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()); + tqDebug(i18n("Failed to get trusted status of the new device: %1").arg(error.message())); connect(device, SIGNAL(PairAsyncReply(int /*asyncCallId*/)), this, TQT_SLOT(slotPairAsyncReply(int /*asyncCallId*/))); @@ -277,7 +277,7 @@ void DeviceSetupWizard::updateServiceList() uuids.clear(); uuids = device->getUUIDs(error); if (error.isValid()) - tqDebug("Failed to get uuids: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed to get uuids: %1").arg(error.message())); tQListViewSrc->clear(); for (TQStringList::iterator it = uuids.begin(); it != uuids.end(); ++it) @@ -305,7 +305,7 @@ void DeviceSetupWizard::startPairing() if (!device->PairAsync(asyncCallId, error)) { if (error.isValid()) - tqDebug("Failed to get paired status for the new device: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed to get paired status for the new device: %1").arg(error.message())); } manager->getConnection()->scheduleDispatch(); } @@ -327,7 +327,7 @@ void DeviceSetupWizard::slotPairingTimeOut() setNextEnabled(pairpage, true); } else - tqDebug("Failed pairing the new device: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed pairing the new device: %1").arg(error.message())); } else { @@ -356,7 +356,7 @@ void DeviceSetupWizard::slotConnectTimeOut() setNextEnabled(connectpage, true); } else - tqDebug("Failed connecting the new device: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed connecting the new device: %1").arg(error.message())); } else { @@ -399,8 +399,7 @@ void DeviceSetupWizard::accept() device->setTrusted(true, error); } if (error.isValid()) - tqDebug("Could not set trusted for %s\nError: %s", - address.latin1(), error.message().local8Bit().data()); + tqDebug(i18n("Could not set trusted for %1\nError: %2").arg(address).arg(error.message())); } hide(); @@ -472,7 +471,7 @@ void DeviceSetupWizard::slotConnectNextProfile() if (!device->ConnectProfileAsync(asyncCallId, connect, error)) { if (error.isValid()) - tqDebug("Failed to call DBus ConnectProfileAsync: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed to call DBus ConnectProfileAsync: %1").arg(error.message())); } manager->getConnection()->scheduleDispatch(); } @@ -480,7 +479,7 @@ void DeviceSetupWizard::slotConnectNextProfile() void DeviceSetupWizard::slotAsyncErrorResponseDetected(int asyncCallId, const TQT_DBusError error) { - tqDebug("AsyncErrorResponseDetected: %i %s %s", error.type(), error.name().local8Bit().data(), error.message().local8Bit().data()); + tqDebug(i18n("AsyncErrorResponseDetected: %1 %2 %3").arg(error.type()).arg(error.name()).arg(error.message())); if(pairingTimer->isActive()) pairingTimer->stop(); @@ -505,15 +504,15 @@ void DeviceSetupWizard::slotAsyncErrorResponseDetected(int asyncCallId, const TQ // 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()), +// .arg(error.name()) +// .arg(error.message()), // TQMessageBox::Ok, TQMessageBox::NoButton, TQMessageBox::NoButton); KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "ConnectionError", tr("AsyncErrorResponseDetected: %1\n%2\n%3") + "ConnectionError", i18n("AsyncErrorResponseDetected: %1\n%2\n%3") .arg(error.type()) - .arg(error.name().local8Bit().data()) - .arg(error.message().local8Bit().data())); + .arg(error.name()) + .arg(error.message())); } void DeviceSetupWizard::slotConnectAsyncReply(int asyncCallId) @@ -561,7 +560,7 @@ void DeviceSetupWizard::slotCancelPairing() if (!device->CancelPairingAsync(asyncCallId, error)) { if (error.isValid()) - tqDebug("Failed to call DBus CancelPairingAsync: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed to call DBus CancelPairingAsync: %1").arg(error.message())); } if(pairingTimer->isActive()) @@ -575,10 +574,10 @@ void DeviceSetupWizard::slotCancelConnecting() if (device->getConnected(error)) { if (!device->DisconnectAsync(asyncCallId, error)) - tqDebug("Failed to call DisconnectAsync: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed to call DisconnectAsync: %1").arg(error.message())); } if (error.isValid()) - tqDebug("Failed in slotCancelConnecting: %s", error.message().local8Bit().data()); + tqDebug(i18n("Failed in slotCancelConnecting: %1").arg(error.message())); if(connectTimer->isActive()) connectTimer->stop(); diff --git a/src/tdebluez/devicewizard.cpp b/src/tdebluez/devicewizard.cpp index 51be413..f7f44db 100644 --- a/src/tdebluez/devicewizard.cpp +++ b/src/tdebluez/devicewizard.cpp @@ -55,7 +55,7 @@ DeviceWizard::DeviceWizard(TDEBluetoothApp* a) : break; } if (dbuserr.isValid()) - tqDebug("Get powered for active adapter failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Get powered for active adapter failed: %1").arg(dbuserr.message())); } } @@ -203,12 +203,12 @@ void DeviceWizard::slotDeviceBoxClicked(TQListViewItem *dev) TQT_DBusError dbuserr; TQString addr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (selAddr == addr) { bool connected = dit.data()->getConnected(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getConnected failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getConnected failed: %1").arg(dbuserr.message())); if (connected) { connectButton->setText(i18n("&Disconnect")); @@ -243,7 +243,7 @@ void DeviceWizard::slotConnectButton() TQT_DBusError dbuserr; TQString addr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (sel->text(2) == addr) { if (connectButton->text() == "C&onnect") @@ -278,7 +278,7 @@ void DeviceWizard::slotConnectButton() } if (dbuserr.isValid()) { - tqDebug("DisconnectAsync failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("DisconnectAsync failed: %1").arg(dbuserr.message())); } } break; @@ -302,7 +302,7 @@ void DeviceWizard::slotConnectNextProfile() { TQString addr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (addr == connectingDevice.address) { path = dit.key(); @@ -328,7 +328,7 @@ void DeviceWizard::slotConnectNextProfile() else { if (dbuserr.isValid()) - tqDebug("ConnectProfileAsync failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("ConnectProfileAsync failed: %1").arg(dbuserr.message())); TQString text = i18n("

Attempt to start connection with the device failed

" "

You can retry to connect or click Cancel to stop.

"); @@ -360,7 +360,7 @@ 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()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); TQListViewItem *devItem = deviceBox->findItem(addr, 2, TQt::ExactMatch); if (!devItem) @@ -415,7 +415,7 @@ void DeviceWizard::slotDeleteDevice() TQT_DBusError dbuserr; TQString addr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (sel->text(2) == addr) { if (!adapter->RemoveDevice(TQT_DBusObjectPath(dit.key()), dbuserr)) @@ -474,7 +474,7 @@ void DeviceWizard::slotDeviceRemoved(const TQString& path) TQT_DBusError dbuserr; TQString addr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (addrList1.grep(addr).size() == 1) addrList1.remove(addr); if (addrList2.grep(addr).size() == 1) @@ -512,7 +512,7 @@ void DeviceWizard::slotConfigDevice() TQT_DBusError dbuserr; TQString addr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (sel->text(2) == addr) { // device to be configured @@ -536,14 +536,14 @@ void DeviceWizard::slotSearch(bool state) { adapter->StartDiscovery(dbuserr); if (dbuserr.isValid()) - tqDebug("Device StartDiscovery failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device StartDiscovery failed: %1").arg(dbuserr.message())); addButton->setText(i18n("&Stop Discovery >>")); } else { adapter->StopDiscovery(dbuserr); if (dbuserr.isValid()) - tqDebug("Device StopDiscovery failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device StopDiscovery failed: %1").arg(dbuserr.message())); addButton->setText(i18n("&Start Discovery <<")); } } @@ -571,12 +571,12 @@ void DeviceWizard::slotAdapterDiscoveringChanged(const TQString& path, bool stat TQString thepath = dit.data()->getPath(); TQString theaddr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (addr == theaddr) { adapter->RemoveDevice(thepath, dbuserr); if (dbuserr.isValid()) - tqDebug("Remove Device failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Remove Device failed: %1").arg(dbuserr.message())); break; } } @@ -600,19 +600,19 @@ 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()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); TQString name = app->devices[path]->getName(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getName failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getName failed: %1").arg(dbuserr.message())); bool paired = app->devices[path]->getPaired(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getPaired failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getPaired failed: %1").arg(dbuserr.message())); TQ_UINT32 devclass = app->devices[path]->getClass(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getClass failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getClass failed: %1").arg(dbuserr.message())); bool connected = app->devices[path]->getConnected(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getConnected failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getConnected failed: %1").arg(dbuserr.message())); connect(app->devices[path], SIGNAL(AsyncErrorResponseDetected(int /*asyncCallId*/, const TQT_DBusError)), @@ -702,7 +702,7 @@ void DeviceWizard::slotDeviceNameChanged(const TQString& path, const TQString& n TQT_DBusError dbuserr; TQString addr = app->devices[path]->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); TQListViewItem *tmp = devicedlg_ext->newdevList->findItem(addr, 1, TQt::ExactMatch); if (tmp) { @@ -745,10 +745,10 @@ void DeviceWizard::slotAsyncErrorResponseDetected(int asyncCallId, const TQT_DBu setStateDeviceButtons(true); KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "ConnectionError", tr("AsyncErrorResponseDetected: %1\n%2\n%3") + "ConnectionError", i18n("AsyncErrorResponseDetected: %1\n%2\n%3") .arg(dbuserr.type()) - .arg(dbuserr.name().local8Bit().data()) - .arg(dbuserr.message().local8Bit().data())); + .arg(dbuserr.name()) + .arg(dbuserr.message())); } void DeviceWizard::slotSetupNewDevice() @@ -774,7 +774,7 @@ void DeviceWizard::slotSetupNewDevice() TQT_DBusError dbuserr; TQString addr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (selAddr == addr) { newdev = dit.data(); @@ -819,7 +819,7 @@ void DeviceWizard::slotDevicePairedChanged(const TQString& path, bool) TQT_DBusError dbuserr; TQString addr = dit.data()->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Device getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Device getAddress failed: %1").arg(dbuserr.message())); if (addr == selAddr) { TQString iconName = DeviceMimeConverter::classToIconName(dit.data()->getClass(dbuserr)); diff --git a/src/tdebluez/mediacontrol.cpp b/src/tdebluez/mediacontrol.cpp index 6d9afac..523ba56 100644 --- a/src/tdebluez/mediacontrol.cpp +++ b/src/tdebluez/mediacontrol.cpp @@ -25,6 +25,7 @@ #include +#include #include #include #include @@ -79,10 +80,10 @@ MediaControl::~MediaControl() 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()); + TQT_DBusError dbuserror; + mediaCtlProxy->Play(dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("Media Play failed: %1").arg(dbuserror.message())); } void MediaControl::slotPlayToggled(bool state) @@ -102,78 +103,78 @@ void MediaControl::slotPlayToggled(bool state) void MediaControl::slotStop() { kdDebug() << k_funcinfo << endl; - TQT_DBusError error; - if (mediaCtlProxy->Stop(error)) + TQT_DBusError dbuserror; + if (mediaCtlProxy->Stop(dbuserror)) { if (tQPushButtonPlay->isOn()) tQPushButtonPlay->toggle(); } - if (error.isValid()) - tqDebug("Media Stop failed: %s", error.message().local8Bit().data()); + if (dbuserror.isValid()) + tqDebug(i18n("Media Stop failed: %1").arg(dbuserror.message())); } 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()); + TQT_DBusError dbuserror; + mediaCtlProxy->Pause(dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("Media Pause failed: %1").arg(dbuserror.message())); } 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()); + TQT_DBusError dbuserror; + mediaCtlProxy->Next(dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("Media Next failed: %1").arg(dbuserror.message())); } 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()); + TQT_DBusError dbuserror; + mediaCtlProxy->Previous(dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("Media Previous failed: %1").arg(dbuserror.message())); } 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()); + TQT_DBusError dbuserror; + mediaCtlProxy->FastForward(dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("Media FastForward failed: %1").arg(dbuserror.message())); } 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()); + TQT_DBusError dbuserror; + mediaCtlProxy->Rewind(dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("Media Rewind failed: %1").arg(dbuserror.message())); } void MediaControl::slotVolumeValueChanged(int val) { kdDebug() << k_funcinfo << endl; - TQT_DBusError error; + TQT_DBusError dbuserror; if (val > volume) { - TQT_DBusError error; - mediaCtlProxy->VolumeUp(error); - if (error.isValid()) - tqDebug("Media VolumeUp getPowered failed: %s", error.message().local8Bit().data()); + TQT_DBusError dbuserror; + mediaCtlProxy->VolumeUp(dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("Media VolumeUp getPowered failed: %1").arg(dbuserror.message())); } if (val < volume) { - mediaCtlProxy->VolumeDown(error); - if (error.isValid()) - tqDebug("Media VolumeDown getPowered failed: %s", error.message().local8Bit().data()); + mediaCtlProxy->VolumeDown(dbuserror); + if (dbuserror.isValid()) + tqDebug(i18n("Media VolumeDown getPowered failed: %1").arg(dbuserror.message())); } volume = val; } diff --git a/src/tdebluez/trayicon.cpp b/src/tdebluez/trayicon.cpp index 3f56194..9185da7 100644 --- a/src/tdebluez/trayicon.cpp +++ b/src/tdebluez/trayicon.cpp @@ -64,19 +64,19 @@ TrayIcon::TrayIcon(TDEBluetoothApp* _app) // 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"), +//// kbluemonAction = new TDEAction(i18n("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"), +//// kbluelockAction = new TDEAction(i18n("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..."), +//// kbtobexclientAction = new TDEAction(i18n("&Send File..."), //// TDEGlobal::iconLoader()->loadIcon("attach", TDEIcon::Small, 16), //// TDEShortcut::null(), this, "kbtobexclient"); //// connect(kbtobexclientAction, SIGNAL(activated()), this, SLOT(slotkbtobexclient())); @@ -90,19 +90,19 @@ TrayIcon::TrayIcon(TDEBluetoothApp* _app) TQT_DBusError dbuserr; bool powered = app->adapters[it.key()]->getPowered(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getPowered failed: %1").arg(dbuserr.message())); TQString name = app->adapters[it.key()]->getAlias(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getAlias failed: %1").arg(dbuserr.message())); TQString msg; if (powered) { anyPowered = powered; - msg = tr("Power off [%1]").arg(name); + msg = i18n("Power off [%1]").arg(name); } else { - msg = tr("Power on [%1]").arg(name); + msg = i18n("Power on [%1]").arg(name); } TDEToggleAction *ad_a = new TDEToggleAction(this, name.utf8()); @@ -115,10 +115,10 @@ TrayIcon::TrayIcon(TDEBluetoothApp* _app) } // Configuration menu - configActionMenu = new TDEActionMenu(tr("&Configuration"), TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), this, "config_menu"); + configActionMenu = new TDEActionMenu(i18n("&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"); + helpActionMenu = new TDEActionMenu(i18n("&Help"), TDEGlobal::iconLoader()->loadIcon("help", TDEIcon::Small, 16), this, "help_menu"); // show documentation showHelpAction = KStdAction::help(this, TQT_SLOT(slotShowHelp()), actionCollection()); @@ -127,22 +127,22 @@ TrayIcon::TrayIcon(TDEBluetoothApp* _app) aboutAction = KStdAction::aboutApp(this, TQT_SLOT(slotAbout()), actionCollection()); // // Inputdevice configuration -// inputConfigAction = new TDEAction(tr("&Input Devices..."), +// inputConfigAction = new TDEAction(i18n("&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"); + deviceConfigAction = new TDEAction(i18n("&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"); + adapterConfigAction = new TDEAction(i18n("&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..."), +// pairedConfigAction = new TDEAction(i18n("&Paired/Trusted Devices..."), // TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), // TDEShortcut::null(), this, "paired_config"); // connect(pairedConfigAction, SIGNAL(activated()), this, SLOT(slotPairedConfig())); @@ -151,19 +151,19 @@ TrayIcon::TrayIcon(TDEBluetoothApp* _app) autostartIconAction = new TDEToggleAction(this, "autostart"); connect(autostartIconAction, SIGNAL(toggled(bool)), this, TQT_SLOT(slotIconAutostartToggled(bool))); autostartIconAction->setChecked(autostart); - autostartIconAction->setText(tr("&Auto Start")); + autostartIconAction->setText(i18n("&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")); + agentIconAction->setText(i18n("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")); + obexIconAction->setText(i18n("&Obex Server")); slotIconAgentToggled(agentstate); slotIconObexToggled(obexserver); @@ -172,7 +172,7 @@ TrayIcon::TrayIcon(TDEBluetoothApp* _app) // showIconAction = new TDEToggleAction(this, "always_visible"); // connect(showIconAction, SIGNAL(toggled(bool)), this, SLOT(slotShowIconToggled(bool))); // showIconAction->setChecked(alwaysVisible); -// showIconAction->setText(tr("Always &Visible")); +// showIconAction->setText(i18n("Always &Visible")); // configActionMenu->insert(showIconAction); KPixmap logoPixmap = TDEGlobal::iconLoader()->loadIcon(PIXMAP_LOGO, TDEIcon::Small, 22); @@ -316,7 +316,7 @@ void TrayIcon::setupTray(bool enable) // Service configuration /* TODO: create BlueZ service UI - serviceConfigAction = new TDEAction(tr("Configure &Services..."), + serviceConfigAction = new TDEAction(i18n("Configure &Services..."), TDEGlobal::iconLoader()->loadIcon("configure", TDEIcon::Small, 16), TDEShortcut::null(), this, "service_config"); connect(serviceConfigAction, SIGNAL(activated()), this, SLOT(slotServiceConfig())); @@ -357,10 +357,10 @@ void TrayIcon::updateIcon() if (showPowerOnActionMap.isEmpty()) { setPixmap(iconNoAdapter); - updateTooltip(tr("No BT adapter")); + updateTooltip(i18n("No BT adapter")); if (!this->isHidden()) KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "AdapterDetached", tr("No BT adapter available.
(BT adapter removed)")); + "AdapterDetached", i18n("No BT adapter available.
(BT adapter removed)")); adapterConfigAction->setEnabled(false); deviceConfigAction->setEnabled(false); @@ -376,14 +376,14 @@ void TrayIcon::updateIcon() { anyPowered = app->adapters[it.key()]->getPowered(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getPowered failed: %1").arg(dbuserr.message())); // 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()); + tqDebug(i18n("Adapter getAlias failed: %1").arg(dbuserr.message())); break; } } @@ -396,7 +396,7 @@ void TrayIcon::updateIcon() { anyConnected = dit.data()->getConnected(dbuserr); if (dbuserr.isValid()) - tqDebug("Check for connected device failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Check for connected device failed: %1").arg(dbuserr.message())); if (anyConnected) break; } @@ -418,7 +418,7 @@ void TrayIcon::updateIcon() 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()); + tqDebug(i18n("Adapter getAlias failed: %1").arg(dbuserr.message())); setPixmap(iconOff); } @@ -459,7 +459,7 @@ void TrayIcon::slotInputConfig() process << PROCESS_KINPUTWIZARD; if (!process.start(TDEProcess::DontCare)) { - KMessageBox::information(this, tr("Could not execute kinputwizard."), tr("TDEBluetooth")); + KMessageBox::information(this, i18n("Could not execute kinputwizard."), i18n("TDEBluetooth")); } } @@ -470,7 +470,7 @@ void TrayIcon::slotkbluemonitor() if (!process.start(TDEProcess::DontCare)) { - KMessageBox::information(this, tr("Could not execute KBlueMon."), tr("TDEBluetooth")); + KMessageBox::information(this, i18n("Could not execute KBlueMon."), i18n("TDEBluetooth")); } } @@ -481,7 +481,7 @@ void TrayIcon::slotkbluelock() if (!process.start(TDEProcess::DontCare)) { - KMessageBox::information(this, tr("Could not execute KBlueLock."), tr("TDEBluetooth")); + KMessageBox::information(this, i18n("Could not execute KBlueLock."), i18n("TDEBluetooth")); } } @@ -493,14 +493,14 @@ void TrayIcon::slotIconObexToggled(bool state) { if (!app->startObexSrv()) { - KMessageBox::information(this, tr("Could not start OBEX server."), tr("TDEBluetooth")); + KMessageBox::information(this, i18n("Could not start OBEX server."), i18n("TDEBluetooth")); } } else { if (!app->stopObexSrv()) { - KMessageBox::information(this, tr("Could not stop OBEX server."), tr("TDEBluetooth")); + KMessageBox::information(this, i18n("Could not stop OBEX server."), i18n("TDEBluetooth")); } } } @@ -513,14 +513,14 @@ void TrayIcon::slotIconAgentToggled(bool state) { if (!app->startAuthAgent()) { - KMessageBox::information(this, tr("Could not start TDEBluez Authentication Agent."), tr("TDEBluetooth")); + KMessageBox::information(this, i18n("Could not start TDEBluez Authentication Agent."), i18n("TDEBluetooth")); } } else { if (!app->stopAuthAgent()) { - KMessageBox::information(this, tr("Could not stop TDEBluez Authentication Agent."), tr("TDEBluetooth")); + KMessageBox::information(this, i18n("Could not stop TDEBluez Authentication Agent."), i18n("TDEBluetooth")); } } } @@ -550,11 +550,11 @@ 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()); + tqDebug(i18n("Adapter getAlias failed: %1").arg(dbuserr.message())); TQString addr = app->adapters[adapter]->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getAddress failed: %1").arg(dbuserr.message())); if (name.isEmpty() && addr.isEmpty()) // adapter was removed return; @@ -563,14 +563,14 @@ void TrayIcon::slotPowerOnChanged(const TQString &adapter, bool state) if (state) { KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "AdapterAvailable", tr("BT adapter %1 is on
(%2)").arg(name).arg(addr)); - msg = tr("Power off [%1]").arg(name); + "AdapterAvailable", i18n("BT adapter %1 is on
(%2)").arg(name).arg(addr)); + msg = i18n("Power off [%1]").arg(name); } else { KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "AdapterAvailable", tr("BT adapter %1 is off
(%2)").arg(name).arg(addr)); - msg = tr("Power on [%1]").arg(name); + "AdapterAvailable", i18n("BT adapter %1 is off
(%2)").arg(name).arg(addr)); + msg = i18n("Power on [%1]").arg(name); } showPowerOnActionMap[adapter]->setText(msg); @@ -584,27 +584,27 @@ 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()); + tqDebug(i18n("Device getAlias failed: %1").arg(dbuserr.message())); TQString address = app->devices[path]->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getAddress failed: %1").arg(dbuserr.message())); if (state) { KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "IncomingConnection", tr("Connected to %1 (%2)").arg(name).arg(address)); + "IncomingConnection", i18n("Connected to %1 (%2)").arg(name).arg(address)); } else { KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "IncomingConnection", tr("Disconnected from %1 (%2)").arg(name).arg(address)); + "IncomingConnection", i18n("Disconnected from %1 (%2)").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); + if (TQString(s) != i18n(s)) + return TQString("%1 (\"%2\")").arg(i18n(s)).arg(s); else return s; } @@ -614,8 +614,8 @@ 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" +// i18n("Use right click to open the menu"), +// i18n("Left click is reserved for ObexFTP browsing.\n" // "ObexFTP is subject of development.")); e->accept(); TDEProcess proc; @@ -635,10 +635,10 @@ void TrayIcon::slotQuitSelected() 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")); + i18n("Should TDEBluetooth still be restarted when you login?"), + i18n("Automatically Start TDEBluetooth?"), + i18n("Start"), + i18n("Do Not Start")); if (autoStart == KMessageBox::Yes) app->setAutoStart(true); @@ -662,21 +662,21 @@ void TrayIcon::slotAddAdapter(const TQString& path) bool powered = app->adapters[path]->getPowered(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getPowered failed: %1").arg(dbuserr.message())); TQString name = app->adapters[path]->getAlias(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getAlias failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getAlias failed: %1").arg(dbuserr.message())); TQString addr = app->adapters[path]->getAddress(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getAddress failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getAddress failed: %1").arg(dbuserr.message())); TQString msg; if (powered) - msg = tr("Power off [%1]").arg(name); + msg = i18n("Power off [%1]").arg(name); else - msg = tr("Power on [%1]").arg(name); + msg = i18n("Power on [%1]").arg(name); TDEToggleAction *ad_a = new TDEToggleAction(this, name.utf8()); ad_a->setText(msg); @@ -686,7 +686,7 @@ void TrayIcon::slotAddAdapter(const TQString& path) connect(ad_a, SIGNAL(toggled(bool)), this, SLOT(slotPowerOn(bool))); KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "AdapterAttached", tr("BT adapter %1 attached
(%2)").arg(name).arg(addr)); + "AdapterAttached", i18n("BT adapter %1 attached
(%2)").arg(name).arg(addr)); if(!powered) // find out if we have some powered adapter { @@ -695,7 +695,7 @@ void TrayIcon::slotAddAdapter(const TQString& path) { powered = app->adapters[it.key()]->getPowered(dbuserr); if (dbuserr.isValid()) - tqDebug("Adapter getPowered failed: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Adapter getPowered failed: %1").arg(dbuserr.message())); // know if any adapter is powered if (powered) break; @@ -727,7 +727,7 @@ void TrayIcon::slotRemoveAdapter(const TQString& path) showPowerOnActionMap.remove(path); KNotifyClient::event(TDEApplication::kApplication()->mainWidget()->winId(), - "AdapterDetached", tr("BT adapter detached")); + "AdapterDetached", i18n("BT adapter detached")); if (showPowerOnActionMap.isEmpty()) { @@ -754,9 +754,9 @@ void TrayIcon::slotAdapterAliasChanged(const TQString &path, const TQString &ali bool powered = showPowerOnActionMap[path]->isChecked(); TQString msg; if (powered) - msg = tr("Power off [%1]").arg(alias); + msg = i18n("Power off [%1]").arg(alias); else - msg = tr("Power on [%1]").arg(alias); + msg = i18n("Power on [%1]").arg(alias); showPowerOnActionMap[path]->setText(msg); } @@ -765,7 +765,7 @@ void TrayIcon::slotDiscoverableTimeoutChanged(const TQString &path, TQ_UINT32 ti TQT_DBusError dbuserr; TQString name = app->adapters[path]->getAlias(dbuserr); if (dbuserr.isValid()) - tqDebug("Error: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Error: %1").arg(dbuserr.message())); slotUpdateToolTip(path, name); } @@ -774,7 +774,7 @@ 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()); + tqDebug(i18n("Error: %1").arg(dbuserr.message())); slotUpdateToolTip(path, name); } @@ -783,13 +783,13 @@ 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()); + tqDebug(i18n("Error: %1").arg(dbuserr.message())); TQString disc = (app->adapters[adapter]->getDiscoverable(dbuserr)) ? "discoverable" : "hidden"; if (dbuserr.isValid()) - tqDebug("Error: %s", dbuserr.message().local8Bit().data()); + tqDebug(i18n("Error: %1").arg(dbuserr.message())); - TQString newText = tr("Adapter: %1\nAddress: %2\nMode: %3\n").arg(name, addr, disc); + TQString newText = i18n("Adapter: %1\nAddress: %2\nMode: %3\n").arg(name, addr, disc); updateTooltip(newText); } diff --git a/src/tdebluezauth/application.cpp b/src/tdebluezauth/application.cpp index 3b1dec8..b546a89 100644 --- a/src/tdebluezauth/application.cpp +++ b/src/tdebluezauth/application.cpp @@ -47,9 +47,9 @@ TDEBluezAuth::TDEBluezAuth() : // 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()); + tqWarning(i18n("Requesting name %1 failed. " + "The object will only be addressable through unique name '%2'").arg( + DBUS_AUTH_SERVICE_NAME).arg(m_connection.uniqueName())); exit(-2); } @@ -123,7 +123,7 @@ bool TDEBluezAuth::configureAgent() { if (!manager->requestDefaultAgent()) { - tqWarning("org.bluez.Agent1 registering FAILED"); + tqWarning(i18n("org.bluez.Agent1 registering FAILED")); return false; } } diff --git a/src/tdebluezioclient/CMakeLists.txt b/src/tdebluezioclient/CMakeLists.txt new file mode 100644 index 0000000..71bfc28 --- /dev/null +++ b/src/tdebluezioclient/CMakeLists.txt @@ -0,0 +1,39 @@ +################################################# +# +# (C) 2018 Emanoil Kotsev +# deloptes (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +project (tdebluezioclient) + +include_directories( + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/src/libtdebluez + ${CMAKE_BINARY_DIR}/src + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${DBUS_INCLUDE_DIRS} + ${DBUS_TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### tdebluezioclient ########################### + +tde_add_executable( ${PROJECT_NAME} AUTOMOC + SOURCES + commandhandler.cpp main.cpp + LINK + ${DBUS_TQT_LIBRARIES} tdecore-shared tdebluez-shared tdeio-shared + DESTINATION ${BIN_INSTALL_DIR} +) diff --git a/src/tdebluezioclient/commandhandler.cpp b/src/tdebluezioclient/commandhandler.cpp new file mode 100644 index 0000000..ca1fde1 --- /dev/null +++ b/src/tdebluezioclient/commandhandler.cpp @@ -0,0 +1,408 @@ +/*************************************************************************** + * Copyright (C) 2004 by Fred Schaettgen * + * * + * 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 +#include +#include +#include +#include +#include +#include +#include + +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/tdebluezioclient/commandhandler.h b/src/tdebluezioclient/commandhandler.h new file mode 100644 index 0000000..29fb552 --- /dev/null +++ b/src/tdebluezioclient/commandhandler.h @@ -0,0 +1,60 @@ +//-*-c++-*- +/*************************************************************************** + * Copyright (C) 2004 by Fred Schaettgen * + * * + * 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 +#include +#include +#include +#include + +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/tdebluezioclient/main.cpp b/src/tdebluezioclient/main.cpp new file mode 100644 index 0000000..7428407 --- /dev/null +++ b/src/tdebluezioclient/main.cpp @@ -0,0 +1,74 @@ +//-*-c++-*- +/*************************************************************************** + * Copyright (C) 2003 by Fred Schaettgen * + * kdebluetooth@schaettgen.de * + * * + * 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 +#include +#include +#include +#include +#include + +#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) +{ + TDELocale::setMainCatalogue("tdebluez"); + TDEAboutData about("tdebluezioclient", + I18N_NOOP("tdeio client for tdebluez"), + version, description, + TDEAboutData::License_GPL, + "(C) 2004 Fred Schaettgen", 0, 0, + "kdebluetooth@schaettgen.de"); + about.addAuthor("Emanoil Kotsev", I18N_NOOP("Bluez5 and port to TDE"), "deloptes@gmail.com"); + 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/tdebluezioslave/CMakeLists.txt b/src/tdebluezioslave/CMakeLists.txt new file mode 100644 index 0000000..11b6614 --- /dev/null +++ b/src/tdebluezioslave/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/tdebluezioslave/bluetooth/CMakeLists.txt b/src/tdebluezioslave/bluetooth/CMakeLists.txt new file mode 100644 index 0000000..aabceb6 --- /dev/null +++ b/src/tdebluezioslave/bluetooth/CMakeLists.txt @@ -0,0 +1,43 @@ +################################################# +# +# (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 +tde_create_translated_desktop( + SOURCE bluetooth.protocol + DESTINATION ${SERVICES_INSTALL_DIR} +) +tde_create_translated_desktop( + SOURCE bluetooth_sidebarentry.desktop + DESTINATION ${DATA_INSTALL_DIR}/konqsidebartng/virtual_folders/services +) diff --git a/src/tdebluezioslave/bluetooth/bluetooth.protocol b/src/tdebluezioslave/bluetooth/bluetooth.protocol new file mode 100644 index 0000000..9253aad --- /dev/null +++ b/src/tdebluezioslave/bluetooth/bluetooth.protocol @@ -0,0 +1,12 @@ +[Protocol] +Description=Bluetooth inquiry protocol + +Icon=tdebluez +protocol=bluetooth +exec=tdeio_bluetooth +maxInstances=3 +input=none +output=filesystem +reading=true +listing=Name,Type +DocPath=tdebluez/components.tdeio_sdp.html diff --git a/src/tdebluezioslave/bluetooth/bluetooth_sidebarentry.desktop b/src/tdebluezioslave/bluetooth/bluetooth_sidebarentry.desktop new file mode 100644 index 0000000..8d8461f --- /dev/null +++ b/src/tdebluezioslave/bluetooth/bluetooth_sidebarentry.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Bluetooth Browser + +Type=Link +URL=bluetooth:/ +Icon=tdebluez +Open=false +X-TDE-TreeModule=Directory +X-TDE-KonqSidebarModule=konqsidebar_tree diff --git a/src/tdebluezioslave/bluetooth/tdeiobluetooth.cpp b/src/tdebluezioslave/bluetooth/tdeiobluetooth.cpp new file mode 100644 index 0000000..d2268a7 --- /dev/null +++ b/src/tdebluezioslave/bluetooth/tdeiobluetooth.cpp @@ -0,0 +1,464 @@ +//-*-c++-*- +/*************************************************************************** + * Copyright (C) 2003 by Fred Schaettgen * + * kdebluetooth@schaettgen.de * + * * + * 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 +#include +#include +#include +#include + +#include +#include +#include + +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 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 &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 &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::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::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/tdebluezioslave/bluetooth/tdeiobluetooth.h b/src/tdebluezioslave/bluetooth/tdeiobluetooth.h new file mode 100644 index 0000000..7b881f2 --- /dev/null +++ b/src/tdebluezioslave/bluetooth/tdeiobluetooth.h @@ -0,0 +1,56 @@ +//-*-c++-*- +/*************************************************************************** + * Copyright (C) 2003 by Fred Schaettgen * + * kdebluetooth@schaettgen.de * + * * + * 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 +#include + +#include +#include + +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 &list, const KURL &url); + bool listServices(TQValueList &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/tdebluezioslave/obex/CMakeLists.txt b/src/tdebluezioslave/obex/CMakeLists.txt new file mode 100644 index 0000000..13aa0f4 --- /dev/null +++ b/src/tdebluezioslave/obex/CMakeLists.txt @@ -0,0 +1,46 @@ +################################################# +# +# (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_obex (part) ############################# +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} +) + +tde_create_translated_desktop( + SOURCE obexftp.protocol + DESTINATION ${SERVICES_INSTALL_DIR} +) +tde_create_translated_desktop( + SOURCE obexopp.protocol + DESTINATION ${SERVICES_INSTALL_DIR} +) +tde_create_translated_desktop( + SOURCE obex_sidebarentry.desktop + DESTINATION ${DATA_INSTALL_DIR}/konqsidebartng/virtual_folders/services +) diff --git a/src/tdebluezioslave/obex/README b/src/tdebluezioslave/obex/README new file mode 100644 index 0000000..a44d55f --- /dev/null +++ b/src/tdebluezioslave/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 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 . 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/tdebluezioslave/obex/obex.cpp b/src/tdebluezioslave/obex/obex.cpp new file mode 100644 index 0000000..fb1d81b --- /dev/null +++ b/src/tdebluezioslave/obex/obex.cpp @@ -0,0 +1,312 @@ +/* + This file is part of tdeio_obex. + + Copyright (c) 2003 Mathias Froehlich + + 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 +#include +#include +#include + +#include + +#include + +#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(job); + m_entryBuffer = stat_job->statResult(); + } + + tqApp->eventLoop()->exitLoop(); +} + +UDSEntry Obex::createUDSEntry(const TQMap &map) +{ + kdDebug() << k_funcinfo << endl; + + UDSEntry entry; + long mode; + uint isFile = 0; + + TQMap::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/tdebluezioslave/obex/obex.h b/src/tdebluezioslave/obex/obex.h new file mode 100644 index 0000000..bc6d3cc --- /dev/null +++ b/src/tdebluezioslave/obex/obex.h @@ -0,0 +1,66 @@ +/* + This file is part of tdeio_obex. + + Copyright (c) 2003 Mathias Froehlich + + 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 +#include +#include +#include + +#include + +#include + +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/tdebluezioslave/obex/obex_sidebarentry.desktop b/src/tdebluezioslave/obex/obex_sidebarentry.desktop new file mode 100644 index 0000000..7d6dcae --- /dev/null +++ b/src/tdebluezioslave/obex/obex_sidebarentry.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Bluetooth Browser + +Type=Link +URL=obexftp:/ +Icon=tdebluez +Open=false +X-TDE-TreeModule=Directory +X-TDE-KonqSidebarModule=konqsidebar_tree diff --git a/src/tdebluezioslave/obex/obexftp.protocol b/src/tdebluezioslave/obex/obexftp.protocol new file mode 100644 index 0000000..744b07c --- /dev/null +++ b/src/tdebluezioslave/obex/obexftp.protocol @@ -0,0 +1,19 @@ +[Protocol] +Description=A tdeioslave for OBEX connections + +protocol=obexftp +exec=tdeio_obex +Icon=remote +maxInstances=1 +Parent=system:/ +input=none +output=filesystem +source=false +reading=true +writing=true +makedir=true +deleting=true +moving=false +linking=false +listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group +DocPath=tdebluez/components.tdeio_obex.html diff --git a/src/tdebluezioslave/obex/obexopp.protocol b/src/tdebluezioslave/obex/obexopp.protocol new file mode 100644 index 0000000..f56b884 --- /dev/null +++ b/src/tdebluezioslave/obex/obexopp.protocol @@ -0,0 +1,19 @@ +[Protocol] +Description=A tdeioslave for OBEX connections + +protocol=obexopp +exec=tdeio_obex +Icon=remote +maxInstances=1 +Parent=system:/ +input=none +output=none +source=false +reading=false +writing=true +makedir=false +deleting=false +moving=false +linking=false +listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group +DocPath=tdebluez/components.tdeio_obex.html diff --git a/src/tdebluezioslave/obex/tdeio_obex.cpp b/src/tdebluezioslave/obex/tdeio_obex.cpp new file mode 100644 index 0000000..4d682ca --- /dev/null +++ b/src/tdebluezioslave/obex/tdeio_obex.cpp @@ -0,0 +1,550 @@ +/* + This file is part of tdeio_obex. + + Copyright (c) 2003 Mathias Froehlich + + 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 +#include +//#include +#include +#include + +#include + +#include +#include +#include + +#include +#include +#include + +#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 ); + TDELocale::setMainCatalogue("tdebluez"); + + // 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 = i18n("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, i18n("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, i18n(dbuserror.message().utf8())); + } + // 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 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 vl = folderinfo.toTQValueList(); + TQValueList::Iterator dit = vl.begin(); + for (dit; dit != vl.end(); ++dit) + { + bool ok = false; + TQMap 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::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(i18n("ObjectManagerImpl::slotPropertiesChanged conversion failed")); + } + } + + if (interface == "org.bluez.obex.FileTransfer1" || interface == "org.bluez.obex.Transfer1") + { + TQMap::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(i18n("ObjectManagerImpl::slotPropertiesChanged conversion failed")); + } + } +} + +#include "tdeio_obex.moc" diff --git a/src/tdebluezioslave/obex/tdeio_obex.h b/src/tdebluezioslave/obex/tdeio_obex.h new file mode 100644 index 0000000..afa4b2e --- /dev/null +++ b/src/tdebluezioslave/obex/tdeio_obex.h @@ -0,0 +1,135 @@ +/* + This file is part of tdeio_obex. + + Copyright (c) 2003 Mathias Froehlich + + 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 +#include +#include + +#include + +#include +#include +#include +#include + +#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& 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 diff --git a/src/tdeioclient/CMakeLists.txt b/src/tdeioclient/CMakeLists.txt deleted file mode 100644 index 71bfc28..0000000 --- a/src/tdeioclient/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -################################################# -# -# (C) 2018 Emanoil Kotsev -# deloptes (AT) gmail.com -# -# Improvements and feedback are welcome -# -# This file is released under GPL >= 2 -# -################################################# - -project (tdebluezioclient) - -include_directories( - ${CMAKE_CURRENT_BINARY_DIR} - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/src/libtdebluez - ${CMAKE_BINARY_DIR}/src - ${TDE_INCLUDE_DIR} - ${TQT_INCLUDE_DIRS} - ${DBUS_INCLUDE_DIRS} - ${DBUS_TQT_INCLUDE_DIRS} -) - -link_directories( - ${TQT_LIBRARY_DIRS} -) - -##### tdebluezioclient ########################### - -tde_add_executable( ${PROJECT_NAME} 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 deleted file mode 100644 index 4a24716..0000000 --- a/src/tdeioclient/commandhandler.cpp +++ /dev/null @@ -1,407 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2004 by Fred Schaettgen * - * * - * 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 -#include -#include -#include -#include -#include -#include -#include - -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 deleted file mode 100644 index 29fb552..0000000 --- a/src/tdeioclient/commandhandler.h +++ /dev/null @@ -1,60 +0,0 @@ -//-*-c++-*- -/*************************************************************************** - * Copyright (C) 2004 by Fred Schaettgen * - * * - * 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 -#include -#include -#include -#include - -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 deleted file mode 100644 index 7428407..0000000 --- a/src/tdeioclient/main.cpp +++ /dev/null @@ -1,74 +0,0 @@ -//-*-c++-*- -/*************************************************************************** - * Copyright (C) 2003 by Fred Schaettgen * - * kdebluetooth@schaettgen.de * - * * - * 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 -#include -#include -#include -#include -#include - -#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) -{ - TDELocale::setMainCatalogue("tdebluez"); - TDEAboutData about("tdebluezioclient", - I18N_NOOP("tdeio client for tdebluez"), - version, description, - TDEAboutData::License_GPL, - "(C) 2004 Fred Schaettgen", 0, 0, - "kdebluetooth@schaettgen.de"); - about.addAuthor("Emanoil Kotsev", I18N_NOOP("Bluez5 and port to TDE"), "deloptes@gmail.com"); - 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 deleted file mode 100644 index 11b6614..0000000 --- a/src/tdeioslave/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -################################################# -# -# (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 deleted file mode 100644 index aabceb6..0000000 --- a/src/tdeioslave/bluetooth/CMakeLists.txt +++ /dev/null @@ -1,43 +0,0 @@ -################################################# -# -# (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 -tde_create_translated_desktop( - SOURCE bluetooth.protocol - DESTINATION ${SERVICES_INSTALL_DIR} -) -tde_create_translated_desktop( - SOURCE 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 deleted file mode 100644 index 9253aad..0000000 --- a/src/tdeioslave/bluetooth/bluetooth.protocol +++ /dev/null @@ -1,12 +0,0 @@ -[Protocol] -Description=Bluetooth inquiry protocol - -Icon=tdebluez -protocol=bluetooth -exec=tdeio_bluetooth -maxInstances=3 -input=none -output=filesystem -reading=true -listing=Name,Type -DocPath=tdebluez/components.tdeio_sdp.html diff --git a/src/tdeioslave/bluetooth/bluetooth_sidebarentry.desktop b/src/tdeioslave/bluetooth/bluetooth_sidebarentry.desktop deleted file mode 100644 index 8d8461f..0000000 --- a/src/tdeioslave/bluetooth/bluetooth_sidebarentry.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=Bluetooth Browser - -Type=Link -URL=bluetooth:/ -Icon=tdebluez -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 deleted file mode 100644 index d2268a7..0000000 --- a/src/tdeioslave/bluetooth/tdeiobluetooth.cpp +++ /dev/null @@ -1,464 +0,0 @@ -//-*-c++-*- -/*************************************************************************** - * Copyright (C) 2003 by Fred Schaettgen * - * kdebluetooth@schaettgen.de * - * * - * 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 -#include -#include -#include -#include - -#include -#include -#include - -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 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 &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 &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::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::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 deleted file mode 100644 index 7b881f2..0000000 --- a/src/tdeioslave/bluetooth/tdeiobluetooth.h +++ /dev/null @@ -1,56 +0,0 @@ -//-*-c++-*- -/*************************************************************************** - * Copyright (C) 2003 by Fred Schaettgen * - * kdebluetooth@schaettgen.de * - * * - * 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 -#include - -#include -#include - -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 &list, const KURL &url); - bool listServices(TQValueList &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 deleted file mode 100644 index 13aa0f4..0000000 --- a/src/tdeioslave/obex/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -################################################# -# -# (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_obex (part) ############################# -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} -) - -tde_create_translated_desktop( - SOURCE obexftp.protocol - DESTINATION ${SERVICES_INSTALL_DIR} -) -tde_create_translated_desktop( - SOURCE obexopp.protocol - DESTINATION ${SERVICES_INSTALL_DIR} -) -tde_create_translated_desktop( - SOURCE obex_sidebarentry.desktop - DESTINATION ${DATA_INSTALL_DIR}/konqsidebartng/virtual_folders/services -) diff --git a/src/tdeioslave/obex/README b/src/tdeioslave/obex/README deleted file mode 100644 index a44d55f..0000000 --- a/src/tdeioslave/obex/README +++ /dev/null @@ -1,91 +0,0 @@ - -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 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 . 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 deleted file mode 100644 index fb1d81b..0000000 --- a/src/tdeioslave/obex/obex.cpp +++ /dev/null @@ -1,312 +0,0 @@ -/* - This file is part of tdeio_obex. - - Copyright (c) 2003 Mathias Froehlich - - 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 -#include -#include -#include - -#include - -#include - -#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(job); - m_entryBuffer = stat_job->statResult(); - } - - tqApp->eventLoop()->exitLoop(); -} - -UDSEntry Obex::createUDSEntry(const TQMap &map) -{ - kdDebug() << k_funcinfo << endl; - - UDSEntry entry; - long mode; - uint isFile = 0; - - TQMap::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 deleted file mode 100644 index bc6d3cc..0000000 --- a/src/tdeioslave/obex/obex.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - This file is part of tdeio_obex. - - Copyright (c) 2003 Mathias Froehlich - - 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 -#include -#include -#include - -#include - -#include - -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 deleted file mode 100644 index 7d6dcae..0000000 --- a/src/tdeioslave/obex/obex_sidebarentry.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Name=Bluetooth Browser - -Type=Link -URL=obexftp:/ -Icon=tdebluez -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 deleted file mode 100644 index 744b07c..0000000 --- a/src/tdeioslave/obex/obexftp.protocol +++ /dev/null @@ -1,19 +0,0 @@ -[Protocol] -Description=A tdeioslave for OBEX connections - -protocol=obexftp -exec=tdeio_obex -Icon=remote -maxInstances=1 -Parent=system:/ -input=none -output=filesystem -source=false -reading=true -writing=true -makedir=true -deleting=true -moving=false -linking=false -listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group -DocPath=tdebluez/components.tdeio_obex.html diff --git a/src/tdeioslave/obex/obexopp.protocol b/src/tdeioslave/obex/obexopp.protocol deleted file mode 100644 index f56b884..0000000 --- a/src/tdeioslave/obex/obexopp.protocol +++ /dev/null @@ -1,19 +0,0 @@ -[Protocol] -Description=A tdeioslave for OBEX connections - -protocol=obexopp -exec=tdeio_obex -Icon=remote -maxInstances=1 -Parent=system:/ -input=none -output=none -source=false -reading=false -writing=true -makedir=false -deleting=false -moving=false -linking=false -listing=Name,Type,Size,Date,AccessDate,Access,Owner,Group -DocPath=tdebluez/components.tdeio_obex.html diff --git a/src/tdeioslave/obex/tdeio_obex.cpp b/src/tdeioslave/obex/tdeio_obex.cpp deleted file mode 100644 index 3e5bdbe..0000000 --- a/src/tdeioslave/obex/tdeio_obex.cpp +++ /dev/null @@ -1,550 +0,0 @@ -/* - This file is part of tdeio_obex. - - Copyright (c) 2003 Mathias Froehlich - - 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 -#include -//#include -#include -#include - -#include - -#include -#include -#include - -#include -#include -#include - -#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 ); - TDELocale::setMainCatalogue("tdebluez"); - - // 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 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 vl = folderinfo.toTQValueList(); - TQValueList::Iterator dit = vl.begin(); - for (dit; dit != vl.end(); ++dit) - { - bool ok = false; - TQMap 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::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::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 deleted file mode 100644 index afa4b2e..0000000 --- a/src/tdeioslave/obex/tdeio_obex.h +++ /dev/null @@ -1,135 +0,0 @@ -/* - This file is part of tdeio_obex. - - Copyright (c) 2003 Mathias Froehlich - - 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 -#include -#include - -#include - -#include -#include -#include -#include - -#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& 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 -- cgit v1.2.1