Ejemplo n.º 1
0
void MainWindow::on_actionLincese_triggered()
{
    LicenseDialog licenseDialog;

    licenseDialog.setModal(true);
    licenseDialog.exec();
}
Ejemplo n.º 2
0
int main(int argc, char *argv[])
{
	QApplication a(argc, argv);

#ifdef __WINDOWS__
	// Start up Winsock2
	{
		WSADATA wsaData;
		WSAStartup(MAKEWORD(2,2),&wsaData);
	}
#endif

	{
		QFile qss(":css/stylesheet.css");
		qss.open(QFile::ReadOnly);
		QString style(qss.readAll());
		a.setStyleSheet(style);
	}

#ifdef __APPLE__
	// If service isn't installed, download and install it
	if (!QFile::exists("/Library/Application Support/ZeroTier/One/zerotier-one")) {
		// InstallDialog is an alternative main window. It will re-launch the app
		// when done.
		InstallDialog id;
		id.setStyleSheet(a.styleSheet());
		id.show();
		return a.exec();
	}

	{
		// Put QSettings here because this is one of the writable directories allowed
		// in Apple's app store sandbox specs. We might end up in app store someday.
		QString zt1AppSupport(QDir::homePath() + "/Library/Application Support/ZeroTier/One");
		QDir::root().mkpath(zt1AppSupport);
		settings = new QSettings(zt1AppSupport + "/ui.ini",QSettings::IniFormat);
	}
#else // on non-Apple boxen put it in the standard place using the default format
	settings = new QSettings("ZeroTier Networks","ZeroTier One");
#endif

	if (!settings->value("acceptedLicenseV1",false).toBool()) {
		LicenseDialog ld;
		ld.setStyleSheet(a.styleSheet());
		ld.exec();
	}

#if defined(__WINDOWS__) && !defined(DISABLE_WINDOWS_SERVICE_MANAGEMENT)
	{
		bool winSvcInstalled = false;
		while (!startWindowsService()) {
			if (winSvcInstalled) {
				// Service was installed and subsequently failed to start again, so
				// something is wrong!
				QMessageBox::critical((QWidget *)0,"Service Not Available","Unable to locate or start ZeroTier One service. There may be a problem with the installation. Try installing from the .msi file again or e-mail [email protected] if you cannot install. (Error: service failed to start)",QMessageBox::Ok);
				return 1;
			}

#ifdef _WIN64
			BOOL is64Bit = TRUE;
#else
			BOOL is64Bit = FALSE;
			IsWow64Process(GetCurrentProcess(),&is64Bit);
#endif
			std::string exe(ZeroTier::ZT_DEFAULTS.defaultHomePath + "\\zerotier-one_");
			exe.append((is64Bit == TRUE) ? "x64.exe" : "x86.exe");

			if (QFile::exists(exe.c_str())) {
				STARTUPINFOA si;
				PROCESS_INFORMATION pi;
				memset(&si,0,sizeof(si));
				memset(&pi,0,sizeof(pi));
				if (CreateProcessA(NULL,const_cast <LPSTR>((exe + " -I").c_str()),NULL,NULL,FALSE,CREATE_NO_WINDOW|CREATE_NEW_PROCESS_GROUP,NULL,NULL,&si,&pi)) {
					WaitForSingleObject(pi.hProcess,INFINITE);
					CloseHandle(pi.hProcess);
					CloseHandle(pi.hThread);
					winSvcInstalled = true;
				}
			}

			if (!winSvcInstalled) {
				// Service failed to install -- installation problem like missing .exe
				QMessageBox::critical((QWidget *)0,"Service Not Available","Unable to locate or start ZeroTier One service. There may be a problem with the installation. Try installing from the .msi file again or e-mail [email protected] if you cannot install. (Error: service not installed)",QMessageBox::Ok);
				return 1;
			}
		}
	}
#endif

	MainWindow w;
	w.show();
	return a.exec();
}
void MainWindow::on_actionLicense_triggered()
{
    LicenseDialog *licenseDialog = new LicenseDialog;
    licenseDialog->exec();
    licenseDialog->deleteLater();
}