示例#1
0
文件: comm.c 项目: icebluechao/piglet
static void *sayingThread(void *arg)
{
    int udpSock = getUdpSock();
    while(1)
    {
        sleep(1);
        LOCK_SAYING(
            if(sayingList != NULL)
    {
        PMSGPACK msg = sayingList;
        while(msg)
            {
                if((int)msg->priv < 4)
                {
                    sendMsg(udpSock, msg);
                    msg->priv = (void*)((int)(msg->priv) + 1);
                }
                else
                {
                    printf("\nmsg send timeout!\n");
                    del_node(&sayingList, msg);
                    delUser(&(msg->address), NULL, NULL);
                    if(sayingList == NULL)
                        break;
                }
                msg = msg->next;
            }
        }
        );
    }
示例#2
0
Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
{        
    ui->setupUi(this);
    bool connFlag = this->connDb();
    if(connFlag) {
        this->userList();
    }
    QObject::connect(ui->addButton,SIGNAL(clicked()),this,SLOT(addUser()));
    QObject::connect(ui->delButton,SIGNAL(clicked()),this,SLOT(delUser()));
    QObject::connect(ui->updateButton,SIGNAL(clicked()),this,SLOT(updateUser()));
    QObject::connect(ui->userListWidget,SIGNAL(itemSelectionChanged()),this,SLOT(changeEditContent()));
}
示例#3
0
int kumo_db::addUser(std::wstring user, std::wstring password)
{
	const std::locale empty_locale = std::locale::empty();
    typedef std::codecvt_utf8<wchar_t> converter_type;
    const converter_type* converter = new converter_type;
    const std::locale utf8_locale = std::locale(empty_locale, converter);

	const BYTE* p = (const BYTE*)password.c_str();

	if (getUserPassHash(user) != NULL_PASSWORD_HASH)
		delUser(user);
	//It's not bug, if you wan't to change password, just call addUser ^_^

	std::wstring wsPasswordHash =
		Protection::getHash((void *)password.c_str(), sizeof WCHAR * password.length());
	wchar_t buffer[128];

	std::wfstream file(USER_LIST_FILE,  std::ios::out | std::ios::in |std::ios::binary);
	if (!file.is_open())
		file.open (USER_LIST_FILE,  std::ios::out | std::ios::binary);

	for(int i = 0; i < 10; i--)
	{
		if (file.is_open()) break;
		Sleep(100);
		file.open (USER_LIST_FILE,  std::ios::out | std::ios::in | std::ios::binary);
	}
	if (!file.is_open()) return -1;

	file.imbue(utf8_locale);

	std::wstring line;
	std::wstring line2;

	do{
		line = line2;
		std::getline(file, line2);
	}
	while(!file.eof());
	file.clear();

	int num = _wtoi( line.substr(0, line.find(DB_SEPARATOR, 0)).c_str() );

	file << ((num > 0)? std::to_wstring((_Longlong)num + 1): L"1")
		<< DB_SEPARATOR  << user << DB_SEPARATOR << wsPasswordHash << std::endl;
	file.close();

	return 0;
}
示例#4
0
wBusiness::wBusiness(business *bus, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::wBusiness)
{
    ui->setupUi(this);
    toAdd = false;
    t_business = bus;
    if(t_business == 0){
        setWindowTitle("Agregar Negocio");
        t_business = new business();
        toAdd = true;
    }else{
        setWindowTitle("Modificar Negocio");
        ui->direcciNLineEdit->setText(t_business->address());
        ui->emailLineEdit->setText(t_business->email());
        ui->nombreLineEdit->setText(t_business->name());
        ui->dueOLineEdit->setText(t_business->owner());
        ui->telefonoLineEdit->setText(t_business->telephone());

        ui->simpleFazDoubleSpinBox->setValue(t_business->sfvalue());
        ui->dobleFazDoubleSpinBox->setValue(t_business->dfvalue());
        ui->impSimpleFazDoubleSpinBox->setValue(t_business->impsfvalue());
        ui->impDoubleFazDoubleSpinBox->setValue(t_business->impdfvalue());
        ui->colorImpSimpleFazDoubleSpinBox->setValue(t_business->coloursfvalue());
        ui->colorImpDoblleFazDoubleSpinBox->setValue(t_business->colourdfvalue());
        ui->copiaColDobleFazDoubleSpinBox->setValue(t_business->impcolordfvalue());
        ui->copiaColSimpleFazDoubleSpinBox->setValue(t_business->impcolorsfvalue());
    };

    connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addUser()));
    connect(ui->delButton, SIGNAL(clicked()), this, SLOT(delUser()));

    connect(ui->anilladoAddButton, SIGNAL(clicked()), this, SLOT(addAnillado()));
    connect(ui->anilladoDelButton, SIGNAL(clicked()), this, SLOT(delAnillado()));

    connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(saved()));
    connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(closed()));
    refresh();
}
示例#5
0
		
		QComboBox *levelCombo = new QComboBox();
		
		levelCombo->addItems(QStringList() << "Guest" << "User" << "Admin");
		levelCombo->setCurrentIndex(user->level());
		
		tableWidget->setCellWidget(row, 2, levelCombo);
		 
		row ++;
	}
	
	tableWidget->resizeColumnsToContents();
	tableWidget->resizeRowsToContents();
	
	connect(ui->addUserBtn, SIGNAL(clicked()), this, SLOT(addUser()));
	connect(ui->delUserBtn, SIGNAL(clicked()), this, SLOT(delUser()));
	connect(tableWidget, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(adjustTableSize()));
	
	connect(ui->buttonBox, SIGNAL(accepted()), this, SLOT(slotAccepted()));
	
}

void HttpUserSetupDialog::addUser()
{
	QTableWidget * tableWidget = ui->httpUsers;
	int row = tableWidget->rowCount();
	tableWidget->setRowCount(row+1);
	tableWidget->setItem(row,0,new QTableWidgetItem("newuser"));
	tableWidget->setItem(row,1,new QTableWidgetItem("newpass"));
	tableWidget->setItem(row,2,new QTableWidgetItem("0"));
		
示例#6
0
int action(char** TabArgs,char** TabFonction,superBlock *sb, int *argInode,int nbfonction, int *userCo){
	int i,NbInstruction=-1,k;

	for(i=0;i<nbfonction;i++){
		if(strcmp(TabArgs[0],TabFonction[i])==0)
			NbInstruction=i;
			}

	switch(NbInstruction){
		case 0://touch
		touch(sb,*argInode,TabArgs[1],*userCo);
		
		break;

		case 1://cat

		cat(sb,chemin(sb,*argInode,TabArgs[1]),*userCo);
		
		break;
		
		case 2://ls
	
		ls(sb,*argInode);		

		break;

		case 3://rm

		unlink(sb,chemin(sb,*argInode, TabArgs[1]),*argInode,*userCo);
		break;	
		case 4://mkdir

		mkdir(sb,*argInode,TabArgs[1],*userCo);
		break;	
		case 5://cd
			*argInode=cd(sb,*argInode,TabArgs[1],*userCo); 
		break;
		case 6://newU
		if(TabArgs[1]!=NULL && TabArgs[2]!=NULL)
		    newUser(sb,TabArgs[1], TabArgs[2]); 
		break;
		case 7://changeU
		if(TabArgs[1]!=NULL && TabArgs[2]!=NULL){
		    int res =connexion(sb,TabArgs[1], TabArgs[2]); 
		    if(res !=-1){
				*userCo=res;
			}
		}
		break;
		case 8://tableU
		    tableUser(sb,*userCo);
		break;
		case 9://chmod
			if(TabArgs[1]!=NULL && TabArgs[2]!= NULL && TabArgs[3]!= NULL)
				chmod(sb,chemin(sb,*argInode,TabArgs[1]), *userCo,atoi(TabArgs[2]), atoi(TabArgs[3]));
		break;
		case 10: //help
			
			printf("commandes : \n");
			for(k;k<NbInstruction;k++){
				printf("%s\t",TabFonction[k]);
			}
			printf("\n");
		break;
		case 11:
			printf("bye\n");
			exit(0);
		break;
		case 12://ln
			ln(sb, chemin(sb,*argInode,TabArgs[1]), chemin(sb,*argInode,TabArgs[3]), TabArgs[2],*userCo);
		break;
		case 13://cp
		    cp(sb,chemin(sb,*argInode,TabArgs[1]),TabArgs[2],chemin(sb,*argInode,TabArgs[3]),*userCo);
		break;
		case 14://echo
			if(chemin(sb,*argInode,TabArgs[1])!=0)
			{
				echo(sb,chemin(sb,*argInode,TabArgs[1]),*userCo);
			}
		break;
		case 15://mv
		    mv(sb,*argInode,chemin(sb,*argInode,TabArgs[1]),chemin(sb,*argInode,TabArgs[3]),TabArgs[2],*userCo);
		break;
		case 16://tableI
			toStringInode(sb);
		break;
		case 17://tableF
			toStringBlocksF(sb);
		break;
		case 18://df
			df(sb);
		break;
		case 19://delU
			if(TabArgs[1]!=NULL)
			delUser(sb, *userCo, TabArgs[1]);
		break;
		case 20://changeP
			if(TabArgs[1]!=NULL)
			delUser(sb, *userCo, TabArgs[2]);
		break;
default:
printf("action non reconnue\n");
break;
	
		}
		
	return 1;
}
int removeuser(void)
{
	
	
	/* Declarations */
	
	WINDOW *rmudlg; /* Prompt Username Window */
	

	rmudlg = newwin(6,61,6,10); /* User name input dialog */
	box(rmudlg, ACS_VLINE, ACS_HLINE);
	wattron(rmudlg, A_UNDERLINE);
	mvwprintw(rmudlg, 1, 20, "Remove user from system");
	wattroff(rmudlg, A_UNDERLINE);
	
	
	
	echo();    /* Turns on Echo to see the text typed */
	/* Username Prompt */
	mvwprintw(rmudlg, 3, 1,  "Please type in username to remove:");
	mvwprintw(rmudlg, 3, 37, "[______________]");
	wrefresh(rmudlg);

	
	
	/* Show a highlighted Field */
	wattron(rmudlg, A_REVERSE);
	mvwprintw(rmudlg, 3, 37, "[______________]");
	wrefresh(rmudlg);
	mvwgetnstr(rmudlg, 3,38, loginname, 15);
	wattroff(rmudlg, A_REVERSE);
	noecho(); /* Removes Echo */
	

	werase(rmudlg);	
	
	while(1)
	{
		rmudlg = newwin(10,61,6,10);
		box(rmudlg, ACS_VLINE, ACS_HLINE);
		wattron(rmudlg, A_UNDERLINE);
		mvwprintw(rmudlg, 1, 20, "Are you sure");
		wattroff(rmudlg, A_UNDERLINE);
		mvwprintw(rmudlg, 3, 7,  "Are you sure you want to delete");
		mvwprintw(rmudlg, 4, 7, "user %s from the system", loginname);
		wattron(rmudlg,A_BOLD);
		mvwprintw(rmudlg, 6, 7, "Y=Yes	 N=No 	F10=Cancel");
		wattroff(rmudlg,A_BOLD);
		wrefresh(rmudlg);
		
		key = getch();
		switch(key)
		{
			case KEY_F(10):
			return 0;
			break;
			
			case 'n':
			return 0;
			break;
			
			case 'N':
			return 0;
			break;
			
			case 'y':
			delUser();
			return 0;
			break;
			
			case 'Y':
			delUser();
			return 0;
			break;
					
			
		}
	};
		
	
	return 0;
}