Mon, 28 Jun 2010 20:02:12 +0000
Added a way to add a user to the (In)Visible list via the context menu.
| 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 | ||
|
29106
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
28520
diff
changeset
|
29 | #include "oscar.h" |
|
51c7b2177e42
Fix all the remaining files for which internal.h doesn't end up being the first include.
Paul Aurich <darkrain42@pidgin.im>
parents:
28520
diff
changeset
|
30 | |
|
27381
e2a0ae2ee7f0
Shuffle this order around for no real reason other than that I prefer it this way
Mark Doliner <markdoliner@pidgin.im>
parents:
27325
diff
changeset
|
31 | #include <ctype.h> |
| 13235 | 32 | |
| 33 | #include "cipher.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; | |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
132 | guint32 distrib; |
| 13235 | 133 | |
| 134 | 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
|
135 | password_encoded = (guint8 *)g_malloc(passwdlen+1); |
| 13235 | 136 | if (passwdlen > MAXICQPASSLEN) |
| 137 | passwdlen = MAXICQPASSLEN; | |
| 138 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
139 | frame = flap_frame_new(od, 0x01, 1152); |
| 13235 | 140 | |
| 141 | aim_encode_password(password, password_encoded); | |
| 142 | ||
|
27687
f46b6b5c25e1
Use the ui_info hash table instead of prefs when passing the clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27381
diff
changeset
|
143 | distrib = oscar_get_ui_info_int( |
|
f46b6b5c25e1
Use the ui_info hash table instead of prefs when passing the clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27381
diff
changeset
|
144 | od->icq ? "prpl-icq-distid" : "prpl-aim-distid", |
|
f46b6b5c25e1
Use the ui_info hash table instead of prefs when passing the clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27381
diff
changeset
|
145 | ci->distrib); |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
146 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
147 | 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
|
148 | 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
|
149 | aim_tlvlist_add_raw(&tlvlist, 0x0002, passwdlen, password_encoded); |
| 13235 | 150 | |
|
27688
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
151 | if (ci->clientstring != NULL) |
|
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
152 | aim_tlvlist_add_str(&tlvlist, 0x0003, ci->clientstring); |
|
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
153 | else { |
|
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
154 | gchar *clientstring = oscar_get_clientstring(); |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
155 | aim_tlvlist_add_str(&tlvlist, 0x0003, clientstring); |
|
27688
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
156 | g_free(clientstring); |
|
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
157 | } |
|
17443
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_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
|
159 | 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
|
160 | 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
|
161 | 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
|
162 | aim_tlvlist_add_16(&tlvlist, 0x001a, (guint16)ci->build); |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
163 | aim_tlvlist_add_32(&tlvlist, 0x0014, distrib); /* distribution chan */ |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
164 | 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
|
165 | aim_tlvlist_add_str(&tlvlist, 0x000e, ci->country); |
| 13235 | 166 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
167 | aim_tlvlist_write(&frame->data, &tlvlist); |
| 13235 | 168 | |
|
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
|
169 | 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
|
170 | aim_tlvlist_free(tlvlist); |
| 13235 | 171 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
172 | flap_connection_send(conn, frame); |
| 13235 | 173 | |
| 174 | return 0; | |
| 175 | } | |
| 176 | #endif | |
| 177 | ||
| 178 | /* | |
| 179 | * Subtype 0x0002 | |
| 180 | * | |
| 181 | * This is the initial login request packet. | |
| 182 | * | |
| 183 | * NOTE!! If you want/need to make use of the aim_sendmemblock() function, | |
| 184 | * then the client information you send here must exactly match the | |
| 185 | * executable that you're pulling the data from. | |
| 186 | * | |
| 187 | * Java AIM 1.1.19: | |
| 188 | * 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" | |
| 189 | * clientid = 0x0001 | |
| 190 | * major = 0x0001 | |
| 191 | * minor = 0x0001 | |
| 192 | * point = (not sent) | |
| 193 | * build = 0x0013 | |
| 194 | * unknown= (not sent) | |
|
13240
db5187cc40d1
[gaim-migrate @ 15605]
Mark Doliner <markdoliner@pidgin.im>
parents:
13235
diff
changeset
|
195 | * |
| 13235 | 196 | * AIM for Linux 1.1.112: |
| 197 | * clientstring = "AOL Instant Messenger (SM)" | |
| 198 | * clientid = 0x1d09 | |
| 199 | * major = 0x0001 | |
| 200 | * minor = 0x0001 | |
| 201 | * point = 0x0001 | |
| 202 | * build = 0x0070 | |
| 203 | * unknown= 0x0000008b | |
| 204 | * serverstore = 0x01 | |
| 205 | * | |
|
22127
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
206 | * @param truncate_pass Truncate the password to 8 characters. This |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
207 | * usually happens for AOL accounts. We are told that we |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
208 | * should truncate it if the 0x0017/0x0007 SNAC contains |
|
307a72c99f1c
Minor comment changes
Mark Doliner <markdoliner@pidgin.im>
parents:
20140
diff
changeset
|
209 | * 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
|
210 | * @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
|
211 | * 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
|
212 | * 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
|
213 | * disconnected automatically as we connect. |
| 13235 | 214 | */ |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
215 | 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
|
216 | 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 | 217 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
218 | FlapFrame *frame; |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
219 | GSList *tlvlist = NULL; |
| 13235 | 220 | guint8 digest[16]; |
| 221 | 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
|
222 | size_t password_len; |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
223 | guint32 distrib; |
| 13235 | 224 | |
| 225 | if (!ci || !sn || !password) | |
| 226 | return -EINVAL; | |
| 227 | ||
| 228 | #ifdef USE_XOR_FOR_ICQ | |
| 229 | /* 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
|
230 | if (aim_snvalid_icq(sn)) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
231 | return goddamnicq2(od, conn, sn, password, ci); |
| 13235 | 232 | #endif |
| 233 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
234 | frame = flap_frame_new(od, 0x02, 1152); |
| 13235 | 235 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
236 | 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
|
237 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, 0x0002, 0x0000, snacid); |
| 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_str(&tlvlist, 0x0001, sn); |
| 13235 | 240 | |
|
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
|
241 | /* 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
|
242 | 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
|
243 | 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
|
244 | 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
|
245 | 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
|
246 | 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
|
247 | |
|
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
|
248 | aim_encode_password_md5(password, password_len, key, digest); |
| 13235 | 249 | |
|
27687
f46b6b5c25e1
Use the ui_info hash table instead of prefs when passing the clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27381
diff
changeset
|
250 | distrib = oscar_get_ui_info_int( |
|
f46b6b5c25e1
Use the ui_info hash table instead of prefs when passing the clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27381
diff
changeset
|
251 | od->icq ? "prpl-icq-distid" : "prpl-aim-distid", |
|
f46b6b5c25e1
Use the ui_info hash table instead of prefs when passing the clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27381
diff
changeset
|
252 | ci->distrib); |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
253 | |
|
17443
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_raw(&tlvlist, 0x0025, 16, digest); |
| 13235 | 255 | |
| 256 | #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
|
257 | aim_tlvlist_add_noval(&tlvlist, 0x004c); |
| 13235 | 258 | #endif |
| 259 | ||
|
27688
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
260 | if (ci->clientstring != NULL) |
|
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
261 | aim_tlvlist_add_str(&tlvlist, 0x0003, ci->clientstring); |
|
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
262 | else { |
|
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
263 | gchar *clientstring = oscar_get_clientstring(); |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
264 | aim_tlvlist_add_str(&tlvlist, 0x0003, clientstring); |
|
27688
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
265 | g_free(clientstring); |
|
8c89470bfe9d
Oh, we don't need a special ui_info field for the AIM clientstring
Mark Doliner <markdoliner@pidgin.im>
parents:
27687
diff
changeset
|
266 | } |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
267 | 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
|
268 | 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
|
269 | 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
|
270 | 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
|
271 | aim_tlvlist_add_16(&tlvlist, 0x001a, (guint16)ci->build); |
|
27325
efe14a748826
Check in a change requested by Gregory Cypes from AOL. They want clients
Mark Doliner <markdoliner@pidgin.im>
parents:
25889
diff
changeset
|
272 | aim_tlvlist_add_32(&tlvlist, 0x0014, distrib); |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
273 | 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
|
274 | aim_tlvlist_add_str(&tlvlist, 0x000e, ci->country); |
| 13235 | 275 | |
| 276 | /* | |
| 277 | * If set, old-fashioned buddy lists will not work. You will need | |
| 278 | * to use SSI. | |
| 279 | */ | |
|
28520
d8964d76432a
These should actually be 0x03, I think. I think it's a bitmask where
Mark Doliner <markdoliner@pidgin.im>
parents:
27688
diff
changeset
|
280 | aim_tlvlist_add_8(&tlvlist, 0x004a, (allow_multiple_logins ? 0x01 : 0x03)); |
| 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 | aim_tlvlist_write(&frame->data, &tlvlist); |
| 13235 | 283 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
284 | aim_tlvlist_free(tlvlist); |
| 13235 | 285 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
286 | flap_connection_send(conn, frame); |
| 13235 | 287 | |
| 288 | return 0; | |
| 289 | } | |
| 290 | ||
| 291 | /* | |
| 292 | * This is sent back as a general response to the login command. | |
| 293 | * 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
|
294 | * presence of certain TLVs. |
| 13235 | 295 | * |
| 296 | * The client should check the value passed as errorcode. If | |
| 297 | * its nonzero, there was an error. | |
| 298 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
299 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
300 | parse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 301 | { |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
302 | GSList *tlvlist; |
| 13235 | 303 | aim_rxcallback_t userfunc; |
| 304 | struct aim_authresp_info *info; | |
| 305 | int ret = 0; | |
| 306 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
307 | info = g_new0(struct aim_authresp_info, 1); |
| 13235 | 308 | |
| 309 | /* | |
| 310 | * Read block of TLVs. All further data is derived | |
| 311 | * from what is parsed here. | |
| 312 | */ | |
| 313 | tlvlist = aim_tlvlist_read(bs); | |
| 314 | ||
| 315 | /* | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
316 | * No matter what, we should have a username. |
| 13235 | 317 | */ |
| 318 | 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
|
319 | 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
|
320 | purple_connection_set_display_name(od->gc, info->bn); |
| 13235 | 321 | } |
| 322 | ||
| 323 | /* | |
| 324 | * Check for an error code. If so, we should also | |
| 325 | * have an error url. | |
| 326 | */ | |
| 327 | if (aim_tlv_gettlv(tlvlist, 0x0008, 1)) | |
| 328 | info->errorcode = aim_tlv_get16(tlvlist, 0x0008, 1); | |
| 329 | if (aim_tlv_gettlv(tlvlist, 0x0004, 1)) | |
| 330 | info->errorurl = aim_tlv_getstr(tlvlist, 0x0004, 1); | |
| 331 | ||
| 332 | /* | |
| 333 | * BOS server address. | |
| 334 | */ | |
| 335 | if (aim_tlv_gettlv(tlvlist, 0x0005, 1)) | |
| 336 | info->bosip = aim_tlv_getstr(tlvlist, 0x0005, 1); | |
| 337 | ||
| 338 | /* | |
| 339 | * Authorization cookie. | |
| 340 | */ | |
| 341 | if (aim_tlv_gettlv(tlvlist, 0x0006, 1)) { | |
| 342 | aim_tlv_t *tmptlv; | |
| 343 | ||
| 344 | tmptlv = aim_tlv_gettlv(tlvlist, 0x0006, 1); | |
|
13653
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
345 | if (tmptlv != NULL) |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
346 | { |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
347 | info->cookielen = tmptlv->length; |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
348 | info->cookie = tmptlv->value; |
|
fab80366d565
[gaim-migrate @ 16053]
Mark Doliner <markdoliner@pidgin.im>
parents:
13593
diff
changeset
|
349 | } |
| 13235 | 350 | } |
| 351 | ||
| 352 | /* | |
| 353 | * The email address attached to this account | |
| 354 | * Not available for ICQ or @mac.com logins. | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
355 | * If you receive this TLV, then you are allowed to use |
| 13235 | 356 | * family 0x0018 to check the status of your email. |
| 357 | * XXX - Not really true! | |
| 358 | */ | |
| 359 | if (aim_tlv_gettlv(tlvlist, 0x0011, 1)) | |
| 360 | info->email = aim_tlv_getstr(tlvlist, 0x0011, 1); | |
| 361 | ||
| 362 | /* | |
| 363 | * The registration status. (Not real sure what it means.) | |
| 364 | * Not available for ICQ or @mac.com logins. | |
| 365 | * | |
| 366 | * 1 = No disclosure | |
| 367 | * 2 = Limited disclosure | |
| 368 | * 3 = Full disclosure | |
| 369 | * | |
| 370 | * This has to do with whether your email address is available | |
| 371 | * to other users or not. AFAIK, this feature is no longer used. | |
| 372 | * | |
| 373 | * Means you can use the admin family? (0x0007) | |
| 374 | * | |
| 375 | */ | |
| 376 | if (aim_tlv_gettlv(tlvlist, 0x0013, 1)) | |
| 377 | info->regstatus = aim_tlv_get16(tlvlist, 0x0013, 1); | |
| 378 | ||
| 379 | if (aim_tlv_gettlv(tlvlist, 0x0040, 1)) | |
| 380 | info->latestbeta.build = aim_tlv_get32(tlvlist, 0x0040, 1); | |
| 381 | if (aim_tlv_gettlv(tlvlist, 0x0041, 1)) | |
| 382 | info->latestbeta.url = aim_tlv_getstr(tlvlist, 0x0041, 1); | |
| 383 | if (aim_tlv_gettlv(tlvlist, 0x0042, 1)) | |
| 384 | info->latestbeta.info = aim_tlv_getstr(tlvlist, 0x0042, 1); | |
| 385 | if (aim_tlv_gettlv(tlvlist, 0x0043, 1)) | |
| 386 | info->latestbeta.name = aim_tlv_getstr(tlvlist, 0x0043, 1); | |
| 387 | ||
| 388 | #if 0 | |
| 389 | if (aim_tlv_gettlv(tlvlist, 0x0048, 1)) { | |
| 390 | /* beta serial */ | |
| 391 | } | |
| 392 | #endif | |
| 393 | ||
| 394 | if (aim_tlv_gettlv(tlvlist, 0x0044, 1)) | |
| 395 | info->latestrelease.build = aim_tlv_get32(tlvlist, 0x0044, 1); | |
| 396 | if (aim_tlv_gettlv(tlvlist, 0x0045, 1)) | |
| 397 | info->latestrelease.url = aim_tlv_getstr(tlvlist, 0x0045, 1); | |
| 398 | if (aim_tlv_gettlv(tlvlist, 0x0046, 1)) | |
| 399 | info->latestrelease.info = aim_tlv_getstr(tlvlist, 0x0046, 1); | |
| 400 | if (aim_tlv_gettlv(tlvlist, 0x0047, 1)) | |
| 401 | info->latestrelease.name = aim_tlv_getstr(tlvlist, 0x0047, 1); | |
| 402 | ||
| 403 | #if 0 | |
| 404 | if (aim_tlv_gettlv(tlvlist, 0x0049, 1)) { | |
| 405 | /* lastest release serial */ | |
| 406 | } | |
| 407 | #endif | |
| 408 | ||
| 409 | /* | |
| 410 | * URL to change password. | |
| 411 | */ | |
| 412 | if (aim_tlv_gettlv(tlvlist, 0x0054, 1)) | |
| 413 | info->chpassurl = aim_tlv_getstr(tlvlist, 0x0054, 1); | |
| 414 | ||
| 415 | #if 0 | |
| 416 | /* | |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
417 | * Unknown. Seen on an @mac.com username with value of 0x003f |
| 13235 | 418 | */ |
| 419 | if (aim_tlv_gettlv(tlvlist, 0x0055, 1)) { | |
| 420 | /* Unhandled */ | |
| 421 | } | |
| 422 | #endif | |
| 423 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
424 | od->authinfo = info; |
| 13235 | 425 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
426 | 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
|
427 | ret = userfunc(od, conn, frame, info); |
| 13235 | 428 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
429 | aim_tlvlist_free(tlvlist); |
| 13235 | 430 | |
| 431 | return ret; | |
| 432 | } | |
| 433 | ||
| 434 | #ifdef USE_XOR_FOR_ICQ | |
| 435 | /* | |
| 436 | * Subtype 0x0007 (kind of) - Send a fake type 0x0007 SNAC to the client | |
| 437 | * | |
| 438 | * This is a bit confusing. | |
| 439 | * | |
| 440 | * Normal SNAC login goes like this: | |
| 441 | * - connect | |
| 442 | * - server sends flap version | |
| 443 | * - 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
|
444 | * - client sends username (17/6) |
| 13235 | 445 | * - server sends hash key (17/7) |
| 446 | * - client sends auth request (17/2 -- aim_send_login) | |
| 447 | * - server yells | |
| 448 | * | |
| 449 | * XOR login (for ICQ) goes like this: | |
| 450 | * - connect | |
| 451 | * - server sends flap version | |
| 452 | * - client sends auth request which contains flap version (aim_send_login) | |
| 453 | * - server yells | |
| 454 | * | |
| 455 | * For the client API, we make them implement the most complicated version, | |
| 456 | * and for the simpler version, we fake it and make it look like the more | |
| 457 | * complicated process. | |
| 458 | * | |
| 459 | * This is done by giving the client a faked key, just so we can convince | |
| 460 | * them to call aim_send_login right away, which will detect the session | |
| 461 | * flag that says this is XOR login and ignore the key, sending an ICQ | |
| 462 | * login request instead of the normal SNAC one. | |
| 463 | * | |
| 464 | * As soon as AOL makes ICQ log in the same way as AIM, this is /gone/. | |
| 465 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
466 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
467 | goddamnicq(OscarData *od, FlapConnection *conn, const char *sn) |
| 13235 | 468 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
469 | FlapFrame frame; |
| 13235 | 470 | aim_rxcallback_t userfunc; |
| 471 | ||
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
472 | if ((userfunc = aim_callhandler(od, SNAC_FAMILY_AUTH, 0x0007))) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
473 | userfunc(od, conn, &frame, ""); |
| 13235 | 474 | |
| 475 | return 0; | |
| 476 | } | |
| 477 | #endif | |
| 478 | ||
| 479 | /* | |
| 480 | * Subtype 0x0006 | |
| 481 | * | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
482 | * 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
|
483 | * 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
|
484 | * 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
|
485 | * 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
|
486 | * login command (0017/0002). |
| 13235 | 487 | * |
| 488 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
489 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
490 | aim_request_login(OscarData *od, FlapConnection *conn, const char *sn) |
| 13235 | 491 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
492 | FlapFrame *frame; |
| 13235 | 493 | 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
|
494 | GSList *tlvlist = NULL; |
| 13235 | 495 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
496 | if (!od || !conn || !sn) |
| 13235 | 497 | return -EINVAL; |
| 498 | ||
| 499 | #ifdef USE_XOR_FOR_ICQ | |
|
19820
0f82885da3d8
A little function name shuffling.
Mark Doliner <markdoliner@pidgin.im>
parents:
18341
diff
changeset
|
500 | if (aim_snvalid_icq(sn)) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
501 | return goddamnicq(od, conn, sn); |
| 13235 | 502 | #endif |
| 503 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
504 | frame = flap_frame_new(od, 0x02, 10+2+2+strlen(sn)+8); |
| 13235 | 505 | |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
506 | 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
|
507 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, 0x0006, 0x0000, snacid); |
| 13235 | 508 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
509 | aim_tlvlist_add_str(&tlvlist, 0x0001, sn); |
| 13235 | 510 | |
| 511 | /* 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
|
512 | aim_tlvlist_add_noval(&tlvlist, 0x004b); |
| 13235 | 513 | |
| 514 | /* 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
|
515 | aim_tlvlist_add_noval(&tlvlist, 0x005a); |
| 13235 | 516 | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
517 | 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
|
518 | aim_tlvlist_free(tlvlist); |
| 13235 | 519 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
520 | flap_connection_send(conn, frame); |
| 13235 | 521 | |
| 522 | return 0; | |
| 523 | } | |
| 524 | ||
| 525 | /* | |
| 526 | * Subtype 0x0007 | |
| 527 | * | |
| 528 | * Middle handler for 0017/0007 SNACs. Contains the auth key prefixed | |
| 529 | * by only its length in a two byte word. | |
| 530 | * | |
| 531 | * Calls the client, which should then use the value to call aim_send_login. | |
| 532 | * | |
| 533 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
534 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
535 | keyparse(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 536 | { |
| 537 | int keylen, ret = 1; | |
| 538 | aim_rxcallback_t userfunc; | |
| 539 | char *keystr; | |
|
17443
bae8548d98b3
Cleanup and simplification of some tlvlist stuff in the oscar protocol.
Mark Doliner <markdoliner@pidgin.im>
parents:
17294
diff
changeset
|
540 | 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
|
541 | gboolean truncate_pass; |
| 13235 | 542 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
543 | keylen = byte_stream_get16(bs); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
544 | 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
|
545 | 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
|
546 | |
|
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
|
547 | /* |
|
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
|
548 | * 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
|
549 | * 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
|
550 | * 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
|
551 | */ |
|
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
|
552 | truncate_pass = aim_tlv_gettlv(tlvlist, 0x0026, 1) != NULL; |
| 13235 | 553 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
554 | /* 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
|
555 | * for the netscape network. This SNAC had a type 0x0058 TLV with length 10. |
| 13235 | 556 | * Data is 0x0007 0004 3e19 ae1e 0006 0004 0000 0005 */ |
| 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))) |
|
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
|
559 | ret = userfunc(od, conn, frame, keystr, (int)truncate_pass); |
| 13235 | 560 | |
|
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
|
561 | 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
|
562 | aim_tlvlist_free(tlvlist); |
| 13235 | 563 | |
| 564 | return ret; | |
| 565 | } | |
| 566 | ||
| 567 | /** | |
| 568 | * Subtype 0x000a | |
| 569 | * | |
| 570 | * Receive SecurID request. | |
| 571 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
572 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
573 | got_securid_request(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 574 | { |
| 575 | int ret = 0; | |
| 576 | aim_rxcallback_t userfunc; | |
| 577 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
578 | if ((userfunc = aim_callhandler(od, snac->family, snac->subtype))) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
579 | ret = userfunc(od, conn, frame); |
| 13235 | 580 | |
| 581 | return ret; | |
| 582 | } | |
| 583 | ||
| 584 | /** | |
| 585 | * Subtype 0x000b | |
| 586 | * | |
| 587 | * Send SecurID response. | |
| 588 | */ | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
589 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
590 | aim_auth_securid_send(OscarData *od, const char *securid) |
| 13235 | 591 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
592 | FlapConnection *conn; |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
593 | FlapFrame *frame; |
| 13235 | 594 | aim_snacid_t snacid; |
| 595 | int len; | |
| 596 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
597 | if (!od || !(conn = flap_connection_getbytype_all(od, SNAC_FAMILY_AUTH)) || !securid) |
| 13235 | 598 | return -EINVAL; |
| 599 | ||
| 600 | len = strlen(securid); | |
| 601 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
602 | frame = flap_frame_new(od, 0x02, 10+2+len); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
603 | |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
604 | 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
|
605 | aim_putsnac(&frame->data, SNAC_FAMILY_AUTH, SNAC_SUBTYPE_AUTH_SECURID_RESPONSE, 0x0000, 0); |
| 13235 | 606 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
607 | byte_stream_put16(&frame->data, len); |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
608 | byte_stream_putstr(&frame->data, securid); |
| 13235 | 609 | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
610 | flap_connection_send(conn, frame); |
| 13235 | 611 | |
| 612 | return 0; | |
| 613 | } | |
| 614 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
615 | static void |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
616 | auth_shutdown(OscarData *od, aim_module_t *mod) |
| 13235 | 617 | { |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
618 | if (od->authinfo != NULL) |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
619 | { |
|
25889
26d9ca30335c
Change "screen name" to "username" or "buddy name" in a whole bunch of
Mark Doliner <markdoliner@pidgin.im>
parents:
25152
diff
changeset
|
620 | 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
|
621 | 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
|
622 | 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
|
623 | 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
|
624 | 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
|
625 | 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
|
626 | 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
|
627 | 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
|
628 | 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
|
629 | 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
|
630 | 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
|
631 | g_free(od->authinfo); |
| 13235 | 632 | } |
| 633 | } | |
| 634 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
635 | static int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
636 | snachandler(OscarData *od, FlapConnection *conn, aim_module_t *mod, FlapFrame *frame, aim_modsnac_t *snac, ByteStream *bs) |
| 13235 | 637 | { |
| 638 | if (snac->subtype == 0x0003) | |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
639 | return parse(od, conn, mod, frame, snac, bs); |
| 13235 | 640 | else if (snac->subtype == 0x0007) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
641 | return keyparse(od, conn, mod, frame, snac, bs); |
| 13235 | 642 | else if (snac->subtype == 0x000a) |
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
643 | return got_securid_request(od, conn, mod, frame, snac, bs); |
| 13235 | 644 | |
| 645 | return 0; | |
| 646 | } | |
| 647 | ||
|
13593
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
648 | int |
|
3450a7cede99
[gaim-migrate @ 15978]
Mark Doliner <markdoliner@pidgin.im>
parents:
13254
diff
changeset
|
649 | auth_modfirst(OscarData *od, aim_module_t *mod) |
| 13235 | 650 | { |
|
23456
66ab07770438
Replaced family_*'s magic numbers of FLAP families with the constants
Evan Schoenberg <evands@pidgin.im>
parents:
23454
diff
changeset
|
651 | mod->family = SNAC_FAMILY_AUTH; |
| 13235 | 652 | mod->version = 0x0000; |
| 653 | mod->flags = 0; | |
| 654 | strncpy(mod->name, "auth", sizeof(mod->name)); | |
| 655 | mod->snachandler = snachandler; | |
| 656 | mod->shutdown = auth_shutdown; | |
| 657 | ||
| 658 | return 0; | |
| 659 | } |