annotate src/protocols/qq/send_core.c @ 14115:8ea1929c4c69

[gaim-migrate @ 16749] Fix a bunch of warnings that I caused. Sorry, I should have compiled before committing. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Mon, 14 Aug 2006 07:27:41 +0000
parents ef8490f9e823
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
1 /**
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
2 * The QQ2003C protocol plugin
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
3 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
4 * for gaim
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
5 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
6 * Copyright (C) 2004 Puzzlebird
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
7 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
11 * (at your option) any later version.
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
12 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
16 * GNU General Public License for more details.
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
17 *
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
21 */
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
22
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
23 #include "debug.h"
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
24 #include "internal.h"
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
25
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
26 #include "crypt.h"
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
27 #include "header_info.h"
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
28 #include "packet_parse.h"
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
29 #include "qq.h"
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
30 #include "qq_proxy.h"
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
31 #include "send_core.h"
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
32 #include "sendqueue.h"
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
33
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
34 /* create qq packet header with given sequence
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
35 * return the number of bytes in header if succeeds
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
36 * return -1 if there is any error */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
37 gint _create_packet_head_seq(guint8 *buf, guint8 **cursor,
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
38 GaimConnection *gc, guint16 cmd, gboolean is_auto_seq, guint16 *seq)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
39 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
40 qq_data *qd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
41 gint bytes_expected, bytes_written;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
42
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
43 g_return_val_if_fail(gc != NULL &&
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
44 gc->proto_data != NULL && buf != NULL && cursor != NULL && *cursor != NULL, -1);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
45
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
46 qd = (qq_data *) gc->proto_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
47 if (is_auto_seq)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
48 *seq = ++(qd->send_seq);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
49
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
50 *cursor = buf;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
51 bytes_written = 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
52 bytes_expected = (qd->use_tcp) ? QQ_TCP_HEADER_LENGTH : QQ_UDP_HEADER_LENGTH;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
53
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
54 /* QQ TCP packet has two bytes in the begining defines packet length
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
55 * so I leave room here for size */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
56 if (qd->use_tcp)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
57 bytes_written += create_packet_w(buf, cursor, 0x0000);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
58
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
59 /* now comes the normal QQ packet as UDP */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
60 bytes_written += create_packet_b(buf, cursor, QQ_PACKET_TAG);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
61 bytes_written += create_packet_w(buf, cursor, QQ_CLIENT);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
62 bytes_written += create_packet_w(buf, cursor, cmd);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
63 bytes_written += create_packet_w(buf, cursor, *seq);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
64
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
65 if (bytes_written != bytes_expected) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
66 gaim_debug(GAIM_DEBUG_ERROR, "QQ",
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
67 "Fail create qq header, expect %d bytes, written %d bytes\n", bytes_expected, bytes_written);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
68 bytes_written = -1;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
69 }
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
70 return bytes_written;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
71 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
72
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
73 /* for those need ack and resend no ack feed back from server
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
74 * return number of bytes written to the socket,
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
75 * return -1 if there is any error */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
76 gint _qq_send_packet(GaimConnection * gc, guint8 *buf, gint len, guint16 cmd)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
77 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
78 qq_data *qd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
79 qq_sendpacket *p;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
80 gint bytes_sent;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
81 guint8 *cursor;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
82
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
83 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, -1);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
84
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
85 qd = (qq_data *) gc->proto_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
86
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
87 if (qd->use_tcp) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
88 if (len > MAX_PACKET_SIZE) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
89 gaim_debug(GAIM_DEBUG_ERROR, "QQ",
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
90 "xxx [%05d] %s, %d bytes is too large, do not send\n",
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
91 qq_get_cmd_desc(cmd), qd->send_seq, len);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
92 return -1;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
93 } else { /* I update the len for TCP packet */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
94 cursor = buf;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
95 create_packet_w(buf, &cursor, len);
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
96 }
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
97 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
98
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
99 bytes_sent = qq_proxy_write(qd, buf, len);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
100
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
101 if (bytes_sent >= 0) { /* put to queue, for matching server ACK usage */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
102 p = g_new0(qq_sendpacket, 1);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
103 p->fd = qd->fd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
104 p->cmd = cmd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
105 p->send_seq = qd->send_seq;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
106 p->resend_times = 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
107 p->sendtime = time(NULL);
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
108 p->buf = g_memdup(buf, len); /* don't use g_strdup, may have 0x00 */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
109 p->len = len;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
110 qd->sendqueue = g_list_append(qd->sendqueue, p);
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
111 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
112
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
113 return bytes_sent;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
114 }
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
115
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
116 /* send the packet generated with the given cmd and data
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
117 * return the number of bytes sent to socket if succeeds
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
118 * return -1 if there is any error */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
119 gint qq_send_cmd(GaimConnection *gc, guint16 cmd,
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
120 gboolean is_auto_seq, guint16 seq, gboolean need_ack, guint8 *data, gint len)
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
121 {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
122 qq_data *qd;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
123 guint8 *buf, *cursor, *encrypted_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
124 guint16 seq_ret;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
125 gint encrypted_len, bytes_written, bytes_expected, bytes_sent;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
126
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
127 g_return_val_if_fail(gc != NULL && gc->proto_data != NULL, -1);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
128
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
129 qd = (qq_data *) gc->proto_data;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
130 g_return_val_if_fail(qd->session_key != NULL, -1);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
131
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
132 buf = g_newa(guint8, MAX_PACKET_SIZE);
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
133 encrypted_len = len + 16; /* at most 16 bytes more */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
134 encrypted_data = g_newa(guint8, encrypted_len);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
135 cursor = buf;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
136 bytes_written = 0;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
137
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
138 qq_crypt(ENCRYPT, data, len, qd->session_key, encrypted_data, &encrypted_len);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
139
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
140 seq_ret = seq;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
141 if (_create_packet_head_seq(buf, &cursor, gc, cmd, is_auto_seq, &seq_ret) >= 0) {
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
142 bytes_expected = 4 + encrypted_len + 1;
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
143 bytes_written += create_packet_dw(buf, &cursor, (guint32) qd->uid);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
144 bytes_written += create_packet_data(buf, &cursor, encrypted_data, encrypted_len);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
145 bytes_written += create_packet_b(buf, &cursor, QQ_PACKET_TAIL);
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
146 if (bytes_written == bytes_expected) { /* packet OK */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
147 /* if it does not need ACK, we send ACK manually several times */
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
148 if (need_ack) /* my request, send it */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
149 bytes_sent = _qq_send_packet(gc, buf, cursor - buf, cmd);
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
150 else /* server's request, send ACK */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
151 bytes_sent = qq_proxy_write(qd, buf, cursor - buf);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
152
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
153 if (QQ_DEBUG)
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
154 gaim_debug(GAIM_DEBUG_INFO, "QQ",
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
155 "<== [%05d] %s, %d bytes\n", seq_ret, qq_get_cmd_desc(cmd), bytes_sent);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
156 return bytes_sent;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
157 } else { /* bad packet */
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
158 gaim_debug(GAIM_DEBUG_ERROR, "QQ",
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
159 "Fail creating packet, expect %d bytes, written %d bytes\n",
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
160 bytes_expected, bytes_written);
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
161 return -1;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
162 }
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
163 }
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
164
13870
983fd420e86b [gaim-migrate @ 16340]
Mark Huetsch <markhuetsch>
parents:
diff changeset
165 return -1;
14021
ef8490f9e823 [gaim-migrate @ 16618]
Mark Huetsch <markhuetsch>
parents: 13871
diff changeset
166 }