示例#1
0
void Download::com(){
    if(abortted){
        qDebug()<<"cancelled - DOWNLOAD::COM";
        if(file){
            file->close();
            file->remove();
            delete file;
            file = 0;
        }
        reply->deleteLater();
        reply = 0;
        emit progress(0);
        kOn = READY;
        emit satatechan(kOn);
        qDebug()<<"iki";
        return;
    }
    file->flush();
    file->close();
    if(reply->error()){
        qDebug()<<"ERROR - COM ; "<<reply->error();
        file->remove();
        emit error();
        emit cda();
    }
    reply->deleteLater();
    reply = 0;
    delete file;
    file = 0;
    kOn = READY;
    emit satatechan(kOn);
    emit downComp();
}
示例#2
0
int Download::down(const QString &url, const QString &name){
    qDebug()<<"down( : "<<url;
    qDebug()<<"down ( : "<<name;
    QString filename = name;
    if(man->networkAccessible() != QNetworkAccessManager::Accessible)
    {
        delete man;
        man = new QNetworkAccessManager(this);
    }
    abortted = false;
    file = new QFile(filename);
    if(!file->open(QIODevice::WriteOnly)){
        kOn = READY;
        emit satatechan(kOn);
        delete file;
        file = NULL;
        return;
    }
    QNetworkRequest req(url);
    reply = man->get(req);
    if(reply)
    {
        connect(reply,SIGNAL(finished()),this,SLOT(com()));
        connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(data(qint64,qint64)));
        connect(reply,SIGNAL(readyRead()),this,SLOT(ready()));
        kOn = DOWNLOADNG;
        emit satatechan(kOn);
    }
    else
    {
        delete file;
        file = NULL;
        emit progress(0);
        kOn = READY;
        emit satatechan(kOn);
    }
    return 0;
}
示例#3
0
int Download::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: progress((*reinterpret_cast< int(*)>(_a[1]))); break;
        case 1: satatechan((*reinterpret_cast< State(*)>(_a[1]))); break;
        case 2: cda(); break;
        case 3: downComp(); break;
        case 4: com(); break;
        case 5: ready(); break;
        case 6: data((*reinterpret_cast< qint64(*)>(_a[1])),(*reinterpret_cast< qint64(*)>(_a[2]))); break;
        case 7: { int _r = cancelDownload();
            if (_a[0]) *reinterpret_cast< int*>(_a[0]) = _r; }  break;
        default: ;
        }
        _id -= 8;
    }
    return _id;
}