From c6f557b7259ee8c8b5d71706abd3ac9b6db0bff8 Mon Sep 17 00:00:00 2001 From: me_desk Date: Fri, 30 Jan 2015 20:10:57 +0000 Subject: renamed structs PICA_conninfo to PICA_c2n (client-to-node) and PICA_chaninfo to PICA_c2c (client-to-client) git-svn-id: svn://localhost/project_picapica/trunk@340 fb96df88-216d-11de-830c-f3023f12d8ac --- pica-client/skynet.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pica-client/skynet.h') diff --git a/pica-client/skynet.h b/pica-client/skynet.h index 5aeb332..a0f974b 100644 --- a/pica-client/skynet.h +++ b/pica-client/skynet.h @@ -62,7 +62,7 @@ private: QList threads; bool self_aware; QString status; - struct PICA_conninfo *nodelink; + struct PICA_c2n *nodelink; Accounts::AccountRecord skynet_account; QMutex write_mutex; QMap > msgqueues; @@ -72,7 +72,7 @@ private: void timerEvent(QTimerEvent * e); void flush_queues(QByteArray to); - struct PICA_chaninfo *find_active_chan(QByteArray peer_id); + struct PICA_c2c *find_active_chan(QByteArray peer_id); QList filter_existing_chans(QList peer_ids); void emit_MessageReceived(QByteArray from, QString msg); -- cgit v1.2.1 From a3b23291f5c50b423faa4d3c3ae88889be02d6cb Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 13 Mar 2015 03:45:11 +0400 Subject: updated client library calls in pica-client and fixed password asking dialog behaviour, now invalid password error is detected and asked again, cancel button is handled --- pica-client/skynet.h | 1 + 1 file changed, 1 insertion(+) (limited to 'pica-client/skynet.h') diff --git a/pica-client/skynet.h b/pica-client/skynet.h index a0f974b..41aac0d 100644 --- a/pica-client/skynet.h +++ b/pica-client/skynet.h @@ -63,6 +63,7 @@ private: bool self_aware; QString status; struct PICA_c2n *nodelink; + struct PICA_acc *acc; Accounts::AccountRecord skynet_account; QMutex write_mutex; QMap > msgqueues; -- cgit v1.2.1 From e3d99b9dc12974ba13806e0c344a52f6c02d4ba6 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 30 Mar 2015 00:57:46 +0400 Subject: do not open account again if already opened, fixed memory leak, added new method SkyNet::open_account() --- pica-client/skynet.h | 1 + 1 file changed, 1 insertion(+) (limited to 'pica-client/skynet.h') 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 filter_existing_chans(QList peer_ids); + bool open_account(); void emit_MessageReceived(QByteArray from, QString msg); void emit_UnableToDeliver(QByteArray to, QString msg); -- cgit v1.2.1 From ec751f3f1260b72ade3a9fcb2dae5b55a6854fa9 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 11 Apr 2015 23:34:46 +0400 Subject: more consistent naming, renamed conn -> c2n, channel -> c2c in function names and enumerations --- pica-client/skynet.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'pica-client/skynet.h') diff --git a/pica-client/skynet.h b/pica-client/skynet.h index 4df41db..0b2c84b 100644 --- a/pica-client/skynet.h +++ b/pica-client/skynet.h @@ -55,7 +55,7 @@ signals: void OutgoingFileFinished(QByteArray peer_id); void IncomingFileFinished(QByteArray peer_id); - void ChannelClosed(QByteArray peer_id); + void c2cClosed(QByteArray peer_id); private: Nodes nodes; @@ -98,22 +98,22 @@ private: void emit_OutgoingFileFinished(QByteArray peer_id); void emit_IncomingFileFinished(QByteArray peer_id); - void emit_ChannelClosed(QByteArray peer_id); + void emit_c2cClosed(QByteArray peer_id); //получение сообщения. static void newmsg_cb(const unsigned char *peer_id,const char* msgbuf,unsigned int nb,int type); //получение подтверждения о доставке сообщения static void msgok_cb(const unsigned char *peer_id); //создание канала с собеседником - static void channel_established_cb(const unsigned char *peer_id); + static void c2c_established_cb(const unsigned char *peer_id); //создать канал не удалось - static void channel_failed(const unsigned char *peer_id); + static void c2c_failed(const unsigned char *peer_id); //входящий запрос на создание канала от пользователя с номером caller_id static int accept_cb(const unsigned char *caller_id); //запрошенный пользователь не найден, в оффлайне или отказался от общения static void notfound_cb(const unsigned char *callee_id); - static void channel_closed_cb(const unsigned char *peer_id, int reason); + static void c2c_closed_cb(const unsigned char *peer_id, int reason); static void nodelist_cb(int type, void *addr_bin, const char *addr_str, unsigned int port); -- cgit v1.2.1 From c4304c26ce0ff043779e861fde9ec39f207f7600 Mon Sep 17 00:00:00 2001 From: Anton Date: Sat, 25 Jun 2016 23:35:49 +0400 Subject: added callbacks --- pica-client/skynet.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'pica-client/skynet.h') diff --git a/pica-client/skynet.h b/pica-client/skynet.h index 0b2c84b..b9e1298 100644 --- a/pica-client/skynet.h +++ b/pica-client/skynet.h @@ -131,6 +131,14 @@ private: static void file_finished(const unsigned char *peer_id, int sending); + static void c2n_established_cb(struct PICA_c2n *c2n); + + static void c2n_failed_cb(struct PICA_c2n *c2n); + + static void c2n_closed_cb(struct PICA_c2n *c2n); + + static void listener_error_cb(struct PICA_listener *lst, int errorcode); + private slots: void nodethread_finished(); void nodethread_connected(QString addr, quint16 port, NodeThread *thread); -- cgit v1.2.1 From fc15c12ff293dfebd6dd7a89d3c982e1c63eebe5 Mon Sep 17 00:00:00 2001 From: Anton Date: Mon, 15 Aug 2016 23:13:25 +0400 Subject: implemented asynchronous processing of all c2n and c2c connections in main thread --- pica-client/skynet.h | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'pica-client/skynet.h') diff --git a/pica-client/skynet.h b/pica-client/skynet.h index b9e1298..3e03b87 100644 --- a/pica-client/skynet.h +++ b/pica-client/skynet.h @@ -2,12 +2,13 @@ #define SKYNET_H #include "nodes.h" -#include "nodethread.h" #include "../PICA_client.h" #include "../PICA_proto.h" #include "accounts.h" #include #include +#include +#include class SkyNet : public QObject @@ -17,7 +18,6 @@ public: SkyNet(); void Join(Accounts::AccountRecord &accrec); bool isSelfAware(); - QString& Status(); void Exit(); void SendMessage(QByteArray to, QString msg); @@ -38,7 +38,7 @@ signals: void LostSelfAwareness(); void PeerCertificateReceived(QByteArray peer_id, QString cert_pem, bool *verified); void CertificateForged(QByteArray peer_id, QString received_cert, QString stored_cert); - void ErrMsgFromNode(QString msg); + void StatusMsg(QString msg, bool is_critical); void ContactsUpdated(); void IncomingFileRequestReceived(QByteArray peer_id, quint64 file_size, QString filename); void OutgoingFileRequestAccepted(QByteArray peer_id); @@ -58,17 +58,18 @@ signals: void c2cClosed(QByteArray peer_id); private: - Nodes nodes; - QList threads; + Nodes nodes; + QList > connecting_nodes; bool self_aware; QString status; - struct PICA_c2n *nodelink; + struct PICA_c2n *active_nodelink; struct PICA_acc *acc; Accounts::AccountRecord skynet_account; - QMutex write_mutex; + QMap > msgqueues; QMap > sndfilequeues; - int timer_id; + int retry_timer_id; + int event_loop_timer_id; void timerEvent(QTimerEvent * e); @@ -133,16 +134,18 @@ private: static void c2n_established_cb(struct PICA_c2n *c2n); - static void c2n_failed_cb(struct PICA_c2n *c2n); + static void c2n_failed_cb(struct PICA_c2n *c2n, int error); - static void c2n_closed_cb(struct PICA_c2n *c2n); + static void c2n_closed_cb(struct PICA_c2n *c2n, int error); static void listener_error_cb(struct PICA_listener *lst, int errorcode); private slots: - void nodethread_finished(); - void nodethread_connected(QString addr, quint16 port, NodeThread *thread); - void node_status_changed(QString addr,quint16 port,bool alive); + void nodelink_activated(PICA_c2n *c2n); + void nodelink_closed(PICA_c2n *c2n, int error); + void nodelink_failed(PICA_c2n *c2n, int error); + + void node_status_changed(Nodes::NodeRecord nr,bool alive); void verify_peer_cert(QByteArray peer_id, QString cert_pem, bool *verified); }; -- cgit v1.2.1 From 9c0a5bf2bbd94539427ece7eb1cb8ea82c6c3dec Mon Sep 17 00:00:00 2001 From: Anton Date: Fri, 1 Dec 2017 18:21:49 +0400 Subject: pica-client: accepting direct connections --- pica-client/skynet.h | 1 + 1 file changed, 1 insertion(+) (limited to 'pica-client/skynet.h') diff --git a/pica-client/skynet.h b/pica-client/skynet.h index 3e03b87..5384023 100644 --- a/pica-client/skynet.h +++ b/pica-client/skynet.h @@ -64,6 +64,7 @@ private: QString status; struct PICA_c2n *active_nodelink; struct PICA_acc *acc; + struct PICA_listener *listener; Accounts::AccountRecord skynet_account; QMap > msgqueues; -- cgit v1.2.1