Logo Search packages:      
Sourcecode: yapet version File versions  Download package

void PasswordRecord::run (  )  throw (YAPETUI::UIException)

Shows the dialog and handles user input.

Shows the dialog and handles user input.

Call getEncEntry() for obtaining the encrypted password record.

Definition at line 104 of file passwordrecord.cc.

References YAPET::PasswordRecord::comment, YAPET::COMMENT_SIZE, entryChanged(), YAPETUI::Button::focus(), YAPETUI::InputWidget::focus(), YAPETUI::InputWidget::getText(), YAPET::PasswordRecord::host, YAPET::HOST_SIZE, KEY_ESC, YAPET::PasswordRecord::name, YAPET::NAME_SIZE, YAPET::PasswordRecord::password, YAPET::PASSWORD_SIZE, YAPETUI::BaseWindow::resizeAll(), YAPETUI::MessageBox::run(), YAPET::PasswordRecord::username, YAPET::USERNAME_SIZE, and YAPET::YAPETException::what().

                                              {
    while (true) {
      int ch = 0;
#ifdef HAVE_WRESIZE
      while ( (ch = name->focus()) == KEY_RESIZE)
          YAPETUI::BaseWindow::resizeAll();
#else // HAVE_WRESIZE
      ch = name->focus();
#endif // HAVE_WRESIZE
      if (ch == KEY_ESC) {
          encentry = NULL;
          return;
      }

#ifdef HAVE_WRESIZE
      while ( (ch = host->focus()) == KEY_RESIZE)
          YAPETUI::BaseWindow::resizeAll();
#else // HAVE_WRESIZE
      ch = host->focus();
#endif // HAVE_WRESIZE
      if (ch == KEY_ESC) {
          encentry = NULL;
          return;
      }


#ifdef HAVE_WRESIZE
      while ( (ch = username->focus()) == KEY_RESIZE)
          YAPETUI::BaseWindow::resizeAll();
#else // HAVE_WRESIZE
      ch = username->focus();
#endif // HAVE_WRESIZE
      if (ch == KEY_ESC) {
          encentry = NULL;
          return;
      }


#ifdef HAVE_WRESIZE
      while ( (ch = password->focus()) == KEY_RESIZE)
          YAPETUI::BaseWindow::resizeAll();
#else // HAVE_WRESIZE
      ch = password->focus();
#endif // HAVE_WRESIZE
      if (ch == KEY_ESC) {
          encentry = NULL;
          return;
      }


#ifdef HAVE_WRESIZE
      while ( (ch = comment->focus()) == KEY_RESIZE)
          YAPETUI::BaseWindow::resizeAll();
#else // HAVE_WRESIZE
      ch = comment->focus();
#endif // HAVE_WRESIZE
      if (ch == KEY_ESC) {
          encentry = NULL;
          return;
      }


#ifdef HAVE_WRESIZE
      while ( (ch = okbutton->focus()) == KEY_RESIZE)
          YAPETUI::BaseWindow::resizeAll();
#else // HAVE_WRESIZE
      ch = okbutton->focus();
#endif // HAVE_WRESIZE
      if (ch == KEY_ESC) {
          encentry = NULL;
          return;
      }

      if (ch == '\n') {
          if (!entryChanged()) {
            encentry = NULL;
            return;
          }

          YAPET::Record<YAPET::PasswordRecord> unenc_rec;
          YAPET::PasswordRecord* ptr_rec = unenc_rec;
          strncpy((char*)ptr_rec->name, name->getText().c_str(), YAPET::NAME_SIZE);
          strncpy((char*)ptr_rec->host, host->getText().c_str(), YAPET::HOST_SIZE);
          strncpy((char*)ptr_rec->username, username->getText().c_str(), YAPET::USERNAME_SIZE);
          strncpy((char*)ptr_rec->password, password->getText().c_str(), YAPET::PASSWORD_SIZE);
          strncpy((char*)ptr_rec->comment, comment->getText().c_str(), YAPET::COMMENT_SIZE);

          YAPET::BDBuffer* enc_rec = NULL;
          try {
            encentry = new YAPET::PartDec(unenc_rec, *key);
          } catch (YAPET::YAPETException& ex) {
            if (enc_rec != NULL)
                delete enc_rec;
            encentry = NULL;

            YAPETUI::MessageBox* msgbox = NULL;
            try {
                msgbox = new YAPETUI::MessageBox(_("E R R O R"), ex.what());
                msgbox->run();
                delete msgbox;
            } catch (YAPETUI::UIException&) {
                if (msgbox != NULL)
                  delete msgbox;
                // What should I do else, looks pretty screwed up??
            }
          }
          return;
      }

#ifdef HAVE_WRESIZE
      while ( (ch = cancelbutton->focus()) == KEY_RESIZE)
          YAPETUI::BaseWindow::resizeAll();
#else // HAVE_WRESIZE
      ch = cancelbutton->focus();
#endif // HAVE_WRESIZE
      if (ch == '\n' || ch == KEY_ESC) {
          encentry = NULL;
          return;
      }
    }
}


Generated by  Doxygen 1.6.0   Back to index