userdatarequest.ui.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /****************************************************************************
  2. ** ui.h extension file, included from the uic-generated form implementation.
  3. **
  4. ** If you want to add, delete, or rename functions or slots, use
  5. ** Qt Designer to update this file, preserving your code.
  6. **
  7. ** You should not define a constructor or destructor in this file.
  8. ** Instead, write your code in functions called init() and destroy().
  9. ** These will automatically be called by the form's constructor and
  10. ** destructor.
  11. *****************************************************************************/
  12. int UserDataRequest::setParams(WpaGui *_wpagui, const char *reqMsg)
  13. {
  14. char *tmp, *pos, *pos2;
  15. wpagui = _wpagui;
  16. tmp = strdup(reqMsg);
  17. if (tmp == NULL)
  18. return -1;
  19. pos = strchr(tmp, '-');
  20. if (pos == NULL) {
  21. free(tmp);
  22. return -1;
  23. }
  24. *pos++ = '\0';
  25. field = tmp;
  26. pos2 = strchr(pos, ':');
  27. if (pos2 == NULL) {
  28. free(tmp);
  29. return -1;
  30. }
  31. *pos2++ = '\0';
  32. networkid = atoi(pos);
  33. queryInfo->setText(pos2);
  34. if (strcmp(tmp, "PASSWORD") == 0) {
  35. queryField->setText("Password: ");
  36. queryEdit->setEchoMode(QLineEdit::Password);
  37. } else if (strcmp(tmp, "NEW_PASSWORD") == 0) {
  38. queryField->setText("New password: ");
  39. queryEdit->setEchoMode(QLineEdit::Password);
  40. } else if (strcmp(tmp, "IDENTITY") == 0)
  41. queryField->setText("Identity: ");
  42. else if (strcmp(tmp, "PASSPHRASE") == 0) {
  43. queryField->setText("Private key passphrase: ");
  44. queryEdit->setEchoMode(QLineEdit::Password);
  45. } else
  46. queryField->setText(field + ":");
  47. free(tmp);
  48. return 0;
  49. }
  50. void UserDataRequest::sendReply()
  51. {
  52. char reply[10];
  53. size_t reply_len = sizeof(reply);
  54. if (wpagui == NULL) {
  55. reject();
  56. return;
  57. }
  58. QString cmd = QString(WPA_CTRL_RSP) + field + '-' +
  59. QString::number(networkid) + ':' +
  60. queryEdit->text();
  61. wpagui->ctrlRequest(cmd.ascii(), reply, &reply_len);
  62. accept();
  63. }