Now the application does not start if it does not find ip, which starts with "fc" (ie, before starting the messenger, you need to run the cjdns daemon)

This commit is contained in:
Denis Davydov 2018-07-26 14:42:37 +03:00
parent 3b58f486ec
commit 5231302217
4 changed files with 22 additions and 3 deletions

View File

@ -37,11 +37,19 @@ void Network::processTheDatagram()
QString Network::localIPv6()
{
QHostAddress address;
QString addressString;
foreach (address, QNetworkInterface::allAddresses()) {
if (address.protocol() == QAbstractSocket::IPv6Protocol && address != QHostAddress(QHostAddress::LocalHostIPv6) && (address.toString()).contains("fc"))
{
addressString = address.toString();
break;
}
return(address.toString());
else
{
addressString = "null";
}
}
return(addressString);
}
Network::~Network()

View File

@ -5,6 +5,10 @@ int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
if(w.doQuit())
{
return -1;
}
w.show();
return a.exec();

View File

@ -5,8 +5,13 @@ MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
network = new Network(false);
if(*network->myIPv6 == "null")
{
QMessageBox::critical(parent, tr("Cjdns is not running!"), tr("Cjdns is not running, so the application will be closed."));
mDoQuit = true;
}
ui->setupUi(this);
handler = new Handler();
timer = new QTimer();
connect(timer, SIGNAL(timeout()), this, SLOT(slotTimerAlarm()));

View File

@ -25,6 +25,7 @@ class MainWindow : public QMainWindow
QVector<ChatWindow*> pChatWindows;
void setButtonToWaiting();
void setButtonToConnect();
inline bool doQuit() const { return mDoQuit; }
public slots:
void peerReceiverAvailable();
private slots:
@ -42,4 +43,5 @@ class MainWindow : public QMainWindow
Network *network;
Handler *handler;
bool receive = false;
bool mDoQuit = false;
};