コード例 #1
0
ファイル: application.cpp プロジェクト: PyroOS/Pyro
/** \brief Parse the arguments and pass it to MainWindow.
 * This is used internally by App.
 *
 * \param myWindow Window to pass the arguments to.
 * \param argc Number of arguments.
 * \param argv Array of argument strings.
 *
 */
bool App::_parseArgs(MainWindow* myWindow, int argc, char **argv)
{
	os::String zScheme = "ftp"; // Default is ftp
	os::String zHost = ""; // No host
	os::String zUser = ""; // No user
	os::String zPass = ""; // No password
	os::String zPort = ""; // No port.
	
	
	// Go to argc - 1 so we don't go past the end.
	for(int i = 1; i < argc; i++)
	{
		/* Type of connection (eg. ftp) */
		if ( !strncmp(argv[i], "-t", 2) )
		{
			if ( i != argc - 1 )
				zScheme = argv[i+1];
			i++;
		}
		else if ( !strncmp(argv[i], "-H", 2) ) // Host.
		{
			if ( i != argc - 1 )
				zHost = argv[i+1];
			i++;
		}
		else if ( !strncmp(argv[i], "-U", 2) ) // Username.
		{
			if ( i != argc - 1 )
				zUser = argv[i+1];
			i++;
		}
		else if ( !strncmp(argv[i], "-P", 2) ) // Password.
		{
			if ( i != argc - 1 )
				zPass = argv[i+1];		
			i++;
		}
		else if ( !strncmp(argv[i], "-N", 2) ) // Port number.
		{
			if ( i != argc - 1 )
				zPort = argv[i+1];		
			i++;
		}
		else // Output usage information.
		{
			_Usage(argv[0]);
			return false;
		}
	}
	
	if ( zScheme != "" && zHost != "" )
	{
		myWindow->OpenConnection(zScheme, zHost, zPort, zUser, zPass);
	}
	
	return true;
}
コード例 #2
0
ファイル: alert.cpp プロジェクト: AmirAbrams/haiku
/*!
	Is called when the app receives a B_READY_TO_RUN message. The message
	is sent automatically during the Run() function, and is sent after the
	initial B_REFS_RECEIVED and B_ARGV_RECEIVED messages (if any) have been
	handled.
*/
void
AlertApplication::ReadyToRun()
{
	if (GoodArguments()) {
		BAlert* alert = new BAlert("alert", fArgumentText,
			fArgumentButton0, fArgumentButton1, fArgumentButton2,
			B_WIDTH_AS_USUAL, fIcon);

		if (fModal)
			alert->SetFeel(B_MODAL_ALL_WINDOW_FEEL);

		_SetChoice(alert->Go());
	} else
		_Usage();

	Quit();
}
コード例 #3
0
void
TermApp::ArgvReceived(int32 argc, char **argv)
{
	fArgs->Parse(argc, argv);

	if (fArgs->UsageRequested()) {
		_Usage(argv[0]);
		sUsageRequested = true;
		PostMessage(B_QUIT_REQUESTED);
		return;
	}

	if (fArgs->Title() != NULL)
		fWindowTitle = fArgs->Title();

	fStartFullscreen = fArgs->FullScreen();
}