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