Mercurial > pidgin
comparison src/protocols/oscar/family_bart.c @ 13592:6519aeb66b31
[gaim-migrate @ 15978]
Holy cow this is crazy.
34 files changed, 5760 insertions(+), 8517 deletions(-)
* Non-blocking I/O for all of oscar. That includes normal FLAP
connections as well as file transfers and direct IM.
* Kick-ass file transfer and direct IM. Either party can request
the connection. Gaim will try both the "public" IP and the
"client" IP. It'll fall back to transferring through a proxy
if that fails. Should be relatively few memleaks (I didn't
have a lot of confidence in the non-memleakiness of the old
code). And the code is reasonably generic, so it shouldn't
be too much work to add voice chat. This might still be a
LITTLE buggy, but it shouldn't be too bad. If anything, file
transfer will be more buggy than direct IM. And sending a
file will be more buggy than receiving a file. Bug reports
with a series of steps to reproduce are welcome.
* I merged OscarData and aim_session_t
* Somewhere between 50 and 100 hours of work.
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 07 Apr 2006 05:10:56 +0000 |
parents | 87a7c3077c19 |
children |
comparison
equal
deleted
inserted
replaced
13591:dcfda39ad547 | 13592:6519aeb66b31 |
---|---|
29 #include "oscar.h" | 29 #include "oscar.h" |
30 | 30 |
31 /** | 31 /** |
32 * Subtype 0x0002 - Upload your icon. | 32 * Subtype 0x0002 - Upload your icon. |
33 * | 33 * |
34 * @param sess The oscar session. | 34 * @param od The oscar session. |
35 * @param conn The icon connection for this session. | |
36 * @param icon The raw data of the icon image file. | 35 * @param icon The raw data of the icon image file. |
37 * @param iconlen Length of the raw data of the icon image file. | 36 * @param iconlen Length of the raw data of the icon image file. |
38 * @return Return 0 if no errors, otherwise return the error number. | 37 * @return Return 0 if no errors, otherwise return the error number. |
39 */ | 38 */ |
40 faim_export int aim_bart_upload(OscarSession *sess, const guint8 *icon, guint16 iconlen) | 39 int |
40 aim_bart_upload(OscarData *od, const guint8 *icon, guint16 iconlen) | |
41 { | 41 { |
42 OscarConnection *conn; | 42 FlapConnection *conn; |
43 FlapFrame *fr; | 43 FlapFrame *fr; |
44 aim_snacid_t snacid; | 44 aim_snacid_t snacid; |
45 | 45 |
46 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0010)) || !icon || !iconlen) | 46 if (!od || !(conn = flap_connection_findbygroup(od, 0x0010)) || !icon || !iconlen) |
47 return -EINVAL; | 47 return -EINVAL; |
48 | 48 |
49 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 2 + 2+iconlen))) | 49 fr = flap_frame_new(od, 0x02, 10 + 2 + 2+iconlen); |
50 return -ENOMEM; | 50 snacid = aim_cachesnac(od, 0x0010, 0x0002, 0x0000, NULL, 0); |
51 snacid = aim_cachesnac(sess, 0x0010, 0x0002, 0x0000, NULL, 0); | |
52 aim_putsnac(&fr->data, 0x0010, 0x0002, 0x0000, snacid); | 51 aim_putsnac(&fr->data, 0x0010, 0x0002, 0x0000, snacid); |
53 | 52 |
54 /* The reference number for the icon */ | 53 /* The reference number for the icon */ |
55 aimbs_put16(&fr->data, 1); | 54 byte_stream_put16(&fr->data, 1); |
56 | 55 |
57 /* The icon */ | 56 /* The icon */ |
58 aimbs_put16(&fr->data, iconlen); | 57 byte_stream_put16(&fr->data, iconlen); |
59 aimbs_putraw(&fr->data, icon, iconlen); | 58 byte_stream_putraw(&fr->data, icon, iconlen); |
60 | 59 |
61 aim_tx_enqueue(sess, fr); | 60 flap_connection_send(conn, fr); |
62 | 61 |
63 return 0; | 62 return 0; |
64 } | 63 } |
65 | 64 |
66 /** | 65 /** |
67 * Subtype 0x0003 - Acknowledgement for uploading a buddy icon. | 66 * Subtype 0x0003 - Acknowledgement for uploading a buddy icon. |
68 * | 67 * |
69 * You get this honky after you upload a buddy icon. | 68 * You get this honky after you upload a buddy icon. |
70 */ | 69 */ |
71 static int uploadack(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 70 static int |
71 uploadack(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
72 { | 72 { |
73 int ret = 0; | 73 int ret = 0; |
74 aim_rxcallback_t userfunc; | 74 aim_rxcallback_t userfunc; |
75 guint16 something, somethingelse; | 75 guint16 something, somethingelse; |
76 guint8 onemorething; | 76 guint8 onemorething; |
77 | 77 |
78 something = aimbs_get16(bs); | 78 something = byte_stream_get16(bs); |
79 somethingelse = aimbs_get16(bs); | 79 somethingelse = byte_stream_get16(bs); |
80 onemorething = aimbs_get8(bs); | 80 onemorething = byte_stream_get8(bs); |
81 | 81 |
82 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 82 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
83 ret = userfunc(sess, rx); | 83 ret = userfunc(od, conn, frame); |
84 | 84 |
85 return ret; | 85 return ret; |
86 } | 86 } |
87 | 87 |
88 /** | 88 /** |
89 * Subtype 0x0004 - Request someone's icon. | 89 * Subtype 0x0004 - Request someone's icon. |
90 * | 90 * |
91 * @param sess The oscar session. | 91 * @param od The oscar session. |
92 * @param conn The icon connection for this session. | |
93 * @param sn The screen name of the person who's icon you are requesting. | 92 * @param sn The screen name of the person who's icon you are requesting. |
94 * @param iconcsum The MD5 checksum of the icon you are requesting. | 93 * @param iconcsum The MD5 checksum of the icon you are requesting. |
95 * @param iconcsumlen Length of the MD5 checksum given above. Should be 10 bytes. | 94 * @param iconcsumlen Length of the MD5 checksum given above. Should be 10 bytes. |
96 * @return Return 0 if no errors, otherwise return the error number. | 95 * @return Return 0 if no errors, otherwise return the error number. |
97 */ | 96 */ |
98 faim_export int aim_bart_request(OscarSession *sess, const char *sn, guint8 iconcsumtype, const guint8 *iconcsum, guint16 iconcsumlen) | 97 int |
98 aim_bart_request(OscarData *od, const char *sn, guint8 iconcsumtype, const guint8 *iconcsum, guint16 iconcsumlen) | |
99 { | 99 { |
100 OscarConnection *conn; | 100 FlapConnection *conn; |
101 FlapFrame *fr; | 101 FlapFrame *fr; |
102 aim_snacid_t snacid; | 102 aim_snacid_t snacid; |
103 | 103 |
104 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0010)) || !sn || !strlen(sn) || !iconcsum || !iconcsumlen) | 104 if (!od || !(conn = flap_connection_findbygroup(od, 0x0010)) || !sn || !strlen(sn) || !iconcsum || !iconcsumlen) |
105 return -EINVAL; | 105 return -EINVAL; |
106 | 106 |
107 if (!(fr = flap_frame_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 1+strlen(sn) + 4 + 1+iconcsumlen))) | 107 fr = flap_frame_new(od, 0x02, 10 + 1+strlen(sn) + 4 + 1+iconcsumlen); |
108 return -ENOMEM; | 108 snacid = aim_cachesnac(od, 0x0010, 0x0004, 0x0000, NULL, 0); |
109 snacid = aim_cachesnac(sess, 0x0010, 0x0004, 0x0000, NULL, 0); | |
110 aim_putsnac(&fr->data, 0x0010, 0x0004, 0x0000, snacid); | 109 aim_putsnac(&fr->data, 0x0010, 0x0004, 0x0000, snacid); |
111 | 110 |
112 /* Screen name */ | 111 /* Screen name */ |
113 aimbs_put8(&fr->data, strlen(sn)); | 112 byte_stream_put8(&fr->data, strlen(sn)); |
114 aimbs_putstr(&fr->data, sn); | 113 byte_stream_putstr(&fr->data, sn); |
115 | 114 |
116 /* Some numbers. You like numbers, right? */ | 115 /* Some numbers. You like numbers, right? */ |
117 aimbs_put8(&fr->data, 0x01); | 116 byte_stream_put8(&fr->data, 0x01); |
118 aimbs_put16(&fr->data, 0x0001); | 117 byte_stream_put16(&fr->data, 0x0001); |
119 aimbs_put8(&fr->data, iconcsumtype); | 118 byte_stream_put8(&fr->data, iconcsumtype); |
120 | 119 |
121 /* Icon string */ | 120 /* Icon string */ |
122 aimbs_put8(&fr->data, iconcsumlen); | 121 byte_stream_put8(&fr->data, iconcsumlen); |
123 aimbs_putraw(&fr->data, iconcsum, iconcsumlen); | 122 byte_stream_putraw(&fr->data, iconcsum, iconcsumlen); |
124 | 123 |
125 aim_tx_enqueue(sess, fr); | 124 flap_connection_send(conn, fr); |
126 | 125 |
127 return 0; | 126 return 0; |
128 } | 127 } |
129 | 128 |
130 /** | 129 /** |
131 * Subtype 0x0005 - Receive a buddy icon. | 130 * Subtype 0x0005 - Receive a buddy icon. |
132 * | 131 * |
133 * This is sent in response to a buddy icon request. | 132 * This is sent in response to a buddy icon request. |
134 */ | 133 */ |
135 static int parseicon(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 134 static int |
135 parseicon(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
136 { | 136 { |
137 int ret = 0; | 137 int ret = 0; |
138 aim_rxcallback_t userfunc; | 138 aim_rxcallback_t userfunc; |
139 char *sn; | 139 char *sn; |
140 guint16 flags, iconlen; | 140 guint16 flags, iconlen; |
141 guint8 iconcsumtype, iconcsumlen, *iconcsum, *icon; | 141 guint8 iconcsumtype, iconcsumlen, *iconcsum, *icon; |
142 | 142 |
143 sn = aimbs_getstr(bs, aimbs_get8(bs)); | 143 sn = byte_stream_getstr(bs, byte_stream_get8(bs)); |
144 flags = aimbs_get16(bs); | 144 flags = byte_stream_get16(bs); |
145 iconcsumtype = aimbs_get8(bs); | 145 iconcsumtype = byte_stream_get8(bs); |
146 iconcsumlen = aimbs_get8(bs); | 146 iconcsumlen = byte_stream_get8(bs); |
147 iconcsum = aimbs_getraw(bs, iconcsumlen); | 147 iconcsum = byte_stream_getraw(bs, iconcsumlen); |
148 iconlen = aimbs_get16(bs); | 148 iconlen = byte_stream_get16(bs); |
149 icon = aimbs_getraw(bs, iconlen); | 149 icon = byte_stream_getraw(bs, iconlen); |
150 | 150 |
151 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) | 151 if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
152 ret = userfunc(sess, rx, sn, iconcsumtype, iconcsum, iconcsumlen, icon, iconlen); | 152 ret = userfunc(od, conn, frame, sn, iconcsumtype, iconcsum, iconcsumlen, icon, iconlen); |
153 | 153 |
154 free(sn); | 154 free(sn); |
155 free(iconcsum); | 155 free(iconcsum); |
156 free(icon); | 156 free(icon); |
157 | 157 |
158 return ret; | 158 return ret; |
159 } | 159 } |
160 | 160 |
161 static int snachandler(OscarSession *sess, aim_module_t *mod, FlapFrame *rx, aim_modsnac_t *snac, ByteStream *bs) | 161 static int |
162 snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) | |
162 { | 163 { |
163 | |
164 if (snac->subtype == 0x0003) | 164 if (snac->subtype == 0x0003) |
165 return uploadack(sess, mod, rx, snac, bs); | 165 return uploadack(od, conn, mod, frame, snac, bs); |
166 else if (snac->subtype == 0x0005) | 166 else if (snac->subtype == 0x0005) |
167 return parseicon(sess, mod, rx, snac, bs); | 167 return parseicon(od, conn, mod, frame, snac, bs); |
168 | 168 |
169 return 0; | 169 return 0; |
170 } | 170 } |
171 | 171 |
172 faim_internal int bart_modfirst(OscarSession *sess, aim_module_t *mod) | 172 int |
173 bart_modfirst(OscarData *od, aim_module_t *mod) | |
173 { | 174 { |
174 | |
175 mod->family = 0x0010; | 175 mod->family = 0x0010; |
176 mod->version = 0x0001; | 176 mod->version = 0x0001; |
177 mod->toolid = 0x0010; | 177 mod->toolid = 0x0010; |
178 mod->toolversion = 0x0629; | 178 mod->toolversion = 0x0629; |
179 mod->flags = 0; | 179 mod->flags = 0; |