examples/network/torrent/torrentclient.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
   223 
   223 
   224 TorrentClient::TorrentClient(QObject *parent)
   224 TorrentClient::TorrentClient(QObject *parent)
   225     : QObject(parent), d(new TorrentClientPrivate(this))
   225     : QObject(parent), d(new TorrentClientPrivate(this))
   226 {
   226 {
   227     // Connect the file manager
   227     // Connect the file manager
   228     connect(&d->fileManager, SIGNAL(dataRead(int, int, int, const QByteArray &)),
   228     connect(&d->fileManager, SIGNAL(dataRead(int,int,int,QByteArray)),
   229             this, SLOT(sendToPeer(int, int, int, const QByteArray &)));
   229             this, SLOT(sendToPeer(int,int,int,QByteArray)));
   230     connect(&d->fileManager, SIGNAL(verificationProgress(int)),
   230     connect(&d->fileManager, SIGNAL(verificationProgress(int)),
   231             this, SLOT(updateProgress(int)));
   231             this, SLOT(updateProgress(int)));
   232     connect(&d->fileManager, SIGNAL(verificationDone()),
   232     connect(&d->fileManager, SIGNAL(verificationDone()),
   233             this, SLOT(fullVerificationDone()));
   233             this, SLOT(fullVerificationDone()));
   234     connect(&d->fileManager, SIGNAL(pieceVerified(int, bool)),
   234     connect(&d->fileManager, SIGNAL(pieceVerified(int,bool)),
   235             this, SLOT(pieceVerified(int, bool)));
   235             this, SLOT(pieceVerified(int,bool)));
   236     connect(&d->fileManager, SIGNAL(error()),
   236     connect(&d->fileManager, SIGNAL(error()),
   237             this, SLOT(handleFileError()));
   237             this, SLOT(handleFileError()));
   238 
   238 
   239     // Connect the tracker client
   239     // Connect the tracker client
   240     connect(&d->trackerClient, SIGNAL(peerListUpdated(const QList<TorrentPeer> &)),
   240     connect(&d->trackerClient, SIGNAL(peerListUpdated(QList<TorrentPeer>)),
   241             this, SLOT(addToPeerList(const QList<TorrentPeer> &)));
   241             this, SLOT(addToPeerList(QList<TorrentPeer>)));
   242     connect(&d->trackerClient, SIGNAL(stopped()),
   242     connect(&d->trackerClient, SIGNAL(stopped()),
   243             this, SIGNAL(stopped()));
   243             this, SIGNAL(stopped()));
   244 }
   244 }
   245 
   245 
   246 TorrentClient::~TorrentClient()
   246 TorrentClient::~TorrentClient()
   834             this, SLOT(setupOutgoingConnection()));
   834             this, SLOT(setupOutgoingConnection()));
   835     connect(client, SIGNAL(disconnected()),
   835     connect(client, SIGNAL(disconnected()),
   836             this, SLOT(removeClient()));
   836             this, SLOT(removeClient()));
   837     connect(client, SIGNAL(error(QAbstractSocket::SocketError)),
   837     connect(client, SIGNAL(error(QAbstractSocket::SocketError)),
   838             this, SLOT(removeClient()));
   838             this, SLOT(removeClient()));
   839     connect(client, SIGNAL(piecesAvailable(const QBitArray &)),
   839     connect(client, SIGNAL(piecesAvailable(QBitArray)),
   840             this, SLOT(peerPiecesAvailable(const QBitArray &)));
   840             this, SLOT(peerPiecesAvailable(QBitArray)));
   841     connect(client, SIGNAL(blockRequested(int, int, int)),
   841     connect(client, SIGNAL(blockRequested(int,int,int)),
   842             this, SLOT(peerRequestsBlock(int, int, int)));
   842             this, SLOT(peerRequestsBlock(int,int,int)));
   843     connect(client, SIGNAL(blockReceived(int, int, const QByteArray &)),
   843     connect(client, SIGNAL(blockReceived(int,int,QByteArray)),
   844             this, SLOT(blockReceived(int, int, const QByteArray &)));
   844             this, SLOT(blockReceived(int,int,QByteArray)));
   845     connect(client, SIGNAL(choked()),
   845     connect(client, SIGNAL(choked()),
   846             this, SLOT(peerChoked()));
   846             this, SLOT(peerChoked()));
   847     connect(client, SIGNAL(unchoked()),
   847     connect(client, SIGNAL(unchoked()),
   848             this, SLOT(peerUnchoked()));
   848             this, SLOT(peerUnchoked()));
   849     connect(client, SIGNAL(bytesWritten(qint64)),
   849     connect(client, SIGNAL(bytesWritten(qint64)),