/** Shows Peer Information/Auth Dialog */ void NetworkDialog::peerdetails() { QTreeWidgetItem* item = getCurrentNeighbour(); if (item == NULL) { return; } PGPKeyDialog::showIt(RsPgpId(item->text(COLUMN_PEERID).toStdString()), PGPKeyDialog::PageDetails); }
void Chatserver::loadChatServerStore(const std::string filename) { std::ifstream ifs(filename); std::string line; while (!ifs.eof()) { getline(ifs, line); std::cout << "reading |" << line << "|" << ", length " << line.length() << std::endl; if (line.length() == 16) friends.push_back(RsPgpId(line)); }; ifs.close(); }
void NetworkDialog::makeFriend() { PGPKeyDialog::showIt(RsPgpId(getCurrentNeighbour()->text(COLUMN_PEERID).toStdString()), PGPKeyDialog::PageDetails); }
void GenCertDialog::genPerson() { /* Check the data from the GUI. */ std::string genLoc = ui.node_input->text().toUtf8().constData(); RsPgpId PGPId; bool isHiddenLoc = false; if (ui.hidden_checkbox->isChecked()) { std::string hl = ui.hiddenaddr_input->text().toStdString(); uint16_t port = ui.hiddenport_spinBox->value(); if (!RsInit::SetHiddenLocation(hl, port)) /* parses it */ { /* Message Dialog */ QMessageBox::warning(this, tr("Invalid hidden node"), tr("Please enter a valid address of the form: 31769173498.onion:7800"), QMessageBox::Ok); return; } isHiddenLoc = true; } if (!genNewGPGKey) { if (genLoc.length() < 3) { /* Message Dialog */ QMessageBox::warning(this, tr("Generate PGP key failure"), tr("Node field is required with a minimum of 3 characters"), QMessageBox::Ok); return; } int pgpidx = ui.genPGPuser->currentIndex(); if (pgpidx < 0) { /* Message Dialog */ QMessageBox::warning(this, "Generate ID failure", "Missing PGP certificate", QMessageBox::Ok); return; } QVariant data = ui.genPGPuser->itemData(pgpidx); PGPId = RsPgpId((data.toString()).toStdString()); } else { if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3 || genLoc.length() < 3) { /* Message Dialog */ QMessageBox::warning(this, tr("Generate PGP key failure"), tr("All fields are required with a minimum of 3 characters"), QMessageBox::Ok); return; } if(ui.password_input->text() != ui.password_input_2->text()) { QMessageBox::warning(this, tr("Generate PGP key failure"), tr("Passwords do not match"), QMessageBox::Ok); return; } //generate a new gpg key std::string err_string; ui.no_gpg_key_label->setText(tr("Generating new PGP key, please be patient: this process needs generating large prime numbers, and can take some minutes on slow computers. \n\nFill in your PGP password when asked, to sign your new key.")); ui.no_gpg_key_label->show(); ui.new_gpg_key_checkbox->hide(); ui.name_label->hide(); ui.name_input->hide(); // ui.email_label->hide(); // ui.email_input->hide(); ui.password_label_2->hide(); ui.password_input_2->hide(); ui.password_label->hide(); ui.password_input->hide(); ui.genPGPuserlabel->hide(); ui.genPGPuser->hide(); ui.node_label->hide(); ui.node_input->hide(); ui.genButton2->hide(); ui.importIdentity_PB->hide(); ui.genprofileinfo_label->hide(); ui.hidden_checkbox->hide(); ui.adv_checkbox->hide(); ui.keylength_label->hide(); ui.keylength_comboBox->hide(); setCursor(Qt::WaitCursor) ; QCoreApplication::processEvents(); while(QAbstractEventDispatcher::instance()->processEvents(QEventLoop::AllEvents)) ; std::string email_str = "" ; RsAccounts::GeneratePGPCertificate( ui.name_input->text().toUtf8().constData(), email_str.c_str(), ui.password_input->text().toUtf8().constData(), PGPId, ui.keylength_comboBox->itemData(ui.keylength_comboBox->currentIndex()).toInt(), err_string); setCursor(Qt::ArrowCursor) ; } //generate a random ssl password std::string sslPasswd = RSRandom::random_alphaNumericString(RsInit::getSslPwdLen()) ; /* GenerateSSLCertificate - selects the PGP Account */ //RsInit::SelectGPGAccount(PGPId); RsPeerId sslId; std::cerr << "GenCertDialog::genPerson() Generating SSL cert with gpg id : " << PGPId << std::endl; std::string err; bool okGen = RsAccounts::GenerateSSLCertificate(PGPId, "", genLoc, "", isHiddenLoc, sslPasswd, sslId, err); if (okGen) { /* complete the process */ RsInit::LoadPassword(sslPasswd); if (Rshare::loadCertificate(sslId, false)) { accept(); } } else { /* Message Dialog */ QMessageBox::warning(this, tr("Generate ID failure"), tr("Failed to generate your new certificate, maybe PGP password is wrong!"), QMessageBox::Ok); reject(); } }
void NotifyQt::UpdateGUI() { if(RsAutoUpdatePage::eventsLocked()) return ; { QMutexLocker m(&_mutex) ; if(!_enabled) return ; } static bool already_updated = false ; // these only update once at start because they may already have been set before // the gui is running, then they get updated by callbacks. if(!already_updated) { emit messagesChanged() ; emit neighboursChanged(); emit configChanged(); already_updated = true ; } /* Finally Check for PopupMessages / System Error Messages */ if (rsNotify) { uint32_t sysid; uint32_t type; std::string title, id, msg; /* You can set timeToShow, timeToLive and timeToHide or can leave the standard */ ToasterItem *toaster = NULL; if (rsNotify->NotifyPopupMessage(type, id, title, msg)) { uint popupflags = Settings->getNotifyFlags(); switch(type) { case RS_POPUP_ENCRYPTED_MSG: SoundManager::play(SOUND_MESSAGE_ARRIVED); if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) { toaster = new ToasterItem(new MessageToaster("", tr("Encrypted message"), QString("[%1]").arg(tr("Encrypted message")))); } break; case RS_POPUP_MSG: SoundManager::play(SOUND_MESSAGE_ARRIVED); if ((popupflags & RS_POPUP_MSG) && !_disableAllToaster) { toaster = new ToasterItem(new MessageToaster(id, QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str()))); } break; case RS_POPUP_CONNECT: SoundManager::play(SOUND_USER_ONLINE); if ((popupflags & RS_POPUP_CONNECT) && !_disableAllToaster) { toaster = new ToasterItem(new OnlineToaster(RsPeerId(id))); } break; case RS_POPUP_DOWNLOAD: SoundManager::play(SOUND_DOWNLOAD_COMPLETE); if ((popupflags & RS_POPUP_DOWNLOAD) && !_disableAllToaster) { /* id = file hash */ toaster = new ToasterItem(new DownloadToaster(RsFileHash(id), QString::fromUtf8(title.c_str()))); } break; case RS_POPUP_CHAT: if ((popupflags & RS_POPUP_CHAT) && !_disableAllToaster) { // TODO: fix for distant chat, look up if dstant chat uses RS_POPUP_CHAT ChatDialog *chatDialog = ChatDialog::getChat(ChatId(RsPeerId(id))); ChatWidget *chatWidget; if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { // do not show when active break; } toaster = new ToasterItem(new ChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); } break; case RS_POPUP_GROUPCHAT: if ((popupflags & RS_POPUP_GROUPCHAT) && !_disableAllToaster) { MainWindow *mainWindow = MainWindow::getInstance(); if (mainWindow && mainWindow->isActiveWindow() && !mainWindow->isMinimized()) { if (MainWindow::getActivatePage() == MainWindow::Friends) { if (FriendsDialog::isGroupChatActive()) { // do not show when active break; } } } toaster = new ToasterItem(new GroupChatToaster(RsPeerId(id), QString::fromUtf8(msg.c_str()))); } break; case RS_POPUP_CHATLOBBY: if ((popupflags & RS_POPUP_CHATLOBBY) && !_disableAllToaster) { ChatId chat_id(id); ChatDialog *chatDialog = ChatDialog::getChat(chat_id); ChatWidget *chatWidget; if (chatDialog && (chatWidget = chatDialog->getChatWidget()) && chatWidget->isActive()) { // do not show when active break; } ChatLobbyDialog *chatLobbyDialog = dynamic_cast<ChatLobbyDialog*>(chatDialog); RsGxsId sender(title); if (!chatLobbyDialog || chatLobbyDialog->isParticipantMuted(sender)) break; // participant is muted toaster = new ToasterItem(new ChatLobbyToaster(chat_id.toLobbyId(), sender, QString::fromUtf8(msg.c_str()))); } break; case RS_POPUP_CONNECT_ATTEMPT: if ((popupflags & RS_POPUP_CONNECT_ATTEMPT) && !_disableAllToaster) { // id = gpgid // title = ssl name // msg = peer id toaster = new ToasterItem(new FriendRequestToaster(RsPgpId(id), QString::fromUtf8(title.c_str()), RsPeerId(msg))); } break; } } /*Now check Plugins*/ if (!toaster) { int pluginCount = rsPlugins->nbPlugins(); for (int i = 0; i < pluginCount; ++i) { RsPlugin *rsPlugin = rsPlugins->plugin(i); if (rsPlugin) { ToasterNotify *toasterNotify = rsPlugin->qt_toasterNotify(); if (toasterNotify) { toaster = toasterNotify->toasterItem(); continue; } } } } if (toaster) { /* init attributes */ toaster->widget->setWindowFlags(Qt::ToolTip | Qt::WindowStaysOnTopHint); /* add toaster to waiting list */ //QMutexLocker lock(&waitingToasterMutex); waitingToasterList.push_back(toaster); } if (rsNotify->NotifySysMessage(sysid, type, title, msg)) { /* make a warning message */ switch(type) { case RS_SYS_ERROR: QMessageBox::critical(MainWindow::getInstance(), QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())); break; case RS_SYS_WARNING: QMessageBox::warning(MainWindow::getInstance(), QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())); break; default: case RS_SYS_INFO: QMessageBox::information(MainWindow::getInstance(), QString::fromUtf8(title.c_str()), QString::fromUtf8(msg.c_str())); break; } } if (rsNotify->NotifyLogMessage(sysid, type, title, msg)) { /* make a log message */ std::string logMesString = title + " " + msg; switch(type) { case RS_SYS_ERROR: case RS_SYS_WARNING: case RS_SYS_INFO: emit logInfoChanged(QString::fromUtf8(logMesString.c_str())); } } } /* Now start the waiting toasters */ startWaitingToasters(); }
MessageToaster::MessageToaster(const std::string &peerId, const QString &title, const QString &message) : QWidget(NULL) { /* Invoke the Qt Designer generated object setup routine */ ui.setupUi(this); /* connect buttons */ connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(hide())); //connect(ui.openmessagebtn, SIGNAL(clicked()), this, SLOT(openmessageClicked())); connect(ui.toasterButton, SIGNAL(clicked()), this, SLOT(openmessageClicked())); /* set informations */ ui.subjectLabel->setText(tr("Sub:") + " " + title); ui.subjectLabel->setToolTip(title); ui.textLabel->setText(message); ui.textLabel->setToolTip(message); std::string name = (!RsPeerId(peerId).isNull())? (rsPeers->getPeerName(RsPeerId(peerId))): (rsPeers->getGPGName(RsPgpId(peerId))) ; ui.toasterLabel->setText(ui.toasterLabel->text() + " " + QString::fromUtf8(name.c_str())); }