Esempio n. 1
0
int start_registering() {
    if (!default_username) {
        struct wait_get_phone phone;
        if (waitAndGet( WAIT_AND_GET_PHONE_NUMBER, &phone) == -1)
          qthreadExitRequest (EXIT_FAILURE);

        set_default_username (phone.phone);
    }
    int res = do_auth_check_phone (default_username);
    assert (res >= 0);
    if (res > 0 && !register_mode) {
      do_send_code (default_username);
      struct wait_get_auth_code auth_code;
      while (1) {
        if (waitAndGet( WAIT_AND_GET_AUTH_CODE, &auth_code ) == -1)
          qthreadExitRequest (EXIT_FAILURE);
        if (auth_code.request_phone == 1) {
          do_phone_call (default_username);
          continue;
        }
        if (do_send_code_result (auth_code.code) >= 0) {
          break;
        }
        registeringInvalidCode();
      }
      auth_state = 300;
    } else {
      struct wait_get_user_details user_details;
      if (waitAndGet(WAIT_AND_GET_USER_DETAILS, &user_details) == -1)
        qthreadExitRequest (EXIT_FAILURE);

      int dc_num = do_get_nearest_dc ();
      assert (dc_num >= 0 && dc_num <= MAX_DC_NUM && DC_list[dc_num]);
      dc_working_num = dc_num;
      DC_working = DC_list[dc_working_num];

      do_send_code (default_username);
      struct wait_get_auth_code auth_code;
      while (1) {
        if (waitAndGet( WAIT_AND_GET_AUTH_CODE, &auth_code ) == -1)
          qthreadExitRequest (EXIT_FAILURE);
        if (auth_code.request_phone == 1) {
          do_phone_call (default_username);
          continue;
        }
        if (do_send_code_result_auth (auth_code.code, user_details.firstname, user_details.lastname) >= 0) {
          break;
        }
        registeringInvalidCode();
      }
      auth_state = 300;
    }

    return 0;
}
Esempio n. 2
0
GLuint Query::waitAndGet(const std::chrono::duration<int, std::nano> & timeout, const GLenum pname) const
{
    return waitAndGet(pname, timeout);
}