[SCM] ktp-send-file packaging branch, master, updated. debian/15.12.1-2-216-g8f07cdf

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


Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-send-file.git;a=commitdiff;h=d8c85ef

The following commit has been merged in the master branch:
commit d8c85ef3ca3b6abd386d4f1a0b1e66de5c066f2a
Author: Francesco Nwokeka <francesco.nwokeka at gmail.com>
Date:   Fri Jun 10 03:16:14 2011 +0200

    ADD: initiate file tranfer with contact selected from list
---
 mainwindow.cpp | 67 +++++++++++++++++++++++++++++++++++++++++++++++++---------
 mainwindow.h   |  4 ++++
 2 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/mainwindow.cpp b/mainwindow.cpp
index e10a0be..ffcfea9 100644
--- a/mainwindow.cpp
+++ b/mainwindow.cpp
@@ -10,29 +10,26 @@
 
 
 #include <TelepathyQt4/AccountManager>
+#include <TelepathyQt4/PendingChannelRequest>
 #include <TelepathyQt4/PendingReady>
 
 
 #include "accounts-model.h"
 #include "flat-model-proxy.h"
 #include "account-filter-model.h"
+#include "contact-model-item.h"
 
+#define PREFERRED_FILETRANSFER_HANDLER "org.freedesktop.Telepathy.Client.KDE.FileTransfer"
 
 MainWindow::MainWindow(QWidget *parent) :
     QWidget(parent),
-    ui(new Ui::MainWindow)
+    ui(new Ui::MainWindow),
+    m_accountsModel(0)
 {
     Tp::registerTypes();
 
     ui->setupUi(this);
 
-//     KFileItem file(KUrl("/home/david/a.png"), "image/png", KFileItem::Unknown);
-//
-//     KIO::PreviewJob* job = KIO::filePreview(KFileItemList() << file, ui->filePreviewLabel->width(), ui->filePreviewLabel->height());
-//
-//     ui->fileNameLabel->setText(file.name());
-//     ui->filePreviewLabel->setText(QString());
-
     qDebug() << KApplication::arguments();
 
 
@@ -68,6 +65,9 @@ MainWindow::MainWindow(QWidget *parent) :
 
 
     connect(m_accountManager->becomeReady(), SIGNAL(finished(Tp::PendingOperation*)), SLOT(onAccountManagerReady()));
+
+    connect(ui->buttonBox, SIGNAL(accepted()), SLOT(onDialogAccepted()));
+    connect(ui->buttonBox, SIGNAL(rejected()), SLOT(close()));
 }
 
 MainWindow::~MainWindow()
@@ -77,11 +77,58 @@ MainWindow::~MainWindow()
 
 void MainWindow::onAccountManagerReady()
 {
-    AccountsModel *model = new AccountsModel(m_accountManager, this);
+    m_accountsModel = new AccountsModel(m_accountManager, this);
     AccountFilterModel *filterModel = new AccountFilterModel(this);
-    filterModel->setSourceModel(model);
+    filterModel->setSourceModel(m_accountsModel);
     filterModel->filterOfflineUsers(true);
     FlatModelProxy *flatProxyModel = new FlatModelProxy(filterModel);
 
     ui->listView->setModel(flatProxyModel);
 }
+
+void MainWindow::onDialogAccepted()
+{
+    // don't do anytghing if no contact has been selected
+    if (!ui->listView->currentIndex().isValid()) {
+        // show message box?
+        return;
+    }
+
+    ContactModelItem *contactModelItem = ui->listView->currentIndex().data(AccountsModel::ItemRole).value<ContactModelItem*>();
+    Tp::ContactPtr contact = contactModelItem->contact();
+    Tp::AccountPtr sendingAccount = m_accountsModel->accountForContactItem(contactModelItem);
+
+    if (sendingAccount.isNull()) {
+        qDebug("sending account: NULL");
+    } else {
+        qDebug() << "Account is: " << sendingAccount->displayName();
+        qDebug() << "sending to: " << contact->alias();
+    }
+
+    // start sending file
+    QString filePath (KCmdLineArgs::parsedArgs()->arg(0));
+    qDebug() << "FILE TO SEND: " << filePath;
+
+    Tp::FileTransferChannelCreationProperties fileTransferProperties(filePath, KMimeType::findByFileContent(filePath)->name());
+
+    Tp::PendingChannelRequest* channelRequest = sendingAccount->createFileTransfer(contact,
+                                                                                   fileTransferProperties,
+                                                                                   QDateTime::currentDateTime(),
+                                                                                   PREFERRED_FILETRANSFER_HANDLER);
+
+    connect(channelRequest, SIGNAL(finished(Tp::PendingOperation*)), SLOT(slotFileTransferFinished(Tp::PendingOperation*)));
+}
+
+void MainWindow::slotFileTransferFinished(Tp::PendingOperation* op)
+{
+    if (op->isError()) {
+        QString errorMsg(op->errorName() + ": " + op->errorMessage());
+        qDebug() << "ERROR!: " << errorMsg;
+    } else {
+        qDebug("FUCK YEAH TRANSFER STARTED");
+        // now I can close the dialog
+        close();
+    }
+}
+
+
diff --git a/mainwindow.h b/mainwindow.h
index 2bd1f82..92c1acd 100644
--- a/mainwindow.h
+++ b/mainwindow.h
@@ -10,6 +10,7 @@ namespace Ui {
     class MainWindow;
 }
 
+class AccountsModel;
 class KFileItem;
 
 class MainWindow : public QWidget
@@ -22,10 +23,13 @@ public:
 
 private slots:
     void onAccountManagerReady();
+    void onDialogAccepted();
 
+    void slotFileTransferFinished(Tp::PendingOperation *op);
 
 private:
     Ui::MainWindow *ui;
+    AccountsModel *m_accountsModel;
     Tp::AccountManagerPtr m_accountManager;
 };
 

-- 
ktp-send-file packaging



More information about the pkg-kde-commits mailing list