Пример #1
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpstrCmdLine, int nCmdShow)
{
	HRESULT hRes = ::CoInitialize(NULL);
// If you are running on NT 4.0 or higher you can use the following call instead to 
// make the EXE free threaded. This means that calls come in on a random RPC thread.
//	HRESULT hRes = ::CoInitializeEx(NULL, COINIT_MULTITHREADED);
	ATLASSERT(SUCCEEDED(hRes));

	// this resolves ATL window thunking problem when Microsoft Layer for Unicode (MSLU) is used
	::DefWindowProc(NULL, 0, 0, 0L);

	AtlInitCommonControls(ICC_COOL_CLASSES | ICC_BAR_CLASSES);	// add flags to support other controls

	hRes = _Module.Init(NULL, hInstance);
	ATLASSERT(SUCCEEDED(hRes));

	_isSysInstall = isServiceRunning(SERVICE_NAME);

	int nRet = EXIT_SUCCESS;
	if (_isSysInstall)
	{
		while (1)
		{
			CLoginDlg	dlg;
			if (IDOK == dlg.DoModal(NULL))
			{
				if (login(dlg.m_passWord.GetBuffer(0)))
				{
					lstrcpy(_passWord, dlg.m_passWord.GetBuffer(0));
					Run(lpstrCmdLine, nCmdShow);
					break;
				}
				else
				{
					MessageBox(NULL, _T("ÃÜÂë´íÎó£¬ÇëÖØÐÂÊäÈëÃÜÂë!"), _T("´íÎó"), MB_OK | MB_ICONERROR);
				}
			}
			else
			{
				break;
			}
		}

	}
	else
	{
		nRet = Run(lpstrCmdLine, nCmdShow);
	}

	_Module.Term();
	::CoUninitialize();

	return nRet;
}
Пример #2
0
void MainWindow::updateServiceControl()
{
	bool running = isServiceRunning();
#ifdef ITALC_BUILD_WIN32
	ui->startService->setEnabled( !running );
	ui->stopService->setEnabled( running );
#else
	ui->startService->setEnabled( false );
	ui->stopService->setEnabled( false );
#endif
	ui->serviceState->setText( running ? tr( "Running" ) : tr( "Stopped" ) );
}
Пример #3
0
void MainWindow::apply()
{
#ifdef ITALC_BUILD_WIN32
	ItalcCore::config->setValue( "EncodedLogonACL", LogonAclSettings().acl(),
															"Authentication" );
#endif
	if( ImcCore::applyConfiguration( *ItalcCore::config ) )
	{
#ifdef ITALC_BUILD_WIN32
		if( isServiceRunning() &&
			QMessageBox::question( this, tr( "Restart iTALC Service" ),
				tr( "All settings were saved successfully. In order to take "
					"effect the iTALC service needs to be restarted. "
					"Restart it now?" ), QMessageBox::Yes | QMessageBox::No,
				QMessageBox::Yes ) == QMessageBox::Yes )
		{
			stopService();
			startService();
		}
#endif
		ui->buttonBox->setEnabled( false );
		m_configChanged = false;
	}
}
Пример #4
0
void MainWindow::clearLogFiles()
{
#ifdef ITALC_BUILD_WIN32
	bool stopped = false;
	if( isServiceRunning() )
	{
		if( QMessageBox::question( this, tr( "iTALC Service" ),
				tr( "The iTALC service needs to be stopped temporarily "
					"in order to remove the log files. Continue?"
					), QMessageBox::Yes | QMessageBox::No,
				QMessageBox::Yes ) == QMessageBox::Yes )
		{
			stopService();
			stopped = true;
		}
		else
		{
			return;
		}
	}
#endif

	bool success = true;
	QDir d( LocalSystem::Path::expand( ItalcCore::config->logFileDirectory() ) );
	foreach( const QString &f, d.entryList( QStringList() << "Italc*.log" ) )
	{
		if( f != "ItalcManagementConsole.log" )
		{
			success &= d.remove( f );
		}
	}

#ifdef ITALC_BUILD_WIN32
	d = QDir( "C:\\Windows\\Temp" );
#else
	d = QDir( "/tmp" );
#endif

	foreach( const QString &f, d.entryList( QStringList() << "Italc*.log" ) )
	{
		if( f != "ItalcManagementConsole.log" )
		{
			success &= d.remove( f );
		}
	}

#ifdef ITALC_BUILD_WIN32
	if( stopped )
	{
		startService();
	}
#endif

	if( success )
	{
		QMessageBox::information( this, tr( "Log files cleared" ),
			tr( "All log files were cleared successfully." ) );
	}
	else
	{
		QMessageBox::critical( this, tr( "Error" ),
			tr( "Could not remove all log files." ) );
	}
}