summaryrefslogtreecommitdiffstats
path: root/pica-client
diff options
context:
space:
mode:
authorAnton <anton@picapica>2015-03-30 00:57:46 +0400
committerAnton <anton@picapica>2015-03-30 00:57:46 +0400
commite3d99b9dc12974ba13806e0c344a52f6c02d4ba6 (patch)
treefef30a3fccae5515a6372ab78c017273c216ed85 /pica-client
parent0a71ba2f66ce2a56d4ada62ef28bbb3f2ba7b991 (diff)
downloadpica-pica-e3d99b9dc12974ba13806e0c344a52f6c02d4ba6.tar.gz
pica-pica-e3d99b9dc12974ba13806e0c344a52f6c02d4ba6.zip
do not open account again if already opened, fixed memory leak, added new method SkyNet::open_account()
Diffstat (limited to 'pica-client')
-rw-r--r--pica-client/skynet.cpp25
-rw-r--r--pica-client/skynet.h1
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);