4805
|
1 /*
|
|
2 * Family 0x0010 - Server stored buddy icons
|
|
3 *
|
|
4 * Used for storing and retrieving your cute little buddy icon
|
|
5 * from the AIM servers.
|
|
6 *
|
|
7 */
|
|
8
|
|
9 #define FAIM_INTERNAL
|
|
10 #include <aim.h>
|
|
11
|
|
12 /**
|
|
13 * Subtype 0x0004 - Request someone's icon.
|
|
14 *
|
|
15 * @param sess The oscar session.
|
|
16 * @param conn The icon connection for this session.
|
|
17 * @return Return 0 if no errors, otherwise return the error number.
|
|
18 */
|
4853
|
19 faim_export int aim_icon_requesticon(aim_session_t *sess, const char *sn, const fu8_t *iconcsum, fu16_t iconcsumlen)
|
4805
|
20 {
|
|
21 aim_conn_t *conn;
|
|
22 aim_frame_t *fr;
|
|
23 aim_snacid_t snacid;
|
|
24
|
4853
|
25 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0010)) || !sn || !strlen(sn) || !iconcsum || !iconcsumlen)
|
4805
|
26 return -EINVAL;
|
|
27
|
4853
|
28 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 1+strlen(sn) + 4 + 1+iconcsumlen)))
|
4805
|
29 return -ENOMEM;
|
|
30 snacid = aim_cachesnac(sess, 0x0010, 0x0004, 0x0000, NULL, 0);
|
|
31 aim_putsnac(&fr->data, 0x0010, 0x0004, 0x0000, snacid);
|
|
32
|
|
33 /* Screen name */
|
|
34 aimbs_put8(&fr->data, strlen(sn));
|
|
35 aimbs_putraw(&fr->data, sn, strlen(sn));
|
|
36
|
4826
|
37 /* Some numbers. You like numbers, right? */
|
|
38 aimbs_put8(&fr->data, 0x01);
|
|
39 aimbs_put16(&fr->data, 0x0001);
|
4805
|
40 aimbs_put8(&fr->data, 0x01);
|
|
41
|
|
42 /* Icon string */
|
4853
|
43 aimbs_put8(&fr->data, iconcsumlen);
|
|
44 aimbs_putraw(&fr->data, iconcsum, iconcsumlen);
|
4805
|
45
|
|
46 aim_tx_enqueue(sess, fr);
|
|
47
|
|
48 return 0;
|
|
49 }
|
|
50
|
|
51
|
|
52 /**
|
|
53 * Subtype 0x0005 - Receive a buddy icon.
|
|
54 *
|
|
55 * This is sent in response to a buddy icon request.
|
|
56 */
|
|
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 {
|
|
59 aim_rxcallback_t userfunc;
|
|
60 int i;
|
|
61 char *sn;
|
4853
|
62 fu16_t flags, iconlen;
|
|
63 fu8_t number, iconcsumlen, *iconcsum, *icon;
|
4805
|
64
|
|
65 sn = aimbs_getstr(bs, aimbs_get8(bs));
|
4853
|
66 flags = aimbs_get16(bs);
|
|
67 number = aimbs_get8(bs);
|
|
68 iconcsumlen = aimbs_get8(bs);
|
|
69 iconcsum = aimbs_getraw(bs, iconcsumlen);
|
4805
|
70 iconlen = aimbs_get16(bs);
|
|
71 icon = aimbs_getraw(bs, iconlen);
|
|
72
|
|
73 if ((userfunc = aim_callhandler(sess, rx->conn, snac->family, snac->subtype)))
|
4853
|
74 return userfunc(sess, rx, sn, iconcsum, iconcsumlen, icon, iconlen);
|
4805
|
75
|
4870
|
76 free(sn);
|
4853
|
77 free(iconcsum);
|
4805
|
78 free(icon);
|
|
79
|
|
80 return 0;
|
|
81 }
|
|
82
|
|
83 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs)
|
|
84 {
|
|
85
|
|
86 if (snac->subtype == 0x0005)
|
|
87 return parseicon(sess, mod, rx, snac, bs);
|
|
88
|
|
89 return 0;
|
|
90 }
|
|
91
|
|
92 faim_internal int icon_modfirst(aim_session_t *sess, aim_module_t *mod)
|
|
93 {
|
|
94
|
|
95 mod->family = 0x0010;
|
|
96 mod->version = 0x0001;
|
|
97 mod->toolid = 0x0010;
|
|
98 mod->toolversion = 0x0629;
|
|
99 mod->flags = 0;
|
|
100 strncpy(mod->name, "icon", sizeof(mod->name));
|
|
101 mod->snachandler = snachandler;
|
|
102
|
|
103 return 0;
|
|
104 }
|