示例#1
0
void aggiunta_utente::aggiungi_utente_a_db(){

    if(username_valido){
        //prendo i campi dati
        std::string username_ = username->text().toStdString();
        std::string cognome_ = cognome->text().toStdString();
        std::string nome_ = nome->text().toStdString();
        //tipo account
        QString tipo_a=tipologia_account->currentText();
        std::string tipo_account=tipo_a.toStdString();
        //competenze
        std::list<std::string> competenze_ =blocco_competenza->get_lista_competenze();
        //lingue
        std::list<std::string> lingue_=blocco_lingua->get_lista_lingue();
        //esperienze
        std::list<std::string> esperienze_=blocco_esperienza_professionale->get_lista_esperienze_txt();
        //carta di credito
        std::string cc=carta_di_credito->text().toStdString();
        if(cc=="") cc="<<< NON INSERITA >>>";

        /* * * * * * * * * * * * * * * * * * * * * * * * * * * *
         *                                                     *
         *              MANCANO GLI ALTRI CAMPI DATI!!!        *
         *                                                     *
         * * * * * * * * * * * * * * * * * * * * * * * * * * * */


        //...

        //chiamo la procedura del controller
        aggiungi_modifica_utenti controller_handler(ptr_repository);
        controller_handler.aggiungi_utente(aggiungi_modifica_utenti::costruisci_utente(tipo_account,
                                                username_,cognome_,nome_,competenze_,lingue_,
                                                esperienze_, cc));

        //inserisco tramite lo smartutente*
        padre->mostra_pag_visualizzazione_utenti();
    }
    else{
        QMessageBox* msg=new QMessageBox(QMessageBox::Critical,"Username già esistente",
                                         "<center>L'username inserito è già in uso<br /> per un altro untente oppure è vuoto.</center>");
        msg->setGeometry(400,400,400,250);
        msg->show();
    }
}
示例#2
0
文件: tmon.c 项目: 908626950/linux
int main(int argc, char **argv)
{
	int err = 0;
	int id2 = 0, c;
	double yk = 0.0; /* controller output */
	int target_tz_index;

	if (geteuid() != 0) {
		printf("TMON needs to be run as root\n");
		exit(EXIT_FAILURE);
	}

	while ((c = getopt_long(argc, argv, "c:dlht:vgz:", opts, &id2)) != -1) {
		switch (c) {
		case 'c':
			no_control = 0;
			strncpy(ctrl_cdev, optarg, CDEV_NAME_SIZE);
			break;
		case 'd':
			start_daemon_mode();
			printf("Run TMON in daemon mode\n");
			break;
		case 't':
			ticktime = strtod(optarg, NULL);
			if (ticktime < 1)
				ticktime = 1;
			break;
		case 'l':
			printf("Logging data to /var/tmp/tmon.log\n");
			logging = 1;
			break;
		case 'h':
			usage();
			break;
		case 'v':
			version();
			break;
		case 'g':
			debug_on = 1;
			break;
		case 'z':
			target_thermal_zone = strtod(optarg, NULL);
			break;
		default:
			break;
		}
	}
	if (pthread_mutex_init(&input_lock, NULL) != 0) {
		fprintf(stderr, "\n mutex init failed, exit\n");
		return 1;
	}
	start_syslog();
	if (signal(SIGINT, tmon_sig_handler) == SIG_ERR)
		syslog(LOG_DEBUG, "Cannot handle SIGINT\n");
	if (signal(SIGTERM, tmon_sig_handler) == SIG_ERR)
		syslog(LOG_DEBUG, "Cannot handle SIGINT\n");

	if (probe_thermal_sysfs()) {
		pthread_mutex_destroy(&input_lock);
		closelog();
		return -1;
	}
	initialize_curses();
	setup_windows();
	signal(SIGWINCH, resize_handler);
	show_title_bar();
	show_sensors_w();
	show_cooling_device();
	update_thermal_data();
	show_data_w();
	prepare_logging();
	init_thermal_controller();

	nodelay(stdscr, TRUE);
	err = pthread_create(&event_tid, NULL, &handle_tui_events, NULL);
	if (err != 0) {
		printf("\ncan't create thread :[%s]", strerror(err));
		tmon_cleanup();
		exit(EXIT_FAILURE);
	}

	/* validate range of user selected target zone, default to the first
	 * instance if out of range
	 */
	target_tz_index = zone_instance_to_index(target_thermal_zone);
	if (target_tz_index < 0) {
		target_thermal_zone = ptdata.tzi[0].instance;
		syslog(LOG_ERR, "target zone is not found, default to %d\n",
			target_thermal_zone);
	}
	while (1) {
		sleep(ticktime);
		show_title_bar();
		show_sensors_w();
		update_thermal_data();
		if (!dialogue_on) {
			show_data_w();
			show_cooling_device();
		}
		cur_thermal_record++;
		time_elapsed += ticktime;
		controller_handler(trec[0].temp[target_tz_index] / 1000,
				&yk);
		trec[0].pid_out_pct = yk;
		if (!dialogue_on)
			show_control_w();
		if (tmon_exit)
			break;
	}
	tmon_cleanup();
	return 0;
}