about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-05-06 02:08:10 +0100
committerJames Booth <boothj5@gmail.com>2016-05-06 02:08:10 +0100
commitc009144b3d08d263e8e7f4090474470bd40dce90 (patch)
tree2b56afe5045b2feadc465cdbc937b926a73ad426
parent3cb60399a18d47ff7f36ba0fe991dced95973c60 (diff)
downloadprofani-tty-c009144b3d08d263e8e7f4090474470bd40dce90.tar.gz
Tidy connect function
-rw-r--r--src/xmpp/connection.c21
-rw-r--r--src/xmpp/connection.h2
-rw-r--r--src/xmpp/session.c6
3 files changed, 7 insertions, 22 deletions
diff --git a/src/xmpp/connection.c b/src/xmpp/connection.c
index 1ad6b1c7..98d241f6 100644
--- a/src/xmpp/connection.c
+++ b/src/xmpp/connection.c
@@ -69,9 +69,6 @@ static void _xmpp_file_logger(void *const userdata, const xmpp_log_level_t level
 static log_level_t _get_log_level(const xmpp_log_level_t xmpp_level);
 static void _connection_handler(xmpp_conn_t *const conn, const xmpp_conn_event_t status, const int error,
     xmpp_stream_error_t *const stream_error, void *const userdata);
-static jabber_conn_status_t
-_connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
-    const char *const tls_policy, char *cert_path);
 
 #ifdef HAVE_LIBMESODE
 static int _connection_certfail_cb(xmpp_tlscert_t *xmpptlscert, const char *const errormsg);
@@ -87,14 +84,13 @@ void connection_init(void)
 }
 
 jabber_conn_status_t
-connection_connect_main(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
+connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
     const char *const tls_policy)
 {
     assert(fulljid != NULL);
     assert(passwd != NULL);
 
     Jid *jid = jid_create(fulljid);
-
     if (jid == NULL) {
         log_error("Malformed JID not able to connect: %s", fulljid);
         conn.conn_status = JABBER_DISCONNECTED;
@@ -105,21 +101,10 @@ connection_connect_main(const char *const fulljid, const char *const passwd, con
         jid_destroy(jid);
         return conn.conn_status;
     }
-
     jid_destroy(jid);
 
     log_info("Connecting as %s", fulljid);
-    char *cert_path = prefs_get_string(PREF_TLS_CERTPATH);
-    jabber_conn_status_t status = _connection_connect(fulljid, passwd, altdomain, port, tls_policy, cert_path);
-    prefs_free_string(cert_path);
-
-    return status;
-}
 
-static jabber_conn_status_t
-_connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
-    const char *const tls_policy, char *cert_path)
-{
     if (conn.log) {
         free(conn.log);
     }
@@ -151,12 +136,12 @@ _connection_connect(const char *const fulljid, const char *const passwd, const c
     }
 
 #ifdef HAVE_LIBMESODE
+    char *cert_path = prefs_get_string(PREF_TLS_CERTPATH);
     if (cert_path) {
         xmpp_conn_tlscert_path(conn.conn, cert_path);
     }
-#endif
+    prefs_free_string(cert_path);
 
-#ifdef HAVE_LIBMESODE
     int connect_status = xmpp_connect_client(
         conn.conn,
         altdomain,
diff --git a/src/xmpp/connection.h b/src/xmpp/connection.h
index 6018dce1..50ef82f8 100644
--- a/src/xmpp/connection.h
+++ b/src/xmpp/connection.h
@@ -39,7 +39,7 @@
 
 void connection_init(void);
 
-jabber_conn_status_t connection_connect_main(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
+jabber_conn_status_t connection_connect(const char *const fulljid, const char *const passwd, const char *const altdomain, int port,
     const char *const tls_policy);
 
 char *connection_get_domain(void);
diff --git a/src/xmpp/session.c b/src/xmpp/session.c
index f2ec3b08..3381baab 100644
--- a/src/xmpp/session.c
+++ b/src/xmpp/session.c
@@ -126,7 +126,7 @@ session_connect_with_account(const ProfAccount *const account)
     // connect with fulljid
     Jid *jidp = jid_create_from_bare_and_resource(account->jid, account->resource);
     jabber_conn_status_t result =
-        connection_connect_main(jidp->fulljid, account->password, account->server, account->port, account->tls_policy);
+        connection_connect(jidp->fulljid, account->password, account->server, account->port, account->tls_policy);
     jid_destroy(jidp);
 
     return result;
@@ -172,7 +172,7 @@ session_connect_with_details(const char *const jid, const char *const passwd, co
     // connect with fulljid
     log_info("Connecting without account, JID: %s", saved_details.jid);
 
-    return connection_connect_main(
+    return connection_connect(
         saved_details.jid,
         passwd,
         saved_details.altdomain,
@@ -435,7 +435,7 @@ _session_reconnect(void)
     } else {
         char *fulljid = create_fulljid(account->jid, account->resource);
         log_debug("Attempting reconnect with account %s", account->name);
-        connection_connect_main(fulljid, saved_account.passwd, account->server, account->port, account->tls_policy);
+        connection_connect(fulljid, saved_account.passwd, account->server, account->port, account->tls_policy);
         free(fulljid);
         g_timer_start(reconnect_timer);
     }
ooth <boothj5@gmail.com> 2016-11-06 23:01:16 +0000 committer James Booth <boothj5@gmail.com> 2016-11-06 23:01:16 +0000 Add get_room_nick to plugins api' href='/danisanti/profani-tty/commit/src/plugins/profapi.c?id=8008d8c3c69b2c898b951e2feaf3faf3ca6fa6af'>8008d8c3 ^
41fe8c22 ^




51a7588b ^
41fe8c22 ^
1654f16a ^

ac91e7ef ^

4c913aa0 ^
a4e6d50a ^
efeb2fcf ^






2518aa50 ^

efeb2fcf ^
194c53c4 ^

623fbe9e ^
a65403c5 ^
fccf56be ^

1b25aa84 ^


c8874cd2 ^



9cfd1782 ^



7090f85d ^







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
114
115