void	savethread::run() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "download thread starts running");
	std::list<std::pair<std::string, int> >::const_iterator	i;
	for (i = _images.begin(); i != _images.end(); i++) {
		std::string	reponame = i->first;
		int	imageid = i->second;
		if (_stopProcess) {
			debug(LOG_DEBUG, DEBUG_LOG, 0, "process abort request");
			emit downloadAborted();
			return;
		}
		QString	r(i->first.c_str());
		downloadstatus	s(r, i->second);
		emit sendStatus(s);
		// now download image
		debug(LOG_DEBUG, DEBUG_LOG, 0, "image %d from repo %s", 
			imageid, reponame.c_str());

		// get image
		snowstar::RepositoryPrx repository
			= _repositories->get(reponame);
		snowstar::ImageInfo	info = repository->getInfo(imageid);
		std::string	filename = astro::stringprintf("%s/%s",
			_directory.c_str(), info.filename.c_str());
		snowstar::ImageFile	image = repository->getImage(imageid);
		astro::image::ImagePtr	imageptr = snowstar::convertfile(image);

		// get the file name from the image
	
                debug(LOG_DEBUG, DEBUG_LOG, 0, "filename: %s",
			filename.c_str());

		// write image
                astro::io::FITSout      out(filename);
                if (out.exists()) {
                        out.unlink();
                }
                try {
                        out.write(imageptr);
                } catch (astro::io::FITSexception& x) {
			_errormsg = astro::stringprintf("cannot write image "
				"%d to %s: %s", imageid, filename.c_str(),
				x.what());
			emit downloadAborted();
			return;
		}
	}
	debug(LOG_DEBUG, DEBUG_LOG, 0, "download complete");
	emit downloadComplete();
}
Example #2
0
void GCF::IconCache::fetchIcon2(const QUrl& url)
{
    if(!url.isValid())
        return;

    d->mutex.lock();
    if(d->fetchingList.contains(url))
    {
        d->mutex.unlock();
        return;
    }
    d->fetchingList.append(url);
    d->mutex.unlock();

    GCF::AbstractFileDownloader* downloader = 0;
    downloader = GCF::AbstractFileDownloader::createDownloader( url.scheme() );
    if( !downloader )
        return; // cant help it.

    connect(downloader, SIGNAL(downloadCompleted()), this, SLOT(iconDownloaded()));
    connect(downloader, SIGNAL(downloadAborted(QString)), this, SLOT(iconDownloadAborted()));
    downloader->setAutoRemoveDownloadedFile(true);
    downloader->setUrl(url);

    GCF_UPDATER_LOG( QString("Fetching icon %1..").arg(url.toString()) );
    downloader->download();
}
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    downloader(this),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    curstep = 0;
    totalSteps = 0;
    tempDir = AppPathManager::userAppDir() + "/PGE Content Manager";
    ui->cpack_info_box->setEnabled(false);
    connect(&downloader, SIGNAL(finished()), this, SLOT(downloadSuccess()));
    connect(&downloader, SIGNAL(canceled()), this, SLOT(downloadAborted()));
    connect(&downloader, SIGNAL(failed(QString)), this, SLOT(downloadFailed(QString)));
    connect(&downloader, SIGNAL(progress(qint64, qint64)), this, SLOT(setProgress(qint64, qint64)));
    ui->progressBar->hide();

    cancelStatusBarButton = new QToolButton(ui->statusBar);
    cancelStatusBarButton->setText("x");
    cancelStatusBarButton->setToolTip("Cancel current action.");

    statusBar()->addPermanentWidget(cancelStatusBarButton);

    cancelStatusBarButton->hide();

    connect(cancelStatusBarButton, &QToolButton::clicked, this, &MainWindow::cancelStatusBarButtonClicked);

    if(MainWindow::autoRefresh)
    {
        refreshRepos();
    }

    ui->actionAuto_Refresh_on_Startup->setChecked(MainWindow::autoRefresh);
}