Example #1
0
void SmugWindow::slotListPhotosDone(int errCode, const QString &errMsg,
                                    const QList <SmugPhoto>& photosList)
{
    if (errCode != 0)
    {
        QMessageBox::critical(QApplication::activeWindow(), i18n("Error"), i18n("SmugMug Call Failed: %1\n", errMsg));
        return;
    }

    m_transferQueue.clear();

    for (int i = 0; i < photosList.size(); ++i)
    {
        m_transferQueue.push_back(QUrl::fromLocalFile(photosList.at(i).originalURL));
    }

    if (m_transferQueue.isEmpty())
        return;

    m_imagesTotal = m_transferQueue.count();
    m_imagesCount = 0;

    m_widget->progressBar()->setMaximum(m_imagesTotal);
    m_widget->progressBar()->setValue(0);

    // start download with first photo in queue
    downloadNextPhoto();
}
Example #2
0
void SmugWindow::slotGetPhotoDone(int errCode, const QString& errMsg,
                                  const QByteArray& photoData)
{
    QString imgPath = m_widget->getDestinationPath() + QLatin1Char('/')
                      + m_transferQueue.first().fileName();

    if (errCode == 0)
    {
        QString errText;
        QFile imgFile(imgPath);

        if (!imgFile.open(QIODevice::WriteOnly))
        {
            errText = imgFile.errorString();
        }
        else if (imgFile.write(photoData) != photoData.size())
        {
            errText = imgFile.errorString();
        }
        else
        {
            imgFile.close();
        }

        if (errText.isEmpty())
        {
            m_transferQueue.pop_front();
            m_imagesCount++;
        }
        else
        {
            if (QMessageBox::question(this, i18n("Processing Failed"),
                                      i18n("Failed to save photo: %1\n"
                                           "Do you want to continue?", errText))
                != QMessageBox::Yes)
            {
                m_transferQueue.clear();
                setUiInProgressState(false);
                return;
            }
        }
    }
    else
    {
        if (QMessageBox::question(this, i18n("Processing Failed"),
                                  i18n("Failed to download photo: %1\n"
                                       "Do you want to continue?", errMsg))
                != QMessageBox::Yes)
        {
            m_transferQueue.clear();
            setUiInProgressState(false);
            return;
        }
    }

    downloadNextPhoto();
}
Example #3
0
void CopyPhotosDialog::downloadFinished()
{
    //plog(tr("Done..."));
    VKAlbumPhoto photo = photos.at(currentPhoto);
    QFile photoFile(photo.cacheFileName);
    if (!photoFile.open(QIODevice::WriteOnly))
        return;
    photoFile.write(currentReply->readAll());
    photoFile.close();
    currentPhoto++;
    downloadNextPhoto();
}
Example #4
0
void CopyPhotosDialog::receivedPhotos_get(VKRequest *req)
{
    if((req->reqType!=VKRequest::Photos_get) ||
            (reqPhotosGet != req->reqId)){
        return;
    }
    reqPhotosGet = -1;
    plog(tr("Get source album photos description"));

    photos.clear();

    QDomDocument doc("Photos");
    doc.setContent(req->result);
    QDomElement docElem = doc.documentElement();
    QDomNodeList users = docElem.elementsByTagName ( "photo" );
    for(int i=0; i < users.count(); i++){
        QDomElement userElem = users.at(i).toElement();

        VKAlbumPhoto photo;

        photo.pid = userElem.elementsByTagName("pid").at(0).toElement().text();
        photo.aid = userElem.elementsByTagName("aid").at(0).toElement().text();
        photo.owner_id = userElem.elementsByTagName("owner_id").at(0).toElement().text();
        photo.src = userElem.elementsByTagName("src").at(0).toElement().text();
        photo.src_big = userElem.elementsByTagName("src_big").at(0).toElement().text();
        photo.src_small = userElem.elementsByTagName("src_small").at(0).toElement().text();
        photo.text = userElem.elementsByTagName("text").at(0).toElement().text();
        photo.src_xbig = userElem.elementsByTagName("src_xbig").at(0).toElement().text();
        photo.src_xxbig = userElem.elementsByTagName("src_xxbig").at(0).toElement().text();
        photo.cacheFileName = albumDir + photo.src_big.right(photo.src_big.length() - (photo.src_big.lastIndexOf("/")));
        qDebug() << photo.cacheFileName;

        photos.append( photo );
    }
    currentPhoto = 0;

    plog(tr("Finded %1 photos").arg(photos.count()));
    plog(tr("Caching all photos to local filesystem"));

    QDir cacheDir(albumDir);
    if (!cacheDir.exists(cacheDir.path())){
        cacheDir.mkpath(cacheDir.path());
    }
    downloadNextPhoto();
}
void PicasawebWindow::slotListPhotosDoneForDownload(int errCode, const QString &errMsg,
                                                    const QList <PicasaWebPhoto>& photosList)
{
    disconnect(m_talker, SIGNAL(signalListPhotosDone(int,QString,QList<PicasaWebPhoto>)),
               this, SLOT(slotListPhotosDoneForDownload(int,QString,QList<PicasaWebPhoto>)));

    if (errCode != 0)
    {
        KMessageBox::error(this, i18n("Picasaweb Call Failed: %1\n", errMsg));
        return;
    }

    typedef QPair<KUrl,PicasaWebPhoto> Pair;
    m_transferQueue.clear();
    QList<PicasaWebPhoto>::const_iterator itPWP;
    for (itPWP = photosList.begin(); itPWP != photosList.end(); ++itPWP)
    {
        m_transferQueue.push_back(Pair((*itPWP).originalURL, (*itPWP)));
    }

    if (m_transferQueue.isEmpty())
        return;

    m_currentAlbumID = m_widget->m_albumsCoB->itemData(
                                 m_widget->m_albumsCoB->currentIndex()).toString();
    m_imagesTotal = m_transferQueue.count();
    m_imagesCount = 0;

    m_widget->progressBar()->setFormat(i18n("%v / %m"));
    m_widget->progressBar()->show();

    m_renamingOpt = 0;

    // start download with first photo in queue
    downloadNextPhoto();
}
Example #6
0
void CopyPhotosDialog::downloadError()
{
    currentPhoto++;
    downloadNextPhoto();
}