[SCM] ktp-filetransfer-handler packaging branch, master, updated. debian/15.12.1-2-226-g825cd93

Maximiliano Curia maxy at moszumanska.debian.org
Sat May 28 00:11:36 UTC 2016


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-filetransfer-handler.git;a=commitdiff;h=64c1d66

The following commit has been merged in the master branch:
commit 64c1d66a1516e7a4ebd61d4c3970eacc671e8e3c
Author: Daniele E. Domenichelli <daniele.domenichelli at gmail.com>
Date:   Sat Sep 17 18:56:34 2011 +0100

    Use KTelepathy::TelepathyHandlerApplication instead of KApplication
    
    Reviewed-by: David Edmundson <kde at davidedmundson.co.uk>
    Reviewed-by: George Kiagiadakis <george.kiagiadakis at collabora.com>
    Reviewed-by: Dario Freddi <dario.freddi at collabora.com>
    REVIEW: 102306
---
 src/CMakeLists.txt           |  1 +
 src/filetransfer-handler.cpp | 47 ++++++++++++++++++++++----------------------
 src/filetransfer-handler.h   |  9 +--------
 src/main.cpp                 | 26 +++++-------------------
 4 files changed, 30 insertions(+), 53 deletions(-)

diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8c4a17b..ad3474e 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,6 @@
 set (telepathy_kde_filetransfer_handler_SRCS
      main.cpp
+     telepathy-handler-application.cpp
      filetransfer-handler.cpp
      telepathy-base-job.cpp
      handle-incoming-file-transfer-channel-job.cpp
diff --git a/src/filetransfer-handler.cpp b/src/filetransfer-handler.cpp
index 57d8288..cdf5fa5 100644
--- a/src/filetransfer-handler.cpp
+++ b/src/filetransfer-handler.cpp
@@ -16,6 +16,7 @@
  */
 
 #include "filetransfer-handler.h"
+#include "telepathy-handler-application.h"
 #include "handle-incoming-file-transfer-channel-job.h"
 #include "handle-outgoing-file-transfer-channel-job.h"
 
@@ -32,19 +33,14 @@
 #include <kjobtrackerinterface.h>
 #include <KDebug>
 
-#include <QApplication>
 
-
-FileTransferHandler::FileTransferHandler(bool persist, QObject *parent)
+FileTransferHandler::FileTransferHandler(QObject *parent)
     : QObject(parent),
       Tp::AbstractClientHandler(Tp::ChannelClassSpecList() << Tp::ChannelClassSpec::incomingFileTransfer()
-                                                           << Tp::ChannelClassSpec::outgoingFileTransfer()),
-      m_persist(persist),
-      m_jobCount(0)
+                                                           << Tp::ChannelClassSpec::outgoingFileTransfer())
 {
 }
 
-
 FileTransferHandler::~FileTransferHandler()
 {
 }
@@ -71,11 +67,15 @@ void FileTransferHandler::handleChannels(const Tp::MethodInvocationContextPtr<>
     Q_FOREACH(const Tp::ChannelPtr &channel, channels) {
         kDebug() << "Handling new file transfer";
 
-
         KJob* job = NULL;
         if (Tp::IncomingFileTransferChannelPtr incomingFileTransferChannel = Tp::IncomingFileTransferChannelPtr::dynamicCast(channel)) {
-            m_jobCount.fetchAndAddOrdered(1);
-            context->setFinished();
+            if (KTelepathy::TelepathyHandlerApplication::newJob() >= 0) {
+                context->setFinished();
+            } else {
+                context->setFinishedWithError(QLatin1String("org.freedesktop.Telepathy.KDE.FileTransfer.Exiting"),
+                                              i18n("File transfer handler is exiting. Cannot start job"));
+                return;
+            }
 
             kDebug() << "Incoming File Transfer:";
             kDebug() << channel->immutableProperties();
@@ -90,13 +90,18 @@ void FileTransferHandler::handleChannels(const Tp::MethodInvocationContextPtr<>
 
             job = new HandleIncomingFileTransferChannelJob(incomingFileTransferChannel, downloadDirectory, this);
         } else if (Tp::OutgoingFileTransferChannelPtr outgoingFileTransferChannel = Tp::OutgoingFileTransferChannelPtr::dynamicCast(channel)) {
-            if (outgoingFileTransferChannel->uri().isEmpty())
-            {
+            if (outgoingFileTransferChannel->uri().isEmpty()) {
                 context->setFinishedWithError(QLatin1String(TELEPATHY_QT4_ERROR_INCONSISTENT),
-                                              QLatin1String("Cannot handle outgoing file transfer without URI"));
+                                              i18n("Cannot handle outgoing file transfer without URI"));
+            }
+
+            if (KTelepathy::TelepathyHandlerApplication::newJob() >= 0) {
+                context->setFinished();
+            } else {
+                context->setFinishedWithError(QLatin1String("org.freedesktop.Telepathy.KDE.FileTransfer.Exiting"),
+                                              i18n("File transfer handler is exiting. Cannot start job"));
+                return;
             }
-            m_jobCount.fetchAndAddOrdered(1);
-            context->setFinished();
 
             kDebug() << "Outgoing File Transfer:";
             kDebug() << channel->immutableProperties();
@@ -104,7 +109,7 @@ void FileTransferHandler::handleChannels(const Tp::MethodInvocationContextPtr<>
             job = new HandleOutgoingFileTransferChannelJob(outgoingFileTransferChannel, this);
         } else {
             context->setFinishedWithError(QLatin1String(TELEPATHY_QT4_ERROR_INCONSISTENT),
-                                          QLatin1String("Unknown channel type"));
+                                          i18n("Unknown channel type"));
             kDebug() << "If you are reading this, then telepathy is broken";
         }
 
@@ -138,13 +143,7 @@ void FileTransferHandler::handleResult(KJob* job)
         // TODO do something;
     }
 
-    QTimer::singleShot(2000, this, SLOT(onTimeout()));
+    KTelepathy::TelepathyHandlerApplication::jobFinished();
 }
 
-void FileTransferHandler::onTimeout()
-{
-    if (!m_persist && m_jobCount.fetchAndAddOrdered(-1) <= 1) {
-        kDebug() << "Timeout. Exiting";
-        QApplication::quit();
-    }
-}
+#include "filetransfer-handler.moc"
diff --git a/src/filetransfer-handler.h b/src/filetransfer-handler.h
index 53b710a..c11d954 100644
--- a/src/filetransfer-handler.h
+++ b/src/filetransfer-handler.h
@@ -33,7 +33,7 @@ class FileTransferHandler : public QObject, public Tp::AbstractClientHandler
     Q_DISABLE_COPY(FileTransferHandler);
 
 public:
-    explicit FileTransferHandler(bool persist, QObject* parent = 0);
+    explicit FileTransferHandler(QObject* parent = 0);
     virtual ~FileTransferHandler();
 
     virtual bool bypassApproval() const;
@@ -45,16 +45,9 @@ public:
                         const QDateTime &userActionTime,
                         const Tp::AbstractClientHandler::HandlerInfo &handlerInfo);
 
-public Q_SLOTS:
-    void onTimeout();
-
 private Q_SLOTS:
     void onInfoMessage(KJob* job, const QString &plain, const QString &rich);
     void handleResult(KJob* job);
-
-private:
-    bool m_persist;
-    QAtomicInt m_jobCount;
 };
 
 #endif // TELEPATHY_KDE_FILETRANSFER_HANDLER_H
diff --git a/src/main.cpp b/src/main.cpp
index eca8e2f..cc9a998 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -15,16 +15,16 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "telepathy-handler-application.h"
 #include "filetransfer-handler.h"
 
-#include <TelepathyQt4/Debug>
-
 #include <KAboutData>
 #include <KCmdLineArgs>
-#include <KApplication>
 #include <KDebug>
 #include <TelepathyQt4/ClientRegistrar>
 #include <TelepathyQt4/FileTransferChannel>
+#include <TelepathyQt4/Debug>
+
 
 int main(int argc, char* argv[])
 {
@@ -35,21 +35,8 @@ int main(int argc, char* argv[])
     aboutData.addAuthor(ki18n("Daniele E. Domenichelli"), ki18n("Developer"), "daniele.domenichelli at gmail.com");
     aboutData.setProductName("telepathy/filetransfer");
 
-    // Add --debug as and --persist commandline options
-    KCmdLineOptions options;
-    options.add("debug", ki18n("Show Telepathy debugging information"));
-    options.add("persist", ki18n("Persistent mode (does not exit on timeout)"));
-    KCmdLineArgs::addCmdLineOptions(options);
-
     KCmdLineArgs::init(argc, argv, &aboutData);
-    KApplication app;
-    app.setQuitOnLastWindowClosed(false);
-
-    Tp::registerTypes();
-    //Enable telepathy-Qt4 debug
-    Tp::enableDebug(KCmdLineArgs::parsedArgs()->isSet("debug"));
-    Tp::enableWarnings(true);
-
+    KTelepathy::TelepathyHandlerApplication app;
 
     Tp::AccountFactoryPtr accountFactory = Tp::AccountFactory::create(QDBusConnection::sessionBus());
 
@@ -67,14 +54,11 @@ int main(int argc, char* argv[])
                                                                    channelFactory,
                                                                    contactFactory);
 
-    Tp::SharedPtr<FileTransferHandler> fth = Tp::SharedPtr<FileTransferHandler>(
-            new FileTransferHandler(KCmdLineArgs::parsedArgs()->isSet("persist"), &app));
+    Tp::SharedPtr<FileTransferHandler> fth = Tp::SharedPtr<FileTransferHandler>(new FileTransferHandler(&app));
     if(!registrar->registerClient(Tp::AbstractClientPtr(fth), QLatin1String("KDE.FileTransfer"))) {
         kDebug() << "File Transfer Handler already running. Exiting";
         return 1;
     }
 
-    QTimer::singleShot(60000, fth.data(), SLOT(onTimeout()));
-
     return app.exec();
 }

-- 
ktp-filetransfer-handler packaging



More information about the pkg-kde-commits mailing list