comparison libpurple/protocols/qq/sendqueue.c @ 15822:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 5fe8042783c1
children b8572b937c09
comparison
equal deleted inserted replaced
15821:84b0f9b23ede 15822:32c366eeeb99
1 /** 1 /**
2 * @file sendqueue.c 2 * @file sendqueue.c
3 * 3 *
4 * gaim 4 * purple
5 * 5 *
6 * Gaim is the legal property of its developers, whose names are too numerous 6 * Purple is the legal property of its developers, whose names are too numerous
7 * to list here. Please refer to the COPYRIGHT file distributed with this 7 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * source distribution. 8 * source distribution.
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
36 #define QQ_RESEND_MAX 8 /* max resend per packet */ 36 #define QQ_RESEND_MAX 8 /* max resend per packet */
37 37
38 typedef struct _gc_and_packet gc_and_packet; 38 typedef struct _gc_and_packet gc_and_packet;
39 39
40 struct _gc_and_packet { 40 struct _gc_and_packet {
41 GaimConnection *gc; 41 PurpleConnection *gc;
42 qq_sendpacket *packet; 42 qq_sendpacket *packet;
43 }; 43 };
44 44
45 /* Remove a packet with send_seq from sendqueue */ 45 /* Remove a packet with send_seq from sendqueue */
46 void qq_sendqueue_remove(qq_data *qd, guint16 send_seq) 46 void qq_sendqueue_remove(qq_data *qd, guint16 send_seq)
73 qd->sendqueue = g_list_remove(qd->sendqueue, p); 73 qd->sendqueue = g_list_remove(qd->sendqueue, p);
74 g_free(p->buf); 74 g_free(p->buf);
75 g_free(p); 75 g_free(p);
76 i++; 76 i++;
77 } 77 }
78 gaim_debug(GAIM_DEBUG_INFO, "QQ", "%d packets in sendqueue are freed!\n", i); 78 purple_debug(PURPLE_DEBUG_INFO, "QQ", "%d packets in sendqueue are freed!\n", i);
79 } 79 }
80 80
81 /* FIXME We shouldn't be dropping packets, but for now we have to because 81 /* FIXME We shouldn't be dropping packets, but for now we have to because
82 * somewhere we're generating invalid packets that the server won't ack. 82 * somewhere we're generating invalid packets that the server won't ack.
83 * Given enough time, a buildup of those packets would crash the client. */ 83 * Given enough time, a buildup of those packets would crash the client. */
84 gboolean qq_sendqueue_timeout_callback(gpointer data) 84 gboolean qq_sendqueue_timeout_callback(gpointer data)
85 { 85 {
86 GaimConnection *gc; 86 PurpleConnection *gc;
87 qq_data *qd; 87 qq_data *qd;
88 GList *list; 88 GList *list;
89 qq_sendpacket *p; 89 qq_sendpacket *p;
90 time_t now; 90 time_t now;
91 gint wait_time; 91 gint wait_time;
92 92
93 gc = (GaimConnection *) data; 93 gc = (PurpleConnection *) data;
94 qd = (qq_data *) gc->proto_data; 94 qd = (qq_data *) gc->proto_data;
95 now = time(NULL); 95 now = time(NULL);
96 list = qd->sendqueue; 96 list = qd->sendqueue;
97 97
98 /* empty queue, return TRUE so that timeout continues functioning */ 98 /* empty queue, return TRUE so that timeout continues functioning */
116 p = (qq_sendpacket *) list->data; 116 p = (qq_sendpacket *) list->data;
117 if (p->resend_times == QQ_RESEND_MAX) { /* reach max */ 117 if (p->resend_times == QQ_RESEND_MAX) { /* reach max */
118 switch (p->cmd) { 118 switch (p->cmd) {
119 case QQ_CMD_KEEP_ALIVE: 119 case QQ_CMD_KEEP_ALIVE:
120 if (qd->logged_in) { 120 if (qd->logged_in) {
121 gaim_debug(GAIM_DEBUG_ERROR, "QQ", "Connection lost!\n"); 121 purple_debug(PURPLE_DEBUG_ERROR, "QQ", "Connection lost!\n");
122 gaim_connection_error(gc, _("Connection lost")); 122 purple_connection_error(gc, _("Connection lost"));
123 qd->logged_in = FALSE; 123 qd->logged_in = FALSE;
124 } 124 }
125 p->resend_times = -1; 125 p->resend_times = -1;
126 break; 126 break;
127 case QQ_CMD_LOGIN: 127 case QQ_CMD_LOGIN:
128 case QQ_CMD_REQUEST_LOGIN_TOKEN: 128 case QQ_CMD_REQUEST_LOGIN_TOKEN:
129 if (!qd->logged_in) /* cancel login progress */ 129 if (!qd->logged_in) /* cancel login progress */
130 gaim_connection_error(gc, _("Login failed, no reply")); 130 purple_connection_error(gc, _("Login failed, no reply"));
131 p->resend_times = -1; 131 p->resend_times = -1;
132 break; 132 break;
133 default:{ 133 default:{
134 gaim_debug(GAIM_DEBUG_WARNING, "QQ", 134 purple_debug(PURPLE_DEBUG_WARNING, "QQ",
135 "%s packet sent %d times but not acked. Not resending it.\n", 135 "%s packet sent %d times but not acked. Not resending it.\n",
136 qq_get_cmd_desc(p->cmd), QQ_RESEND_MAX); 136 qq_get_cmd_desc(p->cmd), QQ_RESEND_MAX);
137 } 137 }
138 p->resend_times = -1; 138 p->resend_times = -1;
139 } 139 }
140 } else { /* resend_times < QQ_RESEND_MAX, so sent it again */ 140 } else { /* resend_times < QQ_RESEND_MAX, so sent it again */
141 wait_time = (gint) (QQ_SENDQUEUE_TIMEOUT / 1000); 141 wait_time = (gint) (QQ_SENDQUEUE_TIMEOUT / 1000);
142 if (difftime(now, p->sendtime) > (wait_time * (p->resend_times + 1))) { 142 if (difftime(now, p->sendtime) > (wait_time * (p->resend_times + 1))) {
143 qq_proxy_write(qd, p->buf, p->len); 143 qq_proxy_write(qd, p->buf, p->len);
144 p->resend_times++; 144 p->resend_times++;
145 gaim_debug(GAIM_DEBUG_INFO, 145 purple_debug(PURPLE_DEBUG_INFO,
146 "QQ", "<<< [%05d] send again for %d times!\n", 146 "QQ", "<<< [%05d] send again for %d times!\n",
147 p->send_seq, p->resend_times); 147 p->send_seq, p->resend_times);
148 } 148 }
149 } 149 }
150 list = list->next; 150 list = list->next;