Blame SOURCES/0004-obexftpdaemon-session-method-now-takes-target-parame.patch

a562b3
From 21f1f3861d5d7a4e4a9c83d1d109d37713191b65 Mon Sep 17 00:00:00 2001
a562b3
From: David Rosca <nowrep@gmail.com>
a562b3
Date: Mon, 29 Dec 2014 12:24:37 +0100
a562b3
Subject: [PATCH 04/20] obexftpdaemon: session() method now takes target
a562b3
 parameter
a562b3
a562b3
This way it is now possible to create other session than only
a562b3
"ftp". This is needed to be able to create "pcsuite" sessions.
a562b3
a562b3
Also address parameter of session() method is now taken
a562b3
in correct form (uppercase colon separated).
a562b3
---
a562b3
 src/kio/obexftp/daemon/ObexFtpDaemon.cpp    | 8 +++-----
a562b3
 src/kio/obexftp/daemon/ObexFtpDaemon.h      | 2 +-
a562b3
 src/kio/obexftp/daemon/createsessionjob.cpp | 7 ++++---
a562b3
 src/kio/obexftp/daemon/createsessionjob.h   | 5 +++--
a562b3
 src/kio/obexftp/kded_obexftp.xml            | 1 +
a562b3
 src/kio/obexftp/kio_obexftp.cpp             | 3 ++-
a562b3
 6 files changed, 14 insertions(+), 12 deletions(-)
a562b3
a562b3
diff --git a/src/kio/obexftp/daemon/ObexFtpDaemon.cpp b/src/kio/obexftp/daemon/ObexFtpDaemon.cpp
a562b3
index 782f8d3..d811291 100644
a562b3
--- a/src/kio/obexftp/daemon/ObexFtpDaemon.cpp
a562b3
+++ b/src/kio/obexftp/daemon/ObexFtpDaemon.cpp
a562b3
@@ -123,15 +123,13 @@ bool ObexFtpDaemon::isOnline()
a562b3
     return d->m_status == Private::Online;
a562b3
 }
a562b3
 
a562b3
-QString ObexFtpDaemon::session(QString address, const QDBusMessage& msg)
a562b3
+QString ObexFtpDaemon::session(const QString &address, const QString &target, const QDBusMessage& msg)
a562b3
 {
a562b3
-    address.replace("-", ":");
a562b3
-
a562b3
     if (d->m_sessionMap.contains(address)) {
a562b3
         return d->m_sessionMap[address];
a562b3
     }
a562b3
 
a562b3
-    kDebug(dobex()) << "Creating session for" << address;
a562b3
+    kDebug(dobex()) << "Creating session for" << address << "target" << target;
a562b3
 
a562b3
     // At this point we always want delayed reply
a562b3
     msg.setDelayedReply(true);
a562b3
@@ -141,7 +139,7 @@ QString ObexFtpDaemon::session(QString address, const QDBusMessage& msg)
a562b3
         return QString();
a562b3
     }
a562b3
 
a562b3
-    CreateSessionJob *job = new CreateSessionJob(address, msg);
a562b3
+    CreateSessionJob *job = new CreateSessionJob(address, target, msg);
a562b3
     connect(job, SIGNAL(finished(KJob*)), SLOT(sessionCreated(KJob*)));
a562b3
     job->start();
a562b3
 
a562b3
diff --git a/src/kio/obexftp/daemon/ObexFtpDaemon.h b/src/kio/obexftp/daemon/ObexFtpDaemon.h
a562b3
index d06b391..e58a74d 100644
a562b3
--- a/src/kio/obexftp/daemon/ObexFtpDaemon.h
a562b3
+++ b/src/kio/obexftp/daemon/ObexFtpDaemon.h
a562b3
@@ -39,7 +39,7 @@ public:
a562b3
 
a562b3
 public Q_SLOTS:
a562b3
     Q_SCRIPTABLE bool isOnline();
a562b3
-    Q_SCRIPTABLE QString session(QString address, const QDBusMessage &msg;;
a562b3
+    Q_SCRIPTABLE QString session(const QString &address, const QString &target, const QDBusMessage &msg;;
a562b3
     Q_SCRIPTABLE bool cancelTransfer(const QString &transfer);
a562b3
 
a562b3
 private Q_SLOTS:
a562b3
diff --git a/src/kio/obexftp/daemon/createsessionjob.cpp b/src/kio/obexftp/daemon/createsessionjob.cpp
a562b3
index e84f8ee..883fe11 100644
a562b3
--- a/src/kio/obexftp/daemon/createsessionjob.cpp
a562b3
+++ b/src/kio/obexftp/daemon/createsessionjob.cpp
a562b3
@@ -25,9 +25,10 @@
a562b3
 #include <KDebug>
a562b3
 
a562b3
 // class
a562b3
-CreateSessionJob::CreateSessionJob(const QString& address, const QDBusMessage& msg, QObject* parent)
a562b3
+CreateSessionJob::CreateSessionJob(const QString &address, const QString &target, const QDBusMessage &msg, QObject *parent)
a562b3
     : KJob(parent)
a562b3
     , m_address(address)
a562b3
+    , m_target(target)
a562b3
     , m_client(0)
a562b3
 {
a562b3
     m_messages.append(msg);
a562b3
@@ -53,7 +54,7 @@ void CreateSessionJob::addMessage(const QDBusMessage& msg)
a562b3
     m_messages.append(msg);
a562b3
 }
a562b3
 
a562b3
-const QList< QDBusMessage > CreateSessionJob::messages() const
a562b3
+const QList<QDBusMessage> CreateSessionJob::messages() const
a562b3
 {
a562b3
     return m_messages;
a562b3
 }
a562b3
@@ -62,7 +63,7 @@ void CreateSessionJob::createSession()
a562b3
 {
a562b3
     kDebug(dobex());
a562b3
     QVariantMap args;
a562b3
-    args["Target"] = "ftp";
a562b3
+    args["Target"] = m_target;
a562b3
     m_client = new OrgBluezObexClient1Interface("org.bluez.obex",
a562b3
                                                 "/org/bluez/obex",
a562b3
                                                 QDBusConnection::sessionBus(), this);
a562b3
diff --git a/src/kio/obexftp/daemon/createsessionjob.h b/src/kio/obexftp/daemon/createsessionjob.h
a562b3
index a457b02..667384b 100644
a562b3
--- a/src/kio/obexftp/daemon/createsessionjob.h
a562b3
+++ b/src/kio/obexftp/daemon/createsessionjob.h
a562b3
@@ -29,7 +29,7 @@ class CreateSessionJob : public KJob
a562b3
 {
a562b3
     Q_OBJECT
a562b3
 public:
a562b3
-    explicit CreateSessionJob(const QString &address, const QDBusMessage &msg, QObject* parent = 0);
a562b3
+    explicit CreateSessionJob(const QString &address, const QString &target, const QDBusMessage &msg, QObject *parent = 0);
a562b3
 
a562b3
     virtual void start();
a562b3
     QString path();
a562b3
@@ -44,9 +44,10 @@ private Q_SLOTS:
a562b3
 private:
a562b3
     QString m_path;
a562b3
     QString m_address;
a562b3
+    QString m_target;
a562b3
     QList<QDBusMessage> m_messages;
a562b3
 
a562b3
     OrgBluezObexClient1Interface* m_client;
a562b3
 };
a562b3
 
a562b3
-#endif //CREATE_SESSION_JOB_H
a562b3
\ No newline at end of file
a562b3
+#endif //CREATE_SESSION_JOB_H
a562b3
diff --git a/src/kio/obexftp/kded_obexftp.xml b/src/kio/obexftp/kded_obexftp.xml
a562b3
index ec718e6..06e3b14 100644
a562b3
--- a/src/kio/obexftp/kded_obexftp.xml
a562b3
+++ b/src/kio/obexftp/kded_obexftp.xml
a562b3
@@ -8,6 +8,7 @@
a562b3
     </method>
a562b3
     <method name="session">
a562b3
       <arg name="address" type="s" direction="in"/>
a562b3
+      <arg name="target" type="s" direction="in"/>
a562b3
       <arg name="sessionPath" type="s" direction="out"/>
a562b3
     </method>
a562b3
     <method name="cancelTransfer">
a562b3
diff --git a/src/kio/obexftp/kio_obexftp.cpp b/src/kio/obexftp/kio_obexftp.cpp
a562b3
index 5ae5920..a8c27e7 100644
a562b3
--- a/src/kio/obexftp/kio_obexftp.cpp
a562b3
+++ b/src/kio/obexftp/kio_obexftp.cpp
a562b3
@@ -83,7 +83,7 @@ void KioFtp::launchProgressBar()
a562b3
 
a562b3
 void KioFtp::connectToHost()
a562b3
 {
a562b3
-    QDBusPendingReply<QString> reply = m_kded->session(m_host);
a562b3
+    QDBusPendingReply<QString> reply = m_kded->session(m_host, "ftp");
a562b3
     reply.waitForFinished();
a562b3
 
a562b3
     const QString &sessionPath = reply.value();
a562b3
@@ -225,6 +225,7 @@ void KioFtp::setHost(const QString &host, quint16 port, const QString &user, con
a562b3
     Q_UNUSED(pass)
a562b3
 
a562b3
     m_host = host;
a562b3
+    m_host = m_host.replace(QLatin1Char('-'), QLatin1Char(':')).toUpper();
a562b3
 
a562b3
     infoMessage(i18n("Connecting to the device"));
a562b3
 
a562b3
-- 
a562b3
2.1.0
a562b3