예제 #1
0
/*! @brief Slot for the returnPressed() signal of m_user_ip_input
 
 		   That is when the user presses return on the QLineEdit we trigger an update of m_current_hosts and emit a signal
 */
void ConnectionManager::onInputFinished()
{
    stringstream userinput(m_user_ip_input->text().toStdString());
    vector<string> hosts;
    
    // first split the user input using the commas
    while (userinput.good())
    {
    	string temp;
    	getline(userinput, temp, ',');
        if (not temp.empty())				// I don't want empty hosts/ipaddresses
        {
            temp.erase(remove_if(temp.begin(), temp.end(), ::isspace), temp.end());
            hosts.push_back(temp);
        }
    }
    
    m_current_hosts.clear();
    for (size_t i=0; i<hosts.size(); i++)
    {
        // two options (a) the user has input an ip address (b) the user has input a hostname
        if (isdigit(hosts[i][0]))
            m_current_hosts.push_back(NUHostInfo("Noname", hosts[i]));
        else
        {	// if it is a hostname is the bonjour provider to resolve it
            NUHostInfo info = m_bonjour->lookupHostName(hosts[i]);
            if (not info.empty())
                m_current_hosts.push_back(info);
        }
    }
    
    debug << "ConnectionManager::onInputFinished(): " << m_current_hosts << endl;
    emit newHosts(m_current_hosts);
}
예제 #2
0
파일: Menus.cpp 프로젝트: GonVas/FinalProg
void opcoesGestaoTransacoes(VendeMaisMais & supermercado){
  unsigned short int opcao;
  string newdate;
  int id;
  vector <string> prods;
 

  while((opcao = menuGestaoTransacoes()))
    switch (opcao){
	case 1: cout << "Transactions: " << endl;
		supermercado.listransactions();
      break;
	case 2: subTransactions(supermercado);
      break;
	case 3: 
      break; 
	case 4: userinput("What is the id? ", id, 0, 1000);
			cout << "What is the date? " << endl;
			getline(cin, newdate);
			Date date1(newdate);
			getstringvec(prods);
			supermercado.createtrans(id, date1, prods);
			cin >> id;

      break;
    }
}
예제 #3
0
파일: Menus.cpp 프로젝트: GonVas/FinalProg
/******************************************
 * Menu Inicial
 ******************************************/
unsigned short int menuInicial(){
  unsigned short int opcao;

  clearScreen();
  cout << TAB_BIG << "Menu Inicial" << endl;
  cout << endl;
  cout << TAB << "1 - Gestao de clientes" << endl;
  cout << TAB << "2 - Lista produto disponiveis" << endl;
  cout << TAB << "3 - Gestao de transacoes" << endl;
  cout << TAB << "4 - Recomendacoes" << endl;
  cout << TAB << "5 - Sair do programa" << endl << endl;
  cout << TAB << "Qual a sua opcao: ";
  userinput("",opcao,1, 5);

  if(opcao == 5)
    return 0;

  return opcao;
}
예제 #4
0
파일: Menus.cpp 프로젝트: GonVas/FinalProg
/******************************************
 * Gestao de Transacoes
 ******************************************/
unsigned short int menuRecomendacao()
{
	unsigned short int opcao;

	clearScreen();
	cout << TAB_BIG << "Sub Menu Transactions" << endl;
	cout << endl;
	cout << TAB << "1 - Show Bottom 10" << endl;
	cout << TAB << "2 - Recommendation for single client" << endl;
	cout << TAB << "3 - Recommendation for Bottom 10" << endl;
	cout << TAB << "4 - Return to main menu" << endl << endl;
	cout << TAB << "Qual a sua opcao: ";
	userinput(" ", opcao, 1, 4);

	if (opcao == 4)
		return 0;

	return opcao;
}
예제 #5
0
파일: Menus.cpp 프로젝트: GonVas/FinalProg
unsigned int menuseeTransactions()
{
	unsigned short int opcao;

	clearScreen();
	cout << TAB_BIG << "Sub Menu Transactions" << endl;
	cout << endl;
	cout << TAB << "1 - Single Client" << endl;
	cout << TAB << "2 - Single Day" << endl;
	cout << TAB << "3 - Between Dates" << endl;
	cout << TAB << "4 - Return to main menu" << endl << endl;
	cout << TAB << "Qual a sua opcao: ";
	userinput(" ", opcao, 1, 4);

	if (opcao == 4)
		return 0;

	return opcao;
}
예제 #6
0
파일: Menus.cpp 프로젝트: GonVas/FinalProg
/******************************************
 * Gestao de Clientes
 ******************************************/
unsigned short int menuGestaoClientes(){
	unsigned short int opcao;

	clearScreen();
	cout << TAB_BIG << "Menu Gestao Clientes" << endl;
	cout << endl;
	cout << TAB << "1 - Listar clientes" << endl;
	cout << TAB << "2 - Ver informacao cliente" << endl;
	cout << TAB << "3 - Editar cliente" << endl;
	cout << TAB << "4 - Remover cliente" << endl;
	cout << TAB << "5 - Adicionar cliente" << endl;
	cout << TAB << "6 - Voltar ao menu inicial" << endl << endl;
	cout << TAB << "Qual a sua opcao: ";
	userinput("", opcao, 1, 6);

	if (opcao == 6)
		return 0;

	return opcao;
}
예제 #7
0
파일: Menus.cpp 프로젝트: GonVas/FinalProg
/******************************************
 * Gestao de Transacoes
 ******************************************/
unsigned short int menuGestaoTransacoes()
{
	unsigned short int opcao;

	clearScreen();
	cout << TAB_BIG << "Menu Transactions" << endl;
	cout << endl;
	cout << TAB << "1 - List Transactions" << endl;
	cout << TAB << "2 - See Transactions" << endl;
	cout << TAB << "3 - Edit Transaction" << endl;
	cout << TAB << "4 - Create Transaction" << endl;
	cout << TAB << "5 - Return to main menu" << endl << endl;
	cout << TAB << "Qual a sua opcao: ";
	userinput("", opcao, 1, 5);

	if (opcao == 5)
		return 0;

	return opcao;
}
예제 #8
0
파일: muse_tui.cpp 프로젝트: dyne/MuSE
void muse_tui::start()
{
	int i;

	setlabels();
	//setdialogs();

	for (i=0;i< MAX_CHANNELS;i++)
	{
		if (i%2 == 0) { //tutti a sinistraaaa ehehhhhh
			chan[i].init (f.screen(),1,i);
		} else { //e tutti a destra ohhohhhhh
			chan[i].init (f.screen(), f.width()/2, i);
		}
	}


	f.refresh();
	chan[0].show();
	chan[1].show();
	setactivechan (0);
	userinput();
}
예제 #9
0
int main(int argc, char* argv[])
{
    initscr();
    scrollok(stdscr, TRUE);
    wprintw(stdscr, "Welcome to Scripted ver. %d.%d for the Brave Quest engine.\nCopyright 2012 Mad Science Inc.\nPlease do not redistrubute.\n",scriptedvernum,scriptedvernum2);
    stufffilename();
    if(loadscript(filename) == 1)
    {
        wprintw(stdscr, "File not Found. Would you like to make a new file?\n");
        if(bie() == 'y')
        {
            cleanfilebuff();
            if(savescript(filename) == 1)
            {
                wprintw(stdscr, "Your disk sucks.\n");
                bi();
                return 1;
            }
        }
        else
        {
            wprintw(stdscr, "Goodbye.\n");
            endwin();
            return 1;
        }
    }
    currlinenum = linenum;
    menu();
    wprintw(stdscr, "Press escape to go to the save menu\n");
    for(;;)
    {
        wprintw(stdscr, "q= give, w= take, e= say, r= flag, t= move, y= battle, u= check flag, i= check item, o= party add, p= party remove, [ = check character\n");
        wprintw(stdscr, "a= warp, s= check experience, d= give experience, f= make experience, g= exec script, h= screen effect, j= user input, k= goline, l= make health\n");
        wprintw(stdscr, "b= check stat, n= make stat, m= blank, ,= show line, .= change line.\n");
        input[0] = bie();
        if(input[0] == 27)
            menu();
        if(input[0] == 'q')
            give();
        if(input[0] == 'w')
            take();
        if(input[0] == 'e')
            say();
        if(input[0] == 'r')
            flag();
        if(input[0] == 't')
            mmove();
        if(input[0] == 'y')
            battle();
        if(input[0] == 'u')
            checkflag();
        if(input[0] == 'i')
            checkitem();
        if(input[0] == 'o')
            partyadd();
        if(input[0] == 'p')
            partyrm();
        if(input[0] == '[')
            checkparty();
        if(input[0] == 'a')
            warp();
        if(input[0] == 's')
            checkexp();
        if(input[0] == 'd')
            giveexp();
        if(input[0] == 'f')
            makeexp();
        if(input[0] == 'g')
            execscript();
        if(input[0] == 'h')
            screeneffect();
        if(input[0] == 'j')
            userinput();
        if(input[0] == 'k')
            goline();
        if(input[0] == 'l')
            makehealth();
        if(input[0] == 'z')
            teachspell();
        if(input[0] == 'x')
            unlearnspell();
        if(input[0] == 'b')
            checkstat();
        if(input[0] == 'n')
            makestat();
        if(input[0] == 'm')
            blank();
        if(input[0] == ',')
            showline();
        if(input[0] == '.')
            changeline();
        if(currlinenum > linenum)
            linenum = currlinenum;
    }
    return 0;
};
예제 #10
0
void
main(int argc, char **argv)
{
	int isnew;
	char *id, buf[Maxmsg], home[Maxmsg], prompt[100], *hexHi;
	char *pass, *passck;
	long expsecs;
	mpint *H = mpnew(0), *Hi = mpnew(0);
	PW *pw;
	Tm *tm;

	ARGBEGIN{
	case 'v':
		verbose++;
		break;
	}ARGEND;
	if(argc!=1){
		fprint(2, "usage: secuser [-v] <user>\n");
		exits("usage");
	}

	ensure_exists(SECSTORE_DIR, DMDIR|0755L);
	snprint(home, sizeof(home), "%s/who", SECSTORE_DIR);
	ensure_exists(home, DMDIR|0755L);
	snprint(home, sizeof(home), "%s/store", SECSTORE_DIR);
	ensure_exists(home, DMDIR|0700L);

	id = argv[0];
	if(verbose)
		fprint(2,"secuser %s\n", id);
	if((pw = getPW(id,1)) == nil){
		isnew = 1;
		print("new account (because %s/%s %r)\n", SECSTORE_DIR, id);
		pw = emalloc(sizeof(*pw));
		pw->id = estrdup(id);
		snprint(home, sizeof(home), "%s/store/%s", SECSTORE_DIR, id);
		if(access(home, AEXIST) == 0)
			sysfatal("new user, but directory %s already exists",
				home);
	}else{
		isnew = 0;
	}

	/* get main password for id */
	for(;;){
		if(isnew)
			snprint(prompt, sizeof(prompt), "%s password: "******"%s password [default = don't change]: ", id);
		pass = getpassm(prompt);
		if(pass == nil)
			sysfatal("getpassm failed");
		if(verbose)
			print("%ld characters\n", strlen(pass));
		if(pass[0] == '\0' && isnew == 0)
			break;
		if(strlen(pass) >= 7)
			break;
		print("password must be at least 7 characters\n");
	}

	if(pass[0] != '\0'){
		snprint(prompt, sizeof(prompt), "retype password: "******"confirming...\n");
		passck = getpassm(prompt);
		if(passck == nil)
			sysfatal("getpassm failed");
		if(strcmp(pass, passck) != 0)
			sysfatal("passwords didn't match");
		memset(passck, 0, strlen(passck));
		free(passck);
		hexHi = PAK_Hi(id, pass, H, Hi);
		memset(pass, 0, strlen(pass));
		free(pass);
		free(hexHi);
		mpfree(H);
		pw->Hi = Hi;
	}

	/* get expiration time (midnight of date specified) */
	if(isnew)
		expsecs = time(0) + 365*24*60*60;
	else
		expsecs = pw->expire;

	for(;;){
		tm = localtime(expsecs);
		print("expires [DDMMYYYY, default = %2.2d%2.2d%4.4d]: ",
				tm->mday, tm->mon+1, tm->year+1900);
		userinput(buf, sizeof(buf));
		if(strlen(buf) == 0)
			break;
		if(strlen(buf) != 8){
			print("!bad date format: %s\n", buf);
			continue;
		}
		tm->mday = (buf[0]-'0')*10 + (buf[1]-'0');
		if(tm->mday > 31 || tm->mday < 1){
			print("!bad day of month: %d\n", tm->mday);
			continue;
		}
		tm->mon = (buf[2]-'0')*10 + (buf[3]-'0') - 1;
		if(tm->mon > 11 || tm->mon < 0){
			print("!bad month: %d\n", tm->mon + 1);
			continue;
		}
		tm->year = atoi(buf+4) - 1900;
		if(tm->year < 70){
			print("!bad year: %d\n", tm->year + 1900);
			continue;
		}
		tm->sec = 59;
		tm->min = 59;
		tm->hour = 23;
		tm->yday = 0;
		expsecs = tm2sec(tm);
		break;
	}
	pw->expire = expsecs;

	/* failed logins */
	if(pw->failed != 0 )
		print("clearing %d failed login attempts\n", pw->failed);
	pw->failed = 0;

	/* status bits */
	if(isnew)
		pw->status = Enabled;
	for(;;){
		print("Enabled or Disabled [default %s]: ",
			(pw->status & Enabled) ? "Enabled" : "Disabled" );
		userinput(buf, sizeof(buf));
		if(strlen(buf) == 0)
			break;
		if(buf[0]=='E' || buf[0]=='e'){
			pw->status |= Enabled;
			break;
		}
		if(buf[0]=='D' || buf[0]=='d'){
			pw->status = pw->status & ~Enabled;
			break;
		}
	}
	for(;;){
		print("require STA? [default %s]: ",
			(pw->status & STA) ? "yes" : "no" );
		userinput(buf, sizeof(buf));
		if(strlen(buf) == 0)
			break;
		if(buf[0]=='Y' || buf[0]=='y'){
			pw->status |= STA;
			break;
		}
		if(buf[0]=='N' || buf[0]=='n'){
			pw->status = pw->status & ~STA;
			break;
		}
	}

	/* free form field */
	if(isnew)
		pw->other = nil;
	print("comments [default = %s]: ", (pw->other == nil) ? "" : pw->other);
	userinput(buf, 72);  /* 72 comes from password.h */
	if(buf[0])
		if((pw->other = strdup(buf)) == nil)
			sysfatal("strdup");

	syslog(0, LOG, "CHANGELOGIN for '%s'", pw->id);
	if(putPW(pw) < 0)
		sysfatal("can't write password file: %r");
	else{
		print("change written\n");
		if(isnew && create(home, OREAD, DMDIR | 0775L) < 0)
			sysfatal("unable to create %s: %r", home);
	}

	exits("");
}