Пример #1
0
//Read the Configuration File
void getConfig(char * confile){

    FILE * fp; 
    char * line;
    char * token;
    size_t len = 0;
    ssize_t read;
    int i=0;
    userVerified = 0;

    servers = malloc(NUM_SERVERS * sizeof(server));


    fp = fopen(confile, "r");
    if (fp == NULL)
        exit(EXIT_FAILURE);

    // printf("We are congfiguring\n");

    //Read the config File
    while ((read = getline(&line, &len, fp)) != -1) {

        // printf("Line: %s", line);

        //Tokenize Hostname, Port, Username and Password
        token = strtok(line, " ");

        if (strcmp("Server", token) == 0){
            token = strtok(NULL, ":");
            // printf("Host: %s\n", token);
            strcpy(servers[i].host,token);
            token = strtok(NULL, " ");
            // printf("Port: %s\n", token);
            servers[i].port = atoi(token);
        } else if(strcmp("Username", token) == 0){
            //Username
            token = strtok(NULL, "\n");
            strcpy(userName, token);
        } else if(strcmp("Password", token) == 0){
            token = strtok(NULL, "\n");
            strcpy(passwd, token);
            // printf("We found the Password!\n");
        }

        i++;
    }

    //Verify that the user is Valid      
    userVerified = verifyUser();

    fclose(fp);
}
Пример #2
0
void LoginWidget::slotCheckAutoLogin(){

    if(autoLogin){

        IMUser::instance()->setUserID(Settings::instance()->getRecentUser());
        IMUser::instance()->setPassword(Settings::instance()->getRecentUserPassword());
        IMUser::instance()->setOnlineState(invisibleLogin ? IM::ONLINESTATE_INVISIBLE : IM::ONLINESTATE_ONLINE);
        verifyUser();

    }

    switchUI(NORMAL);

}
Пример #3
0
void LoginWidget::on_loginToolButton_clicked() {
    //    QString serverHostAddress = serverAddress();
    //    if(serverHostAddress.isEmpty()){
    //        QMessageBox::critical(this, tr("Error"), tr("Server Address Required!"));
    //        localServer->close();
    //        if(ui.groupBoxConfiguration->isHidden()){
    //            ui.toolButtonConfig->setChecked(true);
    //            ui.groupBoxConfiguration->setVisible(true);
    //        }
    //        if(!ui.comboBoxServerIP->count()){
    //            ui.toolButtonServersManager->click();
    //        }
    //        return;
    //    }

    if(!checkServerAddress()){
        return;
    }
    
    if (userName().isEmpty()) {

        QMessageBox::critical(this, tr("Error"), tr(
                                  "<b>ID Required!</b>"));

        ui.idComboBox->setFocus();
        return;

    } else if (passWord().isEmpty()) {

        QMessageBox::critical(this, tr("Error"), tr(
                                  "<b>Password Required!</b>"));
        ui.passwordLineEdit->setFocus();
        return;

    } else{
        QString userID = ui.idComboBox->currentText().trimmed();
        user->setUserID(userID);
        //user->setPassword(ui.passwordLineEdit->text());

        //从密码输入框取回明文密码,将其进行SHA-1加密
        //Fetch the password from the 'ui.passwordLineEdit' and  encrypt it with SHA-1h
        QByteArray password(ui.passwordLineEdit->text().toUtf8());
        password = QCryptographicHash::hash (password, QCryptographicHash::Sha1);

        user->setPassword(password.toBase64());
        qDebug()<<"----LoginWidget::on_loginToolButton_clicked()~~password:"******"----LoginWidget::on_loginToolButton_clicked()~~password.toBase64():"<<password.toBase64();

        user->setStateAfterLoggedin(invisibleLogin?IM::ONLINESTATE_INVISIBLE:IM::ONLINESTATE_ONLINE);

        ui.passwordLineEdit->clear();
        //infoAccepted = true;


        verifyUser();

        Settings::instance()->setCurrentUser(userID);



        //		bool userVerified = verifyUser();
        //		if(userVerified ){
        //			if(autoLogin){
        //					Settings::instance()->setRecentUser(ui.idComboBox->currentText());
        //					Settings::instance()->setRecentUserPassword(password.toBase64());
        //			}
        //			Settings::instance()->setRecentUser(userID);

        //		}


        /*
  switchUI(VERIFYING);
  Login login(user,this);
  if(login.isVerified()){
   //发射验证成功的消息
   emit signalUserVerified();

   QString userID = user->getUserID();
   Settings::instance()->setRecentUser(userID);

  }else{
   switchUI(NORMAL);
  }
*/

    }

}
Пример #4
0
//when button is clicked
void SecondDialog::on_pushButton_clicked()
{
    //tries entered username
    QString user = ui->LineUsername->text();
    verifyUser(user);
}