Tue, 04 Sep 2007 08:09:55 +0000
A little function name shuffling.
| 13235 | 1 | /* |
| 15884 | 2 | * Purple's oscar protocol plugin |
| 13235 | 3 | * This file is the legal property of its developers. |
| 4 | * Please see the AUTHORS file distributed alongside this file. | |
| 5 | * | |
| 6 | * This library is free software; you can redistribute it and/or | |
| 7 | * modify it under the terms of the GNU Lesser General Public | |
| 8 | * License as published by the Free Software Foundation; either | |
| 9 | * version 2 of the License, or (at your option) any later version. | |
| 10 | * | |
| 11 | * This library is distributed in the hope that it will be useful, | |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 14 | * Lesser General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the GNU Lesser General Public | |
| 17 | * License along with this library; if not, write to the Free Software | |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 19 | */ | |
| 20 | ||
| 21 | /* | |
| 22 | * Family 0x0017 - Authentication. | |
| 23 | * | |
| 24 | * Deals with the authorizer for SNAC-based login, and also old-style | |
| 25 | * non-SNAC login. | |
| 26 | * | |
| 27 | */ | |
| 28 | ||
| 29 | #include "oscar.h" | |
| 30 | ||
| 31 | #include "cipher.h" | |
| 32 | ||
| 33 | #include <ctype.h> | |
| 34 | ||
| 35 | #define USE_XOR_FOR_ICQ | |
| 36 | ||
| 37 | #ifdef USE_XOR_FOR_ICQ | |
| 38 | /** | |
| 39 | * Encode a password using old XOR method | |
| 40 | * | |
| 41 | * This takes a const pointer to a (null terminated) string | |
| 42 | * containing the unencoded password. It also gets passed | |
| 43 | * an already allocated buffer to store the encoded password. | |
| 44 | * This buffer should be the exact length of the password without | |
| 45 | * the null. The encoded password buffer /is not %NULL terminated/. | |
| 46 | * | |
| 47 | * The encoding_table seems to be a fixed set of values. We'll | |
| 48 | * hope it doesn't change over time! | |
| 49 | * | |
| 50 | * This is only used for the XOR method, not the better MD5 method. | |
| 51 | * | |
| 52 | * @param password Incoming password. | |
| 53 | * @param encoded Buffer to put encoded password. | |
| 54 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
55 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
56 | aim_encode_password(const char *password, guint8 *encoded) |
| 13235 | 57 | { |
| 58 | guint8 encoding_table[] = { | |
| 59 | #if 0 /* old v1 table */ | |
| 60 | 0xf3, 0xb3, 0x6c, 0x99, | |
| 61 | 0x95, 0x3f, 0xac, 0xb6, | |
| 62 | 0xc5, 0xfa, 0x6b, 0x63, | |
| 63 | 0x69, 0x6c, 0xc3, 0x9f | |
| 64 | #else /* v2.1 table, also works for ICQ */ | |
| 65 | 0xf3, 0x26, 0x81, 0xc4, | |
| 66 | 0x39, 0x86, 0xdb, 0x92, | |
| 67 | 0x71, 0xa3, 0xb9, 0xe6, | |
| 68 | 0x53, 0x7a, 0x95, 0x7c | |
| 69 | #endif | |
| 70 | }; | |
| 71 | unsigned int i; | |
| 72 | ||
| 73 | for (i = 0; i < strlen(password); i++) | |
| 74 | encoded[i] = (password[i] ^ encoding_table[i]); | |
| 75 | ||
| 76 | return 0; | |
| 77 | } | |
| 78 | #endif | |
| 79 | ||
| 80 | #ifdef USE_OLD_MD5 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
81 | static int |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
82 | aim_encode_password_md5(const char *password, size_t password_len, const char *key, guint8 *digest) |
| 13235 | 83 | { |
| 15884 | 84 | PurpleCipher *cipher; |
| 85 | PurpleCipherContext *context; | |
| 13235 | 86 | |
| 15884 | 87 | cipher = purple_ciphers_find_cipher("md5"); |
| 13235 | 88 | |
| 15884 | 89 | context = purple_cipher_context_new(cipher, NULL); |
| 90 | purple_cipher_context_append(context, (const guchar *)key, strlen(key)); | |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
91 | purple_cipher_context_append(context, (const guchar *)password, password_len); |
| 15884 | 92 | purple_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); |
| 93 | purple_cipher_context_digest(context, 16, digest, NULL); | |
| 94 | purple_cipher_context_destroy(context); | |
| 13235 | 95 | |
| 96 | return 0; | |
| 97 | } | |
| 98 | #else | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
99 | static int |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
100 | aim_encode_password_md5(const char *password, size_t password_len, const char *key, guint8 *digest) |
| 13235 | 101 | { |
| 15884 | 102 | PurpleCipher *cipher; |
| 103 | PurpleCipherContext *context; | |
| 13235 | 104 | guchar passdigest[16]; |
| 105 | ||
| 15884 | 106 | cipher = purple_ciphers_find_cipher("md5"); |
| 13235 | 107 | |
| 15884 | 108 | context = purple_cipher_context_new(cipher, NULL); |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
109 | purple_cipher_context_append(context, (const guchar *)password, password_len); |
| 15884 | 110 | purple_cipher_context_digest(context, 16, passdigest, NULL); |
| 111 | purple_cipher_context_destroy(context); | |
| 13235 | 112 | |
| 15884 | 113 | context = purple_cipher_context_new(cipher, NULL); |
| 114 | purple_cipher_context_append(context, (const guchar *)key, strlen(key)); | |
| 115 | purple_cipher_context_append(context, passdigest, 16); | |
| 116 | purple_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
| 117 | purple_cipher_context_digest(context, 16, digest, NULL); | |
| 118 | purple_cipher_context_destroy(context); | |
| 13235 | 119 | |
| 120 | return 0; | |
| 121 | } | |
| 122 | #endif | |
| 123 | ||
| 124 | #ifdef USE_XOR_FOR_ICQ | |
| 125 | /* | |
| 126 | * Part two of the ICQ hack. Note the ignoring of the key. | |
| 127 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
128 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
129 | goddamnicq2(OscarData *od, FlapConnection *conn, const char *sn, const char *password, ClientInfo *ci) |
| 13235 | 130 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
131 | FlapFrame *frame; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
132 | GSList *tlvlist = NULL; |
| 13235 | 133 | int passwdlen; |
| 134 | guint8 *password_encoded; | |
| 135 | ||
| 136 | passwdlen = strlen(password); | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
137 | password_encoded = (guint8 *)g_malloc(passwdlen+1); |
| 13235 | 138 | if (passwdlen > MAXICQPASSLEN) |
| 139 | passwdlen = MAXICQPASSLEN; | |
| 140 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
141 | frame = flap_frame_new(od, 0x01, 1152); |
| 13235 | 142 | |
| 143 | aim_encode_password(password, password_encoded); | |
| 144 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
145 | byte_stream_put32(&frame->data, 0x00000001); /* FLAP Version */ |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
146 | aim_tlvlist_add_str(&tlvlist, 0x0001, sn); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
147 | aim_tlvlist_add_raw(&tlvlist, 0x0002, passwdlen, password_encoded); |
| 13235 | 148 | |
| 149 | if (ci->clientstring) | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
150 | aim_tlvlist_add_str(&tlvlist, 0x0003, ci->clientstring); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
151 | aim_tlvlist_add_16(&tlvlist, 0x0016, (guint16)ci->clientid); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
152 | aim_tlvlist_add_16(&tlvlist, 0x0017, (guint16)ci->major); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
153 | aim_tlvlist_add_16(&tlvlist, 0x0018, (guint16)ci->minor); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
154 | aim_tlvlist_add_16(&tlvlist, 0x0019, (guint16)ci->point); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
155 | aim_tlvlist_add_16(&tlvlist, 0x001a, (guint16)ci->build); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
156 | aim_tlvlist_add_32(&tlvlist, 0x0014, (guint32)ci->distrib); /* distribution chan */ |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
157 | aim_tlvlist_add_str(&tlvlist, 0x000f, ci->lang); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
158 | aim_tlvlist_add_str(&tlvlist, 0x000e, ci->country); |
| 13235 | 159 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
160 | aim_tlvlist_write(&frame->data, &tlvlist); |
| 13235 | 161 | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
162 | g_free(password_encoded); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
163 | aim_tlvlist_free(tlvlist); |
| 13235 | 164 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
165 | flap_connection_send(conn, frame); |
| 13235 | 166 | |
| 167 | return 0; | |
| 168 | } | |
| 169 | #endif | |
| 170 | ||
| 171 | /* | |
| 172 | * Subtype 0x0002 | |
| 173 | * | |
| 174 | * This is the initial login request packet. | |
| 175 | * | |
| 176 | * NOTE!! If you want/need to make use of the aim_sendmemblock() function, | |
| 177 | * then the client information you send here must exactly match the | |
| 178 | * executable that you're pulling the data from. | |
| 179 | * | |
| 180 | * Java AIM 1.1.19: | |
| 181 | * clientstring = "AOL Instant Messenger (TM) version 1.1.19 for Java built 03/24/98, freeMem 215871 totalMem 1048567, i686, Linus, #2 SMP Sun Feb 11 03:41:17 UTC 2001 2.4.1-ac9, IBM Corporation, 1.1.8, 45.3, Tue Mar 27 12:09:17 PST 2001" | |
| 182 | * clientid = 0x0001 | |
| 183 | * major = 0x0001 | |
| 184 | * minor = 0x0001 | |
| 185 | * point = (not sent) | |
| 186 | * build = 0x0013 | |
| 187 | * unknown= (not sent) | |
|
13240
db5187cc40d1
[gaim-migrate @ 15605]
Mark Doliner <markdoliner@pidgin.im>
parents:
13235
diff
changeset
|
188 | * |
| 13235 | 189 | * AIM for Linux 1.1.112: |
| 190 | * clientstring = "AOL Instant Messenger (SM)" | |
| 191 | * clientid = 0x1d09 | |
| 192 | * major = 0x0001 | |
| 193 | * minor = 0x0001 | |
| 194 | * point = 0x0001 | |
| 195 | * build = 0x0070 | |
| 196 | * unknown= 0x0000008b | |
| 197 | * serverstore = 0x01 | |
| 198 | * | |
| 199 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
200 | int |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
201 | aim_send_login(OscarData *od, FlapConnection *conn, const char *sn, const char *password, gboolean truncate_pass, ClientInfo *ci, const char *key) |
| 13235 | 202 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
203 | FlapFrame *frame; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
204 | GSList *tlvlist = NULL; |
| 13235 | 205 | guint8 digest[16]; |
| 206 | aim_snacid_t snacid; | |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
207 | size_t password_len; |
| 13235 | 208 | |
| 209 | if (!ci || !sn || !password) | |
| 210 | return -EINVAL; | |
| 211 | ||
| 212 | #ifdef USE_XOR_FOR_ICQ | |
| 213 | /* If we're signing on an ICQ account then use the older, XOR login method */ | |
|
19820
0f82885da3d8
A little function name shuffling.
Mark Doliner <markdoliner@pidgin.im>
parents:
18341
diff
changeset
|
214 | if (aim_snvalid_icq(sn)) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
215 | return goddamnicq2(od, conn, sn, password, ci); |
| 13235 | 216 | #endif |
| 217 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
218 | frame = flap_frame_new(od, 0x02, 1152); |
| 13235 | 219 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
220 | snacid = aim_cachesnac(od, 0x0017, 0x0002, 0x0000, NULL, 0); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
221 | aim_putsnac(&frame->data, 0x0017, 0x0002, 0x0000, snacid); |
| 13235 | 222 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
223 | aim_tlvlist_add_str(&tlvlist, 0x0001, sn); |
| 13235 | 224 | |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
225 | /* Truncate ICQ and AOL passwords, if necessary */ |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
226 | password_len = strlen(password); |
|
19820
0f82885da3d8
A little function name shuffling.
Mark Doliner <markdoliner@pidgin.im>
parents:
18341
diff
changeset
|
227 | if (aim_snvalid_icq(sn) && (password_len > MAXICQPASSLEN)) |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
228 | password_len = MAXICQPASSLEN; |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
229 | else if (truncate_pass && password_len > 8) |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
230 | password_len = 8; |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
231 | |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
232 | aim_encode_password_md5(password, password_len, key, digest); |
| 13235 | 233 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
234 | aim_tlvlist_add_raw(&tlvlist, 0x0025, 16, digest); |
| 13235 | 235 | |
| 236 | #ifndef USE_OLD_MD5 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
237 | aim_tlvlist_add_noval(&tlvlist, 0x004c); |
| 13235 | 238 | #endif |
| 239 | ||
| 240 | if (ci->clientstring) | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
241 | aim_tlvlist_add_str(&tlvlist, 0x0003, ci->clientstring); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
242 | aim_tlvlist_add_16(&tlvlist, 0x0016, (guint16)ci->clientid); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
243 | aim_tlvlist_add_16(&tlvlist, 0x0017, (guint16)ci->major); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
244 | aim_tlvlist_add_16(&tlvlist, 0x0018, (guint16)ci->minor); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
245 | aim_tlvlist_add_16(&tlvlist, 0x0019, (guint16)ci->point); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
246 | aim_tlvlist_add_16(&tlvlist, 0x001a, (guint16)ci->build); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
247 | aim_tlvlist_add_32(&tlvlist, 0x0014, (guint32)ci->distrib); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
248 | aim_tlvlist_add_str(&tlvlist, 0x000f, ci->lang); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
249 | aim_tlvlist_add_str(&tlvlist, 0x000e, ci->country); |
| 13235 | 250 | |
| 251 | /* | |
| 252 | * If set, old-fashioned buddy lists will not work. You will need | |
| 253 | * to use SSI. | |
| 254 | */ | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
255 | aim_tlvlist_add_8(&tlvlist, 0x004a, 0x01); |
| 13235 | 256 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
257 | aim_tlvlist_write(&frame->data, &tlvlist); |
| 13235 | 258 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
259 | aim_tlvlist_free(tlvlist); |
| 13235 | 260 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
261 | flap_connection_send(conn, frame); |
| 13235 | 262 | |
| 263 | return 0; | |
| 264 | } | |
| 265 | ||
| 266 | /* | |
| 267 | * This is sent back as a general response to the login command. | |
| 268 | * It can be either an error or a success, depending on the | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
269 | * presence of certain TLVs. |
| 13235 | 270 | * |
| 271 | * The client should check the value passed as errorcode. If | |
| 272 | * its nonzero, there was an error. | |
| 273 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
274 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
275 | parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 276 | { |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
277 | GSList *tlvlist; |
| 13235 | 278 | aim_rxcallback_t userfunc; |
| 279 | struct aim_authresp_info *info; | |
| 280 | int ret = 0; | |
| 281 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
282 | info = g_new0(struct aim_authresp_info, 1); |
| 13235 | 283 | |
| 284 | /* | |
| 285 | * Read block of TLVs. All further data is derived | |
| 286 | * from what is parsed here. | |
| 287 | */ | |
| 288 | tlvlist = aim_tlvlist_read(bs); | |
| 289 | ||
| 290 | /* | |
| 291 | * No matter what, we should have a screen name. | |
| 292 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
293 | memset(od->sn, 0, sizeof(od->sn)); |
| 13235 | 294 | if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { |
| 295 | info->sn = aim_tlv_getstr(tlvlist, 0x0001, 1); | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
296 | strncpy(od->sn, info->sn, sizeof(od->sn)); |
| 13235 | 297 | } |
| 298 | ||
| 299 | /* | |
| 300 | * Check for an error code. If so, we should also | |
| 301 | * have an error url. | |
| 302 | */ | |
| 303 | if (aim_tlv_gettlv(tlvlist, 0x0008, 1)) | |
| 304 | info->errorcode = aim_tlv_get16(tlvlist, 0x0008, 1); | |
| 305 | if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) | |
| 306 | info->errorurl = aim_tlv_getstr(tlvlist, 0x0004, 1); | |
| 307 | ||
| 308 | /* | |
| 309 | * BOS server address. | |
| 310 | */ | |
| 311 | if (aim_tlv_gettlv(tlvlist, 0x0005, 1)) | |
| 312 | info->bosip = aim_tlv_getstr(tlvlist, 0x0005, 1); | |
| 313 | ||
| 314 | /* | |
| 315 | * Authorization cookie. | |
| 316 | */ | |
| 317 | if (aim_tlv_gettlv(tlvlist, 0x0006, 1)) { | |
| 318 | aim_tlv_t *tmptlv; | |
| 319 | ||
| 320 | tmptlv = aim_tlv_gettlv(tlvlist, 0x0006, 1); | |
|
13653
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
321 | if (tmptlv != NULL) |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
322 | { |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
323 | info->cookielen = tmptlv->length; |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
324 | info->cookie = tmptlv->value; |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
325 | } |
| 13235 | 326 | } |
| 327 | ||
| 328 | /* | |
| 329 | * The email address attached to this account | |
| 330 | * Not available for ICQ or @mac.com logins. | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
331 | * If you receive this TLV, then you are allowed to use |
| 13235 | 332 | * family 0x0018 to check the status of your email. |
| 333 | * XXX - Not really true! | |
| 334 | */ | |
| 335 | if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) | |
| 336 | info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); | |
| 337 | ||
| 338 | /* | |
| 339 | * The registration status. (Not real sure what it means.) | |
| 340 | * Not available for ICQ or @mac.com logins. | |
| 341 | * | |
| 342 | * 1 = No disclosure | |
| 343 | * 2 = Limited disclosure | |
| 344 | * 3 = Full disclosure | |
| 345 | * | |
| 346 | * This has to do with whether your email address is available | |
| 347 | * to other users or not. AFAIK, this feature is no longer used. | |
| 348 | * | |
| 349 | * Means you can use the admin family? (0x0007) | |
| 350 | * | |
| 351 | */ | |
| 352 | if (aim_tlv_gettlv(tlvlist, 0x0013, 1)) | |
| 353 | info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1); | |
| 354 | ||
| 355 | if (aim_tlv_gettlv(tlvlist, 0x0040, 1)) | |
| 356 | info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1); | |
| 357 | if (aim_tlv_gettlv(tlvlist, 0x0041, 1)) | |
| 358 | info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1); | |
| 359 | if (aim_tlv_gettlv(tlvlist, 0x0042, 1)) | |
| 360 | info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1); | |
| 361 | if (aim_tlv_gettlv(tlvlist, 0x0043, 1)) | |
| 362 | info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1); | |
| 363 | ||
| 364 | #if 0 | |
| 365 | if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) { | |
| 366 | /* beta serial */ | |
| 367 | } | |
| 368 | #endif | |
| 369 | ||
| 370 | if (aim_tlv_gettlv(tlvlist, 0x0044, 1)) | |
| 371 | info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1); | |
| 372 | if (aim_tlv_gettlv(tlvlist, 0x0045, 1)) | |
| 373 | info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1); | |
| 374 | if (aim_tlv_gettlv(tlvlist, 0x0046, 1)) | |
| 375 | info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1); | |
| 376 | if (aim_tlv_gettlv(tlvlist, 0x0047, 1)) | |
| 377 | info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1); | |
| 378 | ||
| 379 | #if 0 | |
| 380 | if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) { | |
| 381 | /* lastest release serial */ | |
| 382 | } | |
| 383 | #endif | |
| 384 | ||
| 385 | /* | |
| 386 | * URL to change password. | |
| 387 | */ | |
| 388 | if (aim_tlv_gettlv(tlvlist, 0x0054, 1)) | |
| 389 | info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1); | |
| 390 | ||
| 391 | #if 0 | |
| 392 | /* | |
| 393 | * Unknown. Seen on an @mac.com screen name with value of 0x003f | |
| 394 | */ | |
| 395 | if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) { | |
| 396 | /* Unhandled */ | |
| 397 | } | |
| 398 | #endif | |
| 399 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
400 | od->authinfo = info; |
| 13235 | 401 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
402 | if ((userfunc = aim_callhandler(od, snac ? snac->family : 0x0017, snac ? snac->subtype : 0x0003))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
403 | ret = userfunc(od, conn, frame, info); |
| 13235 | 404 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
405 | aim_tlvlist_free(tlvlist); |
| 13235 | 406 | |
| 407 | return ret; | |
| 408 | } | |
| 409 | ||
| 410 | #ifdef USE_XOR_FOR_ICQ | |
| 411 | /* | |
| 412 | * Subtype 0x0007 (kind of) - Send a fake type 0x0007 SNAC to the client | |
| 413 | * | |
| 414 | * This is a bit confusing. | |
| 415 | * | |
| 416 | * Normal SNAC login goes like this: | |
| 417 | * - connect | |
| 418 | * - server sends flap version | |
| 419 | * - client sends flap version | |
| 420 | * - client sends screen name (17/6) | |
| 421 | * - server sends hash key (17/7) | |
| 422 | * - client sends auth request (17/2 -- aim_send_login) | |
| 423 | * - server yells | |
| 424 | * | |
| 425 | * XOR login (for ICQ) goes like this: | |
| 426 | * - connect | |
| 427 | * - server sends flap version | |
| 428 | * - client sends auth request which contains flap version (aim_send_login) | |
| 429 | * - server yells | |
| 430 | * | |
| 431 | * For the client API, we make them implement the most complicated version, | |
| 432 | * and for the simpler version, we fake it and make it look like the more | |
| 433 | * complicated process. | |
| 434 | * | |
| 435 | * This is done by giving the client a faked key, just so we can convince | |
| 436 | * them to call aim_send_login right away, which will detect the session | |
| 437 | * flag that says this is XOR login and ignore the key, sending an ICQ | |
| 438 | * login request instead of the normal SNAC one. | |
| 439 | * | |
| 440 | * As soon as AOL makes ICQ log in the same way as AIM, this is /gone/. | |
| 441 | * | |
| 442 | * XXX This may cause problems if the client relies on callbacks only | |
| 443 | * being called from the context of aim_rxdispatch()... | |
| 444 | * | |
| 445 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
446 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
447 | goddamnicq(OscarData *od, FlapConnection *conn, const char *sn) |
| 13235 | 448 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
449 | FlapFrame frame; |
| 13235 | 450 | aim_rxcallback_t userfunc; |
| 451 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
452 | if ((userfunc = aim_callhandler(od, 0x0017, 0x0007))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
453 | userfunc(od, conn, &frame, ""); |
| 13235 | 454 | |
| 455 | return 0; | |
| 456 | } | |
| 457 | #endif | |
| 458 | ||
| 459 | /* | |
| 460 | * Subtype 0x0006 | |
| 461 | * | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
462 | * In AIM 3.5 protocol, the first stage of login is to request login from the |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
463 | * Authorizer, passing it the screen name for verification. If the name is |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
464 | * invalid, a 0017/0003 is spit back, with the standard error contents. If |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
465 | * valid, a 0017/0007 comes back, which is the signal to send it the main |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
466 | * login command (0017/0002). |
| 13235 | 467 | * |
| 468 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
469 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
470 | aim_request_login(OscarData *od, FlapConnection *conn, const char *sn) |
| 13235 | 471 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
472 | FlapFrame *frame; |
| 13235 | 473 | aim_snacid_t snacid; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
474 | GSList *tlvlist = NULL; |
| 13235 | 475 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
476 | if (!od || !conn || !sn) |
| 13235 | 477 | return -EINVAL; |
| 478 | ||
| 479 | #ifdef USE_XOR_FOR_ICQ | |
|
19820
0f82885da3d8
A little function name shuffling.
Mark Doliner <markdoliner@pidgin.im>
parents:
18341
diff
changeset
|
480 | if (aim_snvalid_icq(sn)) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
481 | return goddamnicq(od, conn, sn); |
| 13235 | 482 | #endif |
| 483 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
484 | frame = flap_frame_new(od, 0x02, 10+2+2+strlen(sn)+8); |
| 13235 | 485 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
486 | snacid = aim_cachesnac(od, 0x0017, 0x0006, 0x0000, NULL, 0); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
487 | aim_putsnac(&frame->data, 0x0017, 0x0006, 0x0000, snacid); |
| 13235 | 488 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
489 | aim_tlvlist_add_str(&tlvlist, 0x0001, sn); |
| 13235 | 490 | |
| 491 | /* Tell the server we support SecurID logins. */ | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
492 | aim_tlvlist_add_noval(&tlvlist, 0x004b); |
| 13235 | 493 | |
| 494 | /* Unknown. Sent in recent WinAIM clients.*/ | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
495 | aim_tlvlist_add_noval(&tlvlist, 0x005a); |
| 13235 | 496 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
497 | aim_tlvlist_write(&frame->data, &tlvlist); |
|
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
498 | aim_tlvlist_free(tlvlist); |
| 13235 | 499 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
500 | flap_connection_send(conn, frame); |
| 13235 | 501 | |
| 502 | return 0; | |
| 503 | } | |
| 504 | ||
| 505 | /* | |
| 506 | * Subtype 0x0007 | |
| 507 | * | |
| 508 | * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed | |
| 509 | * by only its length in a two byte word. | |
| 510 | * | |
| 511 | * Calls the client, which should then use the value to call aim_send_login. | |
| 512 | * | |
| 513 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
514 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
515 | keyparse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 516 | { |
| 517 | int keylen, ret = 1; | |
| 518 | aim_rxcallback_t userfunc; | |
| 519 | char *keystr; | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
520 | GSList *tlvlist; |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
521 | gboolean truncate_pass; |
| 13235 | 522 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
523 | keylen = byte_stream_get16(bs); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
524 | keystr = byte_stream_getstr(bs, keylen); |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
525 | tlvlist = aim_tlvlist_read(bs); |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
526 | |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
527 | /* |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
528 | * If the truncate_pass TLV exists then we should truncate the |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
529 | * user's password to 8 characters. This flag is sent when you |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
530 | * try to log in with an AOL user's screen name. |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
531 | */ |
|
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
532 | truncate_pass = aim_tlv_gettlv(tlvlist, 0x0026, 1) != NULL; |
| 13235 | 533 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
534 | /* XXX - When GiantGrayPanda signed on AIM I got a thing asking me to register |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
535 | * for the netscape network. This SNAC had a type 0x0058 TLV with length 10. |
| 13235 | 536 | * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */ |
| 537 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
538 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
17279
2a86b738c7a8
Fix signing on to AIM with an AOL screen name with a password of more
Mark Doliner <markdoliner@pidgin.im>
parents:
15884
diff
changeset
|
539 | ret = userfunc(od, conn, frame, keystr, (int)truncate_pass); |
| 13235 | 540 | |
|
17280
7c0472208173
Make all the oscar memory allocations and frees use the glib functions to avoid problems when mixing C runtimes.
Daniel Atallah <datallah@pidgin.im>
parents:
15884
diff
changeset
|
541 | g_free(keystr); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
542 | aim_tlvlist_free(tlvlist); |
| 13235 | 543 | |
| 544 | return ret; | |
| 545 | } | |
| 546 | ||
| 547 | /** | |
| 548 | * Subtype 0x000a | |
| 549 | * | |
| 550 | * Receive SecurID request. | |
| 551 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
552 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
553 | got_securid_request(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 554 | { |
| 555 | int ret = 0; | |
| 556 | aim_rxcallback_t userfunc; | |
| 557 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
558 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
559 | ret = userfunc(od, conn, frame); |
| 13235 | 560 | |
| 561 | return ret; | |
| 562 | } | |
| 563 | ||
| 564 | /** | |
| 565 | * Subtype 0x000b | |
| 566 | * | |
| 567 | * Send SecurID response. | |
| 568 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
569 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
570 | aim_auth_securid_send(OscarData *od, const char *securid) |
| 13235 | 571 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
572 | FlapConnection *conn; |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
573 | FlapFrame *frame; |
| 13235 | 574 | aim_snacid_t snacid; |
| 575 | int len; | |
| 576 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
577 | if (!od || !(conn = flap_connection_getbytype_all(od, SNAC_FAMILY_AUTH)) || !securid) |
| 13235 | 578 | return -EINVAL; |
| 579 | ||
| 580 | len = strlen(securid); | |
| 581 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
582 | frame = flap_frame_new(od, 0x02, 10+2+len); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
583 | |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
584 | snacid = aim_cachesnac(od, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, NULL, 0); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
585 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, 0); |
| 13235 | 586 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
587 | byte_stream_put16(&frame->data, len); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
588 | byte_stream_putstr(&frame->data, securid); |
| 13235 | 589 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
590 | flap_connection_send(conn, frame); |
| 13235 | 591 | |
| 592 | return 0; | |
| 593 | } | |
| 594 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
595 | static void |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
596 | auth_shutdown(OscarData *od, aim_module_t *mod) |
| 13235 | 597 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
598 | if (od->authinfo != NULL) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
599 | { |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
600 | free(od->authinfo->sn); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
601 | free(od->authinfo->bosip); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
602 | free(od->authinfo->errorurl); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
603 | free(od->authinfo->email); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
604 | free(od->authinfo->chpassurl); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
605 | free(od->authinfo->latestrelease.name); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
606 | free(od->authinfo->latestrelease.url); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
607 | free(od->authinfo->latestrelease.info); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
608 | free(od->authinfo->latestbeta.name); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
609 | free(od->authinfo->latestbeta.url); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
610 | free(od->authinfo->latestbeta.info); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
611 | free(od->authinfo); |
| 13235 | 612 | } |
| 613 | } | |
| 614 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
615 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
616 | snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 617 | { |
| 618 | if (snac->subtype == 0x0003) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
619 | return parse(od, conn, mod, frame, snac, bs); |
| 13235 | 620 | else if (snac->subtype == 0x0007) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
621 | return keyparse(od, conn, mod, frame, snac, bs); |
| 13235 | 622 | else if (snac->subtype == 0x000a) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
623 | return got_securid_request(od, conn, mod, frame, snac, bs); |
| 13235 | 624 | |
| 625 | return 0; | |
| 626 | } | |
| 627 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
628 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
629 | auth_modfirst(OscarData *od, aim_module_t *mod) |
| 13235 | 630 | { |
| 631 | mod->family = 0x0017; | |
| 632 | mod->version = 0x0000; | |
| 633 | mod->flags = 0; | |
| 634 | strncpy(mod->name, "auth", sizeof(mod->name)); | |
| 635 | mod->snachandler = snachandler; | |
| 636 | mod->shutdown = auth_shutdown; | |
| 637 | ||
| 638 | return 0; | |
| 639 | } |