示例#1
0
int main(int argc, char* argv[])
{
	gtk_init(&argc, &argv);
	curl_global_init(CURL_GLOBAL_ALL);

	if (argc < 8)
	{
		std::cerr << "Not enough arguments given, aborting." << std::endl;
		exit(2);
	}

	std::string app_name = argv[1];
	std::string confirm_title = argv[2];
	std::string message = argv[3];
	std::string temp_dir = argv[4];
	std::string install_dir = argv[5];
	std::string unzipper = argv[6];
	int urls_start = 7;

	Installer i = Installer(app_name, confirm_title, message);

	Job::Init(temp_dir, install_dir);

	for (int u = urls_start; u < argc; u++)
		i.AddJob(argv[u]);

	i.Run();
	i.ClearJobs();

	Job::ShutdownDownloader();

}
示例#2
0
void *download_thread_f(gpointer data)
{
	Installer* inst = (Installer*) data;
	std::vector<Job*>& jobs = inst->GetJobs();
	try
	{
		for (size_t i = 0; i < jobs.size(); i++)
		{
			Job *j = jobs.at(i);
			inst->SetCurrentJob(j);
			j->Fetch();
		}
	}
	catch (std::exception& e)
	{
		std::string message = e.what();
		inst->SetError(message);
		inst->SetRunning(false);
	}
	catch (std::string& e)
	{
		inst->SetError(e);
		inst->SetRunning(false);
	}
	catch (...)
	{
		std::string message = "Unknown error";
		inst->SetError(message);
		inst->SetRunning(false);
	}

	inst->DownloadDone();
	return NULL;
}
示例#3
0
文件: main.cpp 项目: biddyweb/pcbsd
int main(int argc, char *argv[])
{
    QString changeLang;

    QApplication a(argc, argv);

    // Check what directory our app is in
    QString appDir;
    if ( QFile::exists("/usr/local/bin/pc-firstboot") )
      appDir = "/usr/local/share/pcbsd";
    else
      appDir = QCoreApplication::applicationDirPath();

    QTranslator translator;
    QLocale mylocale;
    QString langCode = mylocale.name();

    if ( ! changeLang.isEmpty() )       
       langCode = changeLang;

    if ( QFile::exists(appDir + "/i18n/FirstBoot_" + langCode + ".qm" ) ) {
      translator.load( QString("FirstBoot_") + langCode, appDir + "/i18n/" );
      a.installTranslator(&translator);
      qDebug() << "Loaded Translation:" << appDir + "/i18n/FirstBoot_" + langCode + ".qm";
    } else if ( QFile::exists(appDir + "/i18n/FirstBoot_" + langCode.section("_", 0, 0) + ".qm" ) ) {
      translator.load( QString("FirstBoot_") + langCode.section("_", 0, 0), appDir + "/i18n/" );
      a.installTranslator(&translator);
      qDebug() << "Loaded Translation:" << appDir + "/i18n/FirstBoot_" + langCode.section("_", 0, 0) + ".qm";
    } else {
      qDebug() << "Could not find: " << appDir + "/i18n/FirstBoot_" + langCode + ".qm";
      langCode = "";
    }
    QTextCodec::setCodecForLocale( QTextCodec::codecForName("UTF-8") ); //Force Utf-8 compliance
    // Show our splash screen, so the user doesn't freak that that it takes a few seconds to show up
    QPixmap pixmap(":/PCBSD/images/pcbsdheader.png");
    QSplashScreen splash(pixmap);
    splash.show();


    Installer w;

    // Center the installer
    /*QRect dimensions = QApplication::desktop()->screenGeometry();
    int wid = dimensions.width();     // returns desktop width
    int hig = dimensions.height();    // returns desktop height
    QRect wizDimensions = w.geometry();
    int wizWid = wizDimensions.width(); // Wizard width
    int wizHig = wizDimensions.height(); // Wizard height
    qDebug() << "WizWid" << wizWid;
    qDebug() << "WizHig" << wizHig;
    w.setGeometry((wid/2) - (wizWid/2), (hig/2) - (wizHig/2), wizWid, wizHig);*/

    // Start the init
    w.initInstall();

    w.show();
    splash.finish(&w);
    
    return a.exec();
}
示例#4
0
void *install_thread_f(gpointer data)
{
    Installer* inst = (Installer*) data;
    std::vector<Job*>& jobs = Installer::instance->GetJobs();
    try
    {
        for (size_t i = 0; i < jobs.size(); i++)
        {
            Job *j = jobs.at(i);
            inst->SetCurrentJob(j);
            j->Unzip();

            // Wait for an unzip job to finish before actually cancelling
            if (inst->GetStage() == Installer::CANCEL_REQUEST)
            {
                inst->SetStage(Installer::CANCELLED);
                return NULL;
            }
        }
    }
    catch (std::exception& e)
    {
        std::string message = e.what();
        inst->SetError(message);
        return NULL;
    }
    catch (std::string& e)
    {
        inst->SetError(e);
        return NULL;
    }
    catch (...)
    {
        std::string message = "Unknown error";
        inst->SetError(message);
        return NULL;
    }

    inst->SetStage(Installer::SUCCESS);
    return NULL;
}
示例#5
0
static void destroy_cb(GtkWidget *widget, gpointer data)
{
	Installer* i = (Installer*) data;
	i->SetWindow(NULL);
	i->Cancel();
}
示例#6
0
static void cancel_cb(GtkWidget *widget, gpointer data)
{
	Installer* i = (Installer*) data;
	i->Cancel();
}
示例#7
0
static gboolean watcher(gpointer data)
{
	Installer *i = (Installer*) data;

	if (i->DownloadFinished() && i->IsRunning())
	{
		i->StartInstalling();
	}

	if (!i->IsRunning())
	{
		i->ShowError();
		gtk_main_quit();
	}
	else if (i->IsCancelled())
	{
		i->SetError(std::string("Package installation cancelled"));
		i->ShowError();
		gtk_main_quit();
	}
	else
	{
		i->UpdateProgress();
	}

	return i->IsRunning();
}
示例#8
0
文件: main.cpp 项目: KhuramAli/pcbsd
int main(int argc, char *argv[])
{
    QString changeLang;

    QApplication a(argc, argv);

    // Check what directory our app is in
    QString appDir;
    if ( QFile::exists("/usr/local/bin/pc-sysinstaller") )
      appDir = "/usr/local/share/pcbsd";
    else
      appDir = QCoreApplication::applicationDirPath();

    QTranslator translator;
    QLocale mylocale;
    QString langCode = mylocale.name();

    if ( ! changeLang.isEmpty() )       
       langCode = changeLang;

    if ( QFile::exists(appDir + "/i18n/SysInstaller_" + langCode + ".qm" ) ) {
      translator.load( QString("SysInstaller_") + langCode, appDir + "/i18n/" );
      a.installTranslator(&translator);
      qDebug() << "Loaded Translation:" << appDir + "/i18n/SysInstaller_" + langCode + ".qm";
    } else {
      qDebug() << "Could not find: " << appDir + "/i18n/SysInstaller_" + langCode + ".qm";
      langCode = "";
    }

    if ( argc == 2)
    {
      QString flag = argv[1];
      if ( flag == "-checkhardware" )
      {
        dialogCheckHardware d;
        QDesktopWidget *desk = a.desktop();
        QRect dimensions = desk->screenGeometry();
        int wid = dimensions.width();     // returns desktop width
        int hig = dimensions.height();    // returns desktop height
        d.setGeometry((wid/2) - (355/2), (hig/2) - (151/2), 355, 151);
        d.programInit();
        d.show();
        a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
        return a.exec();
      }
    }


    // Show our splash screen, so the user doesn't freak that that it takes a few seconds to show up
    QPixmap pixmap(":/PCBSD/images/pcbsdheader.png");
    QSplashScreen *splash = new QSplashScreen(pixmap);
    splash->show();

    Installer w;


    // Center the installer
    QRect dimensions = QApplication::desktop()->screenGeometry();
    int wid = dimensions.width();     // returns desktop width
    int hig = dimensions.height();    // returns desktop height
    w.setGeometry((wid/2) - (650/2), (hig/2) - (435/2), 650, 435);

    // Start the init
    w.initInstall(splash);

    w.show();
    splash->finish(&w);
    
    return a.exec();
}