diff options
| -rw-r--r-- | pica-client/skynet.cpp | 25 | ||||
| -rw-r--r-- | pica-client/skynet.h | 1 |
2 files changed, 20 insertions, 6 deletions
diff --git a/pica-client/skynet.cpp b/pica-client/skynet.cpp index 122df47..9d66377 100644 --- a/pica-client/skynet.cpp +++ b/pica-client/skynet.cpp @@ -36,7 +36,8 @@ PICA_client_callbacks cbs = { PICA_client_init(&cbs); -nodelink = NULL; +this->nodelink = NULL; +this->acc = NULL; connect(this, SIGNAL(PeerCertificateReceived(QByteArray,QString,bool*)), this, SLOT(verify_peer_cert(QByteArray,QString,bool*)),Qt::DirectConnection); @@ -201,11 +202,8 @@ else } } -void SkyNet::Join(Accounts::AccountRecord &accrec) +bool SkyNet::open_account() { - QList<Nodes::NodeRecord> nodelist; - skynet_account = accrec; - nodelist = nodes.GetNodes(); int ret; AskPassword::clear(); @@ -224,7 +222,22 @@ void SkyNet::Join(Accounts::AccountRecord &accrec) qDebug() << "PICA_open_acc() returned " << ret; if (ret != PICA_OK) - return; + return false; + + return true; +} + +void SkyNet::Join(Accounts::AccountRecord &accrec) +{ + QList<Nodes::NodeRecord> nodelist; + skynet_account = accrec; + nodelist = nodes.GetNodes(); + + if (!acc) + { + if (!open_account()) + return; + } if (nodelist.count()==0) { diff --git a/pica-client/skynet.h b/pica-client/skynet.h index 41aac0d..4df41db 100644 --- a/pica-client/skynet.h +++ b/pica-client/skynet.h @@ -75,6 +75,7 @@ private: void flush_queues(QByteArray to); struct PICA_c2c *find_active_chan(QByteArray peer_id); QList<QByteArray> filter_existing_chans(QList<QByteArray> peer_ids); + bool open_account(); void emit_MessageReceived(QByteArray from, QString msg); void emit_UnableToDeliver(QByteArray to, QString msg); |
