Wed, 13 May 2009 20:29:03 +0000
Support custom smileys in MUCs (when all participants support BoB and a maximum
of 10 participants are in the chat).
Always announce support for BoB, since disable custom smileys will still turn
off fetching them, and BoB can be used for other purposes further on.
| 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19820
diff
changeset
|
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 13235 | 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 | ||
|
24670
84014b07aa10
Patch from 'db42' to enable MD5 auth on ICQ. Refs #4449. Before I merge
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
23526
diff
changeset
|
35 | /* #define USE_XOR_FOR_ICQ */ |
| 13235 | 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 | PurpleCipherContext *context; |
| 13235 | 85 | |
|
23526
23c321e72167
Helper functions are cool
Mark Doliner <markdoliner@pidgin.im>
parents:
23456
diff
changeset
|
86 | context = purple_cipher_context_new_by_name("md5", NULL); |
| 15884 | 87 | 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
|
88 | purple_cipher_context_append(context, (const guchar *)password, password_len); |
| 15884 | 89 | purple_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); |
| 90 | purple_cipher_context_digest(context, 16, digest, NULL); | |
| 91 | purple_cipher_context_destroy(context); | |
| 13235 | 92 | |
| 93 | return 0; | |
| 94 | } | |
| 95 | #else | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
96 | 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
|
97 | aim_encode_password_md5(const char *password, size_t password_len, const char *key, guint8 *digest) |
| 13235 | 98 | { |
| 15884 | 99 | PurpleCipher *cipher; |
| 100 | PurpleCipherContext *context; | |
| 13235 | 101 | guchar passdigest[16]; |
| 102 | ||
| 15884 | 103 | cipher = purple_ciphers_find_cipher("md5"); |
| 13235 | 104 | |
| 15884 | 105 | 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
|
106 | purple_cipher_context_append(context, (const guchar *)password, password_len); |
| 15884 | 107 | purple_cipher_context_digest(context, 16, passdigest, NULL); |
| 108 | purple_cipher_context_destroy(context); | |
| 13235 | 109 | |
| 15884 | 110 | context = purple_cipher_context_new(cipher, NULL); |
| 111 | purple_cipher_context_append(context, (const guchar *)key, strlen(key)); | |
| 112 | purple_cipher_context_append(context, passdigest, 16); | |
| 113 | purple_cipher_context_append(context, (const guchar *)AIM_MD5_STRING, strlen(AIM_MD5_STRING)); | |
| 114 | purple_cipher_context_digest(context, 16, digest, NULL); | |
| 115 | purple_cipher_context_destroy(context); | |
| 13235 | 116 | |
| 117 | return 0; | |
| 118 | } | |
| 119 | #endif | |
| 120 | ||
| 121 | #ifdef USE_XOR_FOR_ICQ | |
| 122 | /* | |
| 123 | * Part two of the ICQ hack. Note the ignoring of the key. | |
| 124 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
125 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
126 | goddamnicq2(OscarData *od, FlapConnection *conn, const char *sn, const char *password, ClientInfo *ci) |
| 13235 | 127 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
128 | FlapFrame *frame; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
129 | GSList *tlvlist = NULL; |
| 13235 | 130 | int passwdlen; |
| 131 | guint8 *password_encoded; | |
| 132 | ||
| 133 | 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
|
134 | password_encoded = (guint8 *)g_malloc(passwdlen+1); |
| 13235 | 135 | if (passwdlen > MAXICQPASSLEN) |
| 136 | passwdlen = MAXICQPASSLEN; | |
| 137 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
138 | frame = flap_frame_new(od, 0x01, 1152); |
| 13235 | 139 | |
| 140 | aim_encode_password(password, password_encoded); | |
| 141 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
142 | 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
|
143 | 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
|
144 | aim_tlvlist_add_raw(&tlvlist, 0x0002, passwdlen, password_encoded); |
| 13235 | 145 | |
| 146 | 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
|
147 | 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
|
148 | 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
|
149 | 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
|
150 | 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
|
151 | 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
|
152 | 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
|
153 | 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
|
154 | 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
|
155 | aim_tlvlist_add_str(&tlvlist, 0x000e, ci->country); |
| 13235 | 156 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
157 | aim_tlvlist_write(&frame->data, &tlvlist); |
| 13235 | 158 | |
|
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
|
159 | 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
|
160 | aim_tlvlist_free(tlvlist); |
| 13235 | 161 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
162 | flap_connection_send(conn, frame); |
| 13235 | 163 | |
| 164 | return 0; | |
| 165 | } | |
| 166 | #endif | |
| 167 | ||
| 168 | /* | |
| 169 | * Subtype 0x0002 | |
| 170 | * | |
| 171 | * This is the initial login request packet. | |
| 172 | * | |
| 173 | * NOTE!! If you want/need to make use of the aim_sendmemblock() function, | |
| 174 | * then the client information you send here must exactly match the | |
| 175 | * executable that you're pulling the data from. | |
| 176 | * | |
| 177 | * Java AIM 1.1.19: | |
| 178 | * 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" | |
| 179 | * clientid = 0x0001 | |
| 180 | * major = 0x0001 | |
| 181 | * minor = 0x0001 | |
| 182 | * point = (not sent) | |
| 183 | * build = 0x0013 | |
| 184 | * unknown= (not sent) | |
|
13240
db5187cc40d1
[gaim-migrate @ 15605]
Mark Doliner <markdoliner@pidgin.im>
parents:
13235
diff
changeset
|
185 | * |
| 13235 | 186 | * AIM for Linux 1.1.112: |
| 187 | * clientstring = "AOL Instant Messenger (SM)" | |
| 188 | * clientid = 0x1d09 | |
| 189 | * major = 0x0001 | |
| 190 | * minor = 0x0001 | |
| 191 | * point = 0x0001 | |
| 192 | * build = 0x0070 | |
| 193 | * unknown= 0x0000008b | |
| 194 | * serverstore = 0x01 | |
| 195 | * | |
|
22127
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
196 | * @param truncate_pass Truncate the password to 8 characters. This |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
197 | * usually happens for AOL accounts. We are told that we |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
198 | * should truncate it if the 0x0017/0x0007 SNAC contains |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
199 | * a TLV of type 0x0026 with data 0x0000. |
|
23454
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
200 | * @param allow_multiple_logins Allow multiple logins? If TRUE, the AIM |
|
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
201 | * server will prompt the user when multiple logins occur. If |
|
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
202 | * FALSE, existing connections (on other clients) will be |
|
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
203 | * disconnected automatically as we connect. |
| 13235 | 204 | */ |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
205 | int |
|
23454
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
206 | aim_send_login(OscarData *od, FlapConnection *conn, const char *sn, const char *password, gboolean truncate_pass, ClientInfo *ci, const char *key, gboolean allow_multiple_logins) |
| 13235 | 207 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
208 | FlapFrame *frame; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
209 | GSList *tlvlist = NULL; |
| 13235 | 210 | guint8 digest[16]; |
| 211 | 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
|
212 | size_t password_len; |
| 13235 | 213 | |
| 214 | if (!ci || !sn || !password) | |
| 215 | return -EINVAL; | |
| 216 | ||
| 217 | #ifdef USE_XOR_FOR_ICQ | |
| 218 | /* 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
|
219 | if (aim_snvalid_icq(sn)) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
220 | return goddamnicq2(od, conn, sn, password, ci); |
| 13235 | 221 | #endif |
| 222 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
223 | frame = flap_frame_new(od, 0x02, 1152); |
| 13235 | 224 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
225 | snacid = aim_cachesnac(od, SNAC_FAMILY_AUTH, 0x0002, 0x0000, NULL, 0); |
|
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
226 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, 0x0002, 0x0000, snacid); |
| 13235 | 227 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
228 | aim_tlvlist_add_str(&tlvlist, 0x0001, sn); |
| 13235 | 229 | |
|
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
|
230 | /* 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
|
231 | password_len = strlen(password); |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
232 | if (oscar_util_valid_name_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
|
233 | 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
|
234 | 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
|
235 | 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
|
236 | |
|
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
|
237 | aim_encode_password_md5(password, password_len, key, digest); |
| 13235 | 238 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
239 | aim_tlvlist_add_raw(&tlvlist, 0x0025, 16, digest); |
| 13235 | 240 | |
| 241 | #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
|
242 | aim_tlvlist_add_noval(&tlvlist, 0x004c); |
| 13235 | 243 | #endif |
| 244 | ||
| 245 | 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
|
246 | 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
|
247 | 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
|
248 | 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
|
249 | 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
|
250 | 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
|
251 | 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
|
252 | 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
|
253 | 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
|
254 | aim_tlvlist_add_str(&tlvlist, 0x000e, ci->country); |
| 13235 | 255 | |
| 256 | /* | |
| 257 | * If set, old-fashioned buddy lists will not work. You will need | |
| 258 | * to use SSI. | |
| 259 | */ | |
|
23454
d8721c84f49c
Added paramater to aim_send_login() to allow control over whether we want
Evan Schoenberg <evands@pidgin.im>
parents:
22127
diff
changeset
|
260 | aim_tlvlist_add_8(&tlvlist, 0x004a, (allow_multiple_logins ? 0x01 : 0x02)); |
| 13235 | 261 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
262 | aim_tlvlist_write(&frame->data, &tlvlist); |
| 13235 | 263 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
264 | aim_tlvlist_free(tlvlist); |
| 13235 | 265 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
266 | flap_connection_send(conn, frame); |
| 13235 | 267 | |
| 268 | return 0; | |
| 269 | } | |
| 270 | ||
| 271 | /* | |
| 272 | * This is sent back as a general response to the login command. | |
| 273 | * 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
|
274 | * presence of certain TLVs. |
| 13235 | 275 | * |
| 276 | * The client should check the value passed as errorcode. If | |
| 277 | * its nonzero, there was an error. | |
| 278 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
279 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
280 | parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 281 | { |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
282 | GSList *tlvlist; |
| 13235 | 283 | aim_rxcallback_t userfunc; |
| 284 | struct aim_authresp_info *info; | |
| 285 | int ret = 0; | |
| 286 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
287 | info = g_new0(struct aim_authresp_info, 1); |
| 13235 | 288 | |
| 289 | /* | |
| 290 | * Read block of TLVs. All further data is derived | |
| 291 | * from what is parsed here. | |
| 292 | */ | |
| 293 | tlvlist = aim_tlvlist_read(bs); | |
| 294 | ||
| 295 | /* | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
296 | * No matter what, we should have a username. |
| 13235 | 297 | */ |
| 298 | if (aim_tlv_gettlv(tlvlist, 0x0001, 1)) { | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
299 | info->bn = aim_tlv_getstr(tlvlist, 0x0001, 1); |
|
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
300 | purple_connection_set_display_name(od->gc, info->bn); |
| 13235 | 301 | } |
| 302 | ||
| 303 | /* | |
| 304 | * Check for an error code. If so, we should also | |
| 305 | * have an error url. | |
| 306 | */ | |
| 307 | if (aim_tlv_gettlv(tlvlist, 0x0008, 1)) | |
| 308 | info->errorcode = aim_tlv_get16(tlvlist, 0x0008, 1); | |
| 309 | if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) | |
| 310 | info->errorurl = aim_tlv_getstr(tlvlist, 0x0004, 1); | |
| 311 | ||
| 312 | /* | |
| 313 | * BOS server address. | |
| 314 | */ | |
| 315 | if (aim_tlv_gettlv(tlvlist, 0x0005, 1)) | |
| 316 | info->bosip = aim_tlv_getstr(tlvlist, 0x0005, 1); | |
| 317 | ||
| 318 | /* | |
| 319 | * Authorization cookie. | |
| 320 | */ | |
| 321 | if (aim_tlv_gettlv(tlvlist, 0x0006, 1)) { | |
| 322 | aim_tlv_t *tmptlv; | |
| 323 | ||
| 324 | tmptlv = aim_tlv_gettlv(tlvlist, 0x0006, 1); | |
|
13653
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
325 | if (tmptlv != NULL) |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
326 | { |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
327 | info->cookielen = tmptlv->length; |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
328 | info->cookie = tmptlv->value; |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
329 | } |
| 13235 | 330 | } |
| 331 | ||
| 332 | /* | |
| 333 | * The email address attached to this account | |
| 334 | * Not available for ICQ or @mac.com logins. | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
335 | * If you receive this TLV, then you are allowed to use |
| 13235 | 336 | * family 0x0018 to check the status of your email. |
| 337 | * XXX - Not really true! | |
| 338 | */ | |
| 339 | if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) | |
| 340 | info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); | |
| 341 | ||
| 342 | /* | |
| 343 | * The registration status. (Not real sure what it means.) | |
| 344 | * Not available for ICQ or @mac.com logins. | |
| 345 | * | |
| 346 | * 1 = No disclosure | |
| 347 | * 2 = Limited disclosure | |
| 348 | * 3 = Full disclosure | |
| 349 | * | |
| 350 | * This has to do with whether your email address is available | |
| 351 | * to other users or not. AFAIK, this feature is no longer used. | |
| 352 | * | |
| 353 | * Means you can use the admin family? (0x0007) | |
| 354 | * | |
| 355 | */ | |
| 356 | if (aim_tlv_gettlv(tlvlist, 0x0013, 1)) | |
| 357 | info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1); | |
| 358 | ||
| 359 | if (aim_tlv_gettlv(tlvlist, 0x0040, 1)) | |
| 360 | info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1); | |
| 361 | if (aim_tlv_gettlv(tlvlist, 0x0041, 1)) | |
| 362 | info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1); | |
| 363 | if (aim_tlv_gettlv(tlvlist, 0x0042, 1)) | |
| 364 | info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1); | |
| 365 | if (aim_tlv_gettlv(tlvlist, 0x0043, 1)) | |
| 366 | info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1); | |
| 367 | ||
| 368 | #if 0 | |
| 369 | if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) { | |
| 370 | /* beta serial */ | |
| 371 | } | |
| 372 | #endif | |
| 373 | ||
| 374 | if (aim_tlv_gettlv(tlvlist, 0x0044, 1)) | |
| 375 | info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1); | |
| 376 | if (aim_tlv_gettlv(tlvlist, 0x0045, 1)) | |
| 377 | info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1); | |
| 378 | if (aim_tlv_gettlv(tlvlist, 0x0046, 1)) | |
| 379 | info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1); | |
| 380 | if (aim_tlv_gettlv(tlvlist, 0x0047, 1)) | |
| 381 | info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1); | |
| 382 | ||
| 383 | #if 0 | |
| 384 | if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) { | |
| 385 | /* lastest release serial */ | |
| 386 | } | |
| 387 | #endif | |
| 388 | ||
| 389 | /* | |
| 390 | * URL to change password. | |
| 391 | */ | |
| 392 | if (aim_tlv_gettlv(tlvlist, 0x0054, 1)) | |
| 393 | info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1); | |
| 394 | ||
| 395 | #if 0 | |
| 396 | /* | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
397 | * Unknown. Seen on an @mac.com username with value of 0x003f |
| 13235 | 398 | */ |
| 399 | if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) { | |
| 400 | /* Unhandled */ | |
| 401 | } | |
| 402 | #endif | |
| 403 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
404 | od->authinfo = info; |
| 13235 | 405 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
406 | if ((userfunc = aim_callhandler(od, snac ? snac->family : SNAC_FAMILY_AUTH, snac ? snac->subtype : 0x0003))) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
407 | ret = userfunc(od, conn, frame, info); |
| 13235 | 408 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
409 | aim_tlvlist_free(tlvlist); |
| 13235 | 410 | |
| 411 | return ret; | |
| 412 | } | |
| 413 | ||
| 414 | #ifdef USE_XOR_FOR_ICQ | |
| 415 | /* | |
| 416 | * Subtype 0x0007 (kind of) - Send a fake type 0x0007 SNAC to the client | |
| 417 | * | |
| 418 | * This is a bit confusing. | |
| 419 | * | |
| 420 | * Normal SNAC login goes like this: | |
| 421 | * - connect | |
| 422 | * - server sends flap version | |
| 423 | * - client sends flap version | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
424 | * - client sends username (17/6) |
| 13235 | 425 | * - server sends hash key (17/7) |
| 426 | * - client sends auth request (17/2 -- aim_send_login) | |
| 427 | * - server yells | |
| 428 | * | |
| 429 | * XOR login (for ICQ) goes like this: | |
| 430 | * - connect | |
| 431 | * - server sends flap version | |
| 432 | * - client sends auth request which contains flap version (aim_send_login) | |
| 433 | * - server yells | |
| 434 | * | |
| 435 | * For the client API, we make them implement the most complicated version, | |
| 436 | * and for the simpler version, we fake it and make it look like the more | |
| 437 | * complicated process. | |
| 438 | * | |
| 439 | * This is done by giving the client a faked key, just so we can convince | |
| 440 | * them to call aim_send_login right away, which will detect the session | |
| 441 | * flag that says this is XOR login and ignore the key, sending an ICQ | |
| 442 | * login request instead of the normal SNAC one. | |
| 443 | * | |
| 444 | * As soon as AOL makes ICQ log in the same way as AIM, this is /gone/. | |
| 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 | ||
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
452 | if ((userfunc = aim_callhandler(od, SNAC_FAMILY_AUTH, 0x0007))) |
|
13593
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 |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
463 | * Authorizer, passing it the username for verification. If the name is |
|
13593
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 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
486 | snacid = aim_cachesnac(od, SNAC_FAMILY_AUTH, 0x0006, 0x0000, NULL, 0); |
|
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
487 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, 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 |
|
22127
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
529 | * user's password to 8 characters. This flag is sent to us |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
530 | * when logging in with an AOL user's username. |
|
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
|
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 | { |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
600 | g_free(od->authinfo->bn); |
|
25152
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
601 | g_free(od->authinfo->bosip); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
602 | g_free(od->authinfo->errorurl); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
603 | g_free(od->authinfo->email); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
604 | g_free(od->authinfo->chpassurl); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
605 | g_free(od->authinfo->latestrelease.name); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
606 | g_free(od->authinfo->latestrelease.url); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
607 | g_free(od->authinfo->latestrelease.info); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
608 | g_free(od->authinfo->latestbeta.name); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
609 | g_free(od->authinfo->latestbeta.url); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
610 | g_free(od->authinfo->latestbeta.info); |
|
128b99dfb286
Fix warnings where size_t/gsize was used for printf with the wrong format
Paul Aurich <darkrain42@pidgin.im>
parents:
25086
diff
changeset
|
611 | g_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 | { |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
631 | mod->family = SNAC_FAMILY_AUTH; |
| 13235 | 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 | } |