summaryrefslogtreecommitdiffstats
path: root/pica-client/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'pica-client/dialogs')
-rw-r--r--pica-client/dialogs/addaccountdialog.cpp118
-rw-r--r--pica-client/dialogs/addaccountdialog.h34
-rw-r--r--pica-client/dialogs/filetransferdialog.cpp472
-rw-r--r--pica-client/dialogs/filetransferdialog.h117
-rw-r--r--pica-client/dialogs/forgedcertdialog.cpp48
-rw-r--r--pica-client/dialogs/forgedcertdialog.h26
-rw-r--r--pica-client/dialogs/registeraccountdialog.cpp316
-rw-r--r--pica-client/dialogs/registeraccountdialog.h58
-rw-r--r--pica-client/dialogs/settingsdialog.cpp90
-rw-r--r--pica-client/dialogs/settingsdialog.h8
-rw-r--r--pica-client/dialogs/showpicaiddialog.cpp36
-rw-r--r--pica-client/dialogs/showpicaiddialog.h12
-rw-r--r--pica-client/dialogs/viewcertdialog.cpp42
-rw-r--r--pica-client/dialogs/viewcertdialog.h18
14 files changed, 699 insertions, 696 deletions
diff --git a/pica-client/dialogs/addaccountdialog.cpp b/pica-client/dialogs/addaccountdialog.cpp
index 8d31ca4..39c2ef3 100644
--- a/pica-client/dialogs/addaccountdialog.cpp
+++ b/pica-client/dialogs/addaccountdialog.cpp
@@ -8,107 +8,107 @@
#include "../../PICA_client.h"
AddAccountDialog::AddAccountDialog(QWidget *parent) :
- QDialog(parent)
+ QDialog(parent)
{
- QGridLayout *grid = new QGridLayout(this);
+ QGridLayout *grid = new QGridLayout(this);
- QLabel *lb_cert_file = new QLabel(tr("Pica Pica Certificate File:"));
- QLabel *lb_pkey_file = new QLabel(tr("Private Key File:"));
+ QLabel *lb_cert_file = new QLabel(tr("Pica Pica Certificate File:"));
+ QLabel *lb_pkey_file = new QLabel(tr("Private Key File:"));
- btOK = new QPushButton(tr("OK"));
- btCancel = new QPushButton(tr("Cancel"));
+ btOK = new QPushButton(tr("OK"));
+ btCancel = new QPushButton(tr("Cancel"));
- cert_filename = new QLineEdit();
- pkey_filename = new QLineEdit();
+ cert_filename = new QLineEdit();
+ pkey_filename = new QLineEdit();
- bt_browse_cert = new QPushButton("...");
- bt_browse_pkey = new QPushButton("...");
+ bt_browse_cert = new QPushButton("...");
+ bt_browse_pkey = new QPushButton("...");
- rb_copyfiles = new QRadioButton(tr("Copy files to config directory"));
- rb_readinplace = new QRadioButton(tr("Read files from selected place"));
+ rb_copyfiles = new QRadioButton(tr("Copy files to config directory"));
+ rb_readinplace = new QRadioButton(tr("Read files from selected place"));
- grid->addWidget(lb_cert_file,0,0,1,1);
+ grid->addWidget(lb_cert_file, 0, 0, 1, 1);
- grid->addWidget(cert_filename,1,0,1,1);
- grid->addWidget(bt_browse_cert,1,1,1,1);
+ grid->addWidget(cert_filename, 1, 0, 1, 1);
+ grid->addWidget(bt_browse_cert, 1, 1, 1, 1);
- grid->addWidget(lb_pkey_file,2,0,1,1);
+ grid->addWidget(lb_pkey_file, 2, 0, 1, 1);
- grid->addWidget(pkey_filename,3,0,1,1);
- grid->addWidget(bt_browse_pkey,3,1,1,1);
+ grid->addWidget(pkey_filename, 3, 0, 1, 1);
+ grid->addWidget(bt_browse_pkey, 3, 1, 1, 1);
- grid->addWidget(rb_copyfiles,4,0,1,1);
- grid->addWidget(rb_readinplace,5,0,1,1);
+ grid->addWidget(rb_copyfiles, 4, 0, 1, 1);
+ grid->addWidget(rb_readinplace, 5, 0, 1, 1);
- grid->addWidget(btOK,6,0,1,1,Qt::AlignRight);
- grid->addWidget(btCancel,6,1,1,1,Qt::AlignLeft);
- //===========
- rb_copyfiles->setChecked(true);
+ grid->addWidget(btOK, 6, 0, 1, 1, Qt::AlignRight);
+ grid->addWidget(btCancel, 6, 1, 1, 1, Qt::AlignLeft);
+ //===========
+ rb_copyfiles->setChecked(true);
- btOK->setMaximumWidth(90);
- btCancel->setMaximumWidth(90);
+ btOK->setMaximumWidth(90);
+ btCancel->setMaximumWidth(90);
- connect(btOK,SIGNAL(clicked()),this,SLOT(OK()));
- connect(btCancel,SIGNAL(clicked()),this,SLOT(Cancel()));
- connect(bt_browse_cert,SIGNAL(clicked()),this,SLOT(browse_cert()));
- connect(bt_browse_pkey,SIGNAL(clicked()),this,SLOT(browse_pkey()));
+ connect(btOK, SIGNAL(clicked()), this, SLOT(OK()));
+ connect(btCancel, SIGNAL(clicked()), this, SLOT(Cancel()));
+ connect(bt_browse_cert, SIGNAL(clicked()), this, SLOT(browse_cert()));
+ connect(bt_browse_pkey, SIGNAL(clicked()), this, SLOT(browse_pkey()));
- setLayout(grid);
+ setLayout(grid);
}
void AddAccountDialog::OK()
{
- {
- QString s;
- if (!QFile::exists(s=cert_filename->text()) || !QFile::exists(s=pkey_filename->text()) )
- {
- QMessageBox mbx;
- mbx.setText(tr("File %1 does not exist").arg(s));
- mbx.exec();
- return;
- }
-
- QByteArray id(PICA_ID_SIZE, 0);
-
- if (!PICA_get_id_from_cert_file(cert_filename->text().toUtf8().constData(), (unsigned char*)id.data()))
- {
- QMessageBox mbx;
- mbx.setText(tr("Invalid certificate file"));
- mbx.exec();
- return;
- }
- }
-
- done(1);
+ {
+ QString s;
+ if (!QFile::exists(s = cert_filename->text()) || !QFile::exists(s = pkey_filename->text()) )
+ {
+ QMessageBox mbx;
+ mbx.setText(tr("File %1 does not exist").arg(s));
+ mbx.exec();
+ return;
+ }
+
+ QByteArray id(PICA_ID_SIZE, 0);
+
+ if (!PICA_get_id_from_cert_file(cert_filename->text().toUtf8().constData(), (unsigned char*)id.data()))
+ {
+ QMessageBox mbx;
+ mbx.setText(tr("Invalid certificate file"));
+ mbx.exec();
+ return;
+ }
+ }
+
+ done(1);
}
void AddAccountDialog::Cancel()
{
- done(0);
+ done(0);
}
void AddAccountDialog::browse_cert()
{
- cert_filename->setText(QFileDialog::getOpenFileName(this,tr("Select Pica Pica Certificate"),"","PEM file (*.pem)"));
+ cert_filename->setText(QFileDialog::getOpenFileName(this, tr("Select Pica Pica Certificate"), "", "PEM file (*.pem)"));
}
void AddAccountDialog::browse_pkey()
{
- pkey_filename->setText(QFileDialog::getOpenFileName(this,tr("Select Private Key"),"","PEM file (*.pem)"));
+ pkey_filename->setText(QFileDialog::getOpenFileName(this, tr("Select Private Key"), "", "PEM file (*.pem)"));
}
QString AddAccountDialog::GetCertFilename()
{
- return cert_filename->text();
+ return cert_filename->text();
}
QString AddAccountDialog::GetPkeyFilename()
{
- return pkey_filename->text();
+ return pkey_filename->text();
}
bool AddAccountDialog::isCopyFilesChecked()
{
- return rb_copyfiles->isChecked();
+ return rb_copyfiles->isChecked();
}
diff --git a/pica-client/dialogs/addaccountdialog.h b/pica-client/dialogs/addaccountdialog.h
index 976d020..2f30a93 100644
--- a/pica-client/dialogs/addaccountdialog.h
+++ b/pica-client/dialogs/addaccountdialog.h
@@ -8,33 +8,33 @@
class AddAccountDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit AddAccountDialog(QWidget *parent = 0);
- QString GetCertFilename();
- QString GetPkeyFilename();
- bool isCopyFilesChecked();
+ explicit AddAccountDialog(QWidget *parent = 0);
+ QString GetCertFilename();
+ QString GetPkeyFilename();
+ bool isCopyFilesChecked();
private:
- QPushButton *btOK;
- QPushButton *btCancel;
+ QPushButton *btOK;
+ QPushButton *btCancel;
- QLineEdit *cert_filename;
- QLineEdit *pkey_filename;
+ QLineEdit *cert_filename;
+ QLineEdit *pkey_filename;
- QPushButton *bt_browse_cert;
- QPushButton *bt_browse_pkey;
+ QPushButton *bt_browse_cert;
+ QPushButton *bt_browse_pkey;
- QRadioButton *rb_copyfiles;
- QRadioButton *rb_readinplace;
+ QRadioButton *rb_copyfiles;
+ QRadioButton *rb_readinplace;
signals:
public slots:
private slots:
- void OK();
- void Cancel();
- void browse_cert();
- void browse_pkey();
+ void OK();
+ void Cancel();
+ void browse_cert();
+ void browse_pkey();
};
diff --git a/pica-client/dialogs/filetransferdialog.cpp b/pica-client/dialogs/filetransferdialog.cpp
index 6007c64..0f7229f 100644
--- a/pica-client/dialogs/filetransferdialog.cpp
+++ b/pica-client/dialogs/filetransferdialog.cpp
@@ -8,308 +8,308 @@
#include <stdlib.h>
FileTransferDialog::FileTransferDialog(QByteArray peer_id, QString filename, quint64 size,
- TransferDirection drct, QWidget *parent) :
- peer_id_(peer_id),
- QDialog(parent),
- dir_(drct),
- filename_(filename),
- filesize_(size)
+ TransferDirection drct, QWidget *parent) :
+ peer_id_(peer_id),
+ QDialog(parent),
+ dir_(drct),
+ filename_(filename),
+ filesize_(size)
{
- Contacts ct(config_dbname, Accounts::GetCurrentAccount().id);
- peer_name_ = ct.GetContactName(peer_id_);
-
- if (peer_name_.isEmpty())
- peer_name_ = peer_id_.toBase64();
- else
- peer_name_ = QString("%1 (%2...)").arg(peer_name_).arg(peer_id_.toBase64().left(8).constData());
-
- QVBoxLayout *layout = new QVBoxLayout(this);
- QHBoxLayout *btlayout = new QHBoxLayout();
-
- lbFilename = new QLabel(this);
- lbPeer = new QLabel(this);
- lbProgressStatus = new QLabel(this);
- lbTransferSpeed = new QLabel(this);
- lbRemainingTime = new QLabel(this);
- lbTransferStatus = new QLabel(this);
-
- pgbar = new QProgressBar(this);
- leftbutton = new QPushButton(this);
- rightbutton = new QPushButton(this);
-
- layout->addWidget(lbFilename);
- layout->addWidget(lbPeer);
- layout->addWidget(lbProgressStatus);
- layout->addWidget(lbTransferSpeed);
- layout->addWidget(lbRemainingTime);
- layout->addWidget(pgbar);
- layout->addWidget(lbTransferStatus);
- layout->addLayout(btlayout);
-
- btlayout->addWidget(leftbutton);
- btlayout->addWidget(rightbutton);
-
- if (drct == RECEIVING)
- {
- leftbutton->setText(tr("Accept"));
- rightbutton->setText(tr("Deny"));
-
- lbPeer->setText("Sender: " + peer_name_);
-
- setWindowTitle(tr("Receiving file %1 from %2").arg(filename_).arg(peer_name_));
- }
- else if (drct == SENDING)
- {
- leftbutton->setText(tr("Pause"));
- rightbutton->setText(tr("Cancel"));
- leftbutton->setEnabled(false);
-
- lbPeer->setText("Receiver: " + peer_name_);
-
- setWindowTitle(tr("Sending file %1 to %2").arg(filename_).arg(peer_name_));
- }
- setTransferStatus(WAITINGFORACCEPT);
-
- lbFilename->setText(filename_);
-
- pgbar->setMinimum(0);
- pgbar->setMaximum(100);
-
- update(0);
-
- timer = new QTimer(this);
- connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
- timer->start(1000);
- progress_ = 0;
- prevprogress_ = 0;
-
- connect(leftbutton, SIGNAL(clicked()), this, SLOT(leftbuttonclick()));
- connect(rightbutton, SIGNAL(clicked()), this, SLOT(rightbuttonclick()));
+ Contacts ct(config_dbname, Accounts::GetCurrentAccount().id);
+ peer_name_ = ct.GetContactName(peer_id_);
+
+ if (peer_name_.isEmpty())
+ peer_name_ = peer_id_.toBase64();
+ else
+ peer_name_ = QString("%1 (%2...)").arg(peer_name_).arg(peer_id_.toBase64().left(8).constData());
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ QHBoxLayout *btlayout = new QHBoxLayout();
+
+ lbFilename = new QLabel(this);
+ lbPeer = new QLabel(this);
+ lbProgressStatus = new QLabel(this);
+ lbTransferSpeed = new QLabel(this);
+ lbRemainingTime = new QLabel(this);
+ lbTransferStatus = new QLabel(this);
+
+ pgbar = new QProgressBar(this);
+ leftbutton = new QPushButton(this);
+ rightbutton = new QPushButton(this);
+
+ layout->addWidget(lbFilename);
+ layout->addWidget(lbPeer);
+ layout->addWidget(lbProgressStatus);
+ layout->addWidget(lbTransferSpeed);
+ layout->addWidget(lbRemainingTime);
+ layout->addWidget(pgbar);
+ layout->addWidget(lbTransferStatus);
+ layout->addLayout(btlayout);
+
+ btlayout->addWidget(leftbutton);
+ btlayout->addWidget(rightbutton);
+
+ if (drct == RECEIVING)
+ {
+ leftbutton->setText(tr("Accept"));
+ rightbutton->setText(tr("Deny"));
+
+ lbPeer->setText("Sender: " + peer_name_);
+
+ setWindowTitle(tr("Receiving file %1 from %2").arg(filename_).arg(peer_name_));
+ }
+ else if (drct == SENDING)
+ {
+ leftbutton->setText(tr("Pause"));
+ rightbutton->setText(tr("Cancel"));
+ leftbutton->setEnabled(false);
+
+ lbPeer->setText("Receiver: " + peer_name_);
+
+ setWindowTitle(tr("Sending file %1 to %2").arg(filename_).arg(peer_name_));
+ }
+ setTransferStatus(WAITINGFORACCEPT);
+
+ lbFilename->setText(filename_);
+
+ pgbar->setMinimum(0);
+ pgbar->setMaximum(100);
+
+ update(0);
+
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), this, SLOT(timeout()));
+ timer->start(1000);
+ progress_ = 0;
+ prevprogress_ = 0;
+
+ connect(leftbutton, SIGNAL(clicked()), this, SLOT(leftbuttonclick()));
+ connect(rightbutton, SIGNAL(clicked()), this, SLOT(rightbuttonclick()));
}
void FileTransferDialog::update(quint64 progress)
{
- progress_ = progress;
- percents = (double)progress / filesize_ * 100.0;
+ progress_ = progress;
+ percents = (double)progress / filesize_ * 100.0;
- lbProgressStatus->setText(bytestoHumanBase2(progress) + " / "
- + bytestoHumanBase2(filesize_) + QString(" %1 %").arg((int)percents));
+ lbProgressStatus->setText(bytestoHumanBase2(progress) + " / "
+ + bytestoHumanBase2(filesize_) + QString(" %1 %").arg((int)percents));
- pgbar->setValue(percents);
+ pgbar->setValue(percents);
- if (progress == filesize_)
- {
- setTransferStatus(FINISHED);
- }
+ if (progress == filesize_)
+ {
+ setTransferStatus(FINISHED);
+ }
}
void FileTransferDialog::setTransferStatus(TransferStatus st)
{
- bool isTerminalState = false;
-
- switch(st)
- {
- case WAITINGFORACCEPT:
- if (dir_ == SENDING)
- lbTransferStatus->setText(tr("Waiting for peer to accept the file"));
- else
- lbTransferStatus->setText(tr("Waiting for acceptance"));
- break;
-
- case DENIED:
- lbTransferStatus->setText(tr("Denied by peer"));
- isTerminalState = true;
- break;
-
- case SENDINGFILE:
- leftbutton->setEnabled(true);
- lbTransferStatus->setText(tr("Sending file"));
- break;
-
- case RECEIVINGFILE:
- lbTransferStatus->setText(tr("Receiving file"));
- break;
-
- case PAUSED:
- lbTransferStatus->setText(tr("Paused"));
- break;
-
- case CANCELLED:
- lbTransferStatus->setText(tr("Cancelled"));
- isTerminalState = true;
- break;
-
- case FINISHED:
- lbTransferStatus->setText(tr("Finished"));
- isTerminalState = true;
- break;
-
- case PEERDISCONNECTED:
- lbTransferStatus->setText(tr("Peer disconnected"));
- isTerminalState = true;
- break;
-
- case IOERROR:
- lbTransferStatus->setText(tr("I/O error"));
- isTerminalState = true;
- break;
- }
-
- if (isTerminalState)
- {
- leftbutton->setEnabled(false);
- rightbutton->setEnabled(false);
-
- QWidget::setAttribute(Qt::WA_DeleteOnClose);
- QWidget::setAttribute(Qt::WA_QuitOnClose, false);
- }
+ bool isTerminalState = false;
+
+ switch(st)
+ {
+ case WAITINGFORACCEPT:
+ if (dir_ == SENDING)
+ lbTransferStatus->setText(tr("Waiting for peer to accept the file"));
+ else
+ lbTransferStatus->setText(tr("Waiting for acceptance"));
+ break;
+
+ case DENIED:
+ lbTransferStatus->setText(tr("Denied by peer"));
+ isTerminalState = true;
+ break;
+
+ case SENDINGFILE:
+ leftbutton->setEnabled(true);
+ lbTransferStatus->setText(tr("Sending file"));
+ break;
+
+ case RECEIVINGFILE:
+ lbTransferStatus->setText(tr("Receiving file"));
+ break;
+
+ case PAUSED:
+ lbTransferStatus->setText(tr("Paused"));
+ break;
+
+ case CANCELLED:
+ lbTransferStatus->setText(tr("Cancelled"));
+ isTerminalState = true;
+ break;
+
+ case FINISHED:
+ lbTransferStatus->setText(tr("Finished"));
+ isTerminalState = true;
+ break;
+
+ case PEERDISCONNECTED:
+ lbTransferStatus->setText(tr("Peer disconnected"));
+ isTerminalState = true;
+ break;
+
+ case IOERROR:
+ lbTransferStatus->setText(tr("I/O error"));
+ isTerminalState = true;
+ break;
+ }
+
+ if (isTerminalState)
+ {
+ leftbutton->setEnabled(false);
+ rightbutton->setEnabled(false);
+
+ QWidget::setAttribute(Qt::WA_DeleteOnClose);
+ QWidget::setAttribute(Qt::WA_QuitOnClose, false);
+ }
}
void FileTransferDialog::pausedByPeer()
{
- leftbutton->setEnabled(false);
- setTransferStatus(PAUSED);
+ leftbutton->setEnabled(false);
+ setTransferStatus(PAUSED);
}
void FileTransferDialog::resumedByPeer()
{
- leftbutton->setEnabled(true);
- setTransferStatus( dir_ == SENDING ? SENDINGFILE : RECEIVINGFILE);
+ leftbutton->setEnabled(true);
+ setTransferStatus( dir_ == SENDING ? SENDINGFILE : RECEIVINGFILE);
}
void FileTransferDialog::cancelledByPeer()
{
- setTransferStatus(CANCELLED);
+ setTransferStatus(CANCELLED);
}
void FileTransferDialog::ioError()
{
- setTransferStatus(IOERROR);
+ setTransferStatus(IOERROR);
}
void FileTransferDialog::peerDisconnected()
{
- setTransferStatus(PEERDISCONNECTED);
+ setTransferStatus(PEERDISCONNECTED);
}
void FileTransferDialog::leftbuttonclick()
{
- if (dir_ == RECEIVING)
- {
- if (leftbutton->text() == tr("Accept"))
- {
- leftbutton->setText("Pause");
- rightbutton->setText("Cancel");
- emit acceptedFile(peer_id_);
- return;
- }
- }
-
- if (leftbutton->text() == tr("Pause"))
- {
- leftbutton->setText(tr("Resume"));
- emit pausedFile(peer_id_, this);
- setTransferStatus(PAUSED);
- }
- else if (leftbutton->text() == tr("Resume"))
- {
- leftbutton->setText(tr("Pause"));
- emit resumedFile(peer_id_, this);
- setTransferStatus(dir_ == SENDING ? SENDINGFILE : RECEIVINGFILE);
- }
+ if (dir_ == RECEIVING)
+ {
+ if (leftbutton->text() == tr("Accept"))
+ {
+ leftbutton->setText("Pause");
+ rightbutton->setText("Cancel");
+ emit acceptedFile(peer_id_);
+ return;
+ }
+ }
+
+ if (leftbutton->text() == tr("Pause"))
+ {
+ leftbutton->setText(tr("Resume"));
+ emit pausedFile(peer_id_, this);
+ setTransferStatus(PAUSED);
+ }
+ else if (leftbutton->text() == tr("Resume"))
+ {
+ leftbutton->setText(tr("Pause"));
+ emit resumedFile(peer_id_, this);
+ setTransferStatus(dir_ == SENDING ? SENDINGFILE : RECEIVINGFILE);
+ }
}
void FileTransferDialog::rightbuttonclick()
{
- if (dir_ == RECEIVING)
- {
- if (rightbutton->text() == tr("Deny"))
- {
- emit deniedFile(peer_id_);
- setTransferStatus(DENIED);
- return;
- }
- }
-
- if (rightbutton->text() == tr("Cancel"))
- {
-
- if (QMessageBox::No == QMessageBox::question(this, tr("Cancel File Transfer"),
- tr("Are you sure you want to cancel file transfer?"),
- QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
- return;
-
- emit cancelledFile(peer_id_, this);
- setTransferStatus(CANCELLED);
- }
+ if (dir_ == RECEIVING)
+ {
+ if (rightbutton->text() == tr("Deny"))
+ {
+ emit deniedFile(peer_id_);
+ setTransferStatus(DENIED);
+ return;
+ }
+ }
+
+ if (rightbutton->text() == tr("Cancel"))
+ {
+
+ if (QMessageBox::No == QMessageBox::question(this, tr("Cancel File Transfer"),
+ tr("Are you sure you want to cancel file transfer?"),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::No))
+ return;
+
+ emit cancelledFile(peer_id_, this);
+ setTransferStatus(CANCELLED);
+ }
}
QString FileTransferDialog::bytestoHumanBase2(quint64 bytes)
{
- const char* units[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"};
- int i = 0;
- double size = bytes;
+ const char* units[] = {"B", "KiB", "MiB", "GiB", "TiB", "PiB"};
+ int i = 0;
+ double size = bytes;
- while (size > 1024)
- {
- size /= 1024;
- i++;
- }
+ while (size > 1024)
+ {
+ size /= 1024;
+ i++;
+ }
- return QString("%1 %2").arg(size, 6, 'f', i ? 2 : 0).arg(units[i]);
+ return QString("%1 %2").arg(size, 6, 'f', i ? 2 : 0).arg(units[i]);
}
QString FileTransferDialog::bytestoHumanBase10(quint64 bytes)
{
- const char* units[] = {"B", "kB", "MB", "GB", "TB", "PB"};
- int i = 0;
- double size = bytes;
+ const char* units[] = {"B", "kB", "MB", "GB", "TB", "PB"};
+ int i = 0;
+ double size = bytes;
- while (size > 1000)
- {
- size /= 1000;
- i++;
- }
+ while (size > 1000)
+ {
+ size /= 1000;
+ i++;
+ }
- return QString("%1 %2").arg(size, 6, 'f', i ? 2 : 0).arg(units[i]);
+ return QString("%1 %2").arg(size, 6, 'f', i ? 2 : 0).arg(units[i]);
}
QString FileTransferDialog::timeLeft(quint64 seconds)
{
- if (seconds < 60)
- {
- return QString(tr("%1 seconds")).arg(seconds);
- }
+ if (seconds < 60)
+ {
+ return QString(tr("%1 seconds")).arg(seconds);
+ }
- int minutes = seconds/60;
- int hours = minutes/60;
- double days = (double)hours/24.0;
+ int minutes = seconds / 60;
+ int hours = minutes / 60;
+ double days = (double)hours / 24.0;
- if (days > 1.0 )
- return QString(tr("%1 days")).arg(days, 6, 'f', 1);
+ if (days > 1.0 )
+ return QString(tr("%1 days")).arg(days, 6, 'f', 1);
- if (hours > 0)
- return QString("%1h:%2m").arg(hours).arg(minutes % 60);
+ if (hours > 0)
+ return QString("%1h:%2m").arg(hours).arg(minutes % 60);
- return QString("%1:%2").arg(minutes).arg((double)(seconds % 60), 2, 'f', 0, '0');
+ return QString("%1:%2").arg(minutes).arg((double)(seconds % 60), 2, 'f', 0, '0');
}
void FileTransferDialog::timeout()
{
- if (progress_ >= filesize_)
- return;
+ if (progress_ >= filesize_)
+ return;
- quint64 bps = progress_ - prevprogress_;
- prevprogress_ = progress_;
+ quint64 bps = progress_ - prevprogress_;
+ prevprogress_ = progress_;
- if (bps != 0)
- {
- quint64 secondsleft = (filesize_ - progress_)/bps;
+ if (bps != 0)
+ {
+ quint64 secondsleft = (filesize_ - progress_) / bps;
- lbRemainingTime->setText(timeLeft(secondsleft));
- }
- else
- lbRemainingTime->setText(QString());
+ lbRemainingTime->setText(timeLeft(secondsleft));
+ }
+ else
+ lbRemainingTime->setText(QString());
- lbTransferSpeed->setText(bytestoHumanBase10(bps) + tr("/s"));
+ lbTransferSpeed->setText(bytestoHumanBase10(bps) + tr("/s"));
}
diff --git a/pica-client/dialogs/filetransferdialog.h b/pica-client/dialogs/filetransferdialog.h
index 952b450..822dcf5 100644
--- a/pica-client/dialogs/filetransferdialog.h
+++ b/pica-client/dialogs/filetransferdialog.h
@@ -10,79 +10,82 @@
class FileTransferDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- enum TransferDirection
- {
- SENDING,
- RECEIVING
- };
+ enum TransferDirection
+ {
+ SENDING,
+ RECEIVING
+ };
- enum TransferStatus
- {
- WAITINGFORACCEPT,
- DENIED,
- SENDINGFILE,
- RECEIVINGFILE,
- PAUSED,
- CANCELLED,
- PEERDISCONNECTED,
- IOERROR,
- FINISHED
- };
+ enum TransferStatus
+ {
+ WAITINGFORACCEPT,
+ DENIED,
+ SENDINGFILE,
+ RECEIVINGFILE,
+ PAUSED,
+ CANCELLED,
+ PEERDISCONNECTED,
+ IOERROR,
+ FINISHED
+ };
- explicit FileTransferDialog(QByteArray peer_id, QString filename, quint64 size,
- TransferDirection drct, QWidget *parent = 0);
+ explicit FileTransferDialog(QByteArray peer_id, QString filename, quint64 size,
+ TransferDirection drct, QWidget *parent = 0);
- TransferDirection getTransferDirection() {return dir_;};
+ TransferDirection getTransferDirection()
+ {
+ return dir_;
+ };
private:
- QLabel *lbFilename;
- QLabel *lbPeer;
- QLabel *lbProgressStatus;
- QLabel *lbTransferSpeed;
- QLabel *lbRemainingTime;
- QLabel *lbTransferStatus;
- QProgressBar *pgbar;
- QPushButton *leftbutton;
- QPushButton *rightbutton;
+ QLabel *lbFilename;
+ QLabel *lbPeer;
+ QLabel *lbProgressStatus;
+ QLabel *lbTransferSpeed;
+ QLabel *lbRemainingTime;
+ QLabel *lbTransferStatus;
+ QProgressBar *pgbar;
+ QPushButton *leftbutton;
+ QPushButton *rightbutton;
- QByteArray peer_id_;
- QString peer_name_;
- TransferDirection dir_;
- QString filename_;
- quint64 filesize_;
+ QByteArray peer_id_;
+ QString peer_name_;
+ TransferDirection dir_;
+ QString filename_;
+ quint64 filesize_;
- double percents;
- quint64 progress_;
- quint64 prevprogress_;
+ double percents;
+ quint64 progress_;
+ quint64 prevprogress_;
- static QString bytestoHumanBase2(quint64 bytes);
- static QString bytestoHumanBase10(quint64 bytes);
- static QString timeLeft(quint64 seconds);
+ static QString bytestoHumanBase2(quint64 bytes);
+ static QString bytestoHumanBase10(quint64 bytes);
+ static QString timeLeft(quint64 seconds);
- QTimer *timer;
+ QTimer *timer;
signals:
- void pausedFile(QByteArray peer_id, FileTransferDialog *sender);
- void resumedFile(QByteArray peer_id, FileTransferDialog *sender);
- void cancelledFile(QByteArray peer_id, FileTransferDialog *sender);
- void acceptedFile(QByteArray peer_id);
- void deniedFile(QByteArray peer_id);
+ void pausedFile(QByteArray peer_id, FileTransferDialog *sender);
+ void resumedFile(QByteArray peer_id, FileTransferDialog *sender);
+ void cancelledFile(QByteArray peer_id, FileTransferDialog *sender);
+ void acceptedFile(QByteArray peer_id);
+ void deniedFile(QByteArray peer_id);
public slots:
- void update(quint64 progress);
- void setTransferStatus(enum TransferStatus st);
- void pausedByPeer();
- void resumedByPeer();
- void cancelledByPeer();
- void ioError();
- void peerDisconnected();
+ void update(quint64 progress);
+ void setTransferStatus(enum TransferStatus st);
+ void pausedByPeer();
+ void resumedByPeer();
+ void cancelledByPeer();
+ void ioError();
+ void peerDisconnected();
private slots:
- void timeout();
- void leftbuttonclick();
- void rightbuttonclick();
+ void timeout();
+ void leftbuttonclick();
+ void rightbuttonclick();
};
diff --git a/pica-client/dialogs/forgedcertdialog.cpp b/pica-client/dialogs/forgedcertdialog.cpp
index ccf144f..54244a2 100644
--- a/pica-client/dialogs/forgedcertdialog.cpp
+++ b/pica-client/dialogs/forgedcertdialog.cpp
@@ -4,50 +4,50 @@
#include <QLabel>
ForgedCertDialog::ForgedCertDialog(QByteArray peer_id, QString received_cert, QString stored_cert, QWidget *parent) :
- QDialog(parent),
- received_cert_(received_cert),
- stored_cert_(stored_cert)
+ QDialog(parent),
+ received_cert_(received_cert),
+ stored_cert_(stored_cert)
{
- QGridLayout *grid = new QGridLayout(this);
+ QGridLayout *grid = new QGridLayout(this);
- QLabel *scary_text = new QLabel(tr(
-"Previously stored and currently present certificates for user %1 do not match.\n\
+ QLabel *scary_text = new QLabel(tr(
+ "Previously stored and currently present certificates for user %1 do not match.\n\
This means that probably someone is trying to eavesdrop your communication\n\
using man-in-the-middle attack or impersonate the user.\n\
Connection aborted.").arg(peer_id.toBase64().constData()));
- btOK = new QPushButton(tr("OK"));
- btShow_stored_cert = new QPushButton(tr("View Stored Certificate..."));
- btShow_received_cert = new QPushButton(tr("View Received Certificate..."));
+ btOK = new QPushButton(tr("OK"));
+ btShow_stored_cert = new QPushButton(tr("View Stored Certificate..."));
+ btShow_received_cert = new QPushButton(tr("View Received Certificate..."));
- grid->addWidget(scary_text, 0,0, 1, 3, Qt::AlignCenter);
- grid->addWidget(btShow_stored_cert, 1, 0, Qt::AlignCenter);
- grid->addWidget(btShow_received_cert, 1, 2, Qt::AlignCenter);
- grid->addWidget(btOK, 2, 1, Qt::AlignCenter);
+ grid->addWidget(scary_text, 0, 0, 1, 3, Qt::AlignCenter);
+ grid->addWidget(btShow_stored_cert, 1, 0, Qt::AlignCenter);
+ grid->addWidget(btShow_received_cert, 1, 2, Qt::AlignCenter);
+ grid->addWidget(btOK, 2, 1, Qt::AlignCenter);
- setLayout(grid);
+ setLayout(grid);
- connect(btOK, SIGNAL(clicked()), this, SLOT(OK()));
- connect(btShow_stored_cert, SIGNAL(clicked()), this, SLOT(StoredCert()));
- connect(btShow_received_cert, SIGNAL(clicked()), this, SLOT(ReceivedCert()));
+ connect(btOK, SIGNAL(clicked()), this, SLOT(OK()));
+ connect(btShow_stored_cert, SIGNAL(clicked()), this, SLOT(StoredCert()));
+ connect(btShow_received_cert, SIGNAL(clicked()), this, SLOT(ReceivedCert()));
}
void ForgedCertDialog::OK()
{
- done(0);
+ done(0);
}
void ForgedCertDialog::ReceivedCert()
{
- ViewCertDialog vcd;
- vcd.SetCert(received_cert_);
- vcd.exec();
+ ViewCertDialog vcd;
+ vcd.SetCert(received_cert_);
+ vcd.exec();
}
void ForgedCertDialog::StoredCert()
{
- ViewCertDialog vcd;
- vcd.SetCert(stored_cert_);
- vcd.exec();
+ ViewCertDialog vcd;
+ vcd.SetCert(stored_cert_);
+ vcd.exec();
}
diff --git a/pica-client/dialogs/forgedcertdialog.h b/pica-client/dialogs/forgedcertdialog.h
index 5386f14..08f5d42 100644
--- a/pica-client/dialogs/forgedcertdialog.h
+++ b/pica-client/dialogs/forgedcertdialog.h
@@ -7,28 +7,28 @@
class ForgedCertDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ForgedCertDialog(QByteArray peer_id, QString received_cert, QString stored_cert, QWidget *parent = 0);
+ explicit ForgedCertDialog(QByteArray peer_id, QString received_cert, QString stored_cert, QWidget *parent = 0);
private:
- QString received_cert_;
- QString stored_cert_;
+ QString received_cert_;
+ QString stored_cert_;
+
+ QPushButton *btOK;
+ QPushButton *btShow_stored_cert;
+ QPushButton *btShow_received_cert;
- QPushButton *btOK;
- QPushButton *btShow_stored_cert;
- QPushButton *btShow_received_cert;
-
signals:
-
+
public slots:
private slots:
- void OK();
- void StoredCert();
- void ReceivedCert();
-
+ void OK();
+ void StoredCert();
+ void ReceivedCert();
+
};
#endif // FORGEDCERTDIALOG_H
diff --git a/pica-client/dialogs/registeraccountdialog.cpp b/pica-client/dialogs/registeraccountdialog.cpp
index e3600ed..090cfe3 100644
--- a/pica-client/dialogs/registeraccountdialog.cpp
+++ b/pica-client/dialogs/registeraccountdialog.cpp
@@ -6,102 +6,102 @@
RegisterAccountDialog::RegisterAccountDialog(QWidget *parent) :
- QDialog(parent)
+ QDialog(parent)
{
- QVBoxLayout *layout = new QVBoxLayout(this);
-
- QLabel *lbNickname = new QLabel(tr("Name:"));
- lbPassword = new QLabel(tr("Password:"));
- lbRepeatPassword = new QLabel(tr("Repeat password:"));
-
- nickname = new QLineEdit();
- btRegister = new QPushButton(tr("Create"));
-
- #ifndef WIN32
- cbUseDevRandom = new QCheckBox(tr("Use /dev/random as a random data source"));
- #endif
-
- cbSetPassword = new QCheckBox(tr("Set passphrase for the secret key"));
- password = new QLineEdit();
- repeatPassword = new QLineEdit();
- lbStatus = new QLabel(tr("Enter your name and press\n \"Create\" to create new Pica Pica certificate"));
- //btOK = new QPushButton(tr("OK"));
-
- password->setEchoMode(QLineEdit::Password);
- repeatPassword->setEchoMode(QLineEdit::Password);
-
- {
- QFont f;
- f= lbStatus->font();
- f.setBold(true);
- lbStatus->setFont(f);
- }
-
- layout->addWidget(lbNickname);
- layout->addWidget(nickname);
- #ifndef WIN32
- layout->addWidget(cbUseDevRandom);
- #endif
- layout->addWidget(cbSetPassword);
- layout->addWidget(lbPassword);
- layout->addWidget(password);
- layout->addWidget(lbRepeatPassword);
- layout->addWidget(repeatPassword);
- layout->addWidget(btRegister);
- layout->addWidget(lbStatus);
- //layout->addWidget(btOK);
-
- setLayout(layout);
-
- vld = new QRegExpValidator(QRegExp("[^\\#\\$&\"\'=\\(\\)\\\\/\\|`!<>\\{\\}\\[\\]\\+]+"), this);
- nickname->setValidator(vld);
-
- //connect(btOK, SIGNAL(clicked()), this, SLOT(OK()));
- connect(btRegister, SIGNAL(clicked()), this, SLOT(Register()));
- connect(cbSetPassword, SIGNAL(clicked()), this, SLOT(setPasswordClick()));
- #ifndef WIN32
- connect(cbUseDevRandom, SIGNAL(clicked()), this, SLOT(useDevRandomClick()));
- #endif
-
- setPasswordClick();
+ QVBoxLayout *layout = new QVBoxLayout(this);
+
+ QLabel *lbNickname = new QLabel(tr("Name:"));
+ lbPassword = new QLabel(tr("Password:"));
+ lbRepeatPassword = new QLabel(tr("Repeat password:"));
+
+ nickname = new QLineEdit();
+ btRegister = new QPushButton(tr("Create"));
+
+#ifndef WIN32
+ cbUseDevRandom = new QCheckBox(tr("Use /dev/random as a random data source"));
+#endif
+
+ cbSetPassword = new QCheckBox(tr("Set passphrase for the secret key"));
+ password = new QLineEdit();
+ repeatPassword = new QLineEdit();
+ lbStatus = new QLabel(tr("Enter your name and press\n \"Create\" to create new Pica Pica certificate"));
+ //btOK = new QPushButton(tr("OK"));
+
+ password->setEchoMode(QLineEdit::Password);
+ repeatPassword->setEchoMode(QLineEdit::Password);
+
+ {
+ QFont f;
+ f = lbStatus->font();
+ f.setBold(true);
+ lbStatus->setFont(f);
+ }
+
+ layout->addWidget(lbNickname);
+ layout->addWidget(nickname);
+#ifndef WIN32
+ layout->addWidget(cbUseDevRandom);
+#endif
+ layout->addWidget(cbSetPassword);
+ layout->addWidget(lbPassword);
+ layout->addWidget(password);
+ layout->addWidget(lbRepeatPassword);
+ layout->addWidget(repeatPassword);
+ layout->addWidget(btRegister);
+ layout->addWidget(lbStatus);
+ //layout->addWidget(btOK);
+
+ setLayout(layout);
+
+ vld = new QRegExpValidator(QRegExp("[^\\#\\$&\"\'=\\(\\)\\\\/\\|`!<>\\{\\}\\[\\]\\+]+"), this);
+ nickname->setValidator(vld);
+
+ //connect(btOK, SIGNAL(clicked()), this, SLOT(OK()));
+ connect(btRegister, SIGNAL(clicked()), this, SLOT(Register()));
+ connect(cbSetPassword, SIGNAL(clicked()), this, SLOT(setPasswordClick()));
+#ifndef WIN32
+ connect(cbUseDevRandom, SIGNAL(clicked()), this, SLOT(useDevRandomClick()));
+#endif
+
+ setPasswordClick();
}
void RegisterAccountDialog::useDevRandomClick()
{
#ifndef WIN32
- if (cbUseDevRandom->isChecked())
- {
- QMessageBox mbx;
- mbx.setText(tr("Using /dev/random is more preferable for generating long-term high-value cryptographic keys, but it can take 5 - 10 minutes to collect required amount of entropy. You'll have to press random keys on keyboard and move mouse randomly to provide random data. "));
- mbx.exec();
- }
+ if (cbUseDevRandom->isChecked())
+ {
+ QMessageBox mbx;
+ mbx.setText(tr("Using /dev/random is more preferable for generating long-term high-value cryptographic keys, but it can take 5 - 10 minutes to collect required amount of entropy. You'll have to press random keys on keyboard and move mouse randomly to provide random data. "));
+ mbx.exec();
+ }
#endif
}
void RegisterAccountDialog::setPasswordClick()
{
- if (cbSetPassword->isChecked())
- {
- password -> setDisabled(false);
- repeatPassword -> setDisabled(false);
-
- password->show();
- repeatPassword->show();
- lbPassword->show();
- lbRepeatPassword->show();
- }
- else
- {
- password -> setDisabled(true);
- repeatPassword -> setDisabled(true);
-
- password->setHidden(true);
- repeatPassword->setHidden(true);
- lbPassword->hide();
- lbRepeatPassword->hide();
- }
-
- adjustSize();
+ if (cbSetPassword->isChecked())
+ {
+ password -> setDisabled(false);
+ repeatPassword -> setDisabled(false);
+
+ password->show();
+ repeatPassword->show();
+ lbPassword->show();
+ lbRepeatPassword->show();
+ }
+ else
+ {
+ password -> setDisabled(true);
+ repeatPassword -> setDisabled(true);
+
+ password->setHidden(true);
+ repeatPassword->setHidden(true);
+ lbPassword->hide();
+ lbRepeatPassword->hide();
+ }
+
+ adjustSize();
}
//void RegisterAccountDialog::OK()
@@ -112,95 +112,95 @@ void RegisterAccountDialog::setPasswordClick()
void RegisterAccountDialog::Register()
{
- //check name
- QString name = nickname->text();
- QString rand = QString::null;
-
- if (name.toUtf8().size() > 63) //64 bytes - CN length in X509 certificate
- {
- QMessageBox mbx;
- mbx.setText(tr("Name is too long"));
- mbx.exec();
- return;
- }
-
- if (name.isEmpty())
- {
- QMessageBox mbx;
- mbx.setText(tr("You must enter account name"));
- mbx.exec();
- return;
- }
-
- if (cbSetPassword->isChecked())
- {
- if (password->text() != repeatPassword->text())
- {
- QMessageBox mbx;
- mbx.setText(tr("Passphrases do not match"));
- mbx.exec();
- return;
- }
- }
-
- #ifndef WIN32
- if (cbUseDevRandom->isChecked())
- {
- rand = "/dev/random";
- }
-
- cbUseDevRandom -> setDisabled(true);
- #endif
-
- cbSetPassword -> setDisabled(true);
-
- //1
- lbStatus->setText(tr("1) generating RSA keypair..."));
-
- nickname->setEnabled(false);
- btRegister->setEnabled(false);
-
- ost.GenRSAKeySignal(4096, config_dir + QDir::separator() + "privkey.pem", cbSetPassword->isChecked(),
- password->text(),rand, this, SLOT(stageSignCert(int,QProcess::ExitStatus)));
+ //check name
+ QString name = nickname->text();
+ QString rand = QString::null;
+
+ if (name.toUtf8().size() > 63) //64 bytes - CN length in X509 certificate
+ {
+ QMessageBox mbx;
+ mbx.setText(tr("Name is too long"));
+ mbx.exec();
+ return;
+ }
+
+ if (name.isEmpty())
+ {
+ QMessageBox mbx;
+ mbx.setText(tr("You must enter account name"));
+ mbx.exec();
+ return;
+ }
+
+ if (cbSetPassword->isChecked())
+ {
+ if (password->text() != repeatPassword->text())
+ {
+ QMessageBox mbx;
+ mbx.setText(tr("Passphrases do not match"));
+ mbx.exec();
+ return;
+ }
+ }
+
+#ifndef WIN32
+ if (cbUseDevRandom->isChecked())
+ {
+ rand = "/dev/random";
+ }
+
+ cbUseDevRandom -> setDisabled(true);
+#endif
+
+ cbSetPassword -> setDisabled(true);
+
+ //1
+ lbStatus->setText(tr("1) generating RSA keypair..."));
+
+ nickname->setEnabled(false);
+ btRegister->setEnabled(false);
+
+ ost.GenRSAKeySignal(4096, config_dir + QDir::separator() + "privkey.pem", cbSetPassword->isChecked(),
+ password->text(), rand, this, SLOT(stageSignCert(int, QProcess::ExitStatus)));
}
-void RegisterAccountDialog::stageSignCert(int retval,QProcess::ExitStatus)
+void RegisterAccountDialog::stageSignCert(int retval, QProcess::ExitStatus)
{
- if (retval != 0)
- {
- lbStatus->setText(tr("Error:\n") + ost.ReadStdErr());
- return;
- }
-
- lbStatus->setText(tr("2) Signing certificate..."));
-
- ost.GenCertSignal(config_dir + QDir::separator() + "cert.pem",
- config_dir + QDir::separator() + "privkey.pem",
- password->text(),nickname->text(),
- this,SLOT(stageFinished(int,QProcess::ExitStatus)));
+ if (retval != 0)
+ {
+ lbStatus->setText(tr("Error:\n") + ost.ReadStdErr());
+ return;
+ }
+
+ lbStatus->setText(tr("2) Signing certificate..."));
+
+ ost.GenCertSignal(config_dir + QDir::separator() + "cert.pem",
+ config_dir + QDir::separator() + "privkey.pem",
+ password->text(), nickname->text(),
+ this, SLOT(stageFinished(int, QProcess::ExitStatus)));
}
void RegisterAccountDialog::stageFinished(int retval, QProcess::ExitStatus)
{
- if (retval != 0)
- {
- lbStatus->setText(tr("Error:\n") + ost.ReadStdErr());
- return;
- }
+ if (retval != 0)
+ {
+ lbStatus->setText(tr("Error:\n") + ost.ReadStdErr());
+ return;
+ }
- CertFilename_ = config_dir + QDir::separator() + "cert.pem";
- PkeyFilename_ = config_dir + QDir::separator() + "privkey.pem";
+ CertFilename_ = config_dir + QDir::separator() + "cert.pem";
+ PkeyFilename_ = config_dir + QDir::separator() + "privkey.pem";
- done(1);
+ done(1);
}
QString RegisterAccountDialog::GetCertFilename()
{
- return CertFilename_;
+ return CertFilename_;
}
QString RegisterAccountDialog::GetPkeyFilename()
{
- return PkeyFilename_;
+ return PkeyFilename_;
}
diff --git a/pica-client/dialogs/registeraccountdialog.h b/pica-client/dialogs/registeraccountdialog.h
index 550d769..9771ccd 100644
--- a/pica-client/dialogs/registeraccountdialog.h
+++ b/pica-client/dialogs/registeraccountdialog.h
@@ -11,40 +11,40 @@
class RegisterAccountDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit RegisterAccountDialog(QWidget *parent = 0);
- QString GetCertFilename();
- QString GetPkeyFilename();
-
+ explicit RegisterAccountDialog(QWidget *parent = 0);
+ QString GetCertFilename();
+ QString GetPkeyFilename();
+
private:
- //QPushButton *btOK;
- QPushButton *btRegister;
- QLineEdit *nickname;
- QLabel *lbStatus;
- QCheckBox *cbSetPassword;
- QLineEdit *password;
- QLineEdit *repeatPassword;
- QLabel *lbPassword ;
- QLabel *lbRepeatPassword;
- QCheckBox *cbUseDevRandom;
-
- QRegExpValidator *vld;
- OpenSSLTool ost;
- QByteArray cert_buf;
-
- QString CertFilename_;
- QString PkeyFilename_;
+ //QPushButton *btOK;
+ QPushButton *btRegister;
+ QLineEdit *nickname;
+ QLabel *lbStatus;
+ QCheckBox *cbSetPassword;
+ QLineEdit *password;
+ QLineEdit *repeatPassword;
+ QLabel *lbPassword ;
+ QLabel *lbRepeatPassword;
+ QCheckBox *cbUseDevRandom;
+
+ QRegExpValidator *vld;
+ OpenSSLTool ost;
+ QByteArray cert_buf;
+
+ QString CertFilename_;
+ QString PkeyFilename_;
signals:
-
+
private slots:
- //void OK();
- void Register();
- void setPasswordClick();
- void useDevRandomClick();
+ //void OK();
+ void Register();
+ void setPasswordClick();
+ void useDevRandomClick();
- void stageSignCert(int retval, QProcess::ExitStatus);
- void stageFinished(int retval, QProcess::ExitStatus);
+ void stageSignCert(int retval, QProcess::ExitStatus);
+ void stageFinished(int retval, QProcess::ExitStatus);
};
#endif // REGISTERACCOUNTDIALOG_H
diff --git a/pica-client/dialogs/settingsdialog.cpp b/pica-client/dialogs/settingsdialog.cpp
index 852cc95..d16bb63 100644
--- a/pica-client/dialogs/settingsdialog.cpp
+++ b/pica-client/dialogs/settingsdialog.cpp
@@ -73,23 +73,23 @@ SettingsDialog::SettingsDialog(QWidget *parent) :
tabW->addTab(soundstab, tr("Sounds"));
settingsLayout->addWidget(tabW);
- QHBoxLayout *buttonsLayout = new QHBoxLayout;
+ QHBoxLayout *buttonsLayout = new QHBoxLayout;
- btOk = new QPushButton(tr("&OK"), this);
- btCancel = new QPushButton(tr("Cancel"), this);
+ btOk = new QPushButton(tr("&OK"), this);
+ btCancel = new QPushButton(tr("Cancel"), this);
- buttonsLayout->addStretch(1);
- buttonsLayout->addWidget(btOk);
- buttonsLayout->addWidget(btCancel);
+ buttonsLayout->addStretch(1);
+ buttonsLayout->addWidget(btOk);
+ buttonsLayout->addWidget(btCancel);
- settingsLayout->addLayout(buttonsLayout);
+ settingsLayout->addLayout(buttonsLayout);
setLayout(settingsLayout);
- connect(btOk, SIGNAL(clicked()), this, SLOT(OK()));
- connect(btCancel, SIGNAL(clicked()), this, SLOT(Cancel()));
+ connect(btOk, SIGNAL(clicked()), this, SLOT(OK()));
+ connect(btCancel, SIGNAL(clicked()), this, SLOT(Cancel()));
- loadSettings();
+ loadSettings();
setWindowTitle(tr("Pica Pica Messenger Settings"));
}
@@ -103,66 +103,66 @@ void SettingsDialog::toggleIncomingConnections(bool checked)
void SettingsDialog::OK()
{
- storeSettings();
- done(1);
+ storeSettings();
+ done(1);
}
void SettingsDialog::Cancel()
{
- done(0);
+ done(0);
}
void SettingsDialog::loadSettings()
{
- Settings st(config_dbname);
+ Settings st(config_dbname);
- //Direct c2c connections
- int c2c_state;
+ //Direct c2c connections
+ int c2c_state;
- c2c_state = st.loadValue("direct_c2c.state", 1).toInt();
+ c2c_state = st.loadValue("direct_c2c.state", 1).toInt();
- switch (c2c_state)
- {
- case 0:
- rbDisableDirectConns->setChecked(true);
- break;
+ switch (c2c_state)
+ {
+ case 0:
+ rbDisableDirectConns->setChecked(true);
+ break;
- case 1:
- rbEnableOutgoingConns->setChecked(true);
- break;
+ case 1:
+ rbEnableOutgoingConns->setChecked(true);
+ break;
- case 2:
- rbEnableIncomingConns->setChecked(true);
- break;
+ case 2:
+ rbEnableIncomingConns->setChecked(true);
+ break;
- default:
- break;
- }
+ default:
+ break;
+ }
addr->lineEdit()->setText(st.loadValue("direct_c2c.public_addr", "0.0.0.0").toString());
- publicPort->setValue(st.loadValue("direct_c2c.public_port", 2298).toInt());
- localPort->setValue(st.loadValue("direct_c2c.local_port", 2298).toInt());
+ publicPort->setValue(st.loadValue("direct_c2c.public_port", 2298).toInt());
+ localPort->setValue(st.loadValue("direct_c2c.local_port", 2298).toInt());
}
void SettingsDialog::storeSettings()
{
- Settings st(config_dbname);
+ Settings st(config_dbname);
- //Direct c2c connections
- int c2c_state;
+ //Direct c2c connections
+ int c2c_state;
- if (rbDisableDirectConns->isChecked())
- c2c_state = 0;
- else if (rbEnableOutgoingConns->isChecked())
- c2c_state = 1;
- else if (rbEnableIncomingConns->isChecked())
- c2c_state = 2;
+ if (rbDisableDirectConns->isChecked())
+ c2c_state = 0;
+ else if (rbEnableOutgoingConns->isChecked())
+ c2c_state = 1;
+ else if (rbEnableIncomingConns->isChecked())
+ c2c_state = 2;
- st.storeValue("direct_c2c.state", QString::number(c2c_state));
+ st.storeValue("direct_c2c.state", QString::number(c2c_state));
st.storeValue("direct_c2c.public_addr", addr->lineEdit()->text());
- st.storeValue("direct_c2c.public_port", QString::number(publicPort->value()));
- st.storeValue("direct_c2c.local_port", QString::number(localPort->value()));
+ st.storeValue("direct_c2c.public_port", QString::number(publicPort->value()));
+ st.storeValue("direct_c2c.local_port", QString::number(localPort->value()));
}
diff --git a/pica-client/dialogs/settingsdialog.h b/pica-client/dialogs/settingsdialog.h
index 9b11630..f0ab0cd 100644
--- a/pica-client/dialogs/settingsdialog.h
+++ b/pica-client/dialogs/settingsdialog.h
@@ -31,12 +31,12 @@ private:
QPushButton *btOk;
QPushButton *btCancel;
- void loadSettings();
- void storeSettings();
+ void loadSettings();
+ void storeSettings();
private slots:
- void OK();
- void Cancel();
+ void OK();
+ void Cancel();
void toggleIncomingConnections(bool checked);
};
diff --git a/pica-client/dialogs/showpicaiddialog.cpp b/pica-client/dialogs/showpicaiddialog.cpp
index 8fed71e..4e45c30 100644
--- a/pica-client/dialogs/showpicaiddialog.cpp
+++ b/pica-client/dialogs/showpicaiddialog.cpp
@@ -4,33 +4,33 @@
#include <QStyle>
ShowPicaIdDialog::ShowPicaIdDialog(QString name, QByteArray id, QString caption, QWidget *parent) :
- QDialog(parent)
+ QDialog(parent)
{
- setWindowTitle(caption);
- QVBoxLayout *layout = new QVBoxLayout(this);
+ setWindowTitle(caption);
+ QVBoxLayout *layout = new QVBoxLayout(this);
- lbname_ = new QLabel(tr("Account: <b>%1</b>").arg(name));
- lbname_ ->setTextFormat(Qt::RichText);
+ lbname_ = new QLabel(tr("Account: <b>%1</b>").arg(name));
+ lbname_ ->setTextFormat(Qt::RichText);
- picaid_ = new QLineEdit();
+ picaid_ = new QLineEdit();
- picaid_ ->setText(id.toBase64().constData());
- picaid_->setReadOnly(true);
- picaid_->setSelection(0, picaid_->text().size());
- picaid_->setMinimumWidth(picaid_->fontMetrics().width(picaid_->text()) + 2 * picaid_->style()->pixelMetric(QStyle::PM_DefaultFrameWidth));
+ picaid_ ->setText(id.toBase64().constData());
+ picaid_->setReadOnly(true);
+ picaid_->setSelection(0, picaid_->text().size());
+ picaid_->setMinimumWidth(picaid_->fontMetrics().width(picaid_->text()) + 2 * picaid_->style()->pixelMetric(QStyle::PM_DefaultFrameWidth));
- btok_ = new QPushButton(tr("OK"));
- btok_->setDefault(true);
- btok_->setMaximumWidth(btok_->fontMetrics().width(btok_->text()) * 3 / 2 + 2 * btok_->style()->pixelMetric(QStyle::PM_ButtonMargin));
+ btok_ = new QPushButton(tr("OK"));
+ btok_->setDefault(true);
+ btok_->setMaximumWidth(btok_->fontMetrics().width(btok_->text()) * 3 / 2 + 2 * btok_->style()->pixelMetric(QStyle::PM_ButtonMargin));
- layout->addWidget(lbname_);
- layout->addWidget(picaid_);
- layout->addWidget(btok_, 0, Qt::AlignHCenter);
+ layout->addWidget(lbname_);
+ layout->addWidget(picaid_);
+ layout->addWidget(btok_, 0, Qt::AlignHCenter);
- connect(btok_, SIGNAL(clicked()), this, SLOT(Ok()));
+ connect(btok_, SIGNAL(clicked()), this, SLOT(Ok()));
}
void ShowPicaIdDialog::Ok()
{
- done(0);
+ done(0);
}
diff --git a/pica-client/dialogs/showpicaiddialog.h b/pica-client/dialogs/showpicaiddialog.h
index a566c12..5523bc3 100644
--- a/pica-client/dialogs/showpicaiddialog.h
+++ b/pica-client/dialogs/showpicaiddialog.h
@@ -10,17 +10,17 @@
class ShowPicaIdDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ShowPicaIdDialog(QString name, QByteArray id, QString caption, QWidget *parent = 0);
+ explicit ShowPicaIdDialog(QString name, QByteArray id, QString caption, QWidget *parent = 0);
private slots:
- void Ok();
+ void Ok();
private:
- QLabel *lbname_;
- QLineEdit *picaid_;
- QPushButton *btok_;
+ QLabel *lbname_;
+ QLineEdit *picaid_;
+ QPushButton *btok_;
};
diff --git a/pica-client/dialogs/viewcertdialog.cpp b/pica-client/dialogs/viewcertdialog.cpp
index f75e7f3..c94df25 100644
--- a/pica-client/dialogs/viewcertdialog.cpp
+++ b/pica-client/dialogs/viewcertdialog.cpp
@@ -5,42 +5,42 @@
#include <QFile>
ViewCertDialog::ViewCertDialog(QWidget *parent) :
- QDialog(parent)
+ QDialog(parent)
{
- QVBoxLayout *layout;
+ QVBoxLayout *layout;
- layout = new QVBoxLayout;
- cert_text = new QTextEdit(this);
- btOK = new QPushButton(tr("OK"));
- btOK->setMaximumWidth(45);
- this->setMinimumWidth(640);
- this->setMinimumHeight(480);
+ layout = new QVBoxLayout;
+ cert_text = new QTextEdit(this);
+ btOK = new QPushButton(tr("OK"));
+ btOK->setMaximumWidth(45);
+ this->setMinimumWidth(640);
+ this->setMinimumHeight(480);
- QTextCharFormat fmt;
+ QTextCharFormat fmt;
- fmt = cert_text->currentCharFormat();
- fmt.setFontFixedPitch(true);
- fmt.setFontStyleHint(QFont::Monospace);
- fmt.setFontFamily("Liberation Mono");
- cert_text->setCurrentCharFormat(fmt);
+ fmt = cert_text->currentCharFormat();
+ fmt.setFontFixedPitch(true);
+ fmt.setFontStyleHint(QFont::Monospace);
+ fmt.setFontFamily("Liberation Mono");
+ cert_text->setCurrentCharFormat(fmt);
- cert_text->setReadOnly(true);
+ cert_text->setReadOnly(true);
- layout->addWidget(cert_text);
- layout->addWidget(btOK, 0, Qt::AlignCenter);
+ layout->addWidget(cert_text);
+ layout->addWidget(btOK, 0, Qt::AlignCenter);
- setLayout(layout);
+ setLayout(layout);
- connect(btOK, SIGNAL(clicked()), this, SLOT(OK()));
+ connect(btOK, SIGNAL(clicked()), this, SLOT(OK()));
}
void ViewCertDialog::SetCert(QString cert_pem)
{
- cert_text->setPlainText(OpenSSLTool::CertTextFromString(cert_pem));
+ cert_text->setPlainText(OpenSSLTool::CertTextFromString(cert_pem));
}
void ViewCertDialog::OK()
{
- done(0);
+ done(0);
}
diff --git a/pica-client/dialogs/viewcertdialog.h b/pica-client/dialogs/viewcertdialog.h
index 013815c..c9a8ade 100644
--- a/pica-client/dialogs/viewcertdialog.h
+++ b/pica-client/dialogs/viewcertdialog.h
@@ -7,22 +7,22 @@
class ViewCertDialog : public QDialog
{
- Q_OBJECT
+ Q_OBJECT
public:
- explicit ViewCertDialog(QWidget *parent = 0);
- void SetCert(QString cert_pem);
-
+ explicit ViewCertDialog(QWidget *parent = 0);
+ void SetCert(QString cert_pem);
+
private:
- QTextEdit *cert_text;
- QPushButton *btOK;
+ QTextEdit *cert_text;
+ QPushButton *btOK;
signals:
-
+
public slots:
private slots:
- void OK();
-
+ void OK();
+
};
#endif // VIEWCERTDIALOG_H