Mercurial > pidgin
comparison libpurple/protocols/qq/qq_network.c @ 31193:1bf763879b96
2011.02.06 - flos <lonicerae(at)gmail.com>
* 'typedef struct _X {} X' cleaned
* added a check
* added some comment
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Sun, 06 Feb 2011 06:43:26 +0000 |
parents | 4deef745de87 |
children | b671728e6ee9 |
comparison
equal
deleted
inserted
replaced
31192:ab175460cea7 | 31193:1bf763879b96 |
---|---|
40 #include "qq_process.h" | 40 #include "qq_process.h" |
41 | 41 |
42 #define QQ_DEFAULT_PORT 8000 | 42 #define QQ_DEFAULT_PORT 8000 |
43 | 43 |
44 /* set QQ_CONNECT_MAX to 1, when test reconnecting */ | 44 /* set QQ_CONNECT_MAX to 1, when test reconnecting */ |
45 #define QQ_CONNECT_MAX 3 | 45 #define QQ_CONNECT_MAX 3 |
46 #define QQ_CONNECT_INTERVAL 2 | 46 #define QQ_CONNECT_INTERVAL 2 |
47 #define QQ_CONNECT_CHECK 5 | 47 #define QQ_CONNECT_CHECK 5 |
48 #define QQ_KEEP_ALIVE_INTERVAL 60 | 48 #define QQ_KEEP_ALIVE_INTERVAL 60 |
49 #define QQ_TRANS_INTERVAL 10 | 49 #define QQ_TRANS_INTERVAL 10 |
50 | 50 |
51 gboolean connect_to_server(PurpleConnection *gc, gchar *server, gint port); | 51 gboolean connect_to_server(PurpleConnection *gc, gchar *server, gint port); |
52 | 52 |
53 static qq_connection *connection_find(qq_data *qd, int fd) { | 53 static qq_connection *connection_find(qq_data *qd, int fd) { |
54 qq_connection *ret = NULL; | 54 qq_connection *ret = NULL; |
61 return NULL; | 61 return NULL; |
62 } | 62 } |
63 | 63 |
64 static qq_connection *connection_create(qq_data *qd, int fd) { | 64 static qq_connection *connection_create(qq_data *qd, int fd) { |
65 qq_connection *ret = g_new0(qq_connection, 1); | 65 qq_connection *ret = g_new0(qq_connection, 1); |
66 g_return_val_if_fail(ret != NULL, NULL); | |
66 ret->fd = fd; | 67 ret->fd = fd; |
67 qd->openconns = g_slist_append(qd->openconns, ret); | 68 qd->openconns = g_slist_append(qd->openconns, ret); |
68 return ret; | 69 return ret; |
69 } | 70 } |
70 | 71 |
770 qd->connect_watcher = purple_timeout_add_seconds(QQ_CONNECT_INTERVAL, qq_connect_later, gc); | 771 qd->connect_watcher = purple_timeout_add_seconds(QQ_CONNECT_INTERVAL, qq_connect_later, gc); |
771 return; | 772 return; |
772 } | 773 } |
773 | 774 |
774 /* _qq_show_socket("Got login socket", source); */ | 775 /* _qq_show_socket("Got login socket", source); */ |
776 /* ok, already connected to the server */ | |
775 qd->fd = source; | 777 qd->fd = source; |
776 conn = connection_create(qd, source); | 778 conn = connection_create(qd, source); |
779 g_return_if_fail( conn != NULL ); | |
780 | |
777 if (qd->use_tcp) { | 781 if (qd->use_tcp) { |
782 /* events which match "PURPLE_INPUT_READ" of | |
783 * "source" would trigger the callback function */ | |
778 conn->input_handler = purple_input_add(source, PURPLE_INPUT_READ, tcp_pending, gc); | 784 conn->input_handler = purple_input_add(source, PURPLE_INPUT_READ, tcp_pending, gc); |
779 } else { | 785 } else { |
780 conn->input_handler = purple_input_add(source, PURPLE_INPUT_READ, udp_pending, gc); | 786 conn->input_handler = purple_input_add(source, PURPLE_INPUT_READ, udp_pending, gc); |
781 } | 787 } |
782 | 788 |