[telepathy-qt4/master] file-transfer receiver example: Added command-line option to test offset support.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Tue Sep 22 20:48:25 PDT 2009


---
 examples/file-transfer/receiver-channel.cpp |    7 ++++---
 examples/file-transfer/receiver-channel.h   |    4 +++-
 examples/file-transfer/receiver.cpp         |   13 ++++++++-----
 examples/file-transfer/receiver.h           |    4 +++-
 4 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/examples/file-transfer/receiver-channel.cpp b/examples/file-transfer/receiver-channel.cpp
index 6564ff1..a067fe6 100644
--- a/examples/file-transfer/receiver-channel.cpp
+++ b/examples/file-transfer/receiver-channel.cpp
@@ -34,8 +34,9 @@
 #include <QFileInfo>
 
 ReceiverChannel::ReceiverChannel(const ConnectionPtr &connection, const QString &objectPath,
-        const QVariantMap &immutableProperties)
-    : mCompleted(false)
+        const QVariantMap &immutableProperties, qulonglong offset)
+    : mCompleted(false),
+      mOffset(offset)
 {
     mChan = IncomingFileTransferChannel::create(connection,
             objectPath, immutableProperties);
@@ -72,7 +73,7 @@ void ReceiverChannel::onFileTransferChannelReady(PendingOperation *op)
     fileName.replace("/", "_");
     mFile.setFileName(fileName);
     qDebug() << "Saving file as" << mFile.fileName();
-    mChan->acceptFile(0, &mFile);
+    mChan->acceptFile(mOffset, &mFile);
 }
 
 void ReceiverChannel::onFileTransferChannelStateChanged(Tp::FileTransferState state,
diff --git a/examples/file-transfer/receiver-channel.h b/examples/file-transfer/receiver-channel.h
index b5a5b3f..a8f2723 100644
--- a/examples/file-transfer/receiver-channel.h
+++ b/examples/file-transfer/receiver-channel.h
@@ -38,7 +38,8 @@ class ReceiverChannel : public QObject
 
 public:
    ReceiverChannel(const ConnectionPtr &connection,
-           const QString &objectPath, const QVariantMap &immutableProperties);
+           const QString &objectPath, const QVariantMap &immutableProperties,
+           qulonglong offset);
    ~ReceiverChannel();
 
 Q_SIGNALS:
@@ -55,6 +56,7 @@ private:
     IncomingFileTransferChannelPtr mChan;
     QFile mFile;
     bool mCompleted;
+    qulonglong mOffset;
 };
 
 #endif
diff --git a/examples/file-transfer/receiver.cpp b/examples/file-transfer/receiver.cpp
index cd75d80..cd8fc93 100644
--- a/examples/file-transfer/receiver.cpp
+++ b/examples/file-transfer/receiver.cpp
@@ -36,9 +36,11 @@
 
 #include <QDebug>
 
-Receiver::Receiver(const QString &username, const QString &password)
+Receiver::Receiver(const QString &username, const QString &password,
+        qulonglong offset)
     : mUsername(username),
-      mPassword(password)
+      mPassword(password),
+      mOffset(offset)
 {
     mCM = ConnectionManager::create("gabble");
     connect(mCM->becomeReady(),
@@ -119,7 +121,8 @@ void Receiver::onNewChannels(const Tp::ChannelDetailsList &channels)
             !requested) {
             ReceiverChannel *channel = new ReceiverChannel(mConn,
                     details.channel.path(),
-                    details.properties);
+                    details.properties,
+                    mOffset);
             connect(channel,
                     SIGNAL(finished()),
                     channel,
@@ -138,14 +141,14 @@ int main(int argc, char **argv)
     QCoreApplication app(argc, argv);
 
     if (argc < 3) {
-        qDebug() << "usage: receiver username password";
+        qDebug() << "usage: receiver username password offset";
         return 1;
     }
 
     Tp::registerTypes();
     Tp::enableDebug(true);
 
-    new Receiver(argv[1], argv[2]);
+    new Receiver(argv[1], argv[2], QString(argv[3]).toULongLong());
 
     return app.exec();
 }
diff --git a/examples/file-transfer/receiver.h b/examples/file-transfer/receiver.h
index b3fc680..1ccc309 100644
--- a/examples/file-transfer/receiver.h
+++ b/examples/file-transfer/receiver.h
@@ -38,7 +38,8 @@ class Receiver : public QObject
     Q_OBJECT
 
 public:
-   Receiver(const QString &username, const QString &password);
+   Receiver(const QString &username, const QString &password,
+           qulonglong offset);
    ~Receiver();
 
 private Q_SLOTS:
@@ -51,6 +52,7 @@ private Q_SLOTS:
 private:
     QString mUsername;
     QString mPassword;
+    qulonglong mOffset;
 
     ConnectionManagerPtr mCM;
     ConnectionPtr mConn;
-- 
1.5.6.5




More information about the telepathy-commits mailing list