Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/bosh.c @ 25600:1cbe5a9f6efb
* adding bosh files to Makefile.am & .mingw
* establishing HTTP connection for BOSH
author | Tobias Markmann <tfar@soc.pidgin.im> |
---|---|
date | Tue, 05 Aug 2008 18:44:42 +0000 |
parents | b238da95f39a |
children | 15d9825a5621 |
comparison
equal
deleted
inserted
replaced
25599:3176d5a0b9dd | 25600:1cbe5a9f6efb |
---|---|
35 #include "presence.h" | 35 #include "presence.h" |
36 #include "xdata.h" | 36 #include "xdata.h" |
37 #include "pep.h" | 37 #include "pep.h" |
38 #include "adhoccommands.h" | 38 #include "adhoccommands.h" |
39 | 39 |
40 PurpleHTTPHeaderField* jabber_bosh_http_header_field(const char *name, *const char *value) { | 40 void jabber_bosh_connection_init(PurpleBOSHConnection *conn, PurpleAccount *account, char *url) { |
41 PurpleHTTPHeaderField *tmp = g_new0(PurpleHTTPHeaderField, 0); | 41 conn->pipelining = TRUE; |
42 tmp->name = g_strdup(name); | 42 conn->account = account; |
43 tmp->value = g_strdup(value); | 43 if (!purple_url_parse(url, &(conn->host), &(conn->port), &(conn->path), &(conn->user), &(conn->passwd))) { |
44 return tmp; | 44 purple_debug_info("jabber", "Unable to parse given URL.\n"); |
45 return; | |
46 } | |
47 if (conn->user || conn->passwd) { | |
48 purple_debug_info("jabber", "Sorry, HTTP Authentication isn't supported yet. Username and password in the BOSH URL will be ignored.\n"); | |
49 } | |
50 conn->conn_a = g_new0(PurpleHTTPConnection, 1); | |
51 jabber_bosh_http_connection_init(conn->conn_a, conn->account, conn->host, conn->port); | |
52 conn->conn_a->userdata = conn; | |
53 } | |
54 | |
55 static void jabber_bosh_connection_connected(PurpleHTTPConnection *conn) { | |
56 PurpleBOSHConnection *bosh_conn = conn->userdata; | |
57 if (bosh_conn->connect_cb) bosh_conn->connect_cb(bosh_conn); | |
58 } | |
59 | |
60 void jabber_bosh_connection_connect(PurpleBOSHConnection *conn) { | |
61 conn->conn_a->connect_cb = jabber_bosh_connection_connected; | |
62 jabber_bosh_http_connection_connect(conn->conn_a); | |
63 } | |
64 | |
65 | |
66 void jabber_bosh_http_connection_init(PurpleHTTPConnection *conn, PurpleAccount *account, char *host, int port) { | |
67 conn->account = account; | |
68 conn->host = host; | |
69 conn->port = port; | |
70 conn->connect_cb = NULL; | |
71 } | |
72 | |
73 static void jabber_bosh_http_connection_callback(gpointer data, gint source, const gchar *error) { | |
74 PurpleHTTPConnection *conn = data; | |
75 if (source < 0) { | |
76 purple_debug_info("jabber", "Couldn't connect becasue of: %s\n", error); | |
77 return; | |
78 } | |
79 conn->fd = source; | |
80 if (conn->connect_cb) conn->connect_cb(conn); | |
45 } | 81 } |
46 | 82 |
47 void jabber_bosh_http_connection_connect(PurpleHTTPConnection *conn) { | 83 void jabber_bosh_http_connection_connect(PurpleHTTPConnection *conn) { |
48 | 84 if((purple_proxy_connect(&(conn->handle), conn->account, conn->host, conn->port, jabber_bosh_http_connection_callback, conn)) == NULL) { |
85 purple_debug_info("jabber", "Unable to connect to %s.\n", conn->host); | |
86 } | |
49 } | 87 } |