示例#1
0
//---------------------------------------------------------------------- 
void aucDialog::connect_slots(void) {
  connect(mp_ui->browseButton, SIGNAL(clicked()), this, SLOT(select_file()));
  connect(mp_ui->installerMenu,  SIGNAL(currentIndexChanged(int)), this, SLOT(set_installer_pict()));
  connect(mp_ui->installerMenu,  SIGNAL(currentIndexChanged(int)), this, SLOT(set_installer_options()));
  connect(mp_ui->installMenu_2,  SIGNAL(currentIndexChanged(int)), this, SLOT(update_options2()));
  connect(mp_ui->installMenu_3,  SIGNAL(currentIndexChanged(int)), this, SLOT(update_options3()));
  connect(mp_ui->installCheckbox,  SIGNAL(stateChanged(int)), this, SLOT(update_options3_fromcheckbox()));
  connect(mp_ui->deviceRefreshButton, SIGNAL(clicked()), this, SLOT(populate_devices()));
  connect(mp_ui->startButton,  SIGNAL(clicked()), this, SLOT(build_installer()));
  connect(&m_thread,  SIGNAL(status(QString)), this, SLOT(status(QString)));
  connect(&m_thread,  SIGNAL(finished()), this, SLOT(enable_widgets()));
  connect(&m_thread,  SIGNAL(terminated()), this, SLOT(enable_widgets()));
  connect(&m_thread,  SIGNAL(progress(int)), this, SLOT(progress(int)));
  connect(&m_thread,  SIGNAL(maxprogress(int)), this, SLOT(maxprogress(int)));
  connect(mp_creator,  SIGNAL(status(QString)), this, SLOT(status(QString)));
  connect(mp_creator,  SIGNAL(progress(int)), this, SLOT(progress(int)));
  connect(mp_creator,  SIGNAL(maxprogress(int)), this, SLOT(maxprogress(int)));
  connect(&m_progress_thread, SIGNAL(progress(int)), this, SLOT(progress(int)));
  connect(&m_progress_thread, SIGNAL(maxprogress(int)), this, SLOT(maxprogress(int)));
  connect(&m_release_downloader, SIGNAL(progress(int)), this, SLOT(progress(int)));
  connect(&m_release_downloader, SIGNAL(maxprogress(int)), this, SLOT(maxprogress(int)));
  connect(&m_release_downloader, SIGNAL(downloadComplete(QString)), this, SLOT(download_complete(QString)));
  connect(&m_release_downloader, SIGNAL(status(QString)), this, SLOT(status(QString)));
  
}
示例#2
0
/* Checks finished transfer. */
static as_bool download_finished (ASDownload *dl)
{
	ASHash *hash;
#ifdef WIN32
	int fd;
#endif

	/* Stop all chunk downloads if there are still any */
	stop_all_connections (dl);

	/* Make sure any source search is gone */
	if (dl->search)
		as_searchman_remove (AS->searchman, dl->search);
	dl->search = NULL;

	AS_DBG_1 ("Verifying download \"%s\"", dl->filename);

	/* Do some sanity checks */
	assert (dl->chunks->next == NULL);
	assert (((ASDownChunk *)dl->chunks->data)->udata == NULL);
	assert (((ASDownChunk *)dl->chunks->data)->size == dl->size);
	assert (dl->fp != NULL);

	/* Close file pointer */
	fclose (dl->fp);
	dl->fp = NULL;

	/* raise callback */
	if (!download_set_state (dl, DOWNLOAD_VERIFYING, TRUE))
		return FALSE;

	/* Truncate incomplete file to correct size removing the state data at
	 * the end.
	 */
	assert (dl->size > 0);

#ifndef WIN32
	if (truncate (dl->path, dl->size) < 0)
#else
	if ((fd = _open (dl->path, _O_BINARY | _O_WRONLY)) < 0 ||
	    _chsize (fd, dl->size) != 0 ||
	    _close (fd) != 0)
#endif
	{
		AS_ERR_1 ("Failed to truncate complete download \"%s\"",
		          dl->path);
		/* File is probably still useful so continue. */
	}

	/* Hash file and compare hashes.
	 * TODO: Make non-blocking.
	 */
	if (!(hash = as_hash_file (dl->path)))
	{
		AS_ERR_1 ("Couldn't hash \"%s\" for verification", dl->path);
		return download_failed (dl);
	}

	if (!as_hash_equal (dl->hash, hash))
	{
		AS_ERR_1 ("Downloaded file \"%s\" corrupted!", dl->path);
		as_hash_free (hash);
		return download_failed (dl);
	}

	as_hash_free (hash);

	/* Download is OK */
	return download_complete (dl);
}