Mercurial > pidgin
annotate src/protocols/oscar/icq.c @ 11544:6723c4930e50
[gaim-migrate @ 13799]
Was this space intentional?
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 14 Sep 2005 12:45:23 +0000 |
parents | 7d31d61e6438 |
children | 7d41c624557f |
rev | line source |
---|---|
2703 | 1 /* |
3952 | 2 * Family 0x0015 - Encapsulated ICQ. |
2703 | 3 * |
4 */ | |
5 | |
6 #define FAIM_INTERNAL | |
7 #include <aim.h> | |
8 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
9 faim_export int aim_icq_reqofflinemsgs(aim_session_t *sess) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
10 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
11 aim_conn_t *conn; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
12 aim_frame_t *fr; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
13 aim_snacid_t snacid; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
14 int bslen; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
15 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
16 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
17 return -EINVAL; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
18 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
19 bslen = 2 + 4 + 2 + 2; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
20 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
21 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
22 return -ENOMEM; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
23 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
24 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
25 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
26 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
27 /* For simplicity, don't bother using a tlvlist */ |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
28 aimbs_put16(&fr->data, 0x0001); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
29 aimbs_put16(&fr->data, bslen); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
30 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
31 aimbs_putle16(&fr->data, bslen - 2); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
32 aimbs_putle32(&fr->data, atoi(sess->sn)); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
33 aimbs_putle16(&fr->data, 0x003c); /* I command thee. */ |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
34 aimbs_putle16(&fr->data, snacid); /* eh. */ |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
35 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
36 aim_tx_enqueue(sess, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
37 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
38 return 0; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
39 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
40 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
41 faim_export int aim_icq_ackofflinemsgs(aim_session_t *sess) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
42 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
43 aim_conn_t *conn; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
44 aim_frame_t *fr; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
45 aim_snacid_t snacid; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
46 int bslen; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
47 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
48 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
49 return -EINVAL; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
50 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
51 bslen = 2 + 4 + 2 + 2; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
52 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
53 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
54 return -ENOMEM; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
55 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
56 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
57 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
58 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
59 /* For simplicity, don't bother using a tlvlist */ |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
60 aimbs_put16(&fr->data, 0x0001); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
61 aimbs_put16(&fr->data, bslen); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
62 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
63 aimbs_putle16(&fr->data, bslen - 2); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
64 aimbs_putle32(&fr->data, atoi(sess->sn)); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
65 aimbs_putle16(&fr->data, 0x003e); /* I command thee. */ |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
66 aimbs_putle16(&fr->data, snacid); /* eh. */ |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
67 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
68 aim_tx_enqueue(sess, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
69 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
70 return 0; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
71 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
72 |
10570 | 73 /** |
74 * Set your ICQ security. | |
75 * | |
76 * @param sess The oscar session. | |
77 * @param auth Ask authorization when a buddy adds us? | |
78 * @param web Show our presence on the ICQ web site. | |
79 * @param hide Hide our IP address. | |
80 * @return Return 0 if no errors, otherwise return the error number. | |
81 */ | |
82 faim_export int aim_icq_setsecurity(aim_session_t *sess, const int auth, const int web, const int hide) | |
4664 | 83 { |
84 aim_conn_t *conn; | |
85 aim_frame_t *fr; | |
86 aim_snacid_t snacid; | |
87 int bslen; | |
88 | |
89 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) | |
90 return -EINVAL; | |
91 | |
92 bslen = 2+4+2+2+2+4; | |
93 | |
94 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) | |
95 return -ENOMEM; | |
96 | |
97 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); | |
98 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); | |
99 | |
100 /* For simplicity, don't bother using a tlvlist */ | |
101 aimbs_put16(&fr->data, 0x0001); | |
102 aimbs_put16(&fr->data, bslen); | |
103 | |
104 aimbs_putle16(&fr->data, bslen - 2); | |
105 aimbs_putle32(&fr->data, atoi(sess->sn)); | |
106 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ | |
107 aimbs_putle16(&fr->data, snacid); /* eh. */ | |
108 aimbs_putle16(&fr->data, 0x0424); /* shrug. */ | |
10570 | 109 aimbs_putle8(&fr->data, (auth == TRUE) ? 0x00 : 0x01); |
110 aimbs_putle8(&fr->data, (web == TRUE) ? 0x00 : 0x01); | |
111 aimbs_putle8(&fr->data, (hide == TRUE) ? 0x00 : 0x01); | |
112 aimbs_putle8(&fr->data, 0x00); | |
4664 | 113 |
114 aim_tx_enqueue(sess, fr); | |
115 | |
116 return 0; | |
117 } | |
118 | |
10570 | 119 /** |
10595 | 120 * I'm not really sure what the difference is between this function |
121 * and the one above. They both definitely exist. | |
10570 | 122 */ |
10560 | 123 faim_export int aim_icq_setauthsetting(aim_session_t *sess, int auth_required) |
124 { | |
125 aim_conn_t *conn; | |
126 aim_frame_t *fr; | |
127 aim_snacid_t snacid; | |
128 int bslen; | |
129 | |
130 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) | |
131 return -EINVAL; | |
132 | |
133 bslen = 2+4+2+2+2+4; | |
134 | |
135 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) | |
136 return -ENOMEM; | |
137 | |
138 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); | |
139 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); | |
140 | |
141 /* For simplicity, don't bother using a tlvlist */ | |
142 aimbs_put16(&fr->data, 0x0001); | |
143 aimbs_put16(&fr->data, bslen); | |
144 | |
145 aimbs_putle16(&fr->data, bslen - 2); | |
146 aimbs_putle32(&fr->data, atoi(sess->sn)); | |
147 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ | |
148 aimbs_putle16(&fr->data, snacid); /* eh. */ | |
149 aimbs_putle16(&fr->data, 0x0c3a); /* shrug. */ | |
150 aimbs_putle16(&fr->data, 0x02f8); | |
151 aimbs_putle16(&fr->data, 0x0001); | |
152 aimbs_putle8(&fr->data, auth_required); | |
153 aimbs_putle8(&fr->data, 0x0c); | |
154 aimbs_putle16(&fr->data, 0x0103); | |
10595 | 155 aimbs_putle16(&fr->data, 0x0000); /* web enabled or not! */ |
10560 | 156 |
157 aim_tx_enqueue(sess, fr); | |
158 | |
159 return 0; | |
160 } | |
161 | |
5345 | 162 /** |
163 * Change your ICQ password. | |
164 * | |
165 * @param sess The oscar session | |
166 * @param passwd The new password. If this is longer than 8 characters it | |
167 * will be truncated. | |
168 * @return Return 0 if no errors, otherwise return the error number. | |
169 */ | |
4617 | 170 faim_export int aim_icq_changepasswd(aim_session_t *sess, const char *passwd) |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
171 { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
172 aim_conn_t *conn; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
173 aim_frame_t *fr; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
174 aim_snacid_t snacid; |
5345 | 175 int bslen, passwdlen; |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
176 |
4617 | 177 if (!passwd) |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
178 return -EINVAL; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
179 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
180 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
181 return -EINVAL; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
182 |
5345 | 183 passwdlen = strlen(passwd); |
184 if (passwdlen > MAXICQPASSLEN) | |
185 passwdlen = MAXICQPASSLEN; | |
186 bslen = 2+4+2+2+2+2+passwdlen+1; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
187 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
188 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
189 return -ENOMEM; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
190 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
191 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
192 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
193 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
194 /* For simplicity, don't bother using a tlvlist */ |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
195 aimbs_put16(&fr->data, 0x0001); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
196 aimbs_put16(&fr->data, bslen); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
197 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
198 aimbs_putle16(&fr->data, bslen - 2); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
199 aimbs_putle32(&fr->data, atoi(sess->sn)); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
200 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
201 aimbs_putle16(&fr->data, snacid); /* eh. */ |
4617 | 202 aimbs_putle16(&fr->data, 0x042e); /* shrug. */ |
5345 | 203 aimbs_putle16(&fr->data, passwdlen+1); |
10997 | 204 aimbs_putstr(&fr->data, passwd); |
4617 | 205 aimbs_putle8(&fr->data, '\0'); |
206 | |
207 aim_tx_enqueue(sess, fr); | |
208 | |
209 return 0; | |
210 } | |
211 | |
212 faim_export int aim_icq_getallinfo(aim_session_t *sess, const char *uin) | |
213 { | |
214 aim_conn_t *conn; | |
215 aim_frame_t *fr; | |
216 aim_snacid_t snacid; | |
217 int bslen; | |
4624 | 218 struct aim_icq_info *info; |
4617 | 219 |
220 if (!uin || uin[0] < '0' || uin[0] > '9') | |
221 return -EINVAL; | |
222 | |
223 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) | |
224 return -EINVAL; | |
225 | |
226 bslen = 2 + 4 + 2 + 2 + 2 + 4; | |
227 | |
228 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) | |
229 return -ENOMEM; | |
230 | |
231 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); | |
232 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); | |
233 | |
234 /* For simplicity, don't bother using a tlvlist */ | |
235 aimbs_put16(&fr->data, 0x0001); | |
236 aimbs_put16(&fr->data, bslen); | |
237 | |
238 aimbs_putle16(&fr->data, bslen - 2); | |
239 aimbs_putle32(&fr->data, atoi(sess->sn)); | |
240 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ | |
241 aimbs_putle16(&fr->data, snacid); /* eh. */ | |
242 aimbs_putle16(&fr->data, 0x04b2); /* shrug. */ | |
243 aimbs_putle32(&fr->data, atoi(uin)); | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
244 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
245 aim_tx_enqueue(sess, fr); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
246 |
4624 | 247 /* Keep track of this request and the ICQ number and request ID */ |
248 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info)); | |
249 info->reqid = snacid; | |
4625 | 250 info->uin = atoi(uin); |
4624 | 251 info->next = sess->icq_info; |
252 sess->icq_info = info; | |
253 | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
254 return 0; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
255 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
256 |
4759 | 257 faim_export int aim_icq_getalias(aim_session_t *sess, const char *uin) |
258 { | |
259 aim_conn_t *conn; | |
260 aim_frame_t *fr; | |
261 aim_snacid_t snacid; | |
262 int bslen; | |
4784 | 263 struct aim_icq_info *info; |
4759 | 264 |
265 if (!uin || uin[0] < '0' || uin[0] > '9') | |
266 return -EINVAL; | |
267 | |
268 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) | |
269 return -EINVAL; | |
270 | |
271 bslen = 2 + 4 + 2 + 2 + 2 + 4; | |
272 | |
273 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) | |
274 return -ENOMEM; | |
275 | |
276 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); | |
277 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); | |
278 | |
279 /* For simplicity, don't bother using a tlvlist */ | |
280 aimbs_put16(&fr->data, 0x0001); | |
281 aimbs_put16(&fr->data, bslen); | |
282 | |
283 aimbs_putle16(&fr->data, bslen - 2); | |
284 aimbs_putle32(&fr->data, atoi(sess->sn)); | |
285 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ | |
286 aimbs_putle16(&fr->data, snacid); /* eh. */ | |
287 aimbs_putle16(&fr->data, 0x04ba); /* shrug. */ | |
288 aimbs_putle32(&fr->data, atoi(uin)); | |
289 | |
290 aim_tx_enqueue(sess, fr); | |
291 | |
4784 | 292 /* Keep track of this request and the ICQ number and request ID */ |
293 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info)); | |
294 info->reqid = snacid; | |
295 info->uin = atoi(uin); | |
296 info->next = sess->icq_info; | |
297 sess->icq_info = info; | |
298 | |
4759 | 299 return 0; |
300 } | |
301 | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
302 faim_export int aim_icq_getsimpleinfo(aim_session_t *sess, const char *uin) |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
303 { |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
304 aim_conn_t *conn; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
305 aim_frame_t *fr; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
306 aim_snacid_t snacid; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
307 int bslen; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
308 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
309 if (!uin || uin[0] < '0' || uin[0] > '9') |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
310 return -EINVAL; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
311 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
312 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
313 return -EINVAL; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
314 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
315 bslen = 2 + 4 + 2 + 2 + 2 + 4; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
316 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
317 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
318 return -ENOMEM; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
319 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
320 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
321 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
322 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
323 /* For simplicity, don't bother using a tlvlist */ |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
324 aimbs_put16(&fr->data, 0x0001); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
325 aimbs_put16(&fr->data, bslen); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
326 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
327 aimbs_putle16(&fr->data, bslen - 2); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
328 aimbs_putle32(&fr->data, atoi(sess->sn)); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
329 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
330 aimbs_putle16(&fr->data, snacid); /* eh. */ |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
331 aimbs_putle16(&fr->data, 0x051f); /* shrug. */ |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
332 aimbs_putle32(&fr->data, atoi(uin)); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
333 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
334 aim_tx_enqueue(sess, fr); |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
335 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
336 return 0; |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
337 } |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
338 |
4617 | 339 faim_export int aim_icq_sendxmlreq(aim_session_t *sess, const char *xml) |
4151 | 340 { |
341 aim_conn_t *conn; | |
342 aim_frame_t *fr; | |
343 aim_snacid_t snacid; | |
344 int bslen; | |
345 | |
4617 | 346 if (!xml || !strlen(xml)) |
4151 | 347 return -EINVAL; |
348 | |
349 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) | |
350 return -EINVAL; | |
351 | |
4617 | 352 bslen = 2 + 10 + 2 + strlen(xml) + 1; |
4151 | 353 |
354 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) | |
355 return -ENOMEM; | |
356 | |
357 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); | |
358 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); | |
359 | |
360 /* For simplicity, don't bother using a tlvlist */ | |
361 aimbs_put16(&fr->data, 0x0001); | |
362 aimbs_put16(&fr->data, bslen); | |
363 | |
364 aimbs_putle16(&fr->data, bslen - 2); | |
365 aimbs_putle32(&fr->data, atoi(sess->sn)); | |
366 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ | |
367 aimbs_putle16(&fr->data, snacid); /* eh. */ | |
4617 | 368 aimbs_putle16(&fr->data, 0x0998); /* shrug. */ |
369 aimbs_putle16(&fr->data, strlen(xml) + 1); | |
10997 | 370 aimbs_putraw(&fr->data, (fu8_t *)xml, strlen(xml) + 1); |
4151 | 371 |
372 aim_tx_enqueue(sess, fr); | |
373 | |
374 return 0; | |
375 } | |
376 | |
7282 | 377 /* |
378 * Send an SMS message. This is the non-US way. The US-way is to IM | |
379 * their cell phone number (+19195551234). | |
380 * | |
381 * We basically construct and send an XML message. The format is: | |
382 * <icq_sms_message> | |
383 * <destination>full_phone_without_leading_+</destination> | |
384 * <text>message</text> | |
385 * <codepage>1252</codepage> | |
386 * <senders_UIN>self_uin</senders_UIN> | |
387 * <senders_name>self_name</senders_name> | |
388 * <delivery_receipt>Yes|No</delivery_receipt> | |
389 * <time>Wkd, DD Mmm YYYY HH:MM:SS TMZ</time> | |
390 * </icq_sms_message> | |
391 * | |
392 * Yeah hi Peter, whaaaat's happening. If there's any way to use | |
393 * a codepage other than 1252 that would be great. Thaaaanks. | |
394 */ | |
395 faim_export int aim_icq_sendsms(aim_session_t *sess, const char *name, const char *msg, const char *alias) | |
396 { | |
397 aim_conn_t *conn; | |
398 aim_frame_t *fr; | |
399 aim_snacid_t snacid; | |
400 int bslen, xmllen; | |
401 char *xml, timestr[30]; | |
402 time_t t; | |
403 struct tm *tm; | |
404 | |
405 if (!sess || !(conn = aim_conn_findbygroup(sess, 0x0015))) | |
406 return -EINVAL; | |
407 | |
408 if (!name || !msg || !alias) | |
409 return -EINVAL; | |
410 | |
411 time(&t); | |
412 tm = gmtime(&t); | |
413 strftime(timestr, 30, "%a, %d %b %Y %T %Z", tm); | |
414 | |
415 /* The length of xml included the null terminating character */ | |
7301 | 416 xmllen = 225 + strlen(name) + strlen(msg) + strlen(sess->sn) + strlen(alias) + strlen(timestr) + 1; |
7282 | 417 |
418 if (!(xml = (char *)malloc(xmllen*sizeof(char)))) | |
419 return -ENOMEM; | |
420 snprintf(xml, xmllen, "<icq_sms_message>\n" | |
421 "\t<destination>%s</destination>\n" | |
422 "\t<text>%s</text>\n" | |
423 "\t<codepage>1252</codepage>\n" | |
424 "\t<senders_UIN>%s</senders_UIN>\n" | |
425 "\t<senders_name>%s</senders_name>\n" | |
426 "\t<delivery_receipt>Yes</delivery_receipt>\n" | |
427 "\t<time>%s</time>\n" | |
428 "</icq_sms_message>\n", | |
429 name, msg, sess->sn, alias, timestr); | |
430 | |
431 bslen = 37 + xmllen; | |
432 | |
433 if (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02, 10 + 4 + bslen))) { | |
434 free(xml); | |
435 return -ENOMEM; | |
436 } | |
437 | |
438 snacid = aim_cachesnac(sess, 0x0015, 0x0002, 0x0000, NULL, 0); | |
439 aim_putsnac(&fr->data, 0x0015, 0x0002, 0x0000, snacid); | |
440 | |
441 /* For simplicity, don't bother using a tlvlist */ | |
442 aimbs_put16(&fr->data, 0x0001); | |
443 aimbs_put16(&fr->data, bslen); | |
444 | |
445 aimbs_putle16(&fr->data, bslen - 2); | |
446 aimbs_putle32(&fr->data, atoi(sess->sn)); | |
447 aimbs_putle16(&fr->data, 0x07d0); /* I command thee. */ | |
448 aimbs_putle16(&fr->data, snacid); /* eh. */ | |
449 | |
450 /* From libicq200-0.3.2/src/SNAC-SRV.cpp */ | |
451 aimbs_putle16(&fr->data, 0x8214); | |
452 aimbs_put16(&fr->data, 0x0001); | |
453 aimbs_put16(&fr->data, 0x0016); | |
454 aimbs_put32(&fr->data, 0x00000000); | |
455 aimbs_put32(&fr->data, 0x00000000); | |
456 aimbs_put32(&fr->data, 0x00000000); | |
457 aimbs_put32(&fr->data, 0x00000000); | |
458 | |
459 aimbs_put16(&fr->data, 0x0000); | |
460 aimbs_put16(&fr->data, xmllen); | |
10997 | 461 aimbs_putstr(&fr->data, xml); |
7282 | 462 |
463 aim_tx_enqueue(sess, fr); | |
464 | |
465 free(xml); | |
466 | |
467 return 0; | |
468 } | |
469 | |
4624 | 470 static void aim_icq_freeinfo(struct aim_icq_info *info) { |
4625 | 471 int i; |
472 | |
4624 | 473 if (!info) |
474 return; | |
475 free(info->nick); | |
476 free(info->first); | |
477 free(info->last); | |
478 free(info->email); | |
479 free(info->homecity); | |
480 free(info->homestate); | |
481 free(info->homephone); | |
482 free(info->homefax); | |
483 free(info->homeaddr); | |
484 free(info->mobile); | |
485 free(info->homezip); | |
486 free(info->personalwebpage); | |
4625 | 487 if (info->email2) |
488 for (i = 0; i < info->numaddresses; i++) | |
489 free(info->email2[i]); | |
4624 | 490 free(info->email2); |
491 free(info->workcity); | |
492 free(info->workstate); | |
493 free(info->workphone); | |
494 free(info->workfax); | |
495 free(info->workaddr); | |
496 free(info->workzip); | |
497 free(info->workcompany); | |
498 free(info->workdivision); | |
499 free(info->workposition); | |
500 free(info->workwebpage); | |
501 free(info->info); | |
502 free(info); | |
503 } | |
504 | |
4617 | 505 /** |
506 * Subtype 0x0003 - Response to 0x0015/0x002, contains an ICQesque packet. | |
2703 | 507 */ |
508 static int icqresponse(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
509 { | |
510 int ret = 0; | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
511 aim_tlvlist_t *tl; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
512 aim_tlv_t *datatlv; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
513 aim_bstream_t qbs; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
514 fu32_t ouruin; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
515 fu16_t cmdlen, cmd, reqid; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
516 |
7167 | 517 if (!(tl = aim_tlvlist_read(bs)) || !(datatlv = aim_tlv_gettlv(tl, 0x0001, 1))) { |
518 aim_tlvlist_free(&tl); | |
11253 | 519 gaim_debug_misc("oscar", "corrupt ICQ response\n"); |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
520 return 0; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
521 } |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
522 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
523 aim_bstream_init(&qbs, datatlv->value, datatlv->length); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
524 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
525 cmdlen = aimbs_getle16(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
526 ouruin = aimbs_getle32(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
527 cmd = aimbs_getle16(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
528 reqid = aimbs_getle16(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
529 |
11253 | 530 gaim_debug_misc("oscar", "icq response: %d bytes, %ld, 0x%04x, 0x%04x\n", cmdlen, ouruin, cmd, reqid); |
2703 | 531 |
4075 | 532 if (cmd == 0x0041) { /* offline message */ |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
533 struct aim_icq_offlinemsg msg; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
534 aim_rxcallback_t userfunc; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
535 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
536 memset(&msg, 0, sizeof(msg)); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
537 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
538 msg.sender = aimbs_getle32(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
539 msg.year = aimbs_getle16(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
540 msg.month = aimbs_getle8(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
541 msg.day = aimbs_getle8(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
542 msg.hour = aimbs_getle8(&qbs); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
543 msg.minute = aimbs_getle8(&qbs); |
4173 | 544 msg.type = aimbs_getle8(&qbs); |
545 msg.flags = aimbs_getle8(&qbs); | |
4076 | 546 msg.msglen = aimbs_getle16(&qbs); |
547 msg.msg = aimbs_getstr(&qbs, msg.msglen); | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
548 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
549 if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSG))) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
550 ret = userfunc(sess, rx, &msg); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
551 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
552 free(msg.msg); |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
553 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
554 } else if (cmd == 0x0042) { |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
555 aim_rxcallback_t userfunc; |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
556 |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
557 if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_OFFLINEMSGCOMPLETE))) |
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
558 ret = userfunc(sess, rx); |
4151 | 559 |
560 } else if (cmd == 0x07da) { /* information */ | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
561 fu16_t subtype; |
4151 | 562 struct aim_icq_info *info; |
563 aim_rxcallback_t userfunc; | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
564 |
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
565 subtype = aimbs_getle16(&qbs); |
4151 | 566 aim_bstream_advance(&qbs, 1); /* 0x0a */ |
567 | |
4624 | 568 /* find other data from the same request */ |
569 for (info = sess->icq_info; info && (info->reqid != reqid); info = info->next); | |
570 if (!info) { | |
571 info = (struct aim_icq_info *)calloc(1, sizeof(struct aim_icq_info)); | |
572 info->reqid = reqid; | |
573 info->next = sess->icq_info; | |
574 sess->icq_info = info; | |
575 } | |
576 | |
4151 | 577 switch (subtype) { |
4664 | 578 case 0x00a0: { /* hide ip status */ |
579 /* nothing */ | |
580 } break; | |
581 | |
4617 | 582 case 0x00aa: { /* password change status */ |
4664 | 583 /* nothing */ |
4617 | 584 } break; |
585 | |
4624 | 586 case 0x00c8: { /* general and "home" information */ |
4151 | 587 info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
588 info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
589 info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
4624 | 590 info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
4151 | 591 info->homecity = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
592 info->homestate = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
4624 | 593 info->homephone = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
594 info->homefax = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
4151 | 595 info->homeaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
4624 | 596 info->mobile = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
4151 | 597 info->homezip = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
598 info->homecountry = aimbs_getle16(&qbs); | |
4625 | 599 /* 0x0a 00 02 00 */ |
600 /* 1 byte timezone? */ | |
601 /* 1 byte hide email flag? */ | |
4151 | 602 } break; |
603 | |
4624 | 604 case 0x00dc: { /* personal information */ |
605 info->age = aimbs_getle8(&qbs); | |
606 info->unknown = aimbs_getle8(&qbs); | |
8902 | 607 info->gender = aimbs_getle8(&qbs); /* Not specified=0x00, Female=0x01, Male=0x02 */ |
4151 | 608 info->personalwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
4624 | 609 info->birthyear = aimbs_getle16(&qbs); |
610 info->birthmonth = aimbs_getle8(&qbs); | |
611 info->birthday = aimbs_getle8(&qbs); | |
612 info->language1 = aimbs_getle8(&qbs); | |
613 info->language2 = aimbs_getle8(&qbs); | |
614 info->language3 = aimbs_getle8(&qbs); | |
4625 | 615 /* 0x00 00 01 00 00 01 00 00 00 00 00 */ |
4151 | 616 } break; |
617 | |
618 case 0x00d2: { /* work information */ | |
619 info->workcity = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
620 info->workstate = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
4624 | 621 info->workphone = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
622 info->workfax = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
4151 | 623 info->workaddr = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
624 info->workzip = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
625 info->workcountry = aimbs_getle16(&qbs); | |
626 info->workcompany = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
627 info->workdivision = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
628 info->workposition = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
4625 | 629 aim_bstream_advance(&qbs, 2); /* 0x01 00 */ |
4151 | 630 info->workwebpage = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); |
631 } break; | |
632 | |
633 case 0x00e6: { /* additional personal information */ | |
4624 | 634 info->info = aimbs_getstr(&qbs, aimbs_getle16(&qbs)-1); |
635 } break; | |
636 | |
637 case 0x00eb: { /* email address(es) */ | |
4625 | 638 int i; |
4624 | 639 info->numaddresses = aimbs_getle16(&qbs); |
4625 | 640 info->email2 = (char **)calloc(info->numaddresses, sizeof(char *)); |
641 for (i = 0; i < info->numaddresses; i++) { | |
642 info->email2[i] = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
643 if (i+1 != info->numaddresses) | |
644 aim_bstream_advance(&qbs, 1); /* 0x00 */ | |
645 } | |
4151 | 646 } break; |
647 | |
648 case 0x00f0: { /* personal interests */ | |
649 } break; | |
650 | |
651 case 0x00fa: { /* past background and current organizations */ | |
652 } break; | |
653 | |
4759 | 654 case 0x0104: { /* alias info */ |
655 info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
656 info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
657 info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
658 aim_bstream_advance(&qbs, aimbs_getle16(&qbs)); /* email address? */ | |
659 /* Then 0x00 02 00 */ | |
660 } break; | |
661 | |
4151 | 662 case 0x010e: { /* unknown */ |
4625 | 663 /* 0x00 00 */ |
4151 | 664 } break; |
665 | |
666 case 0x019a: { /* simple info */ | |
667 aim_bstream_advance(&qbs, 2); | |
668 info->uin = aimbs_getle32(&qbs); | |
669 info->nick = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
670 info->first = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
671 info->last = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
672 info->email = aimbs_getstr(&qbs, aimbs_getle16(&qbs)); | |
4154 | 673 /* Then 0x00 02 00 00 00 00 00 */ |
4151 | 674 } break; |
675 } /* End switch statement */ | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
676 |
4624 | 677 if (!(snac->flags & 0x0001)) { |
4784 | 678 if (subtype != 0x0104) |
4759 | 679 if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_INFO))) |
680 ret = userfunc(sess, rx, info); | |
681 | |
682 if (info->uin && info->nick) | |
683 if ((userfunc = aim_callhandler(sess, rx->conn, AIM_CB_FAM_ICQ, AIM_CB_ICQ_ALIAS))) | |
684 ret = userfunc(sess, rx, info); | |
2742
6f527cbd899d
[gaim-migrate @ 2755]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2733
diff
changeset
|
685 |
4624 | 686 if (sess->icq_info == info) { |
687 sess->icq_info = info->next; | |
688 } else { | |
689 struct aim_icq_info *cur; | |
690 for (cur=sess->icq_info; (cur->next && (cur->next!=info)); cur=cur->next); | |
691 if (cur->next) | |
692 cur->next = cur->next->next; | |
693 } | |
694 aim_icq_freeinfo(info); | |
695 } | |
2706
e841b14b5b89
[gaim-migrate @ 2719]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2703
diff
changeset
|
696 } |
2703 | 697 |
7167 | 698 aim_tlvlist_free(&tl); |
2731
e9e624d8803e
[gaim-migrate @ 2744]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2706
diff
changeset
|
699 |
2703 | 700 return ret; |
701 } | |
702 | |
703 static int snachandler(aim_session_t *sess, aim_module_t *mod, aim_frame_t *rx, aim_modsnac_t *snac, aim_bstream_t *bs) | |
704 { | |
705 | |
706 if (snac->subtype == 0x0003) | |
707 return icqresponse(sess, mod, rx, snac, bs); | |
708 | |
709 return 0; | |
710 } | |
711 | |
4830 | 712 static void icq_shutdown(aim_session_t *sess, aim_module_t *mod) |
713 { | |
714 struct aim_icq_info *del; | |
715 | |
716 while (sess->icq_info) { | |
717 del = sess->icq_info; | |
718 sess->icq_info = sess->icq_info->next; | |
719 aim_icq_freeinfo(del); | |
720 } | |
721 | |
722 return; | |
723 } | |
724 | |
2703 | 725 faim_internal int icq_modfirst(aim_session_t *sess, aim_module_t *mod) |
726 { | |
727 | |
728 mod->family = 0x0015; | |
729 mod->version = 0x0001; | |
730 mod->toolid = 0x0110; | |
4071 | 731 mod->toolversion = 0x047c; |
2703 | 732 mod->flags = 0; |
733 strncpy(mod->name, "icq", sizeof(mod->name)); | |
734 mod->snachandler = snachandler; | |
4830 | 735 mod->shutdown = icq_shutdown; |
2703 | 736 |
737 return 0; | |
738 } |