void UIServer::showSSLInfoDialog(const QString &url, const KIO::MetaData &meta, int mainwindow) { KSSLInfoDlg *kid = new KSSLInfoDlg(meta["ssl_in_use"].upper() == "TRUE", 0L /*parent?*/, 0L, true); KSSLCertificate *x = KSSLCertificate::fromString(meta["ssl_peer_certificate"].local8Bit()); if(x) { // Set the chain back onto the certificate QStringList cl = QStringList::split(QString("\n"), meta["ssl_peer_chain"]); QPtrList< KSSLCertificate > ncl; ncl.setAutoDelete(true); for(QStringList::Iterator it = cl.begin(); it != cl.end(); ++it) { KSSLCertificate *y = KSSLCertificate::fromString((*it).local8Bit()); if(y) ncl.append(y); } if(ncl.count() > 0) x->chain().setChain(ncl); kdDebug(7024) << "ssl_cert_errors=" << meta["ssl_cert_errors"] << endl; kid->setCertState(meta["ssl_cert_errors"]); QString ip = meta.contains("ssl_proxied") ? "" : meta["ssl_peer_ip"]; kid->setup(x, ip, url, // the URL meta["ssl_cipher"], meta["ssl_cipher_desc"], meta["ssl_cipher_version"], meta["ssl_cipher_used_bits"].toInt(), meta["ssl_cipher_bits"].toInt(), KSSLCertificate::KSSLValidation(meta["ssl_cert_state"].toInt())); kdDebug(7024) << "Showing SSL Info dialog" << endl; if(mainwindow != 0) KWin::setMainWindow(kid, mainwindow); kid->exec(); delete x; kdDebug(7024) << "SSL Info dialog closed" << endl; } else { KMessageBox::information(0L, // parent ? i18n("The peer SSL certificate appears to be corrupt."), i18n("SSL")); } // Don't delete kid!! }
int Observer::messageBox(int progressId, int type, const QString &text, const QString &caption, const QString &buttonYes, const QString &buttonNo, const QString &dontAskAgainName) { kdDebug() << "Observer::messageBox " << type << " " << text << " - " << caption << endl; int result = -1; KConfig *config = new KConfig("kioslaverc"); KMessageBox::setDontShowAskAgainConfig(config); switch(type) { case KIO::SlaveBase::QuestionYesNo: result = KMessageBox::questionYesNo(0L, // parent ? text, caption, buttonYes, buttonNo, dontAskAgainName); break; case KIO::SlaveBase::WarningYesNo: result = KMessageBox::warningYesNo(0L, // parent ? text, caption, buttonYes, buttonNo, dontAskAgainName); break; case KIO::SlaveBase::WarningContinueCancel: result = KMessageBox::warningContinueCancel(0L, // parent ? text, caption, buttonYes, dontAskAgainName); break; case KIO::SlaveBase::WarningYesNoCancel: result = KMessageBox::warningYesNoCancel(0L, // parent ? text, caption, buttonYes, buttonNo, dontAskAgainName); break; case KIO::SlaveBase::Information: KMessageBox::information(0L, // parent ? text, caption, dontAskAgainName); result = 1; // whatever break; case KIO::SlaveBase::SSLMessageBox: { QCString observerAppId = caption.utf8(); // hack, see slaveinterface.cpp // Contact the object "KIO::Observer" in the application <appId> // Yes, this could be the same application we are, but not necessarily. Observer_stub observer(observerAppId, "KIO::Observer"); KIO::MetaData meta = observer.metadata(progressId); KSSLInfoDlg *kid = new KSSLInfoDlg(meta["ssl_in_use"].upper() == "TRUE", 0L /*parent?*/, 0L, true); KSSLCertificate *x = KSSLCertificate::fromString(meta["ssl_peer_certificate"].local8Bit()); if(x) { // Set the chain back onto the certificate QStringList cl = QStringList::split(QString("\n"), meta["ssl_peer_chain"]); QPtrList< KSSLCertificate > ncl; ncl.setAutoDelete(true); for(QStringList::Iterator it = cl.begin(); it != cl.end(); ++it) { KSSLCertificate *y = KSSLCertificate::fromString((*it).local8Bit()); if(y) ncl.append(y); } if(ncl.count() > 0) x->chain().setChain(ncl); kid->setup(x, meta["ssl_peer_ip"], text, // the URL meta["ssl_cipher"], meta["ssl_cipher_desc"], meta["ssl_cipher_version"], meta["ssl_cipher_used_bits"].toInt(), meta["ssl_cipher_bits"].toInt(), KSSLCertificate::KSSLValidation(meta["ssl_cert_state"].toInt())); kdDebug(7024) << "Showing SSL Info dialog" << endl; kid->exec(); delete x; kdDebug(7024) << "SSL Info dialog closed" << endl; } else { KMessageBox::information(0L, // parent ? i18n("The peer SSL certificate appears to be corrupt."), i18n("SSL")); } // This doesn't have to get deleted. It deletes on it's own. result = 1; // whatever break; } default: kdWarning() << "Observer::messageBox: unknown type " << type << endl; result = 0; break; } KMessageBox::setDontShowAskAgainConfig(0); delete config; return result; #if 0 QByteArray data, replyData; QCString replyType; QDataStream arg( data, IO_WriteOnly ); arg << progressId; arg << type; arg << text; arg << caption; arg << buttonYes; arg << buttonNo; if ( kapp->dcopClient()->call( "kio_uiserver", "UIServer", "messageBox(int,int,QString,QString,QString,QString)", data, replyType, replyData, true ) && replyType == "int" ) { int result; QDataStream _reply_stream( replyData, IO_ReadOnly ); _reply_stream >> result; kdDebug(KDEBUG_OBSERVER) << "Observer::messageBox got result " << result << endl; return result; }