|
|
|
@ -38,378 +38,406 @@
|
|
|
|
|
#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 };
|
|
|
|
|
"Protocol name"), 0 }, { "+pool", I18N_NOOP("Socket name"), 0 }, {
|
|
|
|
|
"+app", I18N_NOOP("Socket name"), 0 }, TDECmdLineLastOption };
|
|
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
|
int KDE_EXPORT kdemain( int argc, char **argv )
|
|
|
|
|
{
|
|
|
|
|
// TDEApplication is necessary to use other ioslaves
|
|
|
|
|
putenv(strdup("SESSION_MANAGER="));
|
|
|
|
|
TDECmdLineArgs::init(argc, argv, "tdeio_obex", 0, 0, 0, 0);
|
|
|
|
|
TDECmdLineArgs::addCmdLineOptions( options );
|
|
|
|
|
TDEApplication app( false, false, false );
|
|
|
|
|
// We want to be anonymous even if we use DCOP
|
|
|
|
|
app.dcopClient()->attach();
|
|
|
|
|
|
|
|
|
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
|
|
|
|
ObexProtocol slave( args->arg(0), args->arg(1), args->arg(2) );
|
|
|
|
|
slave.dispatchLoop();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
int KDE_EXPORT kdemain( int argc, char **argv )
|
|
|
|
|
{
|
|
|
|
|
// TDEApplication is necessary to use other ioslaves
|
|
|
|
|
putenv(strdup("SESSION_MANAGER="));
|
|
|
|
|
TDECmdLineArgs::init(argc, argv, "tdeio_obex", 0, 0, 0, 0);
|
|
|
|
|
TDECmdLineArgs::addCmdLineOptions( options );
|
|
|
|
|
TDEApplication app( false, false, false );
|
|
|
|
|
// We want to be anonymous even if we use DCOP
|
|
|
|
|
app.dcopClient()->attach();
|
|
|
|
|
|
|
|
|
|
TDECmdLineArgs *args = TDECmdLineArgs::parsedArgs();
|
|
|
|
|
ObexProtocol slave( args->arg(0), args->arg(1), args->arg(2) );
|
|
|
|
|
slave.dispatchLoop();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObexProtocol::ObexProtocol(const TQCString &protocol,
|
|
|
|
|
const TQCString &pool_socket, const TQCString &app_socket)
|
|
|
|
|
: SlaveBase(protocol, pool_socket, app_socket)
|
|
|
|
|
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;
|
|
|
|
|
if (mProtocol == "obexftp" || mProtocol == "obexopp")
|
|
|
|
|
obex = new Obex(mProtocol);
|
|
|
|
|
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()) {
|
|
|
|
|
tqDebug("ObexObjectManager is not connected to DBus");
|
|
|
|
|
infoMessage(i18n("Error"));
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT,
|
|
|
|
|
"ObexObjectManager is not connected to DBus");
|
|
|
|
|
closeConnection();
|
|
|
|
|
TQString err = "ObexObjectManager is not connected to DBus";
|
|
|
|
|
tqDebug(err);
|
|
|
|
|
// infoMessage(i18n("Error"));
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT, err);
|
|
|
|
|
closeObex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kdDebug() << "ObexProtocol::ObexProtocol DBus connection: "
|
|
|
|
|
<< (*(mManager->getConnection())).uniqueName() << endl;
|
|
|
|
|
|
|
|
|
|
if (mProtocol == "obexftp" || mProtocol == "obexopp") {
|
|
|
|
|
obex = new Obex(mProtocol);
|
|
|
|
|
// mConnected = connectObex();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
closeObex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ObexProtocol::~ObexProtocol() {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
if (mConnected)
|
|
|
|
|
closeConnection();
|
|
|
|
|
|
|
|
|
|
if (obex)
|
|
|
|
|
delete obex;
|
|
|
|
|
if (mFileTransfer)
|
|
|
|
|
delete mFileTransfer;
|
|
|
|
|
if (mSessionProperties)
|
|
|
|
|
delete mSessionProperties;
|
|
|
|
|
if (mSession)
|
|
|
|
|
delete mSession;
|
|
|
|
|
if (mClient)
|
|
|
|
|
delete mClient;
|
|
|
|
|
if (mManager)
|
|
|
|
|
delete mManager;
|
|
|
|
|
closeObex();
|
|
|
|
|
if (obex)
|
|
|
|
|
delete obex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObexProtocol::closeConnection() {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
closeObex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObexProtocol::closeObex() {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
|
|
|
|
|
TQT_DBusError dbuserror;
|
|
|
|
|
if (mConnected) {
|
|
|
|
|
// infoMessage(i18n("Disconnecting"));
|
|
|
|
|
mConnected = ! mClient->RemoveSession(mSessionPath, dbuserror);
|
|
|
|
|
mManager->close();
|
|
|
|
|
// infoMessage(i18n("Disconnected"));
|
|
|
|
|
}
|
|
|
|
|
exit();
|
|
|
|
|
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;
|
|
|
|
|
if (!mConnected)
|
|
|
|
|
if (!connectObex())
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
if (!mConnected) {
|
|
|
|
|
mConnected = connectObex();
|
|
|
|
|
if (!mConnected) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT, "ObexClient connection failed");
|
|
|
|
|
// infoMessage(i18n("Error"));
|
|
|
|
|
// closeObex();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool ObexProtocol::connectObex() {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
|
|
|
|
|
// if (mClient && mConnected && ! mSessionPath.isEmpty())
|
|
|
|
|
// return true;
|
|
|
|
|
|
|
|
|
|
TQT_DBusError dbuserror;
|
|
|
|
|
|
|
|
|
|
mClient = mManager->getClient();
|
|
|
|
|
if (!mClient) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT, "ObexClient was not created");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQT_DBusVariant obexprot;
|
|
|
|
|
if (mProtocol == "obexftp")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001106-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
else if (mProtocol == "obexopp")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001105-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
else if (mProtocol == "obexmap")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001134-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
else if (mProtocol == "obexpbap")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001130-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
else if (mProtocol == "obexsync")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001104-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
obexprot.signature = obexprot.value.buildDBusSignature();
|
|
|
|
|
TQMap<TQString, TQT_DBusVariant> args;
|
|
|
|
|
args.insert(TQString("Target"), obexprot);
|
|
|
|
|
|
|
|
|
|
if (mSessionPath.isEmpty()) {
|
|
|
|
|
kdDebug() << "ObexProtocol::connectObex : trying to create session" << endl;
|
|
|
|
|
mConnected = mClient->CreateSession(mAddress, args, mSessionPath, dbuserror);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mConnected) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT,
|
|
|
|
|
i18n("Could not create session for %1.").arg(mAddress));
|
|
|
|
|
if (!mClient)
|
|
|
|
|
mClient = mManager->getClient();
|
|
|
|
|
if (!mClient) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT, "ObexClient was not created");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQT_DBusVariant obexprot;
|
|
|
|
|
if (mProtocol == "obexftp")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001106-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
else if (mProtocol == "obexopp")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001105-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
else if (mProtocol == "obexmap")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001134-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
else if (mProtocol == "obexpbap")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001130-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
else if (mProtocol == "obexsync")
|
|
|
|
|
obexprot.value = TQT_DBusData::fromString(
|
|
|
|
|
"00001104-0000-1000-8000-00805f9b34fb");
|
|
|
|
|
obexprot.signature = obexprot.value.buildDBusSignature();
|
|
|
|
|
TQMap<TQString, TQT_DBusVariant> args;
|
|
|
|
|
args.insert(TQString("Target"), obexprot);
|
|
|
|
|
|
|
|
|
|
if (mSessionPath.isEmpty()) {
|
|
|
|
|
kdDebug() << "ObexProtocol::connectObex : trying to create session" << endl;
|
|
|
|
|
if (!mClient->CreateSession(mAddress, args, mSessionPath, dbuserror)) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_COULD_NOT_CONNECT,
|
|
|
|
|
i18n("Could not create session for %1.").arg(mAddress));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kdDebug() << "ObexProtocol::connectObex mSessionPath: " << mSessionPath << endl;
|
|
|
|
|
mSession = new org::bluez::obex::Session1Proxy("org.bluez.obex", mSessionPath);
|
|
|
|
|
mSession->setConnection((*(mManager->getConnection())));
|
|
|
|
|
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())));
|
|
|
|
|
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& ) ) );
|
|
|
|
|
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())));
|
|
|
|
|
mFileTransfer = new org::bluez::obex::FileTransfer1Proxy("org.bluez.obex",
|
|
|
|
|
mSessionPath);
|
|
|
|
|
mFileTransfer->setConnection((*(mManager->getConnection())));
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return mSession != 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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());
|
|
|
|
|
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());
|
|
|
|
|
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)
|
|
|
|
|
mConnected = connectObex();
|
|
|
|
|
if (!mConnected)
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!path.isEmpty()) {
|
|
|
|
|
if (!changeWorkingDirectory(path)) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_CANNOT_OPEN_FOR_READING, path);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
kdDebug() << k_funcinfo << " at line " << __LINE__ << endl;
|
|
|
|
|
TQT_DBusDataList folderinfo;
|
|
|
|
|
TQT_DBusError dbuserror;
|
|
|
|
|
if (!mFileTransfer->ListFolder(folderinfo, dbuserror)) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_CANNOT_OPEN_FOR_READING, url.prettyURL());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (dbuserror.isValid()) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_CANNOT_OPEN_FOR_READING,
|
|
|
|
|
i18n("%1.\n%2").arg(url.prettyURL()).arg(dbuserror.message()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDEIO::UDSEntryList entries;
|
|
|
|
|
entries.clear();
|
|
|
|
|
|
|
|
|
|
TQValueList < TQT_DBusData > vl = folderinfo.toTQValueList();
|
|
|
|
|
TQValueList<TQT_DBusData>::Iterator dit = vl.begin();
|
|
|
|
|
for (dit; dit != vl.end(); ++dit) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
TQMap<TQString, TQT_DBusData> map = (*dit).toStringKeyMap(&ok).toTQMap();
|
|
|
|
|
if (!ok) {
|
|
|
|
|
kdDebug() << k_funcinfo << " failed " << endl;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
TDEIO::UDSEntry entry = obex->createUDSEntry(map);
|
|
|
|
|
entries.append(entry);
|
|
|
|
|
kdDebug() << k_funcinfo << " at line " << __LINE__ << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listEntries(entries);
|
|
|
|
|
listEntry(UDSEntry(), true); // ready
|
|
|
|
|
|
|
|
|
|
finished();
|
|
|
|
|
closeConnection();
|
|
|
|
|
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) {
|
|
|
|
|
mConnected = connectObex();
|
|
|
|
|
if (!mConnected) {
|
|
|
|
|
finished();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!path.isEmpty()) {
|
|
|
|
|
if (!changeWorkingDirectory(path)) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_CANNOT_OPEN_FOR_READING, path);
|
|
|
|
|
|
|
|
|
|
finished();
|
|
|
|
|
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();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDEIO::UDSEntryList entries;
|
|
|
|
|
entries.clear();
|
|
|
|
|
|
|
|
|
|
TQValueList < TQT_DBusData > vl = folderinfo.toTQValueList();
|
|
|
|
|
TQValueList<TQT_DBusData>::Iterator dit = vl.begin();
|
|
|
|
|
for (dit; dit != vl.end(); ++dit) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
TQMap<TQString, TQT_DBusData> map = (*dit).toStringKeyMap(&ok).toTQMap();
|
|
|
|
|
if (!ok) {
|
|
|
|
|
kdDebug() << k_funcinfo << " failed " << endl;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
TDEIO::UDSEntry entry = obex->createUDSEntry(map);
|
|
|
|
|
entries.append(entry);
|
|
|
|
|
kdDebug() << k_funcinfo << " at line " << __LINE__ << endl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
listEntries(entries);
|
|
|
|
|
listEntry(UDSEntry(), true); // ready
|
|
|
|
|
|
|
|
|
|
finished();
|
|
|
|
|
closeObex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObexProtocol::stat(const KURL &url) {
|
|
|
|
|
kdDebug() << k_funcinfo << " url: " << url << endl;
|
|
|
|
|
|
|
|
|
|
TQString address, name, path;
|
|
|
|
|
bool ok = obex->parseURL(url, address, name, path);
|
|
|
|
|
kdDebug() << k_funcinfo << " addr: " << address << endl;
|
|
|
|
|
kdDebug() << k_funcinfo << " name: " << name << endl;
|
|
|
|
|
kdDebug() << k_funcinfo << " path: " << path << endl;
|
|
|
|
|
|
|
|
|
|
if (!ok || address.isEmpty()) {
|
|
|
|
|
error(TDEIO::ERR_MALFORMED_URL, url.prettyURL());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TDEIO::UDSEntry entry;
|
|
|
|
|
if (path.isEmpty() || path == "/") {
|
|
|
|
|
// The root is "virtual" - it's not a single physical directory
|
|
|
|
|
obex->createTopLevelEntry(entry);
|
|
|
|
|
} else {
|
|
|
|
|
obex->createDirEntry(entry, url.url());
|
|
|
|
|
}
|
|
|
|
|
statEntry(entry);
|
|
|
|
|
finished();
|
|
|
|
|
return;
|
|
|
|
|
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;
|
|
|
|
|
// obex->get(url);
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->get(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObexProtocol::copy(const KURL &src, const KURL &dest, int permissions, bool overwrite) {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->copy(src, dest, permissions, overwrite);
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->copy(src, dest, permissions, overwrite);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObexProtocol::put(const KURL& url, int permissions, bool overwrite,
|
|
|
|
|
bool resume) {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->put(url, permissions, overwrite, resume);
|
|
|
|
|
bool resume) {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->put(url, permissions, overwrite, resume);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObexProtocol::del(const KURL &url, bool isfile) {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->del(url, isfile);
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->del(url, isfile);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void ObexProtocol::rename(const KURL& src, const KURL& dest, bool overwrite) {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->rename(src, dest, overwrite);
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->rename(src, dest, overwrite);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
void ObexProtocol::mkdir(const KURL&url, int permissions) {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->mkdir(url, permissions);
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
// obex->mkdir(url, permissions);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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 (!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;
|
|
|
|
|
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 (!mFileTransfer) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL,
|
|
|
|
|
i18n("Could not change directory: %1. No file transport").arg(dir));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TQT_DBusError dbuserror;
|
|
|
|
|
if (!mFileTransfer->ChangeFolder(dir, dbuserror)) {
|
|
|
|
|
TDEIO::SlaveBase::error(TDEIO::ERR_INTERNAL, i18n("Could not change directory: %1.").arg(dbuserror.message()));
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ObexProtocol::slotPropertiesChanged(const TQString& interface,
|
|
|
|
|
const TQMap<TQString, TQT_DBusVariant>& changed_properties,
|
|
|
|
|
const TQStringList& invalidated_properties) {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
kdDebug() << interface << endl;
|
|
|
|
|
|
|
|
|
|
if (interface == "org.bluez.obex.Session1") {
|
|
|
|
|
TQMap<TQString, TQT_DBusVariant>::const_iterator it;
|
|
|
|
|
for (it = changed_properties.begin(); it != changed_properties.end();
|
|
|
|
|
++it) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
if (it.key() == "Source")
|
|
|
|
|
emit sessionSourceChanged(mSessionPath,
|
|
|
|
|
it.data().value.toBool(&ok));
|
|
|
|
|
else if (it.key() == "Destination")
|
|
|
|
|
emit sessionDestinationChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else if (it.key() == "Channel")
|
|
|
|
|
emit sessionChannelChanged(mSessionPath,
|
|
|
|
|
it.data().value.toByte(&ok));
|
|
|
|
|
else if (it.key() == "Target")
|
|
|
|
|
emit sessionTargetChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else if (it.key() == "Root")
|
|
|
|
|
emit sessionRootChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
if (!ok)
|
|
|
|
|
tqDebug(
|
|
|
|
|
"ObjectManagerImpl::slotPropertiesChanged conversion failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (interface == "org.bluez.obex.FileTransfer1"
|
|
|
|
|
|| interface == "org.bluez.obex.Transfer1") {
|
|
|
|
|
TQMap<TQString, TQT_DBusVariant>::const_iterator it;
|
|
|
|
|
for (it = changed_properties.begin(); it != changed_properties.end();
|
|
|
|
|
++it) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
if (it.key() == "Size")
|
|
|
|
|
emit transferSizeChanged(mSessionPath,
|
|
|
|
|
it.data().value.toUInt64(&ok));
|
|
|
|
|
else if (it.key() == "Status")
|
|
|
|
|
emit transferStatusChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else if (it.key() == "Transferred")
|
|
|
|
|
emit transferTransferredChanged(mSessionPath,
|
|
|
|
|
it.data().value.toUInt64(&ok));
|
|
|
|
|
else if (it.key() == "Time")
|
|
|
|
|
emit transferTimeChanged(mSessionPath,
|
|
|
|
|
it.data().value.toUInt64(&ok));
|
|
|
|
|
else if (it.key() == "Filename")
|
|
|
|
|
emit transferFilenameChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
if (!ok)
|
|
|
|
|
tqDebug(
|
|
|
|
|
"ObjectManagerImpl::slotPropertiesChanged conversion failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const TQMap<TQString, TQT_DBusVariant>& changed_properties,
|
|
|
|
|
const TQStringList& invalidated_properties) {
|
|
|
|
|
kdDebug() << k_funcinfo << endl;
|
|
|
|
|
kdDebug() << interface << endl;
|
|
|
|
|
|
|
|
|
|
if (interface == "org.bluez.obex.Session1") {
|
|
|
|
|
TQMap<TQString, TQT_DBusVariant>::const_iterator it;
|
|
|
|
|
for (it = changed_properties.begin(); it != changed_properties.end();
|
|
|
|
|
++it) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
if (it.key() == "Source")
|
|
|
|
|
emit sessionSourceChanged(mSessionPath,
|
|
|
|
|
it.data().value.toBool(&ok));
|
|
|
|
|
else if (it.key() == "Destination")
|
|
|
|
|
emit sessionDestinationChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else if (it.key() == "Channel")
|
|
|
|
|
emit sessionChannelChanged(mSessionPath,
|
|
|
|
|
it.data().value.toByte(&ok));
|
|
|
|
|
else if (it.key() == "Target")
|
|
|
|
|
emit sessionTargetChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else if (it.key() == "Root")
|
|
|
|
|
emit sessionRootChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
if (!ok)
|
|
|
|
|
tqDebug(
|
|
|
|
|
"ObjectManagerImpl::slotPropertiesChanged conversion failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (interface == "org.bluez.obex.FileTransfer1"
|
|
|
|
|
|| interface == "org.bluez.obex.Transfer1") {
|
|
|
|
|
TQMap<TQString, TQT_DBusVariant>::const_iterator it;
|
|
|
|
|
for (it = changed_properties.begin(); it != changed_properties.end();
|
|
|
|
|
++it) {
|
|
|
|
|
bool ok = false;
|
|
|
|
|
if (it.key() == "Size")
|
|
|
|
|
emit transferSizeChanged(mSessionPath,
|
|
|
|
|
it.data().value.toUInt64(&ok));
|
|
|
|
|
else if (it.key() == "Status")
|
|
|
|
|
emit transferStatusChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else if (it.key() == "Transferred")
|
|
|
|
|
emit transferTransferredChanged(mSessionPath,
|
|
|
|
|
it.data().value.toUInt64(&ok));
|
|
|
|
|
else if (it.key() == "Time")
|
|
|
|
|
emit transferTimeChanged(mSessionPath,
|
|
|
|
|
it.data().value.toUInt64(&ok));
|
|
|
|
|
else if (it.key() == "Filename")
|
|
|
|
|
emit transferFilenameChanged(mSessionPath,
|
|
|
|
|
it.data().value.toString(&ok));
|
|
|
|
|
else
|
|
|
|
|
continue;
|
|
|
|
|
if (!ok)
|
|
|
|
|
tqDebug(
|
|
|
|
|
"ObjectManagerImpl::slotPropertiesChanged conversion failed");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#include "tdeio_obex.moc"
|
|
|
|
|