Example #1
0
void MainWindow::rcvAuthorise (int flag)
{
    switch(flag)
    {
    case 1://验证通过
        //nowAt
        {
        QMessageBox *box = new QMessageBox;
        box->addButton (QMessageBox::Ok);
        box->setText ("登陆成功!");
        box->show();
        connect(box,SIGNAL(buttonClicked(QAbstractButton*)),login,SLOT(close()));

        enable_all();
        del_login ();
        emit callClientTimeEvent();
        break;
    }
    case 0://验证没通过
         login->auth_fail ();
        break;
    default:
;
    }
}
Example #2
0
void MainWindow::on_loginAct_triggered()
{
    login = new Login_ui(this);
    connect (login,SIGNAL(authorise(QByteArray)),this,SIGNAL(authorise(QByteArray)));
    connect (login,SIGNAL(cancle_login()),this,SLOT(del_login()));
    ui->loginAct->setEnabled (false);
    connect(login,SIGNAL(rejected()),this,SLOT(disable_all()));
    login->show ();

}
Example #3
0
void receive(void *arg)
{
	int done = 0;
	int cl_sock = (int) arg;
	char buffer[MAX_BUFFER];
	int argc;
	char *argv[5];
	int i;

	while (!done) {
		recv (cl_sock, buffer, sizeof(buffer), 0);
		
		i = 0;
		while (buffer[i++]!=';') {}
		buffer[i]='\0';

		printf("Received message: '%s'\n", buffer);
		parse (buffer, argv, &argc);
		if      ( !strcmp(argv[0], "LOGIN") )
		{
			if (argc < 4)
				printf("Wrong number of arguments (%d).\n",argc);
			else
				add_login (argv[1], argv[2], (int)(atoi(argv[3])));
		}
		else if ( !strcmp(argv[0], "LOGOUT") )
		{
			if (argc < 4) {
				printf("Wrong number of arguments (%d).\n",argc);
				close(cl_sock);
				printf("Thread exiting with error.\n");
				pthread_exit(NULL);
			} else {
				del_login (argv[1], argv[2], (int)(atoi(argv[3])));
				done = 1;
			}
		}
		else if ( !strcmp(argv[0], "HEY") )
		{
			if (argc < 1)
				printf("Wrong number of arguments (%d).\n",argc);
			else
				get_logins(cl_sock);
		}
  	     else
		{
			 printf("Unrecognized command.\n");
		}
	}
	close(cl_sock);
	printf("Thread exiting.\n");
	pthread_exit(NULL);
}