[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    =?utf-8?q?=5Bbluedevil=5D_src/daemon/helpers/filereceiver=3A_Imp?=
From:       Alex Fiestas <alex () eyeos ! org>
Date:       2011-02-14 13:20:25
Message-ID: 20110214132025.E1F54A60EB () git ! kde ! org
[Download RAW message or body]

Git commit bf383c66a8994c7f50afe2f663bab1dbcc22313b by Alex Fiestas.
Committed on 03/02/2011 at 23:37.
Pushed by afiestas into branch 'master'.

Implement obex ftp server in filereceiver helper.

Obex protocol has to modes "oop" and "ftp". The last one allow
us to share files trhough Bluetooth just like cellphones do.

M  +1    -0    src/daemon/helpers/filereceiver/CMakeLists.txt     
A  +121  -0    src/daemon/helpers/filereceiver/openobex/serverftp.cpp         \
[License: GPL (v2+)] A  +55   -0    \
src/daemon/helpers/filereceiver/openobex/serverftp.h         [License: GPL (v2+)] M  \
+2    -0    src/daemon/helpers/filereceiver/service.cpp      M  +4    -1    \
src/daemon/helpers/filereceiver/service.h     

http://commits.kde.org/bluedevil/bf383c66a8994c7f50afe2f663bab1dbcc22313b

diff --git a/src/daemon/helpers/filereceiver/CMakeLists.txt \
b/src/daemon/helpers/filereceiver/CMakeLists.txt index 2369a85..26c4419 100644
--- a/src/daemon/helpers/filereceiver/CMakeLists.txt
+++ b/src/daemon/helpers/filereceiver/CMakeLists.txt
@@ -5,6 +5,7 @@ set(helper_SRCS
     main.cpp
     service.cpp
     openobex/server.cpp
+    openobex/serverftp.cpp
     openobex/serversession.cpp
     openobex/filetransferjob.cpp
 )
diff --git a/src/daemon/helpers/filereceiver/openobex/serverftp.cpp \
b/src/daemon/helpers/filereceiver/openobex/serverftp.cpp new file mode 100644
index 0000000..72ce662
--- /dev/null
+++ b/src/daemon/helpers/filereceiver/openobex/serverftp.cpp
@@ -0,0 +1,121 @@
+/***************************************************************************
+ *   Copyright (C) 2010 Eduardo Robles Elvira <edulix@gmail.com>           *
+ *   Copyright (C) 2010 Alejandro Fiestas Olivares <alex@eyeos.org>        *
+ *   Copyright (C) 2010 UFO Coders <info@ufocoders.com>                    *
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#include "serverftp.h"
+#include "server_interface.h"
+#include "server_session_interface.h"
+#include "serversession.h"
+#include "filereceiversettings.h"
+
+#include <KDebug>
+#include <KGlobal>
+#include <KConfig>
+#include <KConfigGroup>
+#include <QtGui/QDesktopServices>
+#include <kstandarddirs.h>
+
+OpenObex::ServerFtp::ServerFtp(const QString& addr)
+    : QObject(0),  m_dbusServer(0)
+{
+    kDebug();
+
+    kDebug() << addr;
+
+    QDBusInterface* manager = new QDBusInterface("org.openobex", "/org/openobex",
+        "org.openobex.Manager", QDBusConnection::sessionBus());
+
+    QList<QVariant> args;
+    args << addr << "ftp" << true;
+    kDebug() << args;
+
+    manager->callWithCallback("CreateBluetoothServer", args, this,
+        SLOT(serverCreated(QDBusObjectPath)),
+        SLOT(serverCreatedError(QDBusError)));
+
+}
+
+OpenObex::ServerFtp::~ServerFtp()
+{
+    kDebug();
+    if (m_dbusServer) {
+      m_dbusServer->Stop();
+      m_dbusServer->Close();
+    }
+    disconnect();
+    delete m_dbusServer;
+}
+
+void OpenObex::ServerFtp::slotErrorOccured(const QString& errorName, const QString& \
errorMessage) +{
+    kDebug() << "error_name" << errorName << "error_message" << errorMessage;
+}
+
+void OpenObex::ServerFtp::slotSessionCreated(const QDBusObjectPath &path)
+{
+    kDebug() << "slotSessionCreated path" << path.path();
+
+    QDBusConnection* dbus = new QDBusConnection("dbus");
+    QDBusConnection dbusConnection = dbus->connectToBus(QDBusConnection::SessionBus, \
"dbus"); +    org::openobex::ServerSession* dbusServerSession = new
+        org::openobex::ServerSession("org.openobex", path.path(), dbusConnection, \
this); +
+    if (!dbusServerSession->isValid()) {
+        kDebug() << "invalid org::openobex::ServerSession interface";
+        return;
+    }
+}
+
+void OpenObex::ServerFtp::slotSessionRemoved(const QDBusObjectPath &path)
+{
+    kDebug() << "path" << path.path();
+
+//     if (d->serverSessions.contains(path.path())) {
+//       d->serverSessions[path.path()]->queueDelete();
+//       d->serverSessions.remove(path.path());
+//     }
+}
+void OpenObex::ServerFtp::serverCreated(const QDBusObjectPath &path)
+{
+    m_dbusServer = new org::openobex::Server("org.openobex",
+        path.path(), QDBusConnection::sessionBus(), this);
+
+    if (!m_dbusServer->isValid()) {
+        kDebug() << "open obex error: invalid dbus server interface" << path.path();
+        return;
+    }
+
+    kDebug() << "session interface created for: " << m_dbusServer->path();
+
+    connect(m_dbusServer, SIGNAL(SessionCreated(QDBusObjectPath)), this,
+        SLOT(slotSessionCreated(QDBusObjectPath)));
+    connect(m_dbusServer, SIGNAL(SessionRemoved(QDBusObjectPath)),
+        this, SLOT(slotSessionRemoved(QDBusObjectPath)));
+    connect(m_dbusServer, SIGNAL(ErrorOccured(const QString&, const QString&)),
+        this, SLOT(slotErrorOccured(const QString&, const QString&)));
+
+    //TODO: Check if the dir exists and create it if not
+    m_dbusServer->Start("/home/nasete/Public", true, false);
+}
+
+void OpenObex::ServerFtp::serverCreatedError(const QDBusError &error)
+{
+    kDebug() << error.message();
+}
\ No newline at end of file
diff --git a/src/daemon/helpers/filereceiver/openobex/serverftp.h \
b/src/daemon/helpers/filereceiver/openobex/serverftp.h new file mode 100644
index 0000000..66fc3a2
--- /dev/null
+++ b/src/daemon/helpers/filereceiver/openobex/serverftp.h
@@ -0,0 +1,55 @@
+/***************************************************************************
+ *   Copyright (C) 2010-2011 Alejandro Fiestas Olivares <afiestas@kde.org> *
+ *   Copyright (C) 2010-2011 UFO Coders <info@ufocoders.com>               *
+ *                                                                         *
+ *   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.                                   *
+ *                                                                         *
+ *   This program is distributed in the hope that it will be useful,       *
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
+ *   GNU General Public License for more details.                          *
+ *                                                                         *
+ *   You should have received a copy of the GNU General Public License     *
+ *   along with this program; if not, write to the                         *
+ *   Free Software Foundation, Inc.,                                       *
+ *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
+ ***************************************************************************/
+
+#ifndef OPENOBEX_SERVERFTP_H
+#define OPENOBEX_SERVERFTP_H
+
+#include <QtCore/QObject>
+#include <QtDBus>
+
+class OrgOpenobexServerInterface;
+namespace OpenObex
+{
+
+class ServerFtp : public QObject
+{
+    Q_OBJECT
+public:
+    ServerFtp(const QString &addr);
+    virtual ~ServerFtp();
+
+protected Q_SLOTS:
+    void slotErrorOccured(const QString &errorName, const QString &errorMessage);
+    void slotSessionCreated(const QDBusObjectPath &path);
+    void slotSessionRemoved(const QDBusObjectPath &path);
+
+    void serverCreated(const QDBusObjectPath &path);
+    void serverCreatedError(const QDBusError &error);
+
+private:
+    bool serviceStarted();
+
+private:
+    OrgOpenobexServerInterface *m_dbusServer;
+};
+
+}
+
+#endif // OPENOBEX_SERVERFTP_H
diff --git a/src/daemon/helpers/filereceiver/service.cpp \
b/src/daemon/helpers/filereceiver/service.cpp index 2697574..f836886 100644
--- a/src/daemon/helpers/filereceiver/service.cpp
+++ b/src/daemon/helpers/filereceiver/service.cpp
@@ -21,6 +21,7 @@
 
 #include "service.h"
 #include "serviceadaptor.h"
+#include "openobex/serverftp.h"
 #include "openobex/serversession.h"
 
 #include <KDebug>
@@ -61,6 +62,7 @@ void Service::launchServer()
 
     if (BlueDevil::Manager::self()->defaultAdapter()) {
         m_server = new \
OpenObex::Server(BlueDevil::Manager::self()->defaultAdapter()->address()); +        \
m_serverftp = new OpenObex::ServerFtp(BlueDevil::Manager::self()->defaultAdapter()->address());
  kDebug() << m_server;
     } else{
         kDebug() << "No adapters found";
diff --git a/src/daemon/helpers/filereceiver/service.h \
b/src/daemon/helpers/filereceiver/service.h index 6f52d0c..536f03e 100644
--- a/src/daemon/helpers/filereceiver/service.h
+++ b/src/daemon/helpers/filereceiver/service.h
@@ -26,6 +26,8 @@
 #include <QtDBus/QtDBus>
 
 #include "openobex/server.h"
+#include "openobex/serverftp.h"
+
 class QDBusServiceWatcher;
 class Service
     : public QObject
@@ -45,7 +47,8 @@ private Q_SLOTS:
     void openobexUnregistered();
 
 private:
-    OpenObex::Server* m_server;
+    OpenObex::Server *m_server;
+    OpenObex::ServerFtp *m_serverftp;
     QDBusServiceWatcher *m_watcher;
 };
 


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic