summaryrefslogtreecommitdiff
path: root/core/Messenger.c
diff options
context:
space:
mode:
authorirungentoo <irungentoo@gmail.com>2013-08-20 19:37:05 -0400
committerirungentoo <irungentoo@gmail.com>2013-08-20 19:37:05 -0400
commit128223d9d1c70afe0adb4cfe0cfda39204379c3a (patch)
treed8191c6a088bcaf8c908fbb5e81a22825712330f /core/Messenger.c
parentc7aafcfb4cff44a60fa54fa55cd9e3519b30e720 (diff)
astyle --options=tools/astylerc -r ./*.{c,h}
Diffstat (limited to 'core/Messenger.c')
-rw-r--r--core/Messenger.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/core/Messenger.c b/core/Messenger.c
index dcf0235f..dd24ab09 100644
--- a/core/Messenger.c
+++ b/core/Messenger.c
@@ -624,28 +624,36 @@ static void LANdiscovery(Messenger *m)
624Messenger *initMessenger(void) 624Messenger *initMessenger(void)
625{ 625{
626 Messenger *m = calloc(1, sizeof(Messenger)); 626 Messenger *m = calloc(1, sizeof(Messenger));
627
627 if ( ! m ) 628 if ( ! m )
628 return NULL; 629 return NULL;
630
629 IP ip; 631 IP ip;
630 ip.i = 0; 632 ip.i = 0;
631 m->net = new_networking(ip, PORT); 633 m->net = new_networking(ip, PORT);
634
632 if (m->net == NULL) { 635 if (m->net == NULL) {
633 free(m); 636 free(m);
634 return NULL; 637 return NULL;
635 } 638 }
639
636 m->net_crypto = new_net_crypto(m->net); 640 m->net_crypto = new_net_crypto(m->net);
641
637 if (m->net_crypto == NULL) { 642 if (m->net_crypto == NULL) {
638 kill_networking(m->net); 643 kill_networking(m->net);
639 free(m); 644 free(m);
640 return NULL; 645 return NULL;
641 } 646 }
647
642 m->dht = new_DHT(m->net_crypto); 648 m->dht = new_DHT(m->net_crypto);
649
643 if (m->dht == NULL) { 650 if (m->dht == NULL) {
644 kill_net_crypto(m->net_crypto); 651 kill_net_crypto(m->net_crypto);
645 kill_networking(m->net); 652 kill_networking(m->net);
646 free(m); 653 free(m);
647 return NULL; 654 return NULL;
648 } 655 }
656
649 new_keys(m->net_crypto); 657 new_keys(m->net_crypto);
650 m_set_statusmessage(m, (uint8_t *)"Online", sizeof("Online")); 658 m_set_statusmessage(m, (uint8_t *)"Online", sizeof("Online"));
651 659
@@ -681,7 +689,8 @@ void doFriends(Messenger *m)
681 689
682 for (i = 0; i < m->numfriends; ++i) { 690 for (i = 0; i < m->numfriends; ++i) {
683 if (m->friendlist[i].status == FRIEND_ADDED) { 691 if (m->friendlist[i].status == FRIEND_ADDED) {
684 int fr = send_friendrequest(m->dht, m->friendlist[i].client_id, m->friendlist[i].friendrequest_nospam, m->friendlist[i].info, 692 int fr = send_friendrequest(m->dht, m->friendlist[i].client_id, m->friendlist[i].friendrequest_nospam,
693 m->friendlist[i].info,
685 m->friendlist[i].info_size); 694 m->friendlist[i].info_size);
686 695
687 if (fr >= 0) { 696 if (fr >= 0) {
@@ -842,7 +851,8 @@ void doFriends(Messenger *m)
842 } 851 }
843 } 852 }
844 } else { 853 } else {
845 if (is_cryptoconnected(m->net_crypto, m->friendlist[i].crypt_connection_id) == 4) { /* if the connection timed out, kill it */ 854 if (is_cryptoconnected(m->net_crypto,
855 m->friendlist[i].crypt_connection_id) == 4) { /* if the connection timed out, kill it */
846 crypto_kill(m->net_crypto, m->friendlist[i].crypt_connection_id); 856 crypto_kill(m->net_crypto, m->friendlist[i].crypt_connection_id);
847 m->friendlist[i].crypt_connection_id = -1; 857 m->friendlist[i].crypt_connection_id = -1;
848 set_friend_status(m, i, FRIEND_CONFIRMED); 858 set_friend_status(m, i, FRIEND_CONFIRMED);