コード例 #1
0
ファイル: Tracker.cpp プロジェクト: jwright6323/track-o-bot
void Tracker::CreateAndStoreAccountHandleReply() {
  QNetworkReply *reply = static_cast< QNetworkReply* >( sender() );
  if( reply->error() == QNetworkReply::NoError ) {
    LOG( "Account creation was successful!" );

    QByteArray jsonData = reply->readAll();

    bool ok;
    QtJson::JsonObject user = QtJson::parse( jsonData, ok ).toMap();

    if( !ok ) {
      LOG( "Couldn't parse response" );
    } else {
      LOG( "Welcome %s", user[ "username" ].toString().toStdString().c_str() );

      SetUsername( user["username"].toString() );
      SetPassword( user["password"].toString() );

      emit AccountCreated();
    }
  } else {
    int statusCode = reply->attribute( QNetworkRequest::HttpStatusCodeAttribute ).toInt();
    LOG( "There was a problem creating an account. Error: %i HTTP Status Code: %i", reply->error(), statusCode );
  }
}
コード例 #2
0
ファイル: Window.cpp プロジェクト: atom-b/track-o-bot
SettingsTab::SettingsTab( QWidget *parent )
    : QWidget( parent ), mUI( new Ui::SettingsWidget )
{
    mUI->setupUi( this );
    connect( mUI->exportAccountButton, SIGNAL( clicked() ), this, SLOT( ExportAccount() ) );
    connect( mUI->importAccountButton, SIGNAL( clicked() ), this, SLOT( ImportAccount() ) );
    connect( mUI->checkForUpdatesNowButton, SIGNAL( clicked()), this, SLOT( CheckForUpdatesNow() ) );
    connect( mUI->startAtLogin, SIGNAL( clicked(bool) ), this, SLOT( UpdateAutostart() ) );
    connect( mUI->checkForUpdates, SIGNAL( clicked(bool) ), this, SLOT( UpdateUpdateCheck() ) );
    connect( Tracker::Instance(), SIGNAL( AccountCreated() ), this, SLOT( LoadSettings() ) );
    LoadSettings();
}
コード例 #3
0
ファイル: Create_Account.c プロジェクト: aevernon/triggerman
main()
{
  FILE *password_file_pointer, *account_file_pointer;

  char indata[10000];                 /* data received from standard input */
  char tempdata[10000];  
  char user_name[100];                /* character array for requested user name */
  char user_login_name[100];          /* character array for requested login name */
  char temp_password[100];           
  char encoded_user_password[100]; 
  char user_password[100];            /* character array for requested user password */
  char verify_user_password[100];     /* character array to verify user password */
  char user_email[100];               /* character array for user's email address */
  char user_address[100];             /* character array for user's residence */
  char user_city[100];                /* character array for user's city of residence */
  char user_state[100];               /* character array for user's state of residence */
  char user_zip_code[100];            /* character array for user's zip code */
  char user_area_code[100];           /* character array for user's area code */
  char user_phone_number[100];        /* character array for user's phone number */

  int isValidForm = 0;                /* valid form flag variable */
  int isValidAccount = 0;             /* valid account flag variable */

 /* retrieve data from standard input (a.k.a. POST method of HTML form) */
  gets(indata);  

  /* separate data into respective character arrays */
  strcpy(user_name, get_variable(indata, "user_name="));
  strcpy(user_login_name, get_variable(indata, "&user_login_name="));
  strcpy(user_password, get_variable(indata, "&user_password="******"&verify_user_password="******"&user_email="));
  strcpy(user_address, get_variable(indata, "&user_address="));
  strcpy(user_city, get_variable(indata, "&user_city="));
  strcpy(user_state, get_variable(indata, "&user_state="));
  strcpy(user_zip_code, get_variable(indata, "&user_zip_code="));
  strcpy(user_area_code, get_variable(indata, "&user_area_code="));
  strcpy(user_phone_number, get_variable(indata, "&user_phone_number="));

  /* valid form (10=valid; 11=inconsistent passwords; 12=file error) */
  isValidForm = verify_form(user_name, user_login_name,
			    user_password, verify_user_password,
			    user_email, user_address,
			    user_city, user_state, user_zip_code,
			    user_area_code, user_phone_number);

  /* valid account (10=non-valid account; 11=valid account) */   
  isValidAccount = verify_account(password_file_pointer, user_login_name, user_password);
  
  /* if valid form and valid account, write data into password and account files */
  if (isValidForm == 10) 
  { /* open account file */
    if ((account_file_pointer = fopen(ACCOUNT_FILE, "ab+")) == NULL)
      ErrorInCreateAccount(0); /* error in opening account file */
    else 
    {
      if ((isValidForm == 10) && (isValidAccount == 11))
      { /* write user data into account file */
        fprintf(account_file_pointer, "%s\n", user_name);
        fprintf(account_file_pointer, "%s %s\n", user_login_name, user_password);
        fprintf(account_file_pointer, "%s\n", user_email);
        fprintf(account_file_pointer, "%s\n", user_address);
        fprintf(account_file_pointer, "%s %s %s\n", user_city, user_state,
user_zip_code);
        fprintf(account_file_pointer, "%s %s\n", user_area_code, user_phone_number);
      }
      else
        ErrorInCreateAccount(1);        /* inconsistent passwords */
    }
    fclose(account_file_pointer);		/* close account file */
    /* open password file */ 
    if ((password_file_pointer = fopen(PASSWORD_FILE, "ab+")) == NULL) 
      ErrorInCreateAccount(0);			/* error in opening password file */
    else /* write user login name and password into password file */
      fprintf(password_file_pointer, "%s %s\n", user_login_name, user_password); 
    fclose(password_file_pointer);      /* close password file */
    /* let user know that account was created successfully */
    AccountCreated(user_name, user_login_name, user_email, user_address, 
                    user_city, user_state, user_zip_code, user_area_code, user_phone_number);  
  } 
  else if (isValidForm == 11)           /* error--inconsistent passwords */
    ErrorInCreateAccount(1);
  else if (isValidForm == 12)
    ErrorInCreateAccount(2);			/* error--file error */
  return 0;
}