Mercurial > pidgin
annotate libfaim/aim_info.c @ 931:59d9e1177ab5
[gaim-migrate @ 941]
yay! let's recompile everything, again!
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Wed, 20 Sep 2000 23:35:17 +0000 |
parents | e18815f5a4e9 |
children | 1d8f05ea6bdf |
rev | line source |
---|---|
2 | 1 /* |
237 | 2 * aim_info.c |
3 * | |
4 * The functions here are responsible for requesting and parsing information- | |
5 * gathering SNACs. | |
6 * | |
2 | 7 */ |
8 | |
9 | |
283
0f14e6d8a51b
[gaim-migrate @ 293]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
249
diff
changeset
|
10 #include <faim/aim.h> |
2 | 11 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
12 struct aim_priv_inforeq { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
13 char sn[MAXSNLEN]; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
14 unsigned short infotype; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
15 }; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
16 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
17 faim_export unsigned long aim_getinfo(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
18 struct aim_conn_t *conn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
19 const char *sn, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
20 unsigned short infotype) |
237 | 21 { |
22 struct command_tx_struct *newpacket; | |
23 int i = 0; | |
2 | 24 |
237 | 25 if (!sess || !conn || !sn) |
26 return 0; | |
2 | 27 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
28 if (!(newpacket = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 12+1+strlen(sn)))) |
237 | 29 return -1; |
30 | |
31 newpacket->lock = 1; | |
32 | |
33 i = aim_putsnac(newpacket->data, 0x0002, 0x0005, 0x0000, sess->snac_nextid); | |
2 | 34 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
35 i += aimutil_put16(newpacket->data+i, infotype); |
237 | 36 i += aimutil_put8(newpacket->data+i, strlen(sn)); |
37 i += aimutil_putstr(newpacket->data+i, sn, strlen(sn)); | |
2 | 38 |
237 | 39 newpacket->lock = 0; |
40 aim_tx_enqueue(sess, newpacket); | |
2 | 41 |
42 { | |
43 struct aim_snac_t snac; | |
44 | |
237 | 45 snac.id = sess->snac_nextid; |
2 | 46 snac.family = 0x0002; |
47 snac.type = 0x0005; | |
48 snac.flags = 0x0000; | |
49 | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
50 snac.data = malloc(sizeof(struct aim_priv_inforeq)); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
51 strcpy(((struct aim_priv_inforeq *)snac.data)->sn, sn); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
52 ((struct aim_priv_inforeq *)snac.data)->infotype = infotype; |
2 | 53 |
237 | 54 aim_newsnac(sess, &snac); |
2 | 55 } |
56 | |
237 | 57 return (sess->snac_nextid++); |
58 } | |
59 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
60 faim_internal int aim_parse_locateerr(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
61 struct command_rx_struct *command) |
835
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
62 { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
63 u_long snacid = 0x000000000; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
64 struct aim_snac_t *snac = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
65 int ret = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
66 rxcallback_t userfunc = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
67 char *dest; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
68 unsigned short reason = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
69 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
70 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
71 * Get SNAC from packet and look it up |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
72 * the list of unrepliedto/outstanding |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
73 * SNACs. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
74 * |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
75 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
76 snacid = aimutil_get32(command->data+6); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
77 snac = aim_remsnac(sess, snacid); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
78 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
79 if (!snac) { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
80 printf("faim: locerr: got an locate-failed error on an unknown SNAC ID! (%08lx)\n", snacid); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
81 dest = NULL; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
82 } else |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
83 dest = snac->data; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
84 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
85 reason = aimutil_get16(command->data+10); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
86 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
87 /* |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
88 * Call client. |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
89 */ |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
90 userfunc = aim_callhandler(command->conn, 0x0002, 0x0001); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
91 if (userfunc) |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
92 ret = userfunc(sess, command, dest, reason); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
93 else |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
94 ret = 0; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
95 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
96 if (snac) { |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
97 free(snac->data); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
98 free(snac); |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
99 } |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
100 |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
101 return ret; |
88f8f98de02d
[gaim-migrate @ 845]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
445
diff
changeset
|
102 } |
237 | 103 |
104 /* | |
105 * Capability blocks. | |
106 */ | |
107 u_char aim_caps[6][16] = { | |
108 | |
109 /* Buddy icon */ | |
110 {0x09, 0x46, 0x13, 0x46, 0x4c, 0x7f, 0x11, 0xd1, | |
111 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
112 | |
113 /* Voice */ | |
114 {0x09, 0x46, 0x13, 0x41, 0x4c, 0x7f, 0x11, 0xd1, | |
115 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
116 | |
117 /* IM image */ | |
118 {0x09, 0x46, 0x13, 0x45, 0x4c, 0x7f, 0x11, 0xd1, | |
119 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
120 | |
121 /* Chat */ | |
122 {0x74, 0x8f, 0x24, 0x20, 0x62, 0x87, 0x11, 0xd1, | |
123 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
124 | |
125 /* Get file */ | |
126 {0x09, 0x46, 0x13, 0x48, 0x4c, 0x7f, 0x11, 0xd1, | |
127 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00}, | |
128 | |
129 /* Send file */ | |
130 {0x09, 0x46, 0x13, 0x43, 0x4c, 0x7f, 0x11, 0xd1, | |
131 0x82, 0x22, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} | |
132 }; | |
133 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
134 faim_internal unsigned short aim_getcap(unsigned char *capblock, int buflen) |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
135 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
136 u_short ret = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
137 int y; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
138 int offset = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
139 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
140 while (offset < buflen) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
141 for(y=0; y < (sizeof(aim_caps)/0x10); y++) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
142 if (memcmp(&aim_caps[y], capblock+offset, 0x10) == 0) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
143 switch(y) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
144 case 0: ret |= AIM_CAPS_BUDDYICON; break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
145 case 1: ret |= AIM_CAPS_VOICE; break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
146 case 2: ret |= AIM_CAPS_IMIMAGE; break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
147 case 3: ret |= AIM_CAPS_CHAT; break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
148 case 4: ret |= AIM_CAPS_GETFILE; break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
149 case 5: ret |= AIM_CAPS_SENDFILE; break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
150 default: ret |= 0xff00; break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
151 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
152 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
153 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
154 offset += 0x10; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
155 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
156 return ret; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
157 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
158 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
159 faim_internal int aim_putcap(unsigned char *capblock, int buflen, u_short caps) |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
160 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
161 int offset = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
162 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
163 if (!capblock) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
164 return -1; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
165 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
166 if ((caps & AIM_CAPS_BUDDYICON) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
167 memcpy(capblock+offset, aim_caps[0], sizeof(aim_caps[0])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
168 offset += sizeof(aim_caps[1]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
169 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
170 if ((caps & AIM_CAPS_VOICE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
171 memcpy(capblock+offset, aim_caps[1], sizeof(aim_caps[1])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
172 offset += sizeof(aim_caps[1]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
173 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
174 if ((caps & AIM_CAPS_IMIMAGE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
175 memcpy(capblock+offset, aim_caps[2], sizeof(aim_caps[2])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
176 offset += sizeof(aim_caps[2]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
177 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
178 if ((caps & AIM_CAPS_CHAT) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
179 memcpy(capblock+offset, aim_caps[3], sizeof(aim_caps[3])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
180 offset += sizeof(aim_caps[3]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
181 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
182 if ((caps & AIM_CAPS_GETFILE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
183 memcpy(capblock+offset, aim_caps[4], sizeof(aim_caps[4])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
184 offset += sizeof(aim_caps[4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
185 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
186 if ((caps & AIM_CAPS_SENDFILE) && (offset < buflen)) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
187 memcpy(capblock+offset, aim_caps[5], sizeof(aim_caps[5])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
188 offset += sizeof(aim_caps[5]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
189 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
190 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
191 return offset; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
192 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
193 |
237 | 194 /* |
195 * AIM is fairly regular about providing user info. This | |
196 * is a generic routine to extract it in its standard form. | |
197 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
198 faim_internal int aim_extractuserinfo(u_char *buf, struct aim_userinfo_s *outinfo) |
237 | 199 { |
200 int i = 0; | |
201 int tlvcnt = 0; | |
202 int curtlv = 0; | |
203 int tlv1 = 0; | |
204 u_short curtype; | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
205 int lastvalid; |
237 | 206 |
207 | |
208 if (!buf || !outinfo) | |
209 return -1; | |
210 | |
211 /* Clear out old data first */ | |
212 memset(outinfo, 0x00, sizeof(struct aim_userinfo_s)); | |
213 | |
214 /* | |
215 * Screen name. Stored as an unterminated string prepended | |
216 * with an unsigned byte containing its length. | |
217 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
218 if (buf[i] < MAXSNLEN) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
219 memcpy(outinfo->sn, &(buf[i+1]), buf[i]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
220 outinfo->sn[(int)buf[i]] = '\0'; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
221 } else { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
222 memcpy(outinfo->sn, &(buf[i+1]), MAXSNLEN-1); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
223 outinfo->sn[MAXSNLEN] = '\0'; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
224 } |
237 | 225 i = 1 + (int)buf[i]; |
226 | |
227 /* | |
228 * Warning Level. Stored as an unsigned short. | |
229 */ | |
230 outinfo->warnlevel = aimutil_get16(&buf[i]); | |
231 i += 2; | |
232 | |
233 /* | |
234 * TLV Count. Unsigned short representing the number of | |
235 * Type-Length-Value triples that follow. | |
236 */ | |
237 tlvcnt = aimutil_get16(&buf[i]); | |
238 i += 2; | |
239 | |
240 /* | |
241 * Parse out the Type-Length-Value triples as they're found. | |
242 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
243 while (curtlv < tlvcnt) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
244 lastvalid = 1; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
245 curtype = aimutil_get16(&buf[i]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
246 switch (curtype) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
247 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
248 * Type = 0x0000: Invalid |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
249 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
250 * AOL has been trying to throw these in just to break us. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
251 * They're real nice guys over there at AOL. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
252 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
253 * Just skip the two zero bytes and continue on. (This doesn't |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
254 * count towards tlvcnt!) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
255 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
256 case 0x0000: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
257 lastvalid = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
258 i += 2; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
259 break; |
237 | 260 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
261 /* |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
262 * Type = 0x0001: User flags |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
263 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
264 * Specified as any of the following bitwise ORed together: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
265 * 0x0001 Trial (user less than 60days) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
266 * 0x0002 Unknown bit 2 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
267 * 0x0004 AOL Main Service user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
268 * 0x0008 Unknown bit 4 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
269 * 0x0010 Free (AIM) user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
270 * 0x0020 Away |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
271 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
272 * In some odd cases, we can end up with more |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
273 * than one of these. We only want the first, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
274 * as the others may not be something we want. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
275 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
276 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
277 case 0x0001: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
278 if (tlv1) /* use only the first */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
279 break; |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
280 outinfo->flags = aimutil_get16(&buf[i+4]); |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
281 tlv1++; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
282 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
283 |
237 | 284 /* |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
285 * Type = 0x0002: Member-Since date. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
286 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
287 * The time/date that the user originally |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
288 * registered for the service, stored in |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
289 * time_t format |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
290 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
291 case 0x0002: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
292 outinfo->membersince = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
293 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
294 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
295 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
296 * Type = 0x0003: On-Since date. |
237 | 297 * |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
298 * The time/date that the user started |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
299 * their current session, stored in time_t |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
300 * format. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
301 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
302 case 0x0003: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
303 outinfo->onlinesince = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
304 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
305 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
306 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
307 * Type = 0x0004: Idle time. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
308 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
309 * Number of seconds since the user |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
310 * actively used the service. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
311 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
312 case 0x0004: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
313 outinfo->idletime = aimutil_get16(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
314 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
315 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
316 /* |
931
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
317 * Type = 0x0006: ICQ Online Status |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
318 * |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
319 * ICQ's Away/DND/etc "enriched" status |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
320 * Some decoding of values done by Scott <darkagl@pcnet.com> |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
321 */ |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
322 case 0x0006: |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
323 if (aimutil_get16(buf+i+2) != 0x04) |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
324 break; |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
325 outinfo->icqinfo.status = aimutil_get16(buf+i+2+2+2); |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
326 break; |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
327 |
59d9e1177ab5
[gaim-migrate @ 941]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
900
diff
changeset
|
328 /* |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
329 * Type = 0x000d |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
330 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
331 * Capability information. Not real sure of |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
332 * actual decoding. See comment on aim_bos_setprofile() |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
333 * in aim_misc.c about the capability block, its the same. |
237 | 334 * |
335 */ | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
336 case 0x000d: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
337 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
338 int len; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
339 len = aimutil_get16(buf+i+2); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
340 if (!len) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
341 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
342 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
343 outinfo->capabilities = aim_getcap(buf+i+4, len); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
344 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
345 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
346 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
347 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
348 * Type = 0x000e |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
349 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
350 * Unknown. Always of zero length, and always only |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
351 * on AOL users. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
352 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
353 * Ignore. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
354 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
355 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
356 case 0x000e: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
357 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
358 |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
359 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
360 * Type = 0x000f: Session Length. (AIM) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
361 * Type = 0x0010: Session Length. (AOL) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
362 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
363 * The duration, in seconds, of the user's |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
364 * current session. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
365 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
366 * Which TLV type this comes in depends |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
367 * on the service the user is using (AIM or AOL). |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
368 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
369 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
370 case 0x000f: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
371 case 0x0010: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
372 outinfo->sessionlen = aimutil_get32(&buf[i+4]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
373 break; |
237 | 374 |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
375 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
376 * Reaching here indicates that either AOL has |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
377 * added yet another TLV for us to deal with, |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
378 * or the parsing has gone Terribly Wrong. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
379 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
380 * Either way, inform the owner and attempt |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
381 * recovery. |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
382 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
383 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
384 default: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
385 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
386 int len,z = 0, y = 0, x = 0; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
387 char tmpstr[80]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
388 printf("faim: userinfo: **warning: unexpected TLV:\n"); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
389 printf("faim: userinfo: sn =%s\n", outinfo->sn); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
390 printf("faim: userinfo: curtlv=0x%04x\n", curtlv); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
391 printf("faim: userinfo: type =0x%04x\n",aimutil_get16(&buf[i])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
392 printf("faim: userinfo: length=0x%04x\n", len = aimutil_get16(&buf[i+2])); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
393 printf("faim: userinfo: data: \n"); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
394 while (z<len) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
395 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
396 x = sprintf(tmpstr, "faim: userinfo: "); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
397 for (y = 0; y < 8; y++) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
398 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
399 if (z<len) |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
400 { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
401 sprintf(tmpstr+x, "%02x ", buf[i+4+z]); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
402 z++; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
403 x += 3; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
404 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
405 else |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
406 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
407 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
408 printf("%s\n", tmpstr); |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
409 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
410 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
411 break; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
412 } |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
413 /* |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
414 * No matter what, TLV triplets should always look like this: |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
415 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
416 * u_short type; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
417 * u_short length; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
418 * u_char data[length]; |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
419 * |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
420 */ |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
421 if (lastvalid) { |
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
422 i += (2 + 2 + aimutil_get16(&buf[i+2])); |
237 | 423 curtlv++; |
424 } | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
425 } |
237 | 426 |
427 return i; | |
428 } | |
429 | |
430 /* | |
431 * Oncoming Buddy notifications contain a subset of the | |
432 * user information structure. Its close enough to run | |
433 * through aim_extractuserinfo() however. | |
434 * | |
435 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
436 faim_internal int aim_parse_oncoming_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
437 struct command_rx_struct *command) |
237 | 438 { |
439 struct aim_userinfo_s userinfo; | |
440 u_int i = 0; | |
441 rxcallback_t userfunc=NULL; | |
442 | |
443 i = 10; | |
444 i += aim_extractuserinfo(command->data+i, &userinfo); | |
445 | |
446 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_BUD, AIM_CB_BUD_ONCOMING); | |
447 if (userfunc) | |
448 i = userfunc(sess, command, &userinfo); | |
449 | |
450 return 1; | |
451 } | |
452 | |
453 /* | |
454 * Offgoing Buddy notifications contain no useful | |
455 * information other than the name it applies to. | |
456 * | |
457 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
458 faim_internal int aim_parse_offgoing_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
459 struct command_rx_struct *command) |
237 | 460 { |
461 char sn[MAXSNLEN+1]; | |
462 u_int i = 0; | |
463 rxcallback_t userfunc=NULL; | |
464 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
465 strncpy(sn, (char *)command->data+11, (int)command->data[10]); |
237 | 466 sn[(int)command->data[10]] = '\0'; |
467 | |
468 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_BUD, AIM_CB_BUD_OFFGOING); | |
469 if (userfunc) | |
470 i = userfunc(sess, command, sn); | |
471 | |
472 return 1; | |
2 | 473 } |
474 | |
475 /* | |
476 * This parses the user info stuff out all nice and pretty then calls | |
477 * the higher-level callback (in the user app). | |
478 * | |
479 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
480 faim_internal int aim_parse_userinfo_middle(struct aim_session_t *sess, |
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
481 struct command_rx_struct *command) |
2 | 482 { |
237 | 483 struct aim_userinfo_s userinfo; |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
484 char *text_encoding = NULL; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
485 char *text = NULL; |
237 | 486 u_int i = 0; |
487 rxcallback_t userfunc=NULL; | |
488 struct aim_tlvlist_t *tlvlist; | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
489 struct aim_snac_t *origsnac = NULL; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
490 u_long snacid; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
491 struct aim_priv_inforeq *inforeq; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
492 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
493 snacid = aimutil_get32(&command->data[6]); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
494 origsnac = aim_remsnac(sess, snacid); |
2 | 495 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
496 if (!origsnac || !origsnac->data) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
497 printf("faim: parse_userinfo_middle: major problem: no snac stored!\n"); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
498 return 1; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
499 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
500 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
501 inforeq = (struct aim_priv_inforeq *)origsnac->data; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
502 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
503 switch (inforeq->infotype) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
504 case AIM_GETINFO_GENERALINFO: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
505 case AIM_GETINFO_AWAYMESSAGE: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
506 i = 10; |
2 | 507 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
508 /* |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
509 * extractuserinfo will give us the basic metaTLV information |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
510 */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
511 i += aim_extractuserinfo(command->data+i, &userinfo); |
237 | 512 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
513 /* |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
514 * However, in this command, there's usually more TLVs following... |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
515 */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
516 tlvlist = aim_readtlvchain(command->data+i, command->commandlen-i); |
237 | 517 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
518 /* |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
519 * Depending on what informational text was requested, different |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
520 * TLVs will appear here. |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
521 * |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
522 * Profile will be 1 and 2, away message will be 3 and 4. |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
523 */ |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
524 if (aim_gettlv(tlvlist, 0x0001, 1)) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
525 text_encoding = aim_gettlv_str(tlvlist, 0x0001, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
526 text = aim_gettlv_str(tlvlist, 0x0002, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
527 } else if (aim_gettlv(tlvlist, 0x0003, 1)) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
528 text_encoding = aim_gettlv_str(tlvlist, 0x0003, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
529 text = aim_gettlv_str(tlvlist, 0x0004, 1); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
530 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
531 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
532 userfunc = aim_callhandler(command->conn, AIM_CB_FAM_LOC, AIM_CB_LOC_USERINFO); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
533 if (userfunc) { |
237 | 534 i = userfunc(sess, |
535 command, | |
536 &userinfo, | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
537 text_encoding, |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
538 text, |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
539 inforeq->infotype); |
2 | 540 } |
237 | 541 |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
542 free(text_encoding); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
543 free(text); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
544 aim_freetlvchain(&tlvlist); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
545 break; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
546 default: |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
547 printf("faim: parse_userinfo_middle: unknown infotype in request! (0x%04x)\n", inforeq->infotype); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
548 break; |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
549 } |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
550 |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
551 if (origsnac) { |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
552 if (origsnac->data) |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
553 free(origsnac->data); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
554 free(origsnac); |
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
555 } |
2 | 556 |
237 | 557 return 1; |
558 } | |
559 | |
560 /* | |
561 * Inverse of aim_extractuserinfo() | |
562 */ | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
563 faim_internal int aim_putuserinfo(u_char *buf, int buflen, struct aim_userinfo_s *info) |
237 | 564 { |
565 int i = 0; | |
566 struct aim_tlvlist_t *tlvlist = NULL; | |
567 | |
568 if (!buf || !info) | |
569 return 0; | |
570 | |
571 i += aimutil_put8(buf+i, strlen(info->sn)); | |
572 i += aimutil_putstr(buf+i, info->sn, strlen(info->sn)); | |
573 | |
574 i += aimutil_put16(buf+i, info->warnlevel); | |
575 | |
576 /* XXX: we only put down five */ | |
577 i += aimutil_put16(buf+i, 5); | |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
578 aim_addtlvtochain16(&tlvlist, 0x0001, info->flags); |
237 | 579 aim_addtlvtochain32(&tlvlist, 0x0002, info->membersince); |
580 aim_addtlvtochain32(&tlvlist, 0x0003, info->onlinesince); | |
581 aim_addtlvtochain16(&tlvlist, 0x0004, info->idletime); | |
582 /* XXX: should put caps here */ | |
900
e18815f5a4e9
[gaim-migrate @ 910]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
889
diff
changeset
|
583 aim_addtlvtochain32(&tlvlist, (unsigned short)((info->flags)&AIM_FLAG_AOL?0x0010:0x000f), info->sessionlen); |
237 | 584 |
585 i += aim_writetlvchain(buf+i, buflen-i, &tlvlist); | |
586 aim_freetlvchain(&tlvlist); | |
587 | |
2 | 588 return i; |
589 } | |
237 | 590 |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
591 faim_export int aim_sendbuddyoncoming(struct aim_session_t *sess, struct aim_conn_t *conn, struct aim_userinfo_s *info) |
237 | 592 { |
593 struct command_tx_struct *tx; | |
594 int i = 0; | |
595 | |
596 if (!sess || !conn || !info) | |
597 return 0; | |
598 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
599 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 1152))) |
237 | 600 return -1; |
601 | |
602 tx->lock = 1; | |
603 | |
604 i += aimutil_put16(tx->data+i, 0x0003); | |
605 i += aimutil_put16(tx->data+i, 0x000b); | |
606 i += aimutil_put16(tx->data+i, 0x0000); | |
607 i += aimutil_put16(tx->data+i, 0x0000); | |
608 i += aimutil_put16(tx->data+i, 0x0000); | |
609 | |
610 i += aim_putuserinfo(tx->data+i, tx->commandlen-i, info); | |
611 | |
612 tx->commandlen = i; | |
613 tx->lock = 0; | |
614 aim_tx_enqueue(sess, tx); | |
615 | |
616 return 0; | |
617 } | |
618 | |
840
595ac7759563
[gaim-migrate @ 850]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
835
diff
changeset
|
619 faim_export int aim_sendbuddyoffgoing(struct aim_session_t *sess, struct aim_conn_t *conn, char *sn) |
237 | 620 { |
621 struct command_tx_struct *tx; | |
622 int i = 0; | |
623 | |
624 if (!sess || !conn || !sn) | |
625 return 0; | |
626 | |
445
e4c34ca88d9b
[gaim-migrate @ 455]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
283
diff
changeset
|
627 if (!(tx = aim_tx_new(AIM_FRAMETYPE_OSCAR, 0x0002, conn, 10+1+strlen(sn)))) |
237 | 628 return -1; |
629 | |
630 tx->lock = 1; | |
631 | |
632 i += aimutil_put16(tx->data+i, 0x0003); | |
633 i += aimutil_put16(tx->data+i, 0x000c); | |
634 i += aimutil_put16(tx->data+i, 0x0000); | |
635 i += aimutil_put16(tx->data+i, 0x0000); | |
636 i += aimutil_put16(tx->data+i, 0x0000); | |
637 | |
638 i += aimutil_put8(tx->data+i, strlen(sn)); | |
639 i += aimutil_putstr(tx->data+i, sn, strlen(sn)); | |
640 | |
641 tx->lock = 0; | |
642 aim_tx_enqueue(sess, tx); | |
643 | |
644 return 0; | |
645 } | |
249
810c595258c8
[gaim-migrate @ 259]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
237
diff
changeset
|
646 |