comparison src/protocols/oscar/icon.c @ 4853:fbfdacf7c611

[gaim-migrate @ 5180] This is better auto-getting of icons for oscar. Ethan made me write a tobase16 fucntion and a from16 function (and he done gave me some good advice for that, too) which convert to and from arbitrary data and a null terminated string of hex. I use these to get and store the md5 checksum for each icon sent to you. This way, Gaim will request the icon when the md5sum differs. Er, so the md5sum is stored in blist.xml. Previously, Gaim would only request the icon if you did not have any buddy icon for the other person. Now it will request it if the local md5sum differs from the server md5sum. To sum it up again, if their icon changes, gaim will request the new one. I tried using the base64 functions, but they look like they want to work with null terminated strings, rather than arbitrary data. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sat, 22 Mar 2003 07:29:34 +0000
parents e6654fab588b
children 773135edda4a
comparison
equal deleted inserted replaced
4852:d1c17e81055e 4853:fbfdacf7c611
14 * 14 *
15 * @param sess The oscar session. 15 * @param sess The oscar session.
16 * @param conn The icon connection for this session. 16 * @param conn The icon connection for this session.
17 * @return Return 0 if no errors, otherwise return the error number. 17 * @return Return 0 if no errors, otherwise return the error number.
18 */ 18 */
19 faim_export int aim_icon_requesticon(aim_session_t *sess, const char *sn, const fu8_t *iconstr, fu16_t iconstrlen) 19 faim_export int aim_icon_requesticon(aim_session_t *sess, const char *sn, const fu8_t *iconcsum, fu16_t iconcsumlen)
20 { 20 {
21 aim_conn_t *conn; 21 aim_conn_t *conn;
22 aim_frame_t *fr; 22 aim_frame_t *fr;
23 aim_snacid_t snacid; 23 aim_snacid_t snacid;
24 24
25 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0010)) || !sn || !strlen(sn) || !iconstr || !iconstrlen) 25 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0010)) || !sn || !strlen(sn) || !iconcsum || !iconcsumlen)
26 return -EINVAL; 26 return -EINVAL;
27 27
28 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 1+strlen(sn) + 4 + 1+iconstrlen))) 28 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 1+strlen(sn) + 4 + 1+iconcsumlen)))
29 return -ENOMEM; 29 return -ENOMEM;
30 snacid = aim_cachesnac(sess, 0x0010, 0x0004, 0x0000, NULL, 0); 30 snacid = aim_cachesnac(sess, 0x0010, 0x0004, 0x0000, NULL, 0);
31 aim_putsnac(&fr->data, 0x0010, 0x0004, 0x0000, snacid); 31 aim_putsnac(&fr->data, 0x0010, 0x0004, 0x0000, snacid);
32 32
33 /* Screen name */ 33 /* Screen name */
38 aimbs_put8(&fr->data, 0x01); 38 aimbs_put8(&fr->data, 0x01);
39 aimbs_put16(&fr->data, 0x0001); 39 aimbs_put16(&fr->data, 0x0001);
40 aimbs_put8(&fr->data, 0x01); 40 aimbs_put8(&fr->data, 0x01);
41 41
42 /* Icon string */ 42 /* Icon string */
43 aimbs_put8(&fr->data, iconstrlen); 43 aimbs_put8(&fr->data, iconcsumlen);
44 aimbs_putraw(&fr->data, iconstr, iconstrlen); 44 aimbs_putraw(&fr->data, iconcsum, iconcsumlen);
45 45
46 aim_tx_enqueue(sess, fr); 46 aim_tx_enqueue(sess, fr);
47 47
48 return 0; 48 return 0;
49 } 49 }
57 static int parseicon(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) 57 static int parseicon(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
58 { 58 {
59 aim_rxcallback_t userfunc; 59 aim_rxcallback_t userfunc;
60 int i; 60 int i;
61 char *sn; 61 char *sn;
62 fu16_t iconstrlen, iconlen; 62 fu16_t flags, iconlen;
63 fu8_t iconstr[30], *icon; 63 fu8_t number, iconcsumlen, *iconcsum, *icon;
64 64
65 sn = aimbs_getstr(bs, aimbs_get8(bs)); 65 sn = aimbs_getstr(bs, aimbs_get8(bs));
66 iconstr[0] = aimbs_get8(bs); 66 flags = aimbs_get16(bs);
67 iconstr[1] = aimbs_get8(bs); 67 number = aimbs_get8(bs);
68 iconstr[2] = aimbs_get8(bs); 68 iconcsumlen = aimbs_get8(bs);
69 iconstr[3] = aimbs_get8(bs); 69 iconcsum = aimbs_getraw(bs, iconcsumlen);
70 iconstrlen = iconstr[3] + 4;
71 for (i = 4; i < iconstrlen; i++)
72 iconstr[i] = aimbs_get8(bs);
73 iconlen = aimbs_get16(bs); 70 iconlen = aimbs_get16(bs);
74 icon = aimbs_getraw(bs, iconlen); 71 icon = aimbs_getraw(bs, iconlen);
75 72
76 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype))) 73 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
77 return userfunc(sess, rx, sn, iconstr, iconstrlen, icon, iconlen); 74 return userfunc(sess, rx, sn, iconcsum, iconcsumlen, icon, iconlen);
78 75
79 free(iconstr); 76 free(iconcsum);
80 free(icon); 77 free(icon);
81 78
82 return 0; 79 return 0;
83 } 80 }
84 81