about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorDmitry Podgorny <pasis.ua@gmail.com>2013-01-07 21:35:20 +0200
committerDmitry Podgorny <pasis.ua@gmail.com>2013-01-07 22:00:13 +0200
commite0e8110746a1dfeeff6bf03aae00d7d0c9a56517 (patch)
tree6a8e8c597364c1e1622e17727cdb9b1de0d75f53
parent621832ee4a621f82f4bd693e7c7bf52944c3671a (diff)
downloadprofani-tty-e0e8110746a1dfeeff6bf03aae00d7d0c9a56517.tar.gz
jabber.c: set jabber status in one place in connection handler
-rw-r--r--src/jabber.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/jabber.c b/src/jabber.c
index 8d2dc572..a13feea8 100644
--- a/src/jabber.c
+++ b/src/jabber.c
@@ -202,8 +202,8 @@ jabber_disconnect(void)
     // if connected, send end stream and wait for response
     if (jabber_conn.conn_status == JABBER_CONNECTED) {
         log_info("Closing connection");
-        xmpp_disconnect(jabber_conn.conn);
         jabber_conn.conn_status = JABBER_DISCONNECTING;
+        xmpp_disconnect(jabber_conn.conn);
 
         while (jabber_get_connection_status() == JABBER_DISCONNECTING) {
             jabber_process_events();
@@ -782,40 +782,33 @@ _connection_handler(xmpp_conn_t * const conn,
             }
         }
 
-    } else {
-
-        // received close stream response from server after disconnect
-        if (jabber_conn.conn_status == JABBER_DISCONNECTING) {
-            jabber_conn.conn_status = JABBER_DISCONNECTED;
-            jabber_conn.presence = PRESENCE_OFFLINE;
+    } else if (status == XMPP_CONN_DISCONNECT) {
 
         // lost connection for unkown reason
-        } else if (jabber_conn.conn_status == JABBER_CONNECTED) {
+        if (jabber_conn.conn_status == JABBER_CONNECTED) {
             prof_handle_lost_connection();
             if (prefs_get_reconnect() != 0) {
                 assert(reconnect_timer == NULL);
                 reconnect_timer = g_timer_new();
             }
             xmpp_stop(ctx);
-            jabber_conn.conn_status = JABBER_DISCONNECTED;
-            jabber_conn.presence = PRESENCE_OFFLINE;
 
         // login attempt failed
-        } else {
+        } else if (jabber_conn.conn_status != JABBER_DISCONNECTING) {
             if (reconnect_timer == NULL) {
                 prof_handle_failed_login();
-                jabber_conn.conn_status = JABBER_DISCONNECTED;
-                jabber_conn.presence = PRESENCE_OFFLINE;
                 jabber_free_resources();
             } else {
                 xmpp_stop(ctx);
                 if (prefs_get_reconnect() != 0) {
                     g_timer_start(reconnect_timer);
                 }
-                jabber_conn.conn_status = JABBER_DISCONNECTED;
-                jabber_conn.presence = PRESENCE_OFFLINE;
             }
         }
+
+        // close stream response from server after disconnect is handled too
+        jabber_conn.conn_status = JABBER_DISCONNECTED;
+        jabber_conn.presence = PRESENCE_OFFLINE;
     }
 }
 
58201bb57a07ea931d1764064fc52e64'>1a4de9dd ^
14a38052 ^





ebd35521 ^

14a38052 ^
















ac07e589 ^
14a38052 ^

ac07e589 ^
14a38052 ^
ac07e589 ^
14a38052 ^
08a0eed6 ^
14a38052 ^
ac07e589 ^
14a38052 ^
ac07e589 ^
14a38052 ^


901ae474 ^
14a38052 ^
ac07e589 ^

14a38052 ^

ac07e589 ^
14a38052 ^
ac07e589 ^
14a38052 ^


1a4de9dd ^



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113