mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Source code maintenance
Memory leaks: - NetworkDialog::loadcert -> new QFileDialog - NetworkDialog::insertConnect -> takeTopLevelItem - NetworkDialog::on_actionAddFriend_activated -> new QFileDialog - main -> new StartDialog, new GenCertDialog to be continued Info: Pointer from takeTopLevelItem must be deleted Can someone convert the StartDialog from QMainWindow to QDialog ? git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@2833 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
8957fb919c
commit
8ce338c49c
@ -148,7 +148,7 @@ void GenCertDialog::genPerson()
|
||||
if (!genNewGPGKey) {
|
||||
if (ui.location_input->text().length() < 3) {
|
||||
/* Message Dialog */
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
QMessageBox::warning ( NULL,
|
||||
tr("Generate GPG key Failure"),
|
||||
tr("Location field is required with a minimum of 3 characters"),
|
||||
QMessageBox::Ok);
|
||||
@ -158,7 +158,7 @@ void GenCertDialog::genPerson()
|
||||
if (pgpidx < 0)
|
||||
{
|
||||
/* Message Dialog */
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
QMessageBox::warning ( NULL,
|
||||
"Generate ID Failure",
|
||||
"Missing PGP Certificate",
|
||||
QMessageBox::Ok);
|
||||
@ -170,7 +170,7 @@ void GenCertDialog::genPerson()
|
||||
if (ui.password_input->text().length() < 3 || ui.name_input->text().length() < 3
|
||||
|| ui.email_input->text().length() < 3 || ui.location_label->text().length() < 3) {
|
||||
/* Message Dialog */
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
QMessageBox::warning ( NULL,
|
||||
tr("Generate GPG key Failure"),
|
||||
tr("All fields are required with a minimum of 3 characters"),
|
||||
QMessageBox::Ok);
|
||||
@ -245,7 +245,7 @@ void GenCertDialog::genPerson()
|
||||
else
|
||||
{
|
||||
/* Message Dialog */
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
QMessageBox::warning ( NULL,
|
||||
"Generate ID Failure",
|
||||
"Failed to Generate your new Certificate, maybe PGP password is wrong !",
|
||||
QMessageBox::Ok);
|
||||
@ -312,7 +312,7 @@ void GenCertDialog::loadCertificates()
|
||||
else
|
||||
{
|
||||
/* some error msg */
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
QMessageBox::warning ( NULL,
|
||||
"Generate ID Failure",
|
||||
"Failed to Load your new Certificate!",
|
||||
QMessageBox::Ok);
|
||||
@ -321,6 +321,6 @@ void GenCertDialog::loadCertificates()
|
||||
|
||||
void GenCertDialog::infodlg()
|
||||
{
|
||||
static InfoDialog *infodialog = new InfoDialog();
|
||||
infodialog->show();
|
||||
InfoDialog infodialog (this);
|
||||
infodialog.exec ();
|
||||
}
|
||||
|
@ -75,8 +75,7 @@ RsCertId getNeighRsCertId(QTreeWidgetItem *i);
|
||||
|
||||
/** Constructor */
|
||||
NetworkDialog::NetworkDialog(QWidget *parent)
|
||||
: RsAutoUpdatePage(10000,parent), // updates every 10 sec.
|
||||
connectdialog(NULL)
|
||||
: RsAutoUpdatePage(10000,parent) // updates every 10 sec.
|
||||
{
|
||||
/* Invoke the Qt Designer generated object setup routine */
|
||||
ui.setupUi(this);
|
||||
@ -89,9 +88,6 @@ NetworkDialog::NetworkDialog(QWidget *parent)
|
||||
connect( ui.unvalidGPGkeyWidget, SIGNAL( customContextMenuRequested( QPoint ) ), this, SLOT( connecttreeWidgetCostumPopupMenu( QPoint ) ) );
|
||||
connect( ui.unvalidGPGkeyWidget, SIGNAL( itemSelectionChanged()), ui.connecttreeWidget, SLOT( clearSelection() ) );
|
||||
|
||||
/* create a single connect dialog */
|
||||
connectdialog = new ConnectDialog();
|
||||
|
||||
connect(ui.infoLog, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayInfoLogMenu(const QPoint&)));
|
||||
|
||||
connect(ui.showUnvalidKeys, SIGNAL(clicked()), this, SLOT(insertConnect()));
|
||||
@ -210,8 +206,6 @@ void NetworkDialog::connecttreeWidgetCostumPopupMenu( QPoint point )
|
||||
if (!wi)
|
||||
return;
|
||||
|
||||
// return ;
|
||||
|
||||
QMenu contextMnu( this );
|
||||
QMouseEvent *mevent = new QMouseEvent( QEvent::MouseButtonPress, point, Qt::RightButton, Qt::RightButton, Qt::NoModifier );
|
||||
contextMnu.clear();
|
||||
@ -298,34 +292,21 @@ void NetworkDialog::peerdetails()
|
||||
ConfCertDialog::show(getCurrentNeighbour()->text(4).toStdString());
|
||||
}
|
||||
|
||||
/** Shows Peer Information/Auth Dialog */
|
||||
void NetworkDialog::showpeerdetails(std::string id)
|
||||
{
|
||||
#ifdef NET_DEBUG
|
||||
std::cerr << "NetworkDialog::showpeerdetails()" << std::endl;
|
||||
#endif
|
||||
if ((connectdialog) && (connectdialog -> loadPeer(id)))
|
||||
{
|
||||
connectdialog->show();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Open a QFileDialog to browse for a pem/pqi file. */
|
||||
void NetworkDialog::loadcert()
|
||||
{
|
||||
/* Create a new input dialog, which allows users to create files, too */
|
||||
QFileDialog *dialog = new QFileDialog(this, tr("Select a pem/pqi File"));
|
||||
//dialog->setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
|
||||
//dialog->selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
|
||||
dialog->setFileMode(QFileDialog::AnyFile);
|
||||
dialog->setReadOnly(false);
|
||||
QFileDialog dialog (this, tr("Select a pem/pqi File"));
|
||||
//dialog.setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
|
||||
//dialog.selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
dialog.setReadOnly(false);
|
||||
|
||||
/* Prompt the user to select a file or create a new one */
|
||||
if (!dialog->exec() || dialog->selectedFiles().isEmpty()) {
|
||||
if (!dialog.exec() || dialog.selectedFiles().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QString filename = QDir::convertSeparators(dialog->selectedFiles().at(0));
|
||||
QString filename = QDir::convertSeparators(dialog.selectedFiles().at(0));
|
||||
|
||||
/* Check if the file exists */
|
||||
QFile torrcFile(filename);
|
||||
@ -383,8 +364,8 @@ void NetworkDialog::insertConnect()
|
||||
while (index < connectWidget->topLevelItemCount()) {
|
||||
std::string gpg_widget_id = (connectWidget->topLevelItem(index))->text(4).toStdString();
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl < 3) {
|
||||
connectWidget->takeTopLevelItem(index);
|
||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || (detail.validLvl < 3 && !detail.accept_connection)) {
|
||||
delete connectWidget->takeTopLevelItem(index);
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
@ -393,8 +374,8 @@ void NetworkDialog::insertConnect()
|
||||
while (index < ui.unvalidGPGkeyWidget->topLevelItemCount()) {
|
||||
std::string gpg_widget_id = (ui.unvalidGPGkeyWidget->topLevelItem(index))->text(4).toStdString();
|
||||
RsPeerDetails detail;
|
||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= 3) {
|
||||
ui.unvalidGPGkeyWidget->takeTopLevelItem(index);
|
||||
if (!rsPeers->getGPGDetails(gpg_widget_id, detail) || detail.validLvl >= 3 || detail.accept_connection) {
|
||||
delete ui.unvalidGPGkeyWidget->takeTopLevelItem(index);
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
@ -586,7 +567,7 @@ std::string NetworkDialog::loadneighbour()
|
||||
|
||||
void NetworkDialog::addneighbour()
|
||||
{
|
||||
QTreeWidgetItem *c = getCurrentNeighbour();
|
||||
// QTreeWidgetItem *c = getCurrentNeighbour();
|
||||
#ifdef NET_DEBUG
|
||||
std::cerr << "NetworkDialog::addneighbour()" << std::endl;
|
||||
#endif
|
||||
@ -597,7 +578,7 @@ void NetworkDialog::addneighbour()
|
||||
|
||||
void NetworkDialog::authneighbour()
|
||||
{
|
||||
QTreeWidgetItem *c = getCurrentNeighbour();
|
||||
// QTreeWidgetItem *c = getCurrentNeighbour();
|
||||
#ifdef NET_DEBUG
|
||||
std::cerr << "NetworkDialog::authneighbour()" << std::endl;
|
||||
#endif
|
||||
@ -611,17 +592,17 @@ void NetworkDialog::authneighbour()
|
||||
void NetworkDialog::on_actionAddFriend_activated()
|
||||
{
|
||||
/* Create a new input dialog, which allows users to create files, too */
|
||||
QFileDialog *dialog = new QFileDialog(this, tr("Select a pem/pqi File"));
|
||||
//dialog->setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
|
||||
//dialog->selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
|
||||
dialog->setFileMode(QFileDialog::AnyFile);
|
||||
dialog->setReadOnly(false);
|
||||
QFileDialog dialog (this, tr("Select a pem/pqi File"));
|
||||
//dialog.setDirectory(QFileInfo(ui.lineTorConfig->text()).absoluteDir());
|
||||
//dialog.selectFile(QFileInfo(ui.lineTorConfig->text()).fileName());
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
dialog.setReadOnly(false);
|
||||
|
||||
/* Prompt the user to select a file or create a new one */
|
||||
if (!dialog->exec() || dialog->selectedFiles().isEmpty()) {
|
||||
if (!dialog.exec() || dialog.selectedFiles().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QString filename = QDir::convertSeparators(dialog->selectedFiles().at(0));
|
||||
QString filename = QDir::convertSeparators(dialog.selectedFiles().at(0));
|
||||
|
||||
/* Check if the file exists */
|
||||
QFile torrcFile(filename);
|
||||
@ -692,10 +673,8 @@ void NetworkDialog::on_actionClearLog_triggered() {
|
||||
|
||||
void NetworkDialog::on_actionCreate_New_Profile_activated()
|
||||
{
|
||||
static GenCertDialog *gencertdialog = new GenCertDialog();
|
||||
gencertdialog->show();
|
||||
|
||||
|
||||
// GenCertDialog gencertdialog (this);
|
||||
// gencertdialog.exec ();
|
||||
}
|
||||
|
||||
void NetworkDialog::displayInfoLogMenu(const QPoint& pos) {
|
||||
|
@ -44,8 +44,6 @@ public:
|
||||
NetworkDialog(QWidget *parent = 0);
|
||||
/** Default Destructor */
|
||||
|
||||
void showpeerdetails(std::string id);
|
||||
|
||||
//void load();
|
||||
virtual void updateDisplay() ; // overloaded from RsAutoUpdatePage
|
||||
|
||||
@ -113,9 +111,6 @@ private:
|
||||
QAction* loadcertAct;
|
||||
QAction* exportcertAct;
|
||||
|
||||
/* connection dialog */
|
||||
ConnectDialog *connectdialog;
|
||||
|
||||
QTreeWidget *connecttreeWidget;
|
||||
|
||||
class NetworkView *networkview;
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "profile/ProfileWidget.h"
|
||||
#include "profile/StatusMessage.h"
|
||||
|
||||
#include "GenCertDialog.h"
|
||||
#include "gui/connect/ConnectFriendWizard.h"
|
||||
#include "gui/forums/CreateForum.h"
|
||||
#include "gui/channels/CreateChannel.h"
|
||||
|
@ -22,7 +22,6 @@
|
||||
#include <rshare.h>
|
||||
#include <rsiface/rsinit.h>
|
||||
#include "StartDialog.h"
|
||||
#include "GenCertDialog.h"
|
||||
#include "InfoDialog.h"
|
||||
#include "LogoBar.h"
|
||||
#include <QFileDialog>
|
||||
@ -132,7 +131,7 @@ void StartDialog::loadPerson()
|
||||
if (pgpidx < 0)
|
||||
{
|
||||
/* Message Dialog */
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
QMessageBox::warning ( NULL,
|
||||
"Load Person Failure",
|
||||
"Missing PGP Certificate",
|
||||
QMessageBox::Ok);
|
||||
@ -164,7 +163,7 @@ void StartDialog::loadCertificates()
|
||||
else
|
||||
{
|
||||
/* some error msg */
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
QMessageBox::warning ( NULL,
|
||||
tr("Login Failure"),
|
||||
tr("Maybe password is wrong"),
|
||||
QMessageBox::Ok);
|
||||
@ -175,15 +174,12 @@ void StartDialog::loadCertificates()
|
||||
|
||||
void StartDialog::on_labelProfile_linkActivated(QString link)
|
||||
{
|
||||
//static GenCertDialog *gencertdialog = new GenCertDialog();
|
||||
//gencertdialog->show();
|
||||
|
||||
QMessageBox::StandardButton sb = QMessageBox::question ( NULL,
|
||||
tr("Create a New Profile"),
|
||||
tr("This will generate a new Profile\n Are you sure you want to continue"),
|
||||
(QMessageBox::Ok | QMessageBox::No));
|
||||
(QMessageBox::Yes | QMessageBox::No));
|
||||
|
||||
if (sb == QMessageBox::Ok)
|
||||
if (sb == QMessageBox::Yes)
|
||||
{
|
||||
reqNewCert = true;
|
||||
close();
|
||||
@ -192,8 +188,8 @@ void StartDialog::on_labelProfile_linkActivated(QString link)
|
||||
|
||||
void StartDialog::on_labelInfo_linkActivated(QString link)
|
||||
{
|
||||
static InfoDialog *infodialog = new InfoDialog();
|
||||
infodialog->show();
|
||||
InfoDialog infodialog (this);
|
||||
infodialog.exec ();
|
||||
}
|
||||
|
||||
bool StartDialog::requestedNewCert()
|
||||
@ -209,7 +205,7 @@ void StartDialog::notSecureWarning() {
|
||||
|
||||
/* some error msg */
|
||||
if(ui.autologin_checkbox->isChecked()){
|
||||
QMessageBox::StandardButton sb = QMessageBox::warning ( NULL,
|
||||
QMessageBox::warning ( NULL,
|
||||
tr("Insecure"),
|
||||
tr("Auto Login is not so much secure:\n - Your SSL certificate will be stored unprotected. \n - Your PGP key will however not be stored.\nThis choice be reverted in settings."),
|
||||
QMessageBox::Ok);
|
||||
|
@ -91,6 +91,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* if we're logged in */
|
||||
genCert = sd->requestedNewCert();
|
||||
delete (sd);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -99,19 +100,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (genCert)
|
||||
{
|
||||
GenCertDialog *gd = new GenCertDialog();
|
||||
|
||||
gd->show();
|
||||
|
||||
while(gd -> isVisible())
|
||||
{
|
||||
rshare.processEvents();
|
||||
#ifdef WIN32
|
||||
Sleep(10);
|
||||
#else // __LINUX__
|
||||
usleep(10000);
|
||||
#endif
|
||||
}
|
||||
GenCertDialog gd;
|
||||
gd.exec ();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user