userdatarequest.ui.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. #include <stdlib.h>
  13. int UserDataRequest::setParams(WpaGui *_wpagui, const char *reqMsg)
  14. {
  15. char *tmp, *pos, *pos2;
  16. wpagui = _wpagui;
  17. tmp = strdup(reqMsg);
  18. if (tmp == NULL)
  19. return -1;
  20. pos = strchr(tmp, '-');
  21. if (pos == NULL) {
  22. free(tmp);
  23. return -1;
  24. }
  25. *pos++ = '\0';
  26. field = tmp;
  27. pos2 = strchr(pos, ':');
  28. if (pos2 == NULL) {
  29. free(tmp);
  30. return -1;
  31. }
  32. *pos2++ = '\0';
  33. networkid = atoi(pos);
  34. queryInfo->setText(pos2);
  35. if (strcmp(tmp, "PASSWORD") == 0) {
  36. queryField->setText("Password: ");
  37. queryEdit->setEchoMode(QLineEdit::Password);
  38. } else if (strcmp(tmp, "NEW_PASSWORD") == 0) {
  39. queryField->setText("New password: ");
  40. queryEdit->setEchoMode(QLineEdit::Password);
  41. } else if (strcmp(tmp, "IDENTITY") == 0)
  42. queryField->setText("Identity: ");
  43. else if (strcmp(tmp, "PASSPHRASE") == 0) {
  44. queryField->setText("Private key passphrase: ");
  45. queryEdit->setEchoMode(QLineEdit::Password);
  46. } else
  47. queryField->setText(field + ":");
  48. free(tmp);
  49. return 0;
  50. }
  51. void UserDataRequest::sendReply()
  52. {
  53. char reply[10];
  54. size_t reply_len = sizeof(reply);
  55. if (wpagui == NULL) {
  56. reject();
  57. return;
  58. }
  59. QString cmd = QString(WPA_CTRL_RSP) + field + '-' +
  60. QString::number(networkid) + ':' +
  61. queryEdit->text();
  62. wpagui->ctrlRequest(cmd.ascii(), reply, &reply_len);
  63. accept();
  64. }