comparison src/protocols/oscar/ft.c @ 3033:1143524a2eaf

[gaim-migrate @ 3046] Laying the ground work for image send. Also an IRC fix. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Tue, 12 Mar 2002 17:21:46 +0000
parents 08327a2f25aa
children 9682c0e022c6
comparison
equal deleted inserted replaced
3032:d3536105d581 3033:1143524a2eaf
179 179
180 /** 180 /**
181 * aim_send_im_direct - send IM client-to-client over established connection 181 * aim_send_im_direct - send IM client-to-client over established connection
182 * @sess: session to conn 182 * @sess: session to conn
183 * @conn: directim connection 183 * @conn: directim connection
184 * @msg: null-terminated string to send. 184 * @msg: null-terminated string to send.
185 * len: The length of the message to send, including binary data.
185 * 186 *
186 * Call this just like you would aim_send_im, to send a directim. You 187 * Call this just like you would aim_send_im, to send a directim. You
187 * _must_ have previously established the directim connection. 188 * _must_ have previously established the directim connection.
188 */ 189 */
189 faim_export int aim_send_im_direct(aim_session_t *sess, aim_conn_t *conn, const char *msg) 190 faim_export int aim_send_im_direct(aim_session_t *sess, aim_conn_t *conn, const char *msg, int len)
190 { 191 {
191 struct aim_directim_intdata *intdata = (struct aim_directim_intdata *)conn->internal; 192 struct aim_directim_intdata *intdata = (struct aim_directim_intdata *)conn->internal;
192 aim_frame_t *fr; 193 aim_frame_t *fr;
193 aim_bstream_t hdrbs; /* XXX this should be within aim_frame_t */ 194 aim_bstream_t hdrbs; /* XXX this should be within aim_frame_t */
194 195
195 if (!sess || !conn || !msg || (conn->type != AIM_CONN_TYPE_RENDEZVOUS)) 196 if (!sess || !conn || !msg || (conn->type != AIM_CONN_TYPE_RENDEZVOUS))
196 return -EINVAL; 197 return -EINVAL;
197 198
198 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x01, strlen(msg)))) 199 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_OFT, 0x01, len)))
199 return -ENOMEM; 200 return -ENOMEM;
200 201
201 memcpy(fr->hdr.oft.magic, "ODC2", 4); 202 memcpy(fr->hdr.oft.magic, "ODC2", 4);
202 203
203 fr->hdr.oft.hdr2len = 0x44; 204 fr->hdr.oft.hdr2len = 0x44;
214 aimbs_putraw(&hdrbs, intdata->cookie, 8); 215 aimbs_putraw(&hdrbs, intdata->cookie, 8);
215 aimbs_put16(&hdrbs, 0x0000); 216 aimbs_put16(&hdrbs, 0x0000);
216 aimbs_put16(&hdrbs, 0x0000); 217 aimbs_put16(&hdrbs, 0x0000);
217 aimbs_put16(&hdrbs, 0x0000); 218 aimbs_put16(&hdrbs, 0x0000);
218 aimbs_put16(&hdrbs, 0x0000); 219 aimbs_put16(&hdrbs, 0x0000);
219 aimbs_put32(&hdrbs, strlen(msg)); 220 aimbs_put32(&hdrbs, len);
220 aimbs_put16(&hdrbs, 0x0000); 221 aimbs_put16(&hdrbs, 0x0000);
221 aimbs_put16(&hdrbs, 0x0000); 222 aimbs_put16(&hdrbs, 0x0000);
222 aimbs_put16(&hdrbs, 0x0000); 223 aimbs_put16(&hdrbs, 0x0000);
223 224
224 /* flags -- 0x000e for "started typing", 0x0002 for "stopped typing, 0x0000 for message */ 225 /* flags -- 0x000e for "started typing", 0x0002 for "stopped typing, 0x0000 for message */
249 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0001); 250 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x0001);
250 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x2e0f); 251 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x2e0f);
251 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x393e); 252 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0x393e);
252 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0xcac8); 253 i += aimutil_put16(newpacket->hdr.oft.hdr2+i, 0xcac8);
253 #endif 254 #endif
254 aimbs_putraw(&fr->data, msg, strlen(msg)); 255 aimbs_putraw(&fr->data, msg, len);
255 256
256 aim_tx_enqueue(sess, fr); 257 aim_tx_enqueue(sess, fr);
257 258
258 return 0; 259 return 0;
259 } 260 }
1119 free(msg); 1120 free(msg);
1120 return -1; 1121 return -1;
1121 } 1122 }
1122 recvd = recvd + i; 1123 recvd = recvd + i;
1123 msg2 = msg2 + i; 1124 msg2 = msg2 + i;
1124 if ((userfunc=aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_DOWNLOADIMAGE))) 1125 if ((userfunc=aim_callhandler(sess, conn, AIM_CB_FAM_SPECIAL, AIM_CB_SPECIAL_IMAGETRANSFER)))
1125 userfunc(sess, &fr, snptr, (double)recvd / payloadlength); 1126 userfunc(sess, &fr, snptr, (double)recvd / payloadlength);
1126 } 1127 }
1127 1128
1128 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING)) ) 1129 if ( (userfunc = aim_callhandler(sess, conn, AIM_CB_FAM_OFT, AIM_CB_OFT_DIRECTIMINCOMING)) )
1129 ret = userfunc(sess, &fr, snptr, msg, payloadlength); 1130 ret = userfunc(sess, &fr, snptr, msg, payloadlength);