Пример #1
0
void startmenu::on_lineEdit_textChanged(const QString &arg1) //Username input line
{
        qDebug() << "Username has been changed";
        Username = ui->lineEdit->text();
        if (Creation)
        {
                CheckUsername(Username);
        }
}
Пример #2
0
void startmenu::on_radioButton_2_clicked() //New user creation
{
        ui->pushButton->setGeometry(320, 370, 77, 32);
        ui->label_3->setText("Create Username");
        ui->label_4->setText("Create Password");
        ui->label_6->show();
        ui->label_11->show();
        ui->progressBar->show();
        ui->progressBar->setValue(0);
        ui->lineEdit_3->show();
        ui->label_7->show();
        ui->label_8->hide();
        ui->label_9->hide();
        Login = false;
        Creation = true;
        Username = ui->lineEdit->text();
        CheckUsername(Username);
        getPasswordStrength();
}
Пример #3
0
void startmenu::on_pushButton_clicked() //Login/account creation button
{
        QString Password, UsernameS;
        Username = ui->lineEdit->text();
        UsernameS = Username;
        UsernameS.resize(4);
        Password = ui->lineEdit_2->text();
        Password = UsernameS + Password;
        Password = QGrostlHash(Password).toHexString();
        if (!myDB.isOpen()){
                qDebug() << "Lost connection to db.";
                return;
        }
        QSqlQuery qry;
        if (Login && PasswordIsNotEmpty)
        {
                if (qry.exec("SELECT username, password FROM user WHERE username=\'" + Username
                        + "\' AND password=\'" + Password + "\'"))
                {
                        if (qry.next())
                        {
                                MainWindow *mainWin = new MainWindow();
                                mainWin->setWindowTitle("Secure Shield: " + Username + " logged in");
                                mainWin->show();
                                hide();
                        }
                        else {
                                ui->label_5->setText("[-] Incorrect Username or Password");
                        }
                }
        }
        if (Creation && PasswordIsNotEmpty)
        {
        QString PasswordV;
        UsernameS = Username;
        UsernameS.resize(4);
        PasswordV = ui->lineEdit_3->text();
        PasswordV = UsernameS + PasswordV;
        PasswordV = QGrostlHash(PasswordV).toHexString();

        if (!CheckUsername(Username) && Username != "")
                  {
            if (Password == PasswordV && Password != "")
                        {
                CreateAccount(Username, Password);
                QMessageBox::warning(this, "Success!", "Your account has been created!");
                MainWindow *mainWin = new MainWindow();
                mainWin->setWindowTitle("Secure Shield: " + Username + " logged in");
                mainWin->show();
                mainWin->showPasswords();
                hide();
                        }
        else {
                QMessageBox::warning(this, "ERROR", "The passwords do not match");
             }
                  }
        else {
                QMessageBox::warning(this, "ERROR", "This username is already in use");
             }
        }
}
Пример #4
0
BOOL WINPROC EXPORT DlgRoomWhoAreYou (HWND hWnd,UINT wMsg,WPARAM wParam,LPARAM lParam)
{
	STRING	szTmp;
	WORD	wKey;
	int		iTmp;
    BOOL	bHandled = TRUE;
	int		iPtSize = 30;

	if (wMsg == WM_INITDIALOG)
	{
#ifdef _MAC	
		RECT rEdit;
#endif		
		DefRoomProc (hWnd, wMsg, wParam, lParam);

		if (LoadString (hInstAstral, IDS_FONT_NORMAL, szTmp, sizeof(szTmp)))
		{
			hDlgFont = (HFONT)NULL;
			hDlgFont = CreateFont (-iPtSize,		// Height
									0,				// Width
									0,				// Escapement
									0,				// Orientation
									0,				// Weight
									0,				// Italic
									0,				// Underline
									0,				// Strikeout
									0,				// Charset
									0,				// OutputPrecision
									0,				// ClipPrecision
									0,				// Quality
									0,				// PitchAndFamily
		  							(PSTR)szTmp);	// Typeface Name

			if (hDlgFont != NULL)
			{
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON1, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON2, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON3, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_BUTTON4, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_NEWBUTTON, WM_SETFONT, (WPARAM)hDlgFont, 0L);
				SendDlgItemMessage (hWnd, IDC_WHO_EDIT, WM_SETFONT, (WPARAM)hDlgFont, 0L);
			}
		}
		
		
#ifdef _MAC	
		// Make sure the edit control is exactly the same size as the radio button.
		// Without this hack, it is smaller on the mac.
		
		if (LoadString (hInstAstral, IDS_IM_NEW, szTmp, sizeof(szTmp)))
			SetDlgItemText (hWnd, IDC_WHO_EDIT, szTmp);

		GetClientRect(GetDlgItem(hWnd, IDC_WHO_NEWBUTTON), &rEdit);	
		SetWindowPos(
			GetDlgItem(hWnd, IDC_WHO_EDIT),
			NULL,
			0, 0,
			RectWidth(&rEdit),
			RectHeight(&rEdit),
			SWP_NOMOVE | SWP_NOZORDER);
#endif		
		
		// initially hide the edit control
    	ShowWindow (GetDlgItem(hWnd, IDC_WHO_EDIT), SW_HIDE);

		if (LoadString (hInstAstral, IDS_IM_NEW, szTmp, sizeof(szTmp)))
			SetDlgItemText (hWnd, IDC_WHO_NEWBUTTON, szTmp);

		DoInit (hWnd);

    	ShowWindow (GetDlgItem(hWnd, IDOK), SW_HIDE);
		fButtonHidden = FALSE;
		bHandled = TRUE;
	}
    else if (wMsg == WM_CLOSE)
    {
        AstralDlgEnd (hWnd,TRUE|2);
		bHandled = TRUE;
    }
    else if (wMsg == WM_COMMAND)
    {
		switch (wParam)
		{
			// Go To Room hotspot
			case HS_WHO:
				if (CheckUsername (hWnd))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				bHandled = TRUE;
				break;

			// I'm New button
			case IDC_WHO_NEWBUTTON:
#ifndef _MAC	// This problem doesn't exist on the mac			
				if (! fNoUsers)	// hack for Windows focus problem
#endif				
				{
					CheckRadioButton (hWnd, IDC_WHO_BUTTON1,
					  IDC_WHO_NEWBUTTON, IDC_WHO_NEWBUTTON);
    				ShowWindow (GetDlgItem(hWnd, IDC_WHO_NEWBUTTON), SW_HIDE);
    				ShowWindow (GetDlgItem(hWnd, IDC_WHO_EDIT), SW_SHOW);

					if (LoadString (hInstAstral, IDS_YOUR_NAME, szTmp,
				  	sizeof(szTmp)))
						SetDlgItemText (hWnd, IDC_WHO_EDIT, szTmp);

					SetFocus (GetDlgItem (hWnd, IDC_WHO_EDIT));
					SendDlgItemMessage (hWnd, IDC_WHO_EDIT, EM_SETSEL, 0,
				  	  MAKELONG(0, -1) );
				}
				iButtonIndex = 4;
				fNoUsers = FALSE;
				bHandled = TRUE;
				fButtonHidden = TRUE;
				break;

			// Scroll names down
			case HS_WHO_UPARROW:
				if (iUserCount > 4)
				{
					iTmp = iUserIndex;
					if (iUserIndex > 0)
                    {
						iUserIndex--;
                    	ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_SHOW);

						if (iUserIndex == 0)
                    		ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_HIDE);
                    }
                    else
            			ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_HIDE);

					if (iUserIndex != iTmp)
						UpdateButtons (hWnd, iUserIndex, iUserCount);
				}
				bHandled = TRUE;
				break;

			// Scroll names up
			case HS_WHO_DNARROW:
				if (iUserCount > 4)
				{
					iTmp = iUserIndex;
					if (iUserIndex < (iUserCount - 4))
                    {
						iUserIndex++;
                    	ShowWindow (GetDlgItem(hWnd, HS_WHO_UPARROW), SW_SHOW);

						if (iUserIndex +4 >= iUserCount)
                    		ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_HIDE);
                    }
                    else
            			ShowWindow (GetDlgItem(hWnd, HS_WHO_DNARROW), SW_HIDE);

					if (iUserIndex != iTmp)
						UpdateButtons (hWnd, iUserIndex, iUserCount);
				}
				bHandled = TRUE;
				break;

			case IDC_WHO_BUTTON1:
				HandleButton (hWnd, 0);
        		bHandled = TRUE;
				// if they click twice on same control - validate and continue
				if ((iButtonIndex == 0) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 0;
				break;

			case IDC_WHO_BUTTON2:
				HandleButton (hWnd, 1);
        		bHandled = TRUE;
				if ((iButtonIndex == 1) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 1;
				break;

			case IDC_WHO_BUTTON3:
				HandleButton (hWnd, 2);
        		bHandled = TRUE;
				if ((iButtonIndex == 2) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 2;
				break;

			case IDC_WHO_BUTTON4:
				HandleButton (hWnd, 3);
        		bHandled = TRUE;
				if ((iButtonIndex == 3) && (CheckUsername (hWnd)))
				{
					DeleteObject (hDlgFont);
        			GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				iButtonIndex = 3;
				break;

			case IDC_WHO_DELNAME:
				if (Control.CurrentUser[0] != 0)
				{
					if (! (GetNumberIniEntries() ))
					{
						if (GetUserNameByDir (Control.CurrentUser, szTmp))
						{
							DeleteUserName (szTmp);
							lstrcpy (szTmp, Control.WorkPath);
							lstrcat (szTmp, Control.CurrentUser);
#ifdef WIN32
							RemoveDirectory (szTmp);
#else
							_rmDir (szTmp);
#endif							
							clr ((LPTR)Control.CurrentUser, sizeof(Control.CurrentUser));
							DoInit (hWnd);
						}
					}
				}
        		bHandled = TRUE;
				break;

			case IDOK:
				bHandled = TRUE;
				if (CheckUsername (hWnd))
				{
					DeleteObject (hDlgFont);
       				GoRoom (hInstAstral, RM_ARTROOM, FALSE);
				}
				break;

			default:
        		bHandled = FALSE;
				break;
		}
    }
    else if (wMsg == WM_CHAR)
	{
		wKey = (WORD)lParam;
		if (wKey == VK_DELETE)
		{
			GetUserNameString (iUserIndex, szTmp);
		}
	}
    else
        bHandled = FALSE;

    if (! bHandled)
        bHandled = DefRoomProc (hWnd, wMsg, wParam, lParam);

    return bHandled;
}