Ejemplo n.º 1
0
void CWinMain::on_actionQuickstartWizard_triggered()
{
	CWizardQuickStart* wzrdQuickStart = new CWizardQuickStart( this );
	wzrdQuickStart->exec();
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: c3c/quazaa
int main(int argc, char *argv[])
{
#ifdef Q_OS_MAC
	// QTBUG-32789 - GUI widgets use the wrong font on OS X Mavericks
	QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande");
#endif

	SingleApplication theApp( argc, argv );

	if(!theApp.shouldContinue())return 0;

	QStringList args = theApp.arguments();

	QUrl proxy;
	int index = args.indexOf("-proxy");
	if ( index != -1 )
		proxy = QUrl( args.value(index + 1) );
	else
		proxy = QUrl( qgetenv( "http_proxy" ) );
	if ( !proxy.isEmpty() )
		setApplicationProxy( proxy );

	QByteArray encoding;
	index = args.indexOf( "-encoding" );
	if ( index != -1 )
		encoding = args.value( index + 1 ).toLocal8Bit();
	else if ( !qgetenv( "COMMUNI_ENCODING" ).isEmpty())
		encoding = qgetenv( "COMMUNI_ENCODING" );
	if ( !encoding.isEmpty() )
		SingleApplication::setEncoding( encoding );


// To enable this, run qmake with "DEFINES+=_SNAPSHOT_BUILD"
#ifdef _SNAPSHOT_BUILD
	QDate oExpire = QDate::fromString( Version::BUILD_DATE, Qt::ISODate ).addDays( 60 );

	if( QDate::currentDate() > oExpire )
	{
		QMessageBox::information( NULL,
								  QObject::tr( "Cool Software, but..." ),
								  QObject::tr( "This build is expired. If you wish to continue using this "
											   "Cool Software you must download either latest stable releas"
											   "e or latest snapshot build from http://quazaa.sf.net/.\n\n"
											   "The program will now terminate." ) );
		return 0;
	}

	if( !args.contains("--no-alpha-warning") )
	{
		int ret = QMessageBox::warning( NULL,
										QObject::tr("Snapshot/Debug Build Warning"),
										QObject::tr("WARNING: This is a SNAPSHOT BUILD of Quazaa. \n"
													"It is NOT meant for GENERAL USE, and is only for testi"
													"ng specific features in a controlled environment.\n"
													"It will frequently stop running, or will display debug"
													"information to assist testing.\n"
													"This build will expire on %1.\n\n"
													"Do you wish to continue?"
													).arg( oExpire.toString( Qt::SystemLocaleLongDate ) ),
									   QMessageBox::Yes | QMessageBox::No );
		if( ret == QMessageBox::No )
			return 0;
	}
#endif

	qsrand( time( 0 ) );

#ifdef Q_OS_LINUX

	rlimit sLimit;
	memset( &sLimit, 0, sizeof( rlimit ) );
	getrlimit( RLIMIT_NOFILE, &sLimit );

	sLimit.rlim_cur = sLimit.rlim_max;

	if( setrlimit( RLIMIT_NOFILE, &sLimit ) == 0 )
	{
		qDebug() << "Successfully raised resource limits";
	}
	else
	{
		qDebug() << "Cannot set resource limits";
	}

#endif // Q_OS_LINUX

	theApp.setApplicationName(    CQuazaaGlobals::APPLICATION_NAME() );
	theApp.setApplicationVersion( CQuazaaGlobals::APPLICATION_VERSION_STRING() );
	theApp.setOrganizationDomain( CQuazaaGlobals::APPLICATION_ORGANIZATION_DOMAIN() );
	theApp.setOrganizationName(   CQuazaaGlobals::APPLICATION_ORGANIZATION_NAME() );
	theApp.setApplicationSlogan( QObject::tr("World class file sharing.") );

	QIcon icon;
	icon.addFile( ":/Resource/Quazaa16.png" );
	icon.addFile( ":/Resource/Quazaa24.png" );
	icon.addFile( ":/Resource/Quazaa32.png" );
	icon.addFile( ":/Resource/Quazaa48.png" );
	icon.addFile( ":/Resource/Quazaa64.png" );
	icon.addFile( ":/Resource/Quazaa128.png" );
	qApp->setWindowIcon( icon );

	// Initialize system log component translations
	systemLog.start();

	// Setup Qt elements of signal queue necessary for operation
	signalQueue.setup();

	//Initialize multilanguage support
	quazaaSettings.loadLanguageSettings();
	quazaaSettings.translator.load( quazaaSettings.Language.File );
	qApp->installTranslator( &quazaaSettings.translator );

	//Create splash window
	CDialogSplash* dlgSplash = new CDialogSplash();
	dlgSplash->show();
	qApp->processEvents();

	dlgSplash->updateProgress( 1, QObject::tr( "Loading settings..." ) );
	qApp->processEvents();

	//Initialize Settings
	quazaaSettings.loadSettings();

	//Check if this is Quazaa's first run
	dlgSplash->updateProgress( 8, QObject::tr( "Checking for first run..." ) );
	qApp->processEvents();
	bool bFirstRun = quazaaSettings.isFirstRun();
	if ( bFirstRun )
	{
		CDialogLanguage* dlgLanguage = new CDialogLanguage();
		dlgLanguage->exec();

		dlgSplash->updateProgress( 10, QObject::tr( "Running Quick Start wizard..." ) );
		quazaaSettings.saveFirstRun( false );
		quazaaSettings.saveSettings();
		quazaaSettings.saveProfile();

		CWizardQuickStart* wzrdQuickStart = new CWizardQuickStart();
		wzrdQuickStart->exec();
	}

	// Load Security Manager
	dlgSplash->updateProgress( 15, QObject::tr( "Loading Security Manager..." ) );
	qApp->processEvents();
	if ( !securityManager.start() )
		systemLog.postLog( LogSeverity::Information,
						   QObject::tr( "Security data file was not available." ) );

	// Load Discovery Services Manager
	dlgSplash->updateProgress( 22, QObject::tr( "Loading Discovery Services Manager..." ) );
	qApp->processEvents();
	discoveryManager.start();

	//Load profile
	dlgSplash->updateProgress( 25, QObject::tr( "Loading Profile..." ) );
	qApp->processEvents();
	quazaaSettings.loadProfile();

	//Load Host Cache
	dlgSplash->updateProgress( 30, QObject::tr( "Loading Host Cache..." ) );
	qApp->processEvents();
	hostCache.m_pSection.lock();
	hostCache.load();
	hostCache.m_pSection.unlock();

	//initialize geoip list
	geoIP.loadGeoIP();

	//Load the library
	dlgSplash->updateProgress( 38, QObject::tr( "Loading Library..." ) );
	qApp->processEvents();
	QueryHashMaster.Create();
	ShareManager.Start();

	// Load Download Manager
	dlgSplash->updateProgress( 60, QObject::tr( "Loading Transfer Manager..." ) );
	qApp->processEvents();
	Transfers.start();

	dlgSplash->updateProgress( 80, QObject::tr( "Loading User Interface..." ) );
	qApp->processEvents();

	MainWindow = new CWinMain();
	if ( quazaaSettings.WinMain.Visible )
	{
		if(bFirstRun)
			MainWindow->showMaximized();
		else
			MainWindow->show();
	}

	dlgSplash->updateProgress( 90, QObject::tr( "Loading Tray Icon..." ) );
	qApp->processEvents();
	MainWindow->loadTrayIcon();

	dlgSplash->updateProgress( 100, QObject::tr( "Welcome to Quazaa!" ) );
	qApp->processEvents();

	dlgSplash->deleteLater();
	dlgSplash = 0;

	// Start networks if needed
	if ( quazaaSettings.System.ConnectOnStartup )
	{
		if ( quazaaSettings.Gnutella2.Enable )
		{
			Network.Connect();
		}
	}

	return theApp.exec();
}