~mzanetti/+junk/ubtd

« back to all changes in this revision

Viewing changes to app/transfer.cpp

  • Committer: Michael Zanetti
  • Date: 2016-08-21 10:28:36 UTC
  • Revision ID: michael.zanetti@canonical.com-20160821102836-mam1manqthov2um9
improve!

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#include <QFile>
6
6
#include <QStandardPaths>
7
7
#include <QDBusReply>
 
8
#include <QFileInfo>
8
9
 
9
10
Transfer::Transfer(const QString &path, const QString &filePath, QObject *parent) :
10
11
    QObject(parent),
15
16
    m_status(Status::StatusQueued)
16
17
{
17
18
 
18
 
    m_iface = new QDBusInterface("org.bluez.obex", path, "org.bluez.obex.Transfer", QDBusConnection::sessionBus(), this);
19
 
 
20
 
    qDebug() << "name" << fetchProperty("Name");
21
 
 
22
 
    m_filename = fetchProperty("Name").toString();
23
 
    m_total = fetchProperty("Size").toULongLong();
24
 
    m_status = statusStringToStatus(fetchProperty("Status").toString());
25
 
    m_transferred = fetchProperty("Transferred").toULongLong();
26
 
    qDebug() << "filename" << m_filename;
27
 
 
28
 
    qDebug() << "connected signal" << QDBusConnection::sessionBus().connect("org.bluez.obex", path, "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertiesChanged(QString, QVariantMap, QStringList)));
 
19
    if (path == "/completed") {
 
20
        QFileInfo fi(filePath);
 
21
        m_filePath = fi.absolutePath();
 
22
        m_filename = fi.fileName();
 
23
        m_status = StatusComplete;
 
24
 
 
25
    } else {
 
26
 
 
27
        m_iface = new QDBusInterface("org.bluez.obex", path, "org.bluez.obex.Transfer", QDBusConnection::sessionBus(), this);
 
28
 
 
29
        qDebug() << "name" << fetchProperty("Name");
 
30
 
 
31
        m_filename = fetchProperty("Name").toString();
 
32
        m_total = fetchProperty("Size").toULongLong();
 
33
        m_status = statusStringToStatus(fetchProperty("Status").toString());
 
34
        m_transferred = fetchProperty("Transferred").toULongLong();
 
35
        qDebug() << "filename" << m_filename;
 
36
 
 
37
        qDebug() << "connected signal" << QDBusConnection::sessionBus().connect("org.bluez.obex", path, "org.freedesktop.DBus.Properties", "PropertiesChanged", "sa{sv}as", this, SLOT(propertiesChanged(QString, QVariantMap, QStringList)));
 
38
    }
29
39
 
30
40
}
31
41