comparison libpurple/protocols/qq/send_core.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 44b4e8bd759b
comparison
equal deleted inserted replaced
15821:84b0f9b23ede 15822:32c366eeeb99
1 /** 1 /**
2 * @file send_core.c 2 * @file send_core.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
35 35
36 /* create qq packet header with given sequence 36 /* create qq packet header with given sequence
37 * return the number of bytes in header if succeeds 37 * return the number of bytes in header if succeeds
38 * return -1 if there is any error */ 38 * return -1 if there is any error */
39 gint _create_packet_head_seq(guint8 *buf, guint8 **cursor, 39 gint _create_packet_head_seq(guint8 *buf, guint8 **cursor,
40 GaimConnection *gc, guint16 cmd, gboolean is_auto_seq, guint16 *seq) 40 PurpleConnection *gc, guint16 cmd, gboolean is_auto_seq, guint16 *seq)
41 { 41 {
42 qq_data *qd; 42 qq_data *qd;
43 gint bytes_expected, bytes_written; 43 gint bytes_expected, bytes_written;
44 44
45 g_return_val_if_fail(buf != NULL && cursor != NULL && *cursor != NULL, -1); 45 g_return_val_if_fail(buf != NULL && cursor != NULL && *cursor != NULL, -1);
62 bytes_written += create_packet_w(buf, cursor, QQ_CLIENT); 62 bytes_written += create_packet_w(buf, cursor, QQ_CLIENT);
63 bytes_written += create_packet_w(buf, cursor, cmd); 63 bytes_written += create_packet_w(buf, cursor, cmd);
64 bytes_written += create_packet_w(buf, cursor, *seq); 64 bytes_written += create_packet_w(buf, cursor, *seq);
65 65
66 if (bytes_written != bytes_expected) { 66 if (bytes_written != bytes_expected) {
67 gaim_debug(GAIM_DEBUG_ERROR, "QQ", 67 purple_debug(PURPLE_DEBUG_ERROR, "QQ",
68 "Fail create qq header, expect %d bytes, written %d bytes\n", bytes_expected, bytes_written); 68 "Fail create qq header, expect %d bytes, written %d bytes\n", bytes_expected, bytes_written);
69 bytes_written = -1; 69 bytes_written = -1;
70 } 70 }
71 return bytes_written; 71 return bytes_written;
72 } 72 }
73 73
74 /* for those need ack and resend no ack feed back from server 74 /* for those need ack and resend no ack feed back from server
75 * return number of bytes written to the socket, 75 * return number of bytes written to the socket,
76 * return -1 if there is any error */ 76 * return -1 if there is any error */
77 gint _qq_send_packet(GaimConnection *gc, guint8 *buf, gint len, guint16 cmd) 77 gint _qq_send_packet(PurpleConnection *gc, guint8 *buf, gint len, guint16 cmd)
78 { 78 {
79 qq_data *qd; 79 qq_data *qd;
80 qq_sendpacket *p; 80 qq_sendpacket *p;
81 gint bytes_sent; 81 gint bytes_sent;
82 guint8 *cursor; 82 guint8 *cursor;
83 83
84 qd = (qq_data *) gc->proto_data; 84 qd = (qq_data *) gc->proto_data;
85 85
86 if (qd->use_tcp) { 86 if (qd->use_tcp) {
87 if (len > MAX_PACKET_SIZE) { 87 if (len > MAX_PACKET_SIZE) {
88 gaim_debug(GAIM_DEBUG_ERROR, "QQ", 88 purple_debug(PURPLE_DEBUG_ERROR, "QQ",
89 "xxx [%05d] %s, %d bytes is too large, do not send\n", 89 "xxx [%05d] %s, %d bytes is too large, do not send\n",
90 qq_get_cmd_desc(cmd), qd->send_seq, len); 90 qq_get_cmd_desc(cmd), qd->send_seq, len);
91 return -1; 91 return -1;
92 } else { /* I update the len for TCP packet */ 92 } else { /* I update the len for TCP packet */
93 cursor = buf; 93 cursor = buf;
113 } 113 }
114 114
115 /* send the packet generated with the given cmd and data 115 /* send the packet generated with the given cmd and data
116 * return the number of bytes sent to socket if succeeds 116 * return the number of bytes sent to socket if succeeds
117 * return -1 if there is any error */ 117 * return -1 if there is any error */
118 gint qq_send_cmd(GaimConnection *gc, guint16 cmd, 118 gint qq_send_cmd(PurpleConnection *gc, guint16 cmd,
119 gboolean is_auto_seq, guint16 seq, gboolean need_ack, guint8 *data, gint len) 119 gboolean is_auto_seq, guint16 seq, gboolean need_ack, guint8 *data, gint len)
120 { 120 {
121 qq_data *qd; 121 qq_data *qd;
122 guint8 *buf, *cursor, *encrypted_data; 122 guint8 *buf, *cursor, *encrypted_data;
123 guint16 seq_ret; 123 guint16 seq_ret;
146 bytes_sent = _qq_send_packet(gc, buf, cursor - buf, cmd); 146 bytes_sent = _qq_send_packet(gc, buf, cursor - buf, cmd);
147 else /* server's request, send ACK */ 147 else /* server's request, send ACK */
148 bytes_sent = qq_proxy_write(qd, buf, cursor - buf); 148 bytes_sent = qq_proxy_write(qd, buf, cursor - buf);
149 149
150 if (QQ_DEBUG) 150 if (QQ_DEBUG)
151 gaim_debug(GAIM_DEBUG_INFO, "QQ", 151 purple_debug(PURPLE_DEBUG_INFO, "QQ",
152 "<== [%05d] %s, %d bytes\n", seq_ret, qq_get_cmd_desc(cmd), bytes_sent); 152 "<== [%05d] %s, %d bytes\n", seq_ret, qq_get_cmd_desc(cmd), bytes_sent);
153 return bytes_sent; 153 return bytes_sent;
154 } else { /* bad packet */ 154 } else { /* bad packet */
155 gaim_debug(GAIM_DEBUG_ERROR, "QQ", 155 purple_debug(PURPLE_DEBUG_ERROR, "QQ",
156 "Fail creating packet, expect %d bytes, written %d bytes\n", 156 "Fail creating packet, expect %d bytes, written %d bytes\n",
157 bytes_expected, bytes_written); 157 bytes_expected, bytes_written);
158 return -1; 158 return -1;
159 } 159 }
160 } 160 }