Thu, 09 Jun 2005 04:42:27 +0000
[gaim-migrate @ 12830]
Try to get the prpl tooltip_text even if the buddy is logged off. This doesn't appear to cause any problems with the existing prpls, but I didn't exactly go over them with a fine tooth comb ... if you know what I mean.
| 2681 | 1 | /* |
| 2 | * gaim | |
| 3 | * | |
| 8046 | 4 | * Gaim is the legal property of its developers, whose names are too numerous |
| 5 | * to list here. Please refer to the COPYRIGHT file distributed with this | |
| 6 | * source distribution. | |
| 2681 | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | * | |
| 22 | */ | |
| 9369 | 23 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
24 | #include "internal.h" |
| 2681 | 25 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
26 | #include "account.h" |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
27 | #include "accountopt.h" |
| 6760 | 28 | #include "blist.h" |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
29 | #include "cipher.h" |
| 10119 | 30 | #include "cmds.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
31 | #include "debug.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
32 | #include "notify.h" |
| 6760 | 33 | #include "privacy.h" |
| 2681 | 34 | #include "prpl.h" |
| 35 | #include "proxy.h" | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
36 | #include "request.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
37 | #include "server.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
38 | #include "util.h" |
| 9943 | 39 | #include "version.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
40 | |
| 6513 | 41 | #include "yahoo.h" |
| 10392 | 42 | #include "yahoo_packet.h" |
| 9278 | 43 | #include "yahoo_friend.h" |
| 6729 | 44 | #include "yahoochat.h" |
| 9376 | 45 | #include "ycht.h" |
| 8349 | 46 | #include "yahoo_auth.h" |
| 7651 | 47 | #include "yahoo_filexfer.h" |
| 9306 | 48 | #include "yahoo_picture.h" |
| 2681 | 49 | |
| 5583 | 50 | extern char *yahoo_crypt(const char *, const char *); |
|
2795
b2e15894ab75
[gaim-migrate @ 2808]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2786
diff
changeset
|
51 | |
|
5493
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
52 | /* #define YAHOO_DEBUG */ |
| 2681 | 53 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
54 | static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *, GaimGroup *); |
| 9410 | 55 | static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len); |
| 9306 | 56 | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
57 | static void |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
58 | yahoo_add_permit(GaimConnection *gc, const char *who) |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
59 | { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
60 | gaim_debug_info("yahoo", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
61 | "Permitting ID %s local contact rights for account %s\n", who, gc->account); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
62 | gaim_privacy_permit_add(gc->account,who,TRUE); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
63 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
64 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
65 | static void |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
66 | yahoo_rem_permit(GaimConnection *gc, const char *who) |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
67 | { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
68 | gaim_debug_info("yahoo", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
69 | "Denying ID %s local contact rights for account %s\n", who, gc->account); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
70 | gaim_privacy_permit_remove(gc->account,who,TRUE); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
71 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
72 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
73 | gboolean yahoo_privacy_check(GaimConnection *gc, const char *who) |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
74 | { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
75 | /* returns TRUE if allowed through, FALSE otherwise */ |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
76 | GSList *list; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
77 | gboolean permitted=FALSE; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
78 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
79 | switch (gc->account->perm_deny) { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
80 | case GAIM_PRIVACY_ALLOW_ALL: |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
81 | permitted = TRUE; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
82 | break; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
83 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
84 | case GAIM_PRIVACY_DENY_ALL: |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
85 | gaim_debug_info("yahoo", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
86 | "%s blocked data received from %s (GAIM_PRIVACY_DENY_ALL)\n", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
87 | gc->account->username,who); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
88 | break; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
89 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
90 | case GAIM_PRIVACY_ALLOW_USERS: |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
91 | for( list=gc->account->permit; list!=NULL; list=list->next ) { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
92 | if ( !gaim_utf8_strcasecmp(who, gaim_normalize(gc->account, |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
93 | (char *)list->data)) ) { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
94 | permitted=TRUE; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
95 | gaim_debug_info("yahoo", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
96 | "%s allowed data received from %s (GAIM_PRIVACY_ALLOW_USERS)\n", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
97 | gc->account->username,who); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
98 | break; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
99 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
100 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
101 | break; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
102 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
103 | case GAIM_PRIVACY_DENY_USERS: |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
104 | /* seeing we're letting everyone through, except the deny list*/ |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
105 | permitted=TRUE; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
106 | for( list=gc->account->deny; list!=NULL; list=list->next ) { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
107 | if ( !gaim_utf8_strcasecmp(who, gaim_normalize( gc->account, |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
108 | (char *)list->data )) ) { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
109 | permitted=FALSE; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
110 | gaim_debug_info("yahoo", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
111 | "%s blocked data received from %s (GAIM_PRIVACY_DENY_USERS)\n", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
112 | gc->account->username,who); |
|
10963
8011e6bc10b5
[gaim-migrate @ 12768]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10944
diff
changeset
|
113 | break; |
|
8011e6bc10b5
[gaim-migrate @ 12768]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10944
diff
changeset
|
114 | } |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
115 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
116 | break; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
117 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
118 | case GAIM_PRIVACY_ALLOW_BUDDYLIST: |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
119 | if ( gaim_find_buddy(gc->account,who) != NULL ) { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
120 | permitted = TRUE; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
121 | } else { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
122 | gaim_debug_info("yahoo", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
123 | "%s blocked data received from %s (GAIM_PRIVACY_ALLOW_BUDDYLIST)\n", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
124 | gc->account->username,who); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
125 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
126 | break; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
127 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
128 | default: |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
129 | gaim_debug_warning("yahoo", "Privacy setting was unknown. If you can " |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
130 | "reproduce this, please file a bug report.\n"); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
131 | permitted = FALSE; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
132 | break; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
133 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
134 | |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
135 | return permitted; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
136 | } |
| 6784 | 137 | |
| 9278 | 138 | static void yahoo_update_status(GaimConnection *gc, const char *name, YahooFriend *f) |
| 6784 | 139 | { |
|
9927
7ae7d2accb3e
[gaim-migrate @ 10819]
Daniel Atallah <datallah@pidgin.im>
parents:
9917
diff
changeset
|
140 | gboolean online = TRUE; |
| 9983 | 141 | char *status = NULL; |
| 6840 | 142 | |
| 6784 | 143 | if (!gc || !name || !f || !gaim_find_buddy(gaim_connection_get_account(gc), name)) |
| 144 | return; | |
| 145 | ||
| 6840 | 146 | if (f->status == YAHOO_STATUS_OFFLINE) |
|
9927
7ae7d2accb3e
[gaim-migrate @ 10819]
Daniel Atallah <datallah@pidgin.im>
parents:
9917
diff
changeset
|
147 | online = FALSE; |
| 6840 | 148 | |
| 9983 | 149 | switch (f->status) { |
| 150 | case YAHOO_STATUS_AVAILABLE: | |
| 10373 | 151 | status = YAHOO_STATUS_TYPE_AVAILABLE; |
| 9983 | 152 | break; |
| 153 | case YAHOO_STATUS_BRB: | |
| 10373 | 154 | status = YAHOO_STATUS_TYPE_BRB; |
| 9983 | 155 | break; |
| 156 | case YAHOO_STATUS_BUSY: | |
| 10373 | 157 | status = YAHOO_STATUS_TYPE_BUSY; |
| 9983 | 158 | break; |
| 159 | case YAHOO_STATUS_NOTATHOME: | |
| 10373 | 160 | status = YAHOO_STATUS_TYPE_NOTATHOME; |
| 9983 | 161 | break; |
| 162 | case YAHOO_STATUS_NOTATDESK: | |
| 10373 | 163 | status = YAHOO_STATUS_TYPE_NOTATDESK; |
| 9983 | 164 | break; |
| 165 | case YAHOO_STATUS_NOTINOFFICE: | |
| 10373 | 166 | status = YAHOO_STATUS_TYPE_NOTINOFFICE; |
| 9983 | 167 | break; |
| 168 | case YAHOO_STATUS_ONPHONE: | |
| 10373 | 169 | status = YAHOO_STATUS_TYPE_ONPHONE; |
| 9983 | 170 | break; |
| 171 | case YAHOO_STATUS_ONVACATION: | |
| 10373 | 172 | status = YAHOO_STATUS_TYPE_ONVACATION; |
| 9983 | 173 | break; |
| 174 | case YAHOO_STATUS_OUTTOLUNCH: | |
| 10373 | 175 | status = YAHOO_STATUS_TYPE_OUTTOLUNCH; |
| 9983 | 176 | break; |
| 177 | case YAHOO_STATUS_STEPPEDOUT: | |
| 10373 | 178 | status = YAHOO_STATUS_TYPE_STEPPEDOUT; |
| 9983 | 179 | break; |
| 180 | case YAHOO_STATUS_INVISIBLE: /* this should never happen? */ | |
| 10373 | 181 | status = YAHOO_STATUS_TYPE_INVISIBLE; |
| 9983 | 182 | break; |
| 183 | case YAHOO_STATUS_CUSTOM: | |
| 184 | if (!f->away) | |
| 10373 | 185 | status = YAHOO_STATUS_TYPE_AVAILABLE_WM; |
| 9983 | 186 | else |
| 10373 | 187 | status = YAHOO_STATUS_TYPE_AWAY; |
| 9983 | 188 | break; |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
189 | case YAHOO_STATUS_IDLE: |
| 9983 | 190 | break; |
| 191 | default: | |
| 192 | gaim_debug_warning("yahoo", "Warning, unknown status %d\n", f->status); | |
| 193 | break; | |
| 194 | } | |
| 195 | ||
| 196 | if (status) { | |
| 197 | if (f->status == YAHOO_STATUS_CUSTOM) | |
| 198 | gaim_prpl_got_user_status(gaim_connection_get_account(gc), name, status, "message", | |
| 199 | yahoo_friend_get_status_message(f), NULL); | |
| 200 | else | |
| 201 | gaim_prpl_got_user_status(gaim_connection_get_account(gc), name, status, NULL); | |
| 202 | } | |
| 203 | ||
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
204 | if (f->idle != 0) |
|
10746
5a1ded2c0417
[gaim-migrate @ 12348]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
205 | gaim_prpl_got_user_idle(gaim_connection_get_account(gc), name, TRUE, f->idle); |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
206 | else |
|
10746
5a1ded2c0417
[gaim-migrate @ 12348]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
207 | gaim_prpl_got_user_idle(gaim_connection_get_account(gc), name, FALSE, 0); |
| 6784 | 208 | } |
| 209 | ||
| 5583 | 210 | static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 211 | { |
| 9983 | 212 | GaimAccount *account = gaim_connection_get_account(gc); |
| 2681 | 213 | struct yahoo_data *yd = gc->proto_data; |
| 214 | GSList *l = pkt->hash; | |
| 9278 | 215 | YahooFriend *f = NULL; |
| 2681 | 216 | char *name = NULL; |
| 6784 | 217 | |
| 7892 | 218 | if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) { |
| 8383 | 219 | gc->wants_to_die = TRUE; |
|
10746
5a1ded2c0417
[gaim-migrate @ 12348]
Mark Doliner <markdoliner@pidgin.im>
parents:
10740
diff
changeset
|
220 | gaim_connection_error(gc, _("You have signed on from another location.")); |
| 7892 | 221 | return; |
| 222 | } | |
| 6686 | 223 | |
| 2681 | 224 | while (l) { |
| 225 | struct yahoo_pair *pair = l->data; | |
| 226 | ||
| 227 | switch (pair->key) { | |
| 228 | case 0: /* we won't actually do anything with this */ | |
| 229 | break; | |
| 230 | case 1: /* we don't get the full buddy list here. */ | |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
231 | if (!yd->logged_in) { |
| 7664 | 232 | gaim_connection_set_display_name(gc, pair->value); |
| 5583 | 233 | gaim_connection_set_state(gc, GAIM_CONNECTED); |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
234 | yd->logged_in = TRUE; |
| 9306 | 235 | if (yd->picture_upload_todo) { |
| 236 | yahoo_buddy_icon_upload(gc, yd->picture_upload_todo); | |
| 237 | yd->picture_upload_todo = NULL; | |
| 238 | } | |
| 2681 | 239 | |
| 3147 | 240 | /* this requests the list. i have a feeling that this is very evil |
| 241 | * | |
| 6686 | 242 | * scs.yahoo.com sends you the list before this packet without it being |
| 3147 | 243 | * requested |
| 244 | * | |
| 245 | * do_import(gc, NULL); | |
| 246 | * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0); | |
| 10392 | 247 | * yahoo_packet_send_and_free(newpkt, yd); |
| 3147 | 248 | */ |
| 249 | ||
| 250 | } | |
| 2681 | 251 | break; |
| 252 | case 8: /* how many online buddies we have */ | |
| 253 | break; | |
| 254 | case 7: /* the current buddy */ | |
| 10553 | 255 | if (name && f) /* update the previous buddy before changing the variables */ |
| 256 | yahoo_update_status(gc, name, f); | |
| 2681 | 257 | name = pair->value; |
| 9886 | 258 | if (name && g_utf8_validate(name, -1, NULL)) |
| 259 | f = yahoo_friend_find_or_new(gc, name); | |
| 9888 | 260 | else { |
| 261 | f = NULL; | |
| 262 | name = NULL; | |
| 263 | } | |
| 2681 | 264 | break; |
| 265 | case 10: /* state */ | |
| 6784 | 266 | if (!f) |
| 267 | break; | |
| 268 | ||
| 269 | f->status = strtol(pair->value, NULL, 10); | |
| 270 | if ((f->status >= YAHOO_STATUS_BRB) && (f->status <= YAHOO_STATUS_STEPPEDOUT)) | |
| 271 | f->away = 1; | |
| 272 | else | |
| 273 | f->away = 0; | |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
274 | |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
275 | if (f->status == YAHOO_STATUS_IDLE) { |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
276 | /* Idle may have already been set in a more precise way in case 137 */ |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
277 | if (f->idle == 0) |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
278 | f->idle = time(NULL); |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
279 | } else |
| 6804 | 280 | f->idle = 0; |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
281 | |
| 9283 | 282 | if (f->status != YAHOO_STATUS_CUSTOM) |
| 283 | yahoo_friend_set_status_message(f, NULL); | |
| 6847 | 284 | |
| 285 | f->sms = 0; | |
| 2681 | 286 | break; |
| 287 | case 19: /* custom message */ | |
| 9283 | 288 | if (f) |
| 289 | yahoo_friend_set_status_message(f, yahoo_string_decode(gc, pair->value, FALSE)); | |
| 2681 | 290 | break; |
| 6686 | 291 | case 11: /* this is the buddy's session id */ |
| 2681 | 292 | break; |
| 293 | case 17: /* in chat? */ | |
| 294 | break; | |
| 6784 | 295 | case 47: /* is custom status away or not? 2=idle*/ |
| 296 | if (!f) | |
| 297 | break; | |
| 8441 | 298 | |
| 299 | /* I have no idea what it means when this is | |
| 300 | * set when someone's available, but it doesn't | |
| 301 | * mean idle. */ | |
| 302 | if (f->status == YAHOO_STATUS_AVAILABLE) | |
| 303 | break; | |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
304 | |
| 6784 | 305 | f->away = strtol(pair->value, NULL, 10); |
|
10141
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
306 | if (f->away == 2) { |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
307 | /* Idle may have already been set in a more precise way in case 137 */ |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
308 | if (f->idle == 0) |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
309 | f->idle = time(NULL); |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
310 | } |
|
3db22fc14161
[gaim-migrate @ 11212]
Evan Schoenberg <evands@pidgin.im>
parents:
10126
diff
changeset
|
311 | |
| 6686 | 312 | break; |
| 6784 | 313 | case 138: /* either we're not idle, or we are but won't say how long */ |
| 314 | if (!f) | |
| 315 | break; | |
| 316 | ||
| 317 | if (f->idle) | |
| 318 | f->idle = -1; | |
| 319 | break; | |
| 320 | case 137: /* usually idle time in seconds, sometimes login time */ | |
| 321 | if (!f) | |
| 322 | break; | |
| 323 | ||
| 324 | if (f->status != YAHOO_STATUS_AVAILABLE) | |
| 325 | f->idle = time(NULL) - strtol(pair->value, NULL, 10); | |
| 6686 | 326 | break; |
| 327 | case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */ | |
| 6784 | 328 | if (strtol(pair->value, NULL, 10) == 0) { |
| 329 | if (f) | |
| 330 | f->status = YAHOO_STATUS_OFFLINE; | |
| 9983 | 331 | gaim_prpl_got_user_status(account, name, "offline", NULL); |
|
2807
fe1ea0453890
[gaim-migrate @ 2820]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2805
diff
changeset
|
332 | break; |
|
2805
31c7645db097
[gaim-migrate @ 2818]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2795
diff
changeset
|
333 | } |
| 6784 | 334 | break; |
| 335 | case 60: /* SMS */ | |
| 336 | if (f) { | |
| 337 | f->sms = strtol(pair->value, NULL, 10); | |
| 338 | yahoo_update_status(gc, name, f); | |
|
2771
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
339 | } |
|
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
340 | break; |
| 9292 | 341 | case 197: /* Avatars */ |
| 9277 | 342 | { |
| 343 | char *decoded, *tmp; | |
| 344 | guint len; | |
| 345 | ||
| 346 | if (pair->value) { | |
| 347 | gaim_base64_decode(pair->value, &decoded, &len); | |
| 348 | if (len) { | |
| 349 | tmp = gaim_str_binary_to_ascii(decoded, len); | |
| 350 | gaim_debug_info("yahoo", "Got key 197, value = %s\n", tmp); | |
| 351 | g_free(tmp); | |
| 352 | } | |
| 353 | g_free(decoded); | |
| 354 | } | |
| 355 | break; | |
| 356 | } | |
| 9292 | 357 | case 192: /* Pictures, aka Buddy Icons, checksum */ |
| 358 | { | |
| 359 | int cksum = strtol(pair->value, NULL, 10); | |
| 360 | GaimBuddy *b; | |
| 361 | ||
| 362 | if (!name) | |
| 363 | break; | |
| 364 | ||
| 9325 | 365 | b = gaim_find_buddy(gc->account, name); |
| 366 | ||
| 9292 | 367 | if (!cksum || (cksum == -1)) { |
| 9325 | 368 | if (f) |
| 369 | yahoo_friend_set_buddy_icon_need_request(f, TRUE); | |
| 9292 | 370 | gaim_buddy_icons_set_for_user(gc->account, name, NULL, 0); |
| 9325 | 371 | if (b) |
| 372 | gaim_blist_node_remove_setting((GaimBlistNode *)b, YAHOO_ICON_CHECKSUM_KEY); | |
| 9292 | 373 | break; |
| 374 | } | |
| 375 | ||
| 376 | if (!f) | |
| 377 | break; | |
| 9325 | 378 | |
| 9292 | 379 | yahoo_friend_set_buddy_icon_need_request(f, FALSE); |
| 380 | if (cksum != gaim_blist_node_get_int((GaimBlistNode*)b, YAHOO_ICON_CHECKSUM_KEY)) | |
| 9310 | 381 | yahoo_send_picture_request(gc, name); |
| 9292 | 382 | |
| 383 | break; | |
| 384 | } | |
| 2979 | 385 | case 16: /* Custom error message */ |
| 7827 | 386 | { |
| 387 | char *tmp = yahoo_string_decode(gc, pair->value, TRUE); | |
| 388 | gaim_notify_error(gc, NULL, tmp, NULL); | |
| 389 | g_free(tmp); | |
| 390 | } | |
| 2951 | 391 | break; |
| 2681 | 392 | default: |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
393 | gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
394 | "Unknown status key %d\n", pair->key); |
| 2681 | 395 | break; |
| 396 | } | |
| 397 | ||
| 398 | l = l->next; | |
| 399 | } | |
| 10553 | 400 | |
| 401 | if (name && f) /* update the last buddy */ | |
| 402 | yahoo_update_status(gc, name, f); | |
| 2681 | 403 | } |
| 404 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
405 | static void yahoo_do_group_check(GaimAccount *account, GHashTable *ht, const char *name, const char *group) |
| 6820 | 406 | { |
| 407 | GaimBuddy *b; | |
| 408 | GaimGroup *g; | |
| 409 | GSList *list, *i; | |
| 410 | gboolean onlist = 0; | |
| 411 | char *oname = NULL; | |
| 412 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
413 | char **oname_p = &oname; |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
414 | GSList **list_p = &list; |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
415 | |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
416 | if (!g_hash_table_lookup_extended(ht, gaim_normalize(account, name), (gpointer *) oname_p, (gpointer *) list_p)) |
| 6820 | 417 | list = gaim_find_buddies(account, name); |
| 418 | else | |
| 419 | g_hash_table_steal(ht, name); | |
| 420 | ||
| 421 | for (i = list; i; i = i->next) { | |
| 422 | b = i->data; | |
| 423 | g = gaim_find_buddys_group(b); | |
| 424 | if (!gaim_utf8_strcasecmp(group, g->name)) { | |
| 425 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
| 426 | "Oh good, %s is in the right group (%s).\n", name, group); | |
| 427 | list = g_slist_delete_link(list, i); | |
| 428 | onlist = 1; | |
| 429 | break; | |
| 430 | } | |
| 431 | } | |
| 432 | ||
| 433 | if (!onlist) { | |
| 434 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", | |
| 435 | "Uhoh, %s isn't on the list (or not in this group), adding him to group %s.\n", name, group); | |
| 436 | if (!(g = gaim_find_group(group))) { | |
| 437 | g = gaim_group_new(group); | |
| 438 | gaim_blist_add_group(g, NULL); | |
| 439 | } | |
| 440 | b = gaim_buddy_new(account, name, NULL); | |
| 441 | gaim_blist_add_buddy(b, NULL, g, NULL); | |
| 442 | } | |
| 443 | ||
| 444 | if (list) { | |
| 445 | if (!oname) | |
| 7823 | 446 | oname = g_strdup(gaim_normalize(account, name)); |
| 6820 | 447 | g_hash_table_insert(ht, oname, list); |
| 448 | } else if (oname) | |
| 449 | g_free(oname); | |
| 450 | } | |
| 451 | ||
| 452 | static void yahoo_do_group_cleanup(gpointer key, gpointer value, gpointer user_data) | |
| 453 | { | |
| 454 | char *name = key; | |
| 455 | GSList *list = value, *i; | |
| 456 | GaimBuddy *b; | |
| 457 | GaimGroup *g; | |
| 458 | ||
| 459 | for (i = list; i; i = i->next) { | |
| 460 | b = i->data; | |
| 461 | g = gaim_find_buddys_group(b); | |
| 462 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", "Deleting Buddy %s from group %s.\n", name, g->name); | |
| 463 | gaim_blist_remove_buddy(b); | |
| 464 | } | |
| 465 | } | |
| 466 | ||
| 7651 | 467 | static char *_getcookie(char *rawcookie) |
| 468 | { | |
| 469 | char *cookie = NULL; | |
| 470 | char *tmpcookie; | |
| 471 | char *cookieend; | |
| 472 | ||
| 473 | if (strlen(rawcookie) < 2) | |
| 474 | return NULL; | |
| 475 | tmpcookie = g_strdup(rawcookie+2); | |
| 476 | cookieend = strchr(tmpcookie, ';'); | |
| 477 | ||
| 478 | if (cookieend) | |
| 479 | *cookieend = '\0'; | |
| 480 | ||
| 481 | cookie = g_strdup(tmpcookie); | |
| 482 | g_free(tmpcookie); | |
| 483 | ||
| 484 | return cookie; | |
| 485 | } | |
| 486 | ||
| 487 | static void yahoo_process_cookie(struct yahoo_data *yd, char *c) | |
| 488 | { | |
| 489 | if (c[0] == 'Y') { | |
| 490 | if (yd->cookie_y) | |
| 491 | g_free(yd->cookie_y); | |
| 492 | yd->cookie_y = _getcookie(c); | |
| 493 | } else if (c[0] == 'T') { | |
| 494 | if (yd->cookie_t) | |
| 495 | g_free(yd->cookie_t); | |
| 496 | yd->cookie_t = _getcookie(c); | |
| 497 | } | |
| 498 | } | |
| 499 | ||
| 5583 | 500 | static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 501 | { |
| 502 | GSList *l = pkt->hash; | |
| 503 | gboolean export = FALSE; | |
| 6760 | 504 | gboolean got_serv_list = FALSE; |
| 6695 | 505 | GaimBuddy *b; |
| 506 | GaimGroup *g; | |
| 9278 | 507 | YahooFriend *f = NULL; |
| 6820 | 508 | GaimAccount *account = gaim_connection_get_account(gc); |
| 6784 | 509 | struct yahoo_data *yd = gc->proto_data; |
| 6820 | 510 | GHashTable *ht; |
| 6784 | 511 | |
| 512 | char **lines; | |
| 513 | char **split; | |
| 514 | char **buddies; | |
| 7823 | 515 | char **tmp, **bud, *norm_bud; |
| 7827 | 516 | char *grp = NULL; |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
517 | char *perm_stealth_buddies = NULL; |
| 2681 | 518 | |
| 7651 | 519 | if (pkt->id) |
| 520 | yd->session_id = pkt->id; | |
| 521 | ||
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
522 | while (l) { |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
523 | struct yahoo_pair *pair = l->data; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
524 | l = l->next; |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
525 | |
| 6760 | 526 | switch (pair->key) { |
| 527 | case 87: | |
| 6784 | 528 | if (!yd->tmp_serv_blist) |
| 529 | yd->tmp_serv_blist = g_string_new(pair->value); | |
| 530 | else | |
| 531 | g_string_append(yd->tmp_serv_blist, pair->value); | |
| 6760 | 532 | break; |
| 533 | case 88: | |
| 6784 | 534 | if (!yd->tmp_serv_ilist) |
| 535 | yd->tmp_serv_ilist = g_string_new(pair->value); | |
| 536 | else | |
| 537 | g_string_append(yd->tmp_serv_ilist, pair->value); | |
| 6760 | 538 | break; |
| 7651 | 539 | case 59: /* cookies, yum */ |
| 540 | yahoo_process_cookie(yd, pair->value); | |
| 541 | break; | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
542 | case YAHOO_SERVICE_STEALTH_PERM: |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
543 | perm_stealth_buddies = pair->value; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
544 | break; |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
545 | } |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
546 | } |
| 2681 | 547 | |
| 6784 | 548 | if (pkt->status != 0) |
| 549 | return; | |
| 550 | ||
| 551 | if (yd->tmp_serv_blist) { | |
| 6820 | 552 | ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free); |
| 553 | ||
| 6784 | 554 | lines = g_strsplit(yd->tmp_serv_blist->str, "\n", -1); |
| 555 | for (tmp = lines; *tmp; tmp++) { | |
| 556 | split = g_strsplit(*tmp, ":", 2); | |
| 557 | if (!split) | |
| 558 | continue; | |
| 559 | if (!split[0] || !split[1]) { | |
| 560 | g_strfreev(split); | |
| 561 | continue; | |
| 562 | } | |
| 7827 | 563 | grp = yahoo_string_decode(gc, split[0], FALSE); |
| 6784 | 564 | buddies = g_strsplit(split[1], ",", -1); |
| 565 | for (bud = buddies; bud && *bud; bud++) { | |
| 7823 | 566 | norm_bud = g_strdup(gaim_normalize(account, *bud)); |
| 9279 | 567 | f = yahoo_friend_find_or_new(gc, norm_bud); |
| 568 | ||
| 7827 | 569 | if (!(b = gaim_find_buddy(account, norm_bud))) { |
| 570 | if (!(g = gaim_find_group(grp))) { | |
| 571 | g = gaim_group_new(grp); | |
| 6784 | 572 | gaim_blist_add_group(g, NULL); |
| 573 | } | |
| 7823 | 574 | b = gaim_buddy_new(account, norm_bud, NULL); |
| 6784 | 575 | gaim_blist_add_buddy(b, NULL, g, NULL); |
| 576 | export = TRUE; | |
| 6820 | 577 | } |
| 6784 | 578 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
579 | yahoo_do_group_check(account, ht, norm_bud, grp); |
| 7823 | 580 | g_free(norm_bud); |
| 6784 | 581 | } |
| 582 | g_strfreev(buddies); | |
| 583 | g_strfreev(split); | |
| 7827 | 584 | g_free(grp); |
| 6784 | 585 | } |
| 586 | g_strfreev(lines); | |
| 587 | ||
| 588 | g_string_free(yd->tmp_serv_blist, TRUE); | |
| 589 | yd->tmp_serv_blist = NULL; | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
590 | g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL); |
| 6820 | 591 | g_hash_table_destroy(ht); |
| 6784 | 592 | } |
| 593 | ||
| 594 | ||
| 595 | if (yd->tmp_serv_ilist) { | |
| 596 | buddies = g_strsplit(yd->tmp_serv_ilist->str, ",", -1); | |
| 597 | for (bud = buddies; bud && *bud; bud++) { | |
| 598 | /* The server is already ignoring the user */ | |
| 599 | got_serv_list = TRUE; | |
| 600 | gaim_privacy_deny_add(gc->account, *bud, 1); | |
| 601 | } | |
| 602 | g_strfreev(buddies); | |
| 603 | ||
| 604 | g_string_free(yd->tmp_serv_ilist, TRUE); | |
| 605 | yd->tmp_serv_ilist = NULL; | |
| 606 | } | |
| 607 | ||
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
608 | if (got_serv_list && |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
609 | ((gc->account->perm_deny != GAIM_PRIVACY_ALLOW_BUDDYLIST) && |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
610 | (gc->account->perm_deny != GAIM_PRIVACY_DENY_ALL) && |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
611 | (gc->account->perm_deny != GAIM_PRIVACY_ALLOW_USERS))) |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
612 | { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
613 | gc->account->perm_deny = GAIM_PRIVACY_DENY_USERS; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
614 | gaim_debug_info("yahoo", "Privacy defaulting to GAIM_PRIVACY_DENY_USERS.\n", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
615 | gc->account->username); |
| 6784 | 616 | } |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
617 | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
618 | if (perm_stealth_buddies) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
619 | buddies = g_strsplit(perm_stealth_buddies, ",", -1); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
620 | for (bud = buddies; bud && *bud; bud++) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
621 | f = yahoo_friend_find(gc, *bud); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
622 | if (f) |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
623 | f->stealth = YAHOO_STEALTH_PERM_OFFLINE; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
624 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
625 | g_strfreev(buddies); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
626 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
627 | } |
| 2681 | 628 | } |
| 629 | ||
| 5583 | 630 | static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2993 | 631 | { |
| 632 | char *msg = NULL; | |
| 633 | char *from = NULL; | |
| 3019 | 634 | char *stat = NULL; |
| 635 | char *game = NULL; | |
| 9278 | 636 | YahooFriend *f = NULL; |
| 2993 | 637 | GSList *l = pkt->hash; |
| 6784 | 638 | |
| 2993 | 639 | while (l) { |
| 640 | struct yahoo_pair *pair = l->data; | |
| 641 | if (pair->key == 4) | |
| 642 | from = pair->value; | |
| 643 | if (pair->key == 49) | |
| 644 | msg = pair->value; | |
| 3001 | 645 | if (pair->key == 13) |
| 3019 | 646 | stat = pair->value; |
| 647 | if (pair->key == 14) | |
| 648 | game = pair->value; | |
| 2993 | 649 | l = l->next; |
| 650 | } | |
| 3640 | 651 | |
| 6784 | 652 | if (!from || !msg) |
| 3640 | 653 | return; |
| 6686 | 654 | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
655 | if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING")) |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
656 | && (yahoo_privacy_check(gc, from))) { |
| 3019 | 657 | if (*stat == '1') |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
658 | serv_got_typing(gc, from, 0, GAIM_TYPING); |
| 3019 | 659 | else |
| 660 | serv_got_typing_stopped(gc, from); | |
| 4793 | 661 | } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) { |
| 6695 | 662 | GaimBuddy *bud = gaim_find_buddy(gc->account, from); |
| 6784 | 663 | |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
664 | if (!bud) { |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
665 | gaim_debug(GAIM_DEBUG_WARNING, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
666 | "%s is playing a game, and doesn't want " |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
667 | "you to know.\n", from); |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
668 | } |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
669 | |
| 9279 | 670 | f = yahoo_friend_find(gc, from); |
| 6784 | 671 | if (!f) |
| 672 | return; /* if they're not on the list, don't bother */ | |
| 673 | ||
| 9283 | 674 | yahoo_friend_set_game(f, NULL); |
| 6784 | 675 | |
| 3019 | 676 | if (*stat == '1') { |
| 9283 | 677 | yahoo_friend_set_game(f, game); |
| 3020 | 678 | if (bud) |
| 6784 | 679 | yahoo_update_status(gc, from, f); |
| 3019 | 680 | } |
| 681 | } | |
| 2993 | 682 | } |
| 683 | ||
| 7827 | 684 | |
| 685 | struct _yahoo_im { | |
| 686 | char *from; | |
| 687 | int time; | |
| 688 | int utf8; | |
| 9284 | 689 | int buddy_icon; |
| 7827 | 690 | char *msg; |
| 691 | }; | |
| 692 | ||
| 5583 | 693 | static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 694 | { |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
695 | GSList *l = pkt->hash; |
| 7827 | 696 | GSList *list = NULL; |
| 697 | struct _yahoo_im *im = NULL; | |
| 6069 | 698 | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
699 | if (pkt->status <= 1 || pkt->status == 5) { |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
700 | while (l) { |
|
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
701 | struct yahoo_pair *pair = l->data; |
| 7827 | 702 | if (pair->key == 4) { |
| 703 | im = g_new0(struct _yahoo_im, 1); | |
| 704 | list = g_slist_append(list, im); | |
| 705 | im->from = pair->value; | |
| 706 | im->time = time(NULL); | |
| 707 | } | |
| 708 | if (pair->key == 97) | |
| 709 | if (im) | |
| 710 | im->utf8 = strtol(pair->value, NULL, 10); | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
711 | if (pair->key == 15) |
| 7827 | 712 | if (im) |
| 713 | im->time = strtol(pair->value, NULL, 10); | |
| 9284 | 714 | if (pair->key == 206) |
| 715 | if (im) | |
| 716 | im->buddy_icon = strtol(pair->value, NULL, 10); | |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
717 | if (pair->key == 14) { |
| 7827 | 718 | if (im) |
| 719 | im->msg = pair->value; | |
| 6687 | 720 | } |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
721 | l = l->next; |
| 6687 | 722 | } |
| 2681 | 723 | } else if (pkt->status == 2) { |
|
5436
a0e0bacaa196
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5367
diff
changeset
|
724 | gaim_notify_error(gc, NULL, |
|
10386
6fcc45a26a16
[gaim-migrate @ 11612]
Daniel Atallah <datallah@pidgin.im>
parents:
10379
diff
changeset
|
725 | _("Your Yahoo! message did not get sent."), NULL); |
| 2681 | 726 | } |
| 7827 | 727 | |
| 728 | for (l = list; l; l = l->next) { | |
| 9306 | 729 | YahooFriend *f; |
| 7827 | 730 | char *m, *m2; |
| 731 | im = l->data; | |
| 732 | ||
| 733 | if (!im->from || !im->msg) { | |
| 734 | g_free(im); | |
| 735 | continue; | |
| 736 | } | |
| 737 | ||
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
738 | if (!yahoo_privacy_check(gc, im->from)) { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
739 | gaim_debug_info("yahoo", "Message from %s dropped.\n", im->from); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
740 | return; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
741 | } |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
742 | |
| 7827 | 743 | m = yahoo_string_decode(gc, im->msg, im->utf8); |
| 744 | gaim_str_strip_cr(m); | |
| 8375 | 745 | |
| 746 | if (!strcmp(m, "<ding>")) { | |
| 747 | GaimConversation *c = gaim_conversation_new(GAIM_CONV_IM, | |
| 748 | gaim_connection_get_account(gc), im->from); | |
| 749 | gaim_conv_im_write(GAIM_CONV_IM(c), "", _("Buzz!!"), GAIM_MESSAGE_NICK|GAIM_MESSAGE_RECV, | |
| 750 | im->time); | |
| 751 | g_free(m); | |
| 752 | g_free(im); | |
| 753 | continue; | |
| 754 | } | |
| 755 | ||
| 7827 | 756 | m2 = yahoo_codes_to_html(m); |
| 757 | g_free(m); | |
| 758 | serv_got_im(gc, im->from, m2, 0, im->time); | |
| 759 | g_free(m2); | |
| 9284 | 760 | |
| 761 | if ((f = yahoo_friend_find(gc, im->from)) && im->buddy_icon == 2) { | |
| 762 | if (yahoo_friend_get_buddy_icon_need_request(f)) { | |
| 9310 | 763 | yahoo_send_picture_request(gc, im->from); |
| 9284 | 764 | yahoo_friend_set_buddy_icon_need_request(f, FALSE); |
| 765 | } | |
| 766 | } | |
| 767 | ||
| 7827 | 768 | g_free(im); |
| 769 | } | |
| 770 | g_slist_free(list); | |
| 2681 | 771 | } |
| 772 | ||
| 7865 | 773 | static void yahoo_process_sysmessage(GaimConnection *gc, struct yahoo_packet *pkt) |
| 774 | { | |
| 775 | GSList *l = pkt->hash; | |
| 10070 | 776 | char *prim, *me = NULL, *msg = NULL, *escmsg = NULL; |
| 7865 | 777 | |
| 778 | while (l) { | |
| 779 | struct yahoo_pair *pair = l->data; | |
| 780 | ||
| 781 | if (pair->key == 5) | |
| 782 | me = pair->value; | |
| 783 | if (pair->key == 14) | |
| 784 | msg = pair->value; | |
| 785 | ||
| 786 | l = l->next; | |
| 787 | } | |
| 788 | ||
| 10070 | 789 | if (!msg || !g_utf8_validate(msg, -1, NULL)) |
| 7865 | 790 | return; |
| 791 | ||
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10687
diff
changeset
|
792 | escmsg = g_markup_escape_text(msg, -1); |
| 10070 | 793 | |
| 7865 | 794 | prim = g_strdup_printf(_("Yahoo! system message for %s:"), |
| 795 | me?me:gaim_connection_get_display_name(gc)); | |
| 10070 | 796 | gaim_notify_info(NULL, NULL, prim, escmsg); |
| 7865 | 797 | g_free(prim); |
| 10070 | 798 | g_free(escmsg); |
| 7865 | 799 | } |
| 800 | ||
| 6686 | 801 | static void yahoo_buddy_added_us(GaimConnection *gc, struct yahoo_packet *pkt) { |
| 2681 | 802 | char *id = NULL; |
| 803 | char *who = NULL; | |
| 7827 | 804 | char *msg = NULL, *tmpmsg = NULL; |
| 2681 | 805 | GSList *l = pkt->hash; |
| 806 | ||
| 807 | while (l) { | |
| 808 | struct yahoo_pair *pair = l->data; | |
| 6686 | 809 | |
| 810 | switch (pair->key) { | |
| 811 | case 1: | |
| 2681 | 812 | id = pair->value; |
| 6686 | 813 | break; |
| 814 | case 3: | |
| 2681 | 815 | who = pair->value; |
| 6686 | 816 | break; |
| 817 | case 15: /* time, for when they add us and we're offline */ | |
| 818 | break; | |
| 819 | case 14: | |
| 2681 | 820 | msg = pair->value; |
| 6686 | 821 | break; |
| 822 | } | |
| 2681 | 823 | l = l->next; |
| 824 | } | |
| 825 | ||
| 7827 | 826 | if (id) { |
| 827 | if (msg) | |
| 828 | tmpmsg = yahoo_string_decode(gc, msg, FALSE); | |
| 829 | gaim_account_notify_added(gc->account, id, who, NULL, tmpmsg); | |
| 830 | if (tmpmsg) | |
| 831 | g_free(tmpmsg); | |
| 832 | } | |
| 6686 | 833 | } |
| 834 | ||
| 835 | static void yahoo_buddy_denied_our_add(GaimConnection *gc, struct yahoo_packet *pkt) | |
| 836 | { | |
| 837 | char *who = NULL; | |
| 838 | char *msg = NULL; | |
| 839 | GSList *l = pkt->hash; | |
| 840 | GString *buf = NULL; | |
| 6784 | 841 | struct yahoo_data *yd = gc->proto_data; |
| 6686 | 842 | |
| 843 | while (l) { | |
| 844 | struct yahoo_pair *pair = l->data; | |
| 845 | ||
| 846 | switch (pair->key) { | |
| 847 | case 3: | |
| 848 | who = pair->value; | |
| 849 | break; | |
| 850 | case 14: | |
| 851 | msg = pair->value; | |
| 852 | break; | |
| 853 | } | |
| 854 | l = l->next; | |
| 855 | } | |
| 856 | ||
| 857 | if (who) { | |
| 7827 | 858 | char *msg2; |
| 6686 | 859 | buf = g_string_sized_new(0); |
| 7827 | 860 | if (!msg) { |
| 6686 | 861 | g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list."), who); |
| 7827 | 862 | } else { |
| 863 | msg2 = yahoo_string_decode(gc, msg, FALSE); | |
| 864 | g_string_printf(buf, _("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg2); | |
| 865 | g_free(msg2); | |
| 866 | } | |
| 6840 | 867 | gaim_notify_info(gc, NULL, _("Add buddy rejected"), buf->str); |
| 6686 | 868 | g_string_free(buf, TRUE); |
| 6784 | 869 | g_hash_table_remove(yd->friends, who); |
| 9983 | 870 | gaim_prpl_got_user_status(gaim_connection_get_account(gc), who, "offline", NULL); /* FIXME: make this set not on list status instead */ |
| 6686 | 871 | } |
| 872 | } | |
| 873 | ||
| 874 | static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt) | |
| 875 | { | |
| 876 | ||
| 877 | ||
| 878 | switch (pkt->status) { | |
| 879 | case 1: | |
| 880 | yahoo_process_status(gc, pkt); | |
| 881 | return; | |
| 882 | case 3: | |
| 883 | yahoo_buddy_added_us(gc, pkt); | |
| 884 | break; | |
| 885 | case 7: | |
| 886 | yahoo_buddy_denied_our_add(gc, pkt); | |
| 887 | break; | |
| 888 | default: | |
| 889 | break; | |
|
2683
06507dfdd96c
[gaim-migrate @ 2696]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2682
diff
changeset
|
890 | } |
| 2681 | 891 | } |
| 892 | ||
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
893 | #define OUT_CHARSET "utf-8" |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
894 | |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
895 | static char *yahoo_decode(const char *text) |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
896 | { |
| 9221 | 897 | char *converted = NULL; |
| 8125 | 898 | char *n, *new; |
| 899 | const char *end, *p; | |
| 8616 | 900 | int i, k; |
| 8125 | 901 | |
| 7771 | 902 | n = new = g_malloc(strlen (text) + 1); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
903 | end = text + strlen(text); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
904 | |
| 8125 | 905 | for (p = text; p < end; p++, n++) { |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
906 | if (*p == '\\') { |
| 9064 | 907 | if (p[1] >= '0' && p[1] <= '7') { |
| 908 | p += 1; | |
| 909 | for (i = 0, k = 0; k < 3; k += 1) { | |
| 910 | char c = p[k]; | |
| 9065 | 911 | if (c < '0' || c > '7') break; |
| 9064 | 912 | i *= 8; |
| 913 | i += c - '0'; | |
| 914 | } | |
| 915 | *n = i; | |
| 916 | p += k - 1; | |
| 917 | } else { /* bug 959248 */ | |
| 918 | /* If we see a \ not followed by an octal number, | |
| 919 | * it means that it is actually a \\ with one \ | |
| 920 | * already eaten by some unknown function. | |
| 921 | * This is arguably broken. | |
| 922 | * | |
| 923 | * I think wing is wrong here, there is no function | |
| 924 | * called that I see that could have done it. I guess | |
| 925 | * it is just really sending single \'s. That's yahoo | |
| 926 | * for you. | |
| 927 | */ | |
| 928 | *n = *p; | |
| 929 | } | |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
930 | } |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
931 | else |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
932 | *n = *p; |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
933 | } |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
934 | |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
935 | *n = '\0'; |
| 8125 | 936 | |
| 9221 | 937 | if (strstr(text, "\033$B")) |
| 938 | converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL); | |
| 939 | if (!converted) | |
| 940 | converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL); | |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
941 | g_free(new); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
942 | |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
943 | return converted; |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
944 | } |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
945 | |
| 5583 | 946 | static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 947 | { |
| 5583 | 948 | GaimAccount *account = gaim_connection_get_account(gc); |
| 9221 | 949 | struct yahoo_data *yd = gc->proto_data; |
| 2681 | 950 | char *who = NULL; |
| 951 | char *email = NULL; | |
| 952 | char *subj = NULL; | |
| 9221 | 953 | char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL); |
| 2681 | 954 | int count = 0; |
| 955 | GSList *l = pkt->hash; | |
| 956 | ||
| 5583 | 957 | if (!gaim_account_get_check_mail(account)) |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
958 | return; |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
959 | |
| 2681 | 960 | while (l) { |
| 961 | struct yahoo_pair *pair = l->data; | |
| 962 | if (pair->key == 9) | |
| 963 | count = strtol(pair->value, NULL, 10); | |
| 964 | else if (pair->key == 43) | |
| 965 | who = pair->value; | |
| 966 | else if (pair->key == 42) | |
| 967 | email = pair->value; | |
| 968 | else if (pair->key == 18) | |
| 969 | subj = pair->value; | |
| 970 | l = l->next; | |
| 971 | } | |
| 972 | ||
| 4001 | 973 | if (who && subj && email && *email) { |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
974 | char *dec_who = yahoo_decode(who); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
975 | char *dec_subj = yahoo_decode(subj); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
976 | char *from = g_strdup_printf("%s (%s)", dec_who, email); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
977 | |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
978 | gaim_notify_email(gc, dec_subj, from, gaim_account_get_username(account), |
| 9221 | 979 | yahoo_mail_url, NULL, NULL); |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
980 | |
|
7747
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
981 | g_free(dec_who); |
|
ce63da454857
[gaim-migrate @ 8392]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
7696
diff
changeset
|
982 | g_free(dec_subj); |
| 2850 | 983 | g_free(from); |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
984 | } else if (count > 0) { |
| 5583 | 985 | const char *to = gaim_account_get_username(account); |
| 9221 | 986 | const char *url = yahoo_mail_url; |
|
5521
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
987 | |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
988 | gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url, |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
989 | NULL, NULL); |
|
fca5b7c1340d
[gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents:
5498
diff
changeset
|
990 | } |
| 2681 | 991 | } |
| 3147 | 992 | /* This is the y64 alphabet... it's like base64, but has a . and a _ */ |
| 993 | char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._"; | |
| 994 | ||
| 995 | /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function | |
| 996 | * in util.c, but it has a bug I don't feel like finding right now ;) */ | |
| 997 | void to_y64(unsigned char *out, const unsigned char *in, int inlen) | |
| 998 | /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */ | |
| 999 | { | |
| 1000 | for (; inlen >= 3; inlen -= 3) | |
| 1001 | { | |
| 1002 | *out++ = base64digits[in[0] >> 2]; | |
| 1003 | *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)]; | |
| 1004 | *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)]; | |
| 1005 | *out++ = base64digits[in[2] & 0x3f]; | |
| 1006 | in += 3; | |
| 1007 | } | |
| 1008 | if (inlen > 0) | |
| 1009 | { | |
| 1010 | unsigned char fragment; | |
| 1011 | ||
| 1012 | *out++ = base64digits[in[0] >> 2]; | |
| 1013 | fragment = (in[0] << 4) & 0x30; | |
| 1014 | if (inlen > 1) | |
| 1015 | fragment |= in[1] >> 4; | |
| 1016 | *out++ = base64digits[fragment]; | |
| 1017 | *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c]; | |
| 1018 | *out++ = '-'; | |
| 1019 | } | |
| 1020 | *out = '\0'; | |
| 1021 | } | |
| 1022 | ||
| 6986 | 1023 | static void yahoo_process_auth_old(GaimConnection *gc, const char *seed) |
| 1024 | { | |
| 1025 | struct yahoo_packet *pack; | |
| 1026 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 7261 | 1027 | const char *name = gaim_normalize(account, gaim_account_get_username(account)); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
1028 | const char *pass = gaim_connection_get_password(gc); |
| 6986 | 1029 | struct yahoo_data *yd = gc->proto_data; |
| 1030 | ||
| 1031 | /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly | |
| 1032 | * will soon do so in the rest of the world. | |
| 1033 | * | |
| 1034 | * The new clients use this authentication method. I warn you in advance, it's | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8713
diff
changeset
|
1035 | * bizarre, convoluted, inordinately complicated. It's also no more secure than |
| 6986 | 1036 | * crypt() was. The only purpose this scheme could serve is to prevent third |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1037 | * party clients from connecting to their servers. |
| 6986 | 1038 | * |
| 1039 | * Sorry, Yahoo. | |
| 1040 | */ | |
| 9277 | 1041 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1042 | GaimCipher *cipher; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1043 | GaimCipherContext *context; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1044 | guint8 digest[16]; |
| 9277 | 1045 | |
| 6986 | 1046 | char *crypt_result; |
| 1047 | char password_hash[25]; | |
| 1048 | char crypt_hash[25]; | |
| 1049 | char *hash_string_p = g_malloc(50 + strlen(name)); | |
| 1050 | char *hash_string_c = g_malloc(50 + strlen(name)); | |
| 9277 | 1051 | |
| 6986 | 1052 | char checksum; |
| 9277 | 1053 | |
| 6986 | 1054 | int sv; |
| 9277 | 1055 | |
| 6986 | 1056 | char result6[25]; |
| 1057 | char result96[25]; | |
| 1058 | ||
| 1059 | sv = seed[15]; | |
| 1060 | sv = sv % 8; | |
| 1061 | ||
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1062 | cipher = gaim_ciphers_find_cipher("md5"); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1063 | context = gaim_cipher_context_new(cipher, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1064 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1065 | gaim_cipher_context_append(context, pass, strlen(pass)); |
| 10687 | 1066 | gaim_cipher_context_digest(context, sizeof(digest), digest, NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1067 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1068 | to_y64(password_hash, digest, 16); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1069 | |
| 9277 | 1070 | crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1071 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1072 | gaim_cipher_context_reset(context, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1073 | gaim_cipher_context_append(context, crypt_result, strlen(crypt_result)); |
| 10687 | 1074 | gaim_cipher_context_digest(context, sizeof(digest), digest, NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1075 | to_y64(crypt_hash, digest, 16); |
| 6986 | 1076 | |
| 1077 | switch (sv) { | |
| 1078 | case 1: | |
| 1079 | case 6: | |
| 1080 | checksum = seed[seed[9] % 16]; | |
| 1081 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1082 | "%c%s%s%s", checksum, name, seed, password_hash); | |
| 1083 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1084 | "%c%s%s%s", checksum, name, seed, crypt_hash); | |
| 1085 | break; | |
| 1086 | case 2: | |
| 1087 | case 7: | |
| 1088 | checksum = seed[seed[15] % 16]; | |
| 1089 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1090 | "%c%s%s%s", checksum, seed, password_hash, name); | |
| 1091 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1092 | "%c%s%s%s", checksum, seed, crypt_hash, name); | |
| 1093 | break; | |
| 1094 | case 3: | |
| 1095 | checksum = seed[seed[1] % 16]; | |
| 1096 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1097 | "%c%s%s%s", checksum, name, password_hash, seed); | |
| 1098 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1099 | "%c%s%s%s", checksum, name, crypt_hash, seed); | |
| 1100 | break; | |
| 1101 | case 4: | |
| 1102 | checksum = seed[seed[3] % 16]; | |
| 1103 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1104 | "%c%s%s%s", checksum, password_hash, seed, name); | |
| 1105 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1106 | "%c%s%s%s", checksum, crypt_hash, seed, name); | |
| 1107 | break; | |
| 1108 | case 0: | |
| 1109 | case 5: | |
| 1110 | checksum = seed[seed[7] % 16]; | |
| 1111 | g_snprintf(hash_string_p, strlen(name) + 50, | |
| 1112 | "%c%s%s%s", checksum, password_hash, name, seed); | |
| 1113 | g_snprintf(hash_string_c, strlen(name) + 50, | |
| 1114 | "%c%s%s%s", checksum, crypt_hash, name, seed); | |
| 1115 | break; | |
| 1116 | } | |
| 9277 | 1117 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1118 | gaim_cipher_context_reset(context, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1119 | gaim_cipher_context_append(context, hash_string_p, strlen(hash_string_p)); |
| 10687 | 1120 | gaim_cipher_context_digest(context, sizeof(digest), digest, NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1121 | to_y64(result6, digest, 16); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1122 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1123 | gaim_cipher_context_reset(context, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1124 | gaim_cipher_context_append(context, hash_string_c, strlen(hash_string_c)); |
| 10687 | 1125 | gaim_cipher_context_digest(context, sizeof(digest), digest, NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1126 | gaim_cipher_context_destroy(context); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1127 | to_y64(result96, digest, 16); |
| 6986 | 1128 | |
| 1129 | pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 1130 | yahoo_packet_hash(pack, "ssss", 0, name, 6, result6, 96, result96, 1, name); |
| 10392 | 1131 | yahoo_packet_send_and_free(pack, yd); |
| 9277 | 1132 | |
| 6986 | 1133 | g_free(hash_string_p); |
| 1134 | g_free(hash_string_c); | |
| 1135 | } | |
| 1136 | ||
| 6998 | 1137 | /* I'm dishing out some uber-mad props to Cerulean Studios for cracking this |
| 1138 | * and sending the fix! Thanks guys. */ | |
| 1139 | ||
| 6986 | 1140 | static void yahoo_process_auth_new(GaimConnection *gc, const char *seed) |
| 1141 | { | |
| 1142 | struct yahoo_packet *pack = NULL; | |
| 1143 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 7261 | 1144 | const char *name = gaim_normalize(account, gaim_account_get_username(account)); |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
1145 | const char *pass = gaim_connection_get_password(gc); |
| 6986 | 1146 | struct yahoo_data *yd = gc->proto_data; |
| 9277 | 1147 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1148 | GaimCipher *md5_cipher; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1149 | GaimCipherContext *md5_ctx; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1150 | guint8 md5_digest[16]; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1151 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1152 | GaimCipher *sha1_cipher; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1153 | GaimCipherContext *sha1_ctx1; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1154 | GaimCipherContext *sha1_ctx2; |
| 9277 | 1155 | |
| 8349 | 1156 | char *alphabet1 = "FBZDWAGHrJTLMNOPpRSKUVEXYChImkwQ"; |
| 1157 | char *alphabet2 = "F0E1D2C3B4A59687abcdefghijklmnop"; | |
| 1158 | ||
| 1159 | char *challenge_lookup = "qzec2tb3um1olpar8whx4dfgijknsvy5"; | |
| 1160 | char *operand_lookup = "+|&%/*^-"; | |
| 1161 | char *delimit_lookup = ",;"; | |
| 1162 | ||
| 1163 | char *password_hash = (char *)g_malloc(25); | |
| 1164 | char *crypt_hash = (char *)g_malloc(25); | |
| 1165 | char *crypt_result = NULL; | |
| 1166 | ||
| 1167 | char pass_hash_xor1[64]; | |
| 1168 | char pass_hash_xor2[64]; | |
| 1169 | char crypt_hash_xor1[64]; | |
| 1170 | char crypt_hash_xor2[64]; | |
| 1171 | char resp_6[100]; | |
| 1172 | char resp_96[100]; | |
| 1173 | ||
| 1174 | unsigned char digest1[20]; | |
| 1175 | unsigned char digest2[20]; | |
| 1176 | unsigned char comparison_src[20]; | |
| 1177 | unsigned char magic_key_char[4]; | |
| 8375 | 1178 | const unsigned char *magic_ptr; |
| 8349 | 1179 | |
| 1180 | unsigned int magic[64]; | |
| 1181 | unsigned int magic_work = 0; | |
| 1182 | unsigned int magic_4 = 0; | |
| 1183 | ||
| 1184 | int x; | |
| 1185 | int y; | |
| 1186 | int cnt = 0; | |
| 1187 | int magic_cnt = 0; | |
| 1188 | int magic_len; | |
| 1189 | ||
| 1190 | memset(password_hash, 0, 25); | |
| 1191 | memset(crypt_hash, 0, 25); | |
| 6986 | 1192 | memset(&pass_hash_xor1, 0, 64); |
| 1193 | memset(&pass_hash_xor2, 0, 64); | |
| 1194 | memset(&crypt_hash_xor1, 0, 64); | |
| 1195 | memset(&crypt_hash_xor2, 0, 64); | |
| 1196 | memset(&digest1, 0, 20); | |
| 1197 | memset(&digest2, 0, 20); | |
| 1198 | memset(&magic, 0, 64); | |
| 1199 | memset(&resp_6, 0, 100); | |
| 1200 | memset(&resp_96, 0, 100); | |
| 1201 | memset(&magic_key_char, 0, 4); | |
| 8349 | 1202 | memset(&comparison_src, 0, 20); |
| 6986 | 1203 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1204 | md5_cipher = gaim_ciphers_find_cipher("md5"); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1205 | md5_ctx = gaim_cipher_context_new(md5_cipher, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1206 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1207 | sha1_cipher = gaim_ciphers_find_cipher("sha1"); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1208 | sha1_ctx1 = gaim_cipher_context_new(sha1_cipher, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1209 | sha1_ctx2 = gaim_cipher_context_new(sha1_cipher, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1210 | |
| 6986 | 1211 | /* |
| 8349 | 1212 | * Magic: Phase 1. Generate what seems to be a 30 byte value (could change if base64 |
| 1213 | * ends up differently? I don't remember and I'm tired, so use a 64 byte buffer. | |
| 6986 | 1214 | */ |
| 9277 | 1215 | |
| 6986 | 1216 | magic_ptr = seed; |
| 8375 | 1217 | |
| 6986 | 1218 | while (*magic_ptr != (int)NULL) { |
| 8349 | 1219 | char *loc; |
| 6986 | 1220 | |
| 8349 | 1221 | /* Ignore parentheses. |
| 1222 | */ | |
| 6986 | 1223 | |
| 1224 | if (*magic_ptr == '(' || *magic_ptr == ')') { | |
| 1225 | magic_ptr++; | |
| 1226 | continue; | |
| 1227 | } | |
| 1228 | ||
| 8349 | 1229 | /* Characters and digits verify against the challenge lookup. |
| 1230 | */ | |
| 6986 | 1231 | |
| 1232 | if (isalpha(*magic_ptr) || isdigit(*magic_ptr)) { | |
| 1233 | loc = strchr(challenge_lookup, *magic_ptr); | |
| 1234 | if (!loc) { | |
| 8349 | 1235 | /* SME XXX Error - disconnect here */ |
| 6986 | 1236 | } |
| 1237 | ||
| 8349 | 1238 | /* Get offset into lookup table and shl 3. |
| 1239 | */ | |
| 6986 | 1240 | |
| 1241 | magic_work = loc - challenge_lookup; | |
| 1242 | magic_work <<= 3; | |
| 1243 | ||
| 1244 | magic_ptr++; | |
| 1245 | continue; | |
| 1246 | } else { | |
| 8349 | 1247 | unsigned int local_store; |
| 6986 | 1248 | |
| 1249 | loc = strchr(operand_lookup, *magic_ptr); | |
| 1250 | if (!loc) { | |
| 8349 | 1251 | /* SME XXX Disconnect */ |
| 6986 | 1252 | } |
| 1253 | ||
| 1254 | local_store = loc - operand_lookup; | |
| 8349 | 1255 | |
| 1256 | /* Oops; how did this happen? | |
| 1257 | */ | |
| 1258 | ||
| 6986 | 1259 | if (magic_cnt >= 64) |
| 1260 | break; | |
| 8349 | 1261 | |
| 6986 | 1262 | magic[magic_cnt++] = magic_work | local_store; |
| 1263 | magic_ptr++; | |
| 1264 | continue; | |
| 1265 | } | |
| 8349 | 1266 | } |
| 6986 | 1267 | |
| 1268 | magic_len = magic_cnt; | |
| 1269 | magic_cnt = 0; | |
| 1270 | ||
| 8349 | 1271 | /* Magic: Phase 2. Take generated magic value and sprinkle fairy dust on the values. |
| 1272 | */ | |
| 1273 | ||
| 6986 | 1274 | for (magic_cnt = magic_len-2; magic_cnt >= 0; magic_cnt--) { |
| 8349 | 1275 | unsigned char byte1; |
| 1276 | unsigned char byte2; | |
| 6986 | 1277 | |
| 1278 | /* Bad. Abort. | |
| 1279 | */ | |
| 8349 | 1280 | |
| 1281 | if ((magic_cnt + 1 > magic_len) || (magic_cnt > magic_len)) | |
| 6986 | 1282 | break; |
| 1283 | ||
| 1284 | byte1 = magic[magic_cnt]; | |
| 1285 | byte2 = magic[magic_cnt+1]; | |
| 8349 | 1286 | |
| 6986 | 1287 | byte1 *= 0xcd; |
| 1288 | byte1 ^= byte2; | |
| 1289 | ||
| 1290 | magic[magic_cnt+1] = byte1; | |
| 8349 | 1291 | } |
| 1292 | ||
| 1293 | /* | |
| 1294 | * Magic: Phase 3. This computes 20 bytes. The first 4 bytes are used as our magic | |
| 1295 | * key (and may be changed later); the next 16 bytes are an MD5 sum of the magic key | |
| 1296 | * plus 3 bytes. The 3 bytes are found by looping, and they represent the offsets | |
| 1297 | * into particular functions we'll later call to potentially alter the magic key. | |
| 1298 | * | |
| 1299 | * %-) | |
| 1300 | */ | |
| 1301 | ||
| 1302 | magic_cnt = 1; | |
| 1303 | x = 0; | |
| 1304 | ||
| 1305 | do { | |
| 1306 | unsigned int bl = 0; | |
| 1307 | unsigned int cl = magic[magic_cnt++]; | |
| 1308 | ||
| 1309 | if (magic_cnt >= magic_len) | |
| 1310 | break; | |
| 1311 | ||
| 1312 | if (cl > 0x7F) { | |
| 1313 | if (cl < 0xe0) | |
| 1314 | bl = cl = (cl & 0x1f) << 6; | |
| 1315 | else { | |
| 1316 | bl = magic[magic_cnt++]; | |
| 1317 | cl = (cl & 0x0f) << 6; | |
| 1318 | bl = ((bl & 0x3f) + cl) << 6; | |
| 1319 | } | |
| 9277 | 1320 | |
| 8349 | 1321 | cl = magic[magic_cnt++]; |
| 1322 | bl = (cl & 0x3f) + bl; | |
| 1323 | } else | |
| 1324 | bl = cl; | |
| 1325 | ||
| 1326 | comparison_src[x++] = (bl & 0xff00) >> 8; | |
| 1327 | comparison_src[x++] = bl & 0xff; | |
| 1328 | } while (x < 20); | |
| 1329 | ||
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1330 | /* First four bytes are magic key. */ |
| 8349 | 1331 | memcpy(&magic_key_char[0], comparison_src, 4); |
|
8482
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1332 | magic_4 = magic_key_char[0] | (magic_key_char[1]<<8) | (magic_key_char[2]<<16) | (magic_key_char[3]<<24); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1333 | |
| 8349 | 1334 | /* |
| 1335 | * Magic: Phase 4. Determine what function to use later by getting outside/inside | |
| 1336 | * loop values until we match our previous buffer. | |
| 1337 | */ | |
| 1338 | for (x = 0; x < 65535; x++) { | |
| 1339 | int leave = 0; | |
| 1340 | ||
| 1341 | for (y = 0; y < 5; y++) { | |
| 1342 | unsigned char test[3]; | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1343 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1344 | /* Calculate buffer. */ |
| 8349 | 1345 | test[0] = x; |
| 1346 | test[1] = x >> 8; | |
| 1347 | test[2] = y; | |
| 1348 | ||
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1349 | gaim_cipher_context_reset(md5_ctx, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1350 | gaim_cipher_context_append(md5_ctx, magic_key_char, 4); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1351 | gaim_cipher_context_append(md5_ctx, test, 3); |
| 10687 | 1352 | gaim_cipher_context_digest(md5_ctx, sizeof(md5_digest), |
| 1353 | md5_digest, NULL); | |
| 8349 | 1354 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1355 | if (!memcmp(md5_digest, comparison_src+4, 16)) { |
| 8349 | 1356 | leave = 1; |
| 1357 | break; | |
| 1358 | } | |
| 1359 | } | |
| 1360 | ||
| 1361 | if (leave == 1) | |
| 1362 | break; | |
| 6986 | 1363 | } |
| 1364 | ||
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1365 | /* If y != 0, we need some help. */ |
| 8349 | 1366 | if (y != 0) { |
| 1367 | unsigned int updated_key; | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1368 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1369 | /* Update magic stuff. |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1370 | * Call it twice because Yahoo's encryption is super bad ass. |
| 8349 | 1371 | */ |
| 1372 | updated_key = yahoo_auth_finalCountdown(magic_4, 0x60, y, x); | |
| 1373 | updated_key = yahoo_auth_finalCountdown(updated_key, 0x60, y, x); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1374 | |
|
8482
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1375 | magic_key_char[0] = updated_key & 0xff; |
|
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1376 | magic_key_char[1] = (updated_key >> 8) & 0xff; |
|
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1377 | magic_key_char[2] = (updated_key >> 16) & 0xff; |
|
75fc0de5be78
[gaim-migrate @ 9215]
Andrew Wellington <proton@users.sourceforge.net>
parents:
8441
diff
changeset
|
1378 | magic_key_char[3] = (updated_key >> 24) & 0xff; |
| 8349 | 1379 | } |
| 7127 | 1380 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1381 | /* Get password and crypt hashes as per usual. */ |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1382 | gaim_cipher_context_reset(md5_ctx, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1383 | gaim_cipher_context_append(md5_ctx, pass, strlen(pass)); |
| 10687 | 1384 | gaim_cipher_context_digest(md5_ctx, sizeof(md5_digest), |
| 1385 | md5_digest, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1386 | to_y64(password_hash, md5_digest, 16); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1387 | |
| 6986 | 1388 | crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$"); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1389 | gaim_cipher_context_reset(md5_ctx, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1390 | gaim_cipher_context_append(md5_ctx, crypt_result, strlen(crypt_result)); |
| 10687 | 1391 | gaim_cipher_context_digest(md5_ctx, sizeof(md5_digest), |
| 1392 | md5_digest, NULL); | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1393 | to_y64(crypt_hash, md5_digest, 16); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1394 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1395 | /* Our first authentication response is based off of the password hash. */ |
| 6986 | 1396 | for (x = 0; x < (int)strlen(password_hash); x++) |
| 1397 | pass_hash_xor1[cnt++] = password_hash[x] ^ 0x36; | |
| 1398 | ||
| 1399 | if (cnt < 64) | |
| 1400 | memset(&(pass_hash_xor1[cnt]), 0x36, 64-cnt); | |
| 8349 | 1401 | |
| 6986 | 1402 | cnt = 0; |
| 1403 | ||
| 1404 | for (x = 0; x < (int)strlen(password_hash); x++) | |
| 1405 | pass_hash_xor2[cnt++] = password_hash[x] ^ 0x5c; | |
| 1406 | ||
| 1407 | if (cnt < 64) | |
| 1408 | memset(&(pass_hash_xor2[cnt]), 0x5c, 64-cnt); | |
| 1409 | ||
| 8349 | 1410 | /* |
| 1411 | * The first context gets the password hash XORed with 0x36 plus a magic value | |
| 1412 | * which we previously extrapolated from our challenge. | |
| 1413 | */ | |
| 6986 | 1414 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1415 | gaim_cipher_context_append(sha1_ctx1, pass_hash_xor1, 64); |
| 9382 | 1416 | if (y >= 3) |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1417 | gaim_cipher_context_set_option(sha1_ctx1, "sizeLo", GINT_TO_POINTER(0x1ff)); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1418 | gaim_cipher_context_append(sha1_ctx1, magic_key_char, 4); |
| 10687 | 1419 | gaim_cipher_context_digest(sha1_ctx1, sizeof(digest1), digest1, NULL); |
| 6986 | 1420 | |
| 8349 | 1421 | /* |
| 1422 | * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest | |
| 1423 | * of the first context. | |
| 1424 | */ | |
| 6986 | 1425 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1426 | gaim_cipher_context_append(sha1_ctx2, pass_hash_xor2, 64); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1427 | gaim_cipher_context_append(sha1_ctx2, digest1, 20); |
| 10687 | 1428 | gaim_cipher_context_digest(sha1_ctx2, sizeof(digest2), digest2, NULL); |
| 6986 | 1429 | |
| 8349 | 1430 | /* |
| 1431 | * Now that we have digest2, use it to fetch characters from an alphabet to construct | |
| 1432 | * our first authentication response. | |
| 1433 | */ | |
| 1434 | ||
| 6986 | 1435 | for (x = 0; x < 20; x += 2) { |
| 8349 | 1436 | unsigned int val = 0; |
| 1437 | unsigned int lookup = 0; | |
| 6986 | 1438 | |
| 8349 | 1439 | char byte[6]; |
| 1440 | ||
| 6986 | 1441 | memset(&byte, 0, 6); |
| 8349 | 1442 | |
| 1443 | /* First two bytes of digest stuffed together. | |
| 6986 | 1444 | */ |
| 9277 | 1445 | |
| 6986 | 1446 | val = digest2[x]; |
| 1447 | val <<= 8; | |
| 1448 | val += digest2[x+1]; | |
| 1449 | ||
| 1450 | lookup = (val >> 0x0b); | |
| 1451 | lookup &= 0x1f; | |
| 1452 | if (lookup >= strlen(alphabet1)) | |
| 1453 | break; | |
| 1454 | sprintf(byte, "%c", alphabet1[lookup]); | |
| 1455 | strcat(resp_6, byte); | |
| 1456 | strcat(resp_6, "="); | |
| 8349 | 1457 | |
| 6986 | 1458 | lookup = (val >> 0x06); |
| 1459 | lookup &= 0x1f; | |
| 1460 | if (lookup >= strlen(alphabet2)) | |
| 1461 | break; | |
| 1462 | sprintf(byte, "%c", alphabet2[lookup]); | |
| 1463 | strcat(resp_6, byte); | |
| 1464 | ||
| 1465 | lookup = (val >> 0x01); | |
| 1466 | lookup &= 0x1f; | |
| 1467 | if (lookup >= strlen(alphabet2)) | |
| 1468 | break; | |
| 1469 | sprintf(byte, "%c", alphabet2[lookup]); | |
| 1470 | strcat(resp_6, byte); | |
| 8349 | 1471 | |
| 6986 | 1472 | lookup = (val & 0x01); |
| 1473 | if (lookup >= strlen(delimit_lookup)) | |
| 1474 | break; | |
| 1475 | sprintf(byte, "%c", delimit_lookup[lookup]); | |
| 1476 | strcat(resp_6, byte); | |
| 1477 | } | |
| 1478 | ||
| 8349 | 1479 | /* Our second authentication response is based off of the crypto hash. |
| 1480 | */ | |
| 6986 | 1481 | |
| 1482 | cnt = 0; | |
| 1483 | memset(&digest1, 0, 20); | |
| 1484 | memset(&digest2, 0, 20); | |
| 1485 | ||
| 1486 | for (x = 0; x < (int)strlen(crypt_hash); x++) | |
| 1487 | crypt_hash_xor1[cnt++] = crypt_hash[x] ^ 0x36; | |
| 1488 | ||
| 1489 | if (cnt < 64) | |
| 1490 | memset(&(crypt_hash_xor1[cnt]), 0x36, 64-cnt); | |
| 8349 | 1491 | |
| 6986 | 1492 | cnt = 0; |
| 1493 | ||
| 1494 | for (x = 0; x < (int)strlen(crypt_hash); x++) | |
| 1495 | crypt_hash_xor2[cnt++] = crypt_hash[x] ^ 0x5c; | |
| 1496 | ||
| 1497 | if (cnt < 64) | |
| 1498 | memset(&(crypt_hash_xor2[cnt]), 0x5c, 64-cnt); | |
| 1499 | ||
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1500 | gaim_cipher_context_reset(sha1_ctx1, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1501 | gaim_cipher_context_reset(sha1_ctx2, NULL); |
| 6986 | 1502 | |
| 8349 | 1503 | /* |
| 1504 | * The first context gets the password hash XORed with 0x36 plus a magic value | |
| 1505 | * which we previously extrapolated from our challenge. | |
| 1506 | */ | |
| 6986 | 1507 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1508 | gaim_cipher_context_append(sha1_ctx1, crypt_hash_xor1, 64); |
| 10687 | 1509 | if (y >= 3) { |
| 1510 | gaim_cipher_context_set_option(sha1_ctx1, "sizeLo", | |
| 1511 | GINT_TO_POINTER(0x1ff)); | |
| 1512 | } | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1513 | gaim_cipher_context_append(sha1_ctx1, magic_key_char, 4); |
| 10687 | 1514 | gaim_cipher_context_digest(sha1_ctx1, sizeof(digest1), digest1, NULL); |
| 6986 | 1515 | |
| 8349 | 1516 | /* |
| 1517 | * The second context gets the password hash XORed with 0x5c plus the SHA-1 digest | |
| 1518 | * of the first context. | |
| 1519 | */ | |
| 6986 | 1520 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1521 | gaim_cipher_context_append(sha1_ctx2, crypt_hash_xor2, 64); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1522 | gaim_cipher_context_append(sha1_ctx2, digest1, 20); |
| 10687 | 1523 | gaim_cipher_context_digest(sha1_ctx2, sizeof(digest2), digest2, NULL); |
| 6986 | 1524 | |
| 8349 | 1525 | /* |
| 1526 | * Now that we have digest2, use it to fetch characters from an alphabet to construct | |
| 1527 | * our first authentication response. | |
| 1528 | */ | |
| 6986 | 1529 | |
| 1530 | for (x = 0; x < 20; x += 2) { | |
| 8349 | 1531 | unsigned int val = 0; |
| 1532 | unsigned int lookup = 0; | |
| 6986 | 1533 | |
| 8349 | 1534 | char byte[6]; |
| 6986 | 1535 | |
| 1536 | memset(&byte, 0, 6); | |
| 1537 | ||
| 8349 | 1538 | /* First two bytes of digest stuffed together. |
| 1539 | */ | |
| 6986 | 1540 | |
| 1541 | val = digest2[x]; | |
| 1542 | val <<= 8; | |
| 1543 | val += digest2[x+1]; | |
| 8349 | 1544 | |
| 6986 | 1545 | lookup = (val >> 0x0b); |
| 1546 | lookup &= 0x1f; | |
| 1547 | if (lookup >= strlen(alphabet1)) | |
| 1548 | break; | |
| 1549 | sprintf(byte, "%c", alphabet1[lookup]); | |
| 1550 | strcat(resp_96, byte); | |
| 1551 | strcat(resp_96, "="); | |
| 1552 | ||
| 1553 | lookup = (val >> 0x06); | |
| 1554 | lookup &= 0x1f; | |
| 1555 | if (lookup >= strlen(alphabet2)) | |
| 1556 | break; | |
| 1557 | sprintf(byte, "%c", alphabet2[lookup]); | |
| 1558 | strcat(resp_96, byte); | |
| 1559 | ||
| 1560 | lookup = (val >> 0x01); | |
| 1561 | lookup &= 0x1f; | |
| 1562 | if (lookup >= strlen(alphabet2)) | |
| 1563 | break; | |
| 1564 | sprintf(byte, "%c", alphabet2[lookup]); | |
| 1565 | strcat(resp_96, byte); | |
| 1566 | ||
| 1567 | lookup = (val & 0x01); | |
| 1568 | if (lookup >= strlen(delimit_lookup)) | |
| 1569 | break; | |
| 1570 | sprintf(byte, "%c", delimit_lookup[lookup]); | |
| 1571 | strcat(resp_96, byte); | |
| 1572 | } | |
|
10784
bfce89c840f9
[gaim-migrate @ 12417]
Richard Laager <rlaager@pidgin.im>
parents:
10755
diff
changeset
|
1573 | gaim_debug_info("yahoo", "yahoo status: %d\n", yd->current_status); |
| 10400 | 1574 | pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->current_status, 0); |
| 10394 | 1575 | yahoo_packet_hash(pack, "sssss", 0, name, 6, resp_6, 96, resp_96, 1, |
| 1576 | name, 135, "6,0,0,1710"); | |
| 1577 | if (yd->picture_checksum) | |
| 1578 | yahoo_packet_hash_int(pack, 192, yd->picture_checksum); | |
| 1579 | ||
| 10392 | 1580 | yahoo_packet_send_and_free(pack, yd); |
| 6986 | 1581 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1582 | gaim_cipher_context_destroy(md5_ctx); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1583 | gaim_cipher_context_destroy(sha1_ctx1); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1584 | gaim_cipher_context_destroy(sha1_ctx2); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
1585 | |
| 7424 | 1586 | g_free(password_hash); |
| 1587 | g_free(crypt_hash); | |
| 6986 | 1588 | } |
| 1589 | ||
| 5583 | 1590 | static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt) |
| 3147 | 1591 | { |
| 1592 | char *seed = NULL; | |
| 1593 | char *sn = NULL; | |
| 1594 | GSList *l = pkt->hash; | |
| 7010 | 1595 | int m = 0; |
| 9277 | 1596 | gchar *buf; |
| 1597 | ||
| 1598 | ||
| 3147 | 1599 | while (l) { |
| 1600 | struct yahoo_pair *pair = l->data; | |
| 1601 | if (pair->key == 94) | |
| 1602 | seed = pair->value; | |
| 1603 | if (pair->key == 1) | |
| 1604 | sn = pair->value; | |
| 6986 | 1605 | if (pair->key == 13) |
| 1606 | m = atoi(pair->value); | |
| 3147 | 1607 | l = l->next; |
| 1608 | } | |
| 9277 | 1609 | |
| 3147 | 1610 | if (seed) { |
| 6986 | 1611 | switch (m) { |
| 1612 | case 0: | |
| 1613 | yahoo_process_auth_old(gc, seed); | |
| 1614 | break; | |
| 3147 | 1615 | case 1: |
| 6986 | 1616 | yahoo_process_auth_new(gc, seed); |
| 3147 | 1617 | break; |
| 6986 | 1618 | default: |
|
7043
b79933739678
[gaim-migrate @ 7606]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7015
diff
changeset
|
1619 | buf = g_strdup_printf(_("The Yahoo server has requested the use of an unrecognized " |
|
7129
53748de036e6
[gaim-migrate @ 7696]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7127
diff
changeset
|
1620 | "authentication method. This version of Gaim will likely not be able " |
|
7043
b79933739678
[gaim-migrate @ 7606]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7015
diff
changeset
|
1621 | "to successfully sign on to Yahoo. Check %s for updates."), GAIM_WEBSITE); |
| 6986 | 1622 | gaim_notify_error(gc, "", _("Failed Yahoo! Authentication"), |
|
7043
b79933739678
[gaim-migrate @ 7606]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7015
diff
changeset
|
1623 | buf); |
|
b79933739678
[gaim-migrate @ 7606]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
7015
diff
changeset
|
1624 | g_free(buf); |
| 6986 | 1625 | yahoo_process_auth_new(gc, seed); /* Can't hurt to try it anyway. */ |
| 3147 | 1626 | } |
| 1627 | } | |
| 1628 | } | |
| 2681 | 1629 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1630 | static void ignore_buddy(GaimBuddy *buddy) { |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1631 | GaimGroup *group; |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1632 | GaimConversation *conv; |
| 6760 | 1633 | GaimAccount *account; |
| 1634 | gchar *name; | |
| 1635 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1636 | if (!buddy) |
| 6792 | 1637 | return; |
| 6760 | 1638 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1639 | group = gaim_find_buddys_group(buddy); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1640 | name = g_strdup(buddy->name); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1641 | account = buddy->account; |
| 6760 | 1642 | |
| 6792 | 1643 | gaim_debug(GAIM_DEBUG_INFO, "blist", |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1644 | "Removing '%s' from buddy list.\n", buddy->name); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1645 | serv_remove_buddy(account->gc, buddy, group); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1646 | gaim_blist_remove_buddy(buddy); |
| 6760 | 1647 | |
| 6792 | 1648 | serv_add_deny(account->gc, name); |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1649 | |
|
10246
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10240
diff
changeset
|
1650 | /* The follow should really be done by the core... */ |
|
aa5bff72f94c
[gaim-migrate @ 11386]
Mark Doliner <markdoliner@pidgin.im>
parents:
10240
diff
changeset
|
1651 | conv = gaim_find_conversation_with_account(GAIM_CONV_IM, name, account); |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1652 | |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1653 | if (conv != NULL) |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
1654 | gaim_conversation_update(conv, GAIM_CONV_UPDATE_REMOVE); |
| 6760 | 1655 | |
| 1656 | g_free(name); | |
| 1657 | } | |
| 1658 | ||
| 1659 | static void keep_buddy(GaimBuddy *b) { | |
| 1660 | gaim_privacy_deny_remove(b->account, b->name, 1); | |
| 1661 | } | |
| 1662 | ||
| 1663 | static void yahoo_process_ignore(GaimConnection *gc, struct yahoo_packet *pkt) { | |
| 1664 | GaimBuddy *b; | |
| 1665 | GSList *l; | |
| 1666 | gchar *who = NULL; | |
| 1667 | gchar *sn = NULL; | |
| 1668 | gchar buf[BUF_LONG]; | |
| 1669 | gint ignore = 0; | |
| 1670 | gint status = 0; | |
| 1671 | ||
| 1672 | for (l = pkt->hash; l; l = l->next) { | |
| 1673 | struct yahoo_pair *pair = l->data; | |
| 1674 | switch (pair->key) { | |
| 1675 | case 0: | |
| 1676 | who = pair->value; | |
| 1677 | break; | |
| 1678 | case 1: | |
| 1679 | sn = pair->value; | |
| 1680 | break; | |
| 1681 | case 13: | |
| 1682 | ignore = strtol(pair->value, NULL, 10); | |
| 1683 | break; | |
| 1684 | case 66: | |
| 1685 | status = strtol(pair->value, NULL, 10); | |
| 1686 | break; | |
| 1687 | default: | |
| 1688 | break; | |
| 1689 | } | |
| 1690 | } | |
| 1691 | ||
| 1692 | switch (status) { | |
| 1693 | case 12: | |
| 1694 | b = gaim_find_buddy(gc->account, who); | |
| 1695 | g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the " | |
| 1696 | "user is on your buddy list. Clicking \"Yes\" " | |
| 1697 | "will remove and ignore the buddy."), who); | |
| 1698 | gaim_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0, b, | |
| 1699 | G_CALLBACK(ignore_buddy), | |
| 1700 | G_CALLBACK(keep_buddy)); | |
| 1701 | break; | |
| 1702 | case 2: | |
| 1703 | case 3: | |
| 1704 | case 0: | |
| 1705 | default: | |
| 1706 | break; | |
| 1707 | } | |
| 1708 | } | |
| 1709 | ||
| 6761 | 1710 | static void yahoo_process_authresp(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1711 | { | |
| 9410 | 1712 | struct yahoo_data *yd = gc->proto_data; |
| 6761 | 1713 | GSList *l = pkt->hash; |
| 1714 | int err = 0; | |
| 1715 | char *msg; | |
| 7865 | 1716 | char *url = NULL; |
| 1717 | char *fullmsg; | |
| 6761 | 1718 | |
| 1719 | while (l) { | |
| 1720 | struct yahoo_pair *pair = l->data; | |
| 1721 | ||
| 1722 | if (pair->key == 66) | |
| 1723 | err = strtol(pair->value, NULL, 10); | |
| 7865 | 1724 | if (pair->key == 20) |
| 1725 | url = pair->value; | |
| 6761 | 1726 | |
| 1727 | l = l->next; | |
| 1728 | } | |
| 1729 | ||
| 1730 | switch (err) { | |
| 1731 | case 3: | |
| 7865 | 1732 | msg = g_strdup(_("Invalid username.")); |
| 6761 | 1733 | break; |
| 1734 | case 13: | |
| 9410 | 1735 | if (!yd->wm) { |
| 1736 | yd->wm = TRUE; | |
| 1737 | if (yd->fd >= 0) | |
| 1738 | close(yd->fd); | |
| 1739 | if (gc->inpa) | |
| 1740 | gaim_input_remove(gc->inpa); | |
| 1741 | gaim_url_fetch(WEBMESSENGER_URL, TRUE, "Gaim/" VERSION, FALSE, | |
| 1742 | yahoo_login_page_cb, gc); | |
| 9835 | 1743 | gaim_notify_warning(gc, NULL, _("Normal authentication failed!"), |
| 1744 | _("The normal authentication method has failed. " | |
| 9410 | 1745 | "This means either your password is incorrect, " |
| 9835 | 1746 | "or Yahoo!'s authentication scheme has changed. " |
| 9410 | 1747 | "Gaim will now attempt to log in using Web " |
| 9835 | 1748 | "Messenger authentication, which will result " |
| 9410 | 1749 | "in reduced functionality and features.")); |
| 1750 | return; | |
| 1751 | } | |
| 7865 | 1752 | msg = g_strdup(_("Incorrect password.")); |
| 1753 | break; | |
| 1754 | case 14: | |
| 9280 | 1755 | msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website.")); |
| 6761 | 1756 | break; |
| 1757 | default: | |
| 9280 | 1758 | msg = g_strdup_printf(_("Unknown error number %d. Logging into the Yahoo! website may fix this."), err); |
| 6761 | 1759 | } |
| 7865 | 1760 | |
| 1761 | if (url) | |
| 1762 | fullmsg = g_strdup_printf("%s\n%s", msg, url); | |
| 1763 | else | |
| 1764 | fullmsg = g_strdup(msg); | |
| 1765 | ||
| 9280 | 1766 | gc->wants_to_die = TRUE; |
| 7865 | 1767 | gaim_connection_error(gc, fullmsg); |
| 1768 | g_free(msg); | |
| 1769 | g_free(fullmsg); | |
| 6761 | 1770 | } |
| 1771 | ||
| 6840 | 1772 | static void yahoo_process_addbuddy(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1773 | { | |
| 1774 | int err = 0; | |
| 1775 | char *who = NULL; | |
| 1776 | char *group = NULL; | |
| 7827 | 1777 | char *decoded_group; |
| 6840 | 1778 | char *buf; |
| 9278 | 1779 | YahooFriend *f; |
| 6840 | 1780 | GSList *l = pkt->hash; |
| 1781 | ||
| 1782 | while (l) { | |
| 1783 | struct yahoo_pair *pair = l->data; | |
| 1784 | ||
| 1785 | switch (pair->key) { | |
| 1786 | case 66: | |
| 1787 | err = strtol(pair->value, NULL, 10); | |
| 1788 | break; | |
| 1789 | case 7: | |
| 1790 | who = pair->value; | |
| 1791 | break; | |
| 1792 | case 65: | |
| 1793 | group = pair->value; | |
| 1794 | break; | |
| 1795 | } | |
| 1796 | ||
| 1797 | l = l->next; | |
| 1798 | } | |
| 1799 | ||
| 1800 | if (!who) | |
| 1801 | return; | |
| 1802 | if (!group) | |
| 1803 | group = ""; | |
| 1804 | ||
| 1805 | if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */ | |
| 9279 | 1806 | f = yahoo_friend_find_or_new(gc, who); |
| 1807 | yahoo_update_status(gc, who, f); | |
| 6840 | 1808 | return; |
| 1809 | } | |
| 1810 | ||
| 7827 | 1811 | decoded_group = yahoo_string_decode(gc, group, FALSE); |
| 6840 | 1812 | buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."), |
| 7827 | 1813 | who, decoded_group, gaim_connection_get_display_name(gc)); |
| 9637 | 1814 | if (!gaim_conv_present_error(who, gaim_connection_get_account(gc), buf)) |
| 1815 | gaim_notify_error(gc, NULL, _("Could not add buddy to server list"), buf); | |
| 6840 | 1816 | g_free(buf); |
| 7827 | 1817 | g_free(decoded_group); |
| 6840 | 1818 | } |
| 1819 | ||
| 9062 | 1820 | static void yahoo_process_p2p(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1821 | { | |
| 1822 | GSList *l = pkt->hash; | |
| 1823 | char *who = NULL; | |
| 1824 | char *base64 = NULL; | |
| 9277 | 1825 | char *decoded; |
| 9062 | 1826 | int len; |
| 1827 | ||
| 1828 | while (l) { | |
| 1829 | struct yahoo_pair *pair = l->data; | |
| 1830 | ||
| 1831 | switch (pair->key) { | |
| 1832 | case 5: | |
| 1833 | /* our identity */ | |
| 1834 | break; | |
| 1835 | case 4: | |
| 1836 | who = pair->value; | |
| 1837 | break; | |
| 1838 | case 1: | |
| 1839 | /* who again, the master identity this time? */ | |
| 1840 | break; | |
| 1841 | case 12: | |
| 1842 | base64 = pair->value; | |
| 1843 | /* so, this is an ip address. in base64. decoded it's in ascii. | |
| 1844 | after strtol, it's in reversed byte order. Who thought this up?*/ | |
| 1845 | break; | |
| 1846 | /* | |
| 1847 | TODO: figure these out | |
| 1848 | yahoo: Key: 61 Value: 0 | |
| 1849 | yahoo: Key: 2 Value: | |
| 1850 | yahoo: Key: 13 Value: 0 | |
| 1851 | yahoo: Key: 49 Value: PEERTOPEER | |
| 1852 | yahoo: Key: 140 Value: 1 | |
| 1853 | yahoo: Key: 11 Value: -1786225828 | |
| 1854 | */ | |
| 1855 | ||
| 1856 | } | |
| 1857 | ||
| 1858 | l = l->next; | |
| 1859 | } | |
| 1860 | ||
| 9277 | 1861 | if (base64) { |
| 9281 | 1862 | guint32 ip; |
| 1863 | char *tmp2; | |
| 1864 | YahooFriend *f; | |
| 1865 | ||
| 9062 | 1866 | gaim_base64_decode(base64, &decoded, &len); |
| 9277 | 1867 | if (len) { |
| 1868 | char *tmp = gaim_str_binary_to_ascii(decoded, len); | |
| 1869 | gaim_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, tmp); | |
| 1870 | g_free(tmp); | |
| 1871 | } | |
| 9281 | 1872 | |
| 1873 | tmp2 = g_strndup(decoded, len); /* so its \0 terminated...*/ | |
| 1874 | ip = strtol(tmp2, NULL, 10); | |
| 1875 | g_free(tmp2); | |
| 9062 | 1876 | g_free(decoded); |
| 9281 | 1877 | tmp2 = g_strdup_printf("%u.%u.%u.%u", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff, |
| 1878 | (ip >> 24) & 0xff); | |
| 1879 | f = yahoo_friend_find(gc, who); | |
| 1880 | if (f) | |
| 1881 | yahoo_friend_set_ip(f, tmp2); | |
| 1882 | g_free(tmp2); | |
| 9062 | 1883 | } |
| 1884 | } | |
| 1885 | ||
| 9604 | 1886 | static void yahoo_process_audible(GaimConnection *gc, struct yahoo_packet *pkt) |
| 1887 | { | |
| 1888 | char *who = NULL, *msg = NULL; | |
| 1889 | GSList *l = pkt->hash; | |
| 1890 | ||
| 1891 | while (l) { | |
| 1892 | struct yahoo_pair *pair = l->data; | |
| 1893 | ||
| 1894 | switch (pair->key) { | |
| 1895 | case 4: | |
| 1896 | who = pair->value; | |
| 1897 | break; | |
| 1898 | case 5: | |
| 1899 | /* us */ | |
| 1900 | break; | |
| 1901 | case 230: | |
| 1902 | /* the audible, in foo.bar.baz format */ | |
| 1903 | break; | |
| 1904 | case 231: | |
| 1905 | /* the text of the audible */ | |
| 1906 | msg = pair->value; | |
| 1907 | break; | |
| 1908 | case 232: | |
| 1909 | /* weird number (md5 hash?), like 8ebab9094156135f5dcbaccbeee662a5c5fd1420 */ | |
| 1910 | break; | |
| 1911 | } | |
| 1912 | ||
| 1913 | l = l->next; | |
| 1914 | } | |
| 1915 | ||
| 1916 | if (!who || !msg) | |
| 1917 | return; | |
| 1918 | if (!g_utf8_validate(msg, -1, NULL)) { | |
| 1919 | gaim_debug_misc("yahoo", "Warning, nonutf8 audible, ignoring!\n"); | |
| 1920 | return; | |
| 1921 | } | |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
1922 | if (!yahoo_privacy_check(gc, who)) { |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
1923 | gaim_debug_misc("yahoo", "Audible message from %s for %s dropped!\n", |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
1924 | gc->account->username, who); |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
1925 | return; |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
1926 | } |
| 9604 | 1927 | serv_got_im(gc, who, msg, 0, time(NULL)); |
| 1928 | } | |
| 1929 | ||
| 5583 | 1930 | static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt) |
| 2681 | 1931 | { |
| 6760 | 1932 | switch (pkt->service) { |
| 2681 | 1933 | case YAHOO_SERVICE_LOGON: |
|
2771
8c214f13da39
[gaim-migrate @ 2784]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2741
diff
changeset
|
1934 | case YAHOO_SERVICE_LOGOFF: |
| 2681 | 1935 | case YAHOO_SERVICE_ISAWAY: |
|
2737
f7edb9c3f348
[gaim-migrate @ 2750]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2724
diff
changeset
|
1936 | case YAHOO_SERVICE_ISBACK: |
| 3019 | 1937 | case YAHOO_SERVICE_GAMELOGON: |
| 1938 | case YAHOO_SERVICE_GAMELOGOFF: | |
| 6686 | 1939 | case YAHOO_SERVICE_CHATLOGON: |
| 1940 | case YAHOO_SERVICE_CHATLOGOFF: | |
| 10373 | 1941 | case YAHOO_SERVICE_Y6_STATUS_UPDATE: |
| 2681 | 1942 | yahoo_process_status(gc, pkt); |
| 1943 | break; | |
| 3019 | 1944 | case YAHOO_SERVICE_NOTIFY: |
| 1945 | yahoo_process_notify(gc, pkt); | |
| 2993 | 1946 | break; |
| 2681 | 1947 | case YAHOO_SERVICE_MESSAGE: |
| 2786 | 1948 | case YAHOO_SERVICE_GAMEMSG: |
| 5939 | 1949 | case YAHOO_SERVICE_CHATMSG: |
| 2681 | 1950 | yahoo_process_message(gc, pkt); |
| 1951 | break; | |
| 7865 | 1952 | case YAHOO_SERVICE_SYSMESSAGE: |
| 1953 | yahoo_process_sysmessage(gc, pkt); | |
| 1954 | break; | |
| 2681 | 1955 | case YAHOO_SERVICE_NEWMAIL: |
| 1956 | yahoo_process_mail(gc, pkt); | |
| 1957 | break; | |
| 1958 | case YAHOO_SERVICE_NEWCONTACT: | |
| 1959 | yahoo_process_contact(gc, pkt); | |
| 1960 | break; | |
| 6784 | 1961 | case YAHOO_SERVICE_AUTHRESP: |
| 1962 | yahoo_process_authresp(gc, pkt); | |
| 1963 | break; | |
| 2681 | 1964 | case YAHOO_SERVICE_LIST: |
| 1965 | yahoo_process_list(gc, pkt); | |
| 1966 | break; | |
| 3147 | 1967 | case YAHOO_SERVICE_AUTH: |
| 1968 | yahoo_process_auth(gc, pkt); | |
| 1969 | break; | |
| 6840 | 1970 | case YAHOO_SERVICE_ADDBUDDY: |
| 1971 | yahoo_process_addbuddy(gc, pkt); | |
| 1972 | break; | |
| 6760 | 1973 | case YAHOO_SERVICE_IGNORECONTACT: |
| 1974 | yahoo_process_ignore(gc, pkt); | |
| 1975 | break; | |
| 6729 | 1976 | case YAHOO_SERVICE_CONFINVITE: |
| 1977 | case YAHOO_SERVICE_CONFADDINVITE: | |
| 1978 | yahoo_process_conference_invite(gc, pkt); | |
| 1979 | break; | |
| 1980 | case YAHOO_SERVICE_CONFDECLINE: | |
| 1981 | yahoo_process_conference_decline(gc, pkt); | |
| 1982 | break; | |
| 1983 | case YAHOO_SERVICE_CONFLOGON: | |
| 1984 | yahoo_process_conference_logon(gc, pkt); | |
| 1985 | break; | |
| 1986 | case YAHOO_SERVICE_CONFLOGOFF: | |
| 1987 | yahoo_process_conference_logoff(gc, pkt); | |
| 1988 | break; | |
| 1989 | case YAHOO_SERVICE_CONFMSG: | |
| 1990 | yahoo_process_conference_message(gc, pkt); | |
| 1991 | break; | |
| 1992 | case YAHOO_SERVICE_CHATONLINE: | |
| 1993 | yahoo_process_chat_online(gc, pkt); | |
| 1994 | break; | |
| 1995 | case YAHOO_SERVICE_CHATLOGOUT: | |
| 1996 | yahoo_process_chat_logout(gc, pkt); | |
| 1997 | break; | |
| 1998 | case YAHOO_SERVICE_CHATGOTO: | |
| 1999 | yahoo_process_chat_goto(gc, pkt); | |
| 2000 | break; | |
| 2001 | case YAHOO_SERVICE_CHATJOIN: | |
| 2002 | yahoo_process_chat_join(gc, pkt); | |
| 2003 | break; | |
| 2004 | case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */ | |
| 2005 | case YAHOO_SERVICE_CHATEXIT: | |
| 2006 | yahoo_process_chat_exit(gc, pkt); | |
| 2007 | break; | |
| 2008 | case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */ | |
| 2009 | case YAHOO_SERVICE_CHATADDINVITE: | |
| 2010 | yahoo_process_chat_addinvite(gc, pkt); | |
| 2011 | break; | |
| 2012 | case YAHOO_SERVICE_COMMENT: | |
| 2013 | yahoo_process_chat_message(gc, pkt); | |
| 2014 | break; | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2015 | case YAHOO_SERVICE_STEALTH_PERM: |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2016 | case YAHOO_SERVICE_STEALTH_SESSION: |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2017 | yahoo_process_stealth(gc, pkt); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2018 | break; |
| 7651 | 2019 | case YAHOO_SERVICE_P2PFILEXFER: |
| 2020 | case YAHOO_SERVICE_FILETRANSFER: | |
| 2021 | yahoo_process_filetransfer(gc, pkt); | |
| 2022 | break; | |
| 9062 | 2023 | case YAHOO_SERVICE_PEEPTOPEER: |
| 2024 | yahoo_process_p2p(gc, pkt); | |
| 2025 | break; | |
| 9284 | 2026 | case YAHOO_SERVICE_PICTURE: |
| 2027 | yahoo_process_picture(gc, pkt); | |
| 2028 | break; | |
| 9292 | 2029 | case YAHOO_SERVICE_PICTURE_UPDATE: |
| 2030 | yahoo_process_picture_update(gc, pkt); | |
| 2031 | break; | |
| 2032 | case YAHOO_SERVICE_PICTURE_CHECKSUM: | |
| 2033 | yahoo_process_picture_checksum(gc, pkt); | |
| 2034 | break; | |
| 9306 | 2035 | case YAHOO_SERVICE_PICTURE_UPLOAD: |
| 2036 | yahoo_process_picture_upload(gc, pkt); | |
| 2037 | break; | |
| 9604 | 2038 | case YAHOO_SERVICE_AUDIBLE: |
| 2039 | yahoo_process_audible(gc, pkt); | |
| 2681 | 2040 | default: |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2041 | gaim_debug(GAIM_DEBUG_ERROR, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2042 | "Unhandled service 0x%02x\n", pkt->service); |
| 2681 | 2043 | break; |
| 2044 | } | |
| 2045 | } | |
| 2046 | ||
| 2047 | static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond) | |
| 2048 | { | |
| 5583 | 2049 | GaimConnection *gc = data; |
| 2681 | 2050 | struct yahoo_data *yd = gc->proto_data; |
| 2051 | char buf[1024]; | |
| 2052 | int len; | |
| 2053 | ||
| 2054 | len = read(yd->fd, buf, sizeof(buf)); | |
| 2055 | ||
| 2056 | if (len <= 0) { | |
|
6321
0b54b2a172d1
[gaim-migrate @ 6820]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
6115
diff
changeset
|
2057 | gaim_connection_error(gc, _("Unable to read")); |
| 2681 | 2058 | return; |
| 2059 | } | |
| 2060 | ||
| 2061 | yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen); | |
| 2062 | memcpy(yd->rxqueue + yd->rxlen, buf, len); | |
| 2063 | yd->rxlen += len; | |
| 2064 | ||
| 2065 | while (1) { | |
| 2066 | struct yahoo_packet *pkt; | |
| 2067 | int pos = 0; | |
| 2068 | int pktlen; | |
| 2069 | ||
| 2070 | if (yd->rxlen < YAHOO_PACKET_HDRLEN) | |
| 2071 | return; | |
| 2072 | ||
| 10610 | 2073 | if (strncmp(yd->rxqueue, "YMSG", MIN(4, yd->rxlen)) != 0) { |
| 2074 | /* HEY! This isn't even a YMSG packet. What | |
| 2075 | * are you trying to pull? */ | |
| 2076 | guchar *start; | |
| 2077 | ||
| 2078 | gaim_debug_warning("yahoo", "Error in YMSG stream, got something not a YMSG packet!"); | |
| 10611 | 2079 | |
| 10635 | 2080 | start = memchr(yd->rxqueue + 1, 'Y', yd->rxlen - 1); |
| 10610 | 2081 | if (start) { |
| 2082 | g_memmove(yd->rxqueue, start, yd->rxlen - (start - yd->rxqueue)); | |
| 2083 | yd->rxlen -= start - yd->rxqueue; | |
| 2084 | continue; | |
| 2085 | } else { | |
| 2086 | g_free(yd->rxqueue); | |
| 2087 | yd->rxqueue = NULL; | |
| 2088 | yd->rxlen = 0; | |
| 2089 | return; | |
| 2090 | } | |
| 2091 | } | |
| 2092 | ||
| 2681 | 2093 | pos += 4; /* YMSG */ |
| 2094 | pos += 2; | |
| 2095 | pos += 2; | |
| 2096 | ||
| 2097 | pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2098 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2099 | "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen); |
| 2681 | 2100 | |
| 2101 | if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen)) | |
| 2102 | return; | |
| 2103 | ||
| 2104 | yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen); | |
| 2105 | ||
| 2106 | pkt = yahoo_packet_new(0, 0, 0); | |
| 2107 | ||
| 2108 | pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2; | |
| 3021 | 2109 | pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4; |
|
5220
f42438a0cc06
[gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents:
5216
diff
changeset
|
2110 | gaim_debug(GAIM_DEBUG_MISC, "yahoo", |
|
5216
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2111 | "Yahoo Service: 0x%02x Status: %d\n", |
|
13074c9a7ab0
[gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2112 | pkt->service, pkt->status); |
| 2681 | 2113 | pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4; |
| 2114 | ||
| 2115 | yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen); | |
| 2116 | ||
| 2117 | yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen; | |
| 2118 | if (yd->rxlen) { | |
| 2119 | char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen); | |
| 2120 | g_free(yd->rxqueue); | |
| 2121 | yd->rxqueue = tmp; | |
| 2122 | } else { | |
| 2123 | g_free(yd->rxqueue); | |
| 2124 | yd->rxqueue = NULL; | |
| 2125 | } | |
| 2126 | ||
| 2127 | yahoo_packet_process(gc, pkt); | |
| 2128 | ||
| 2129 | yahoo_packet_free(pkt); | |
| 2130 | } | |
| 2131 | } | |
| 2132 | ||
| 2133 | static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond) | |
| 2134 | { | |
| 5583 | 2135 | GaimConnection *gc = data; |
| 2681 | 2136 | struct yahoo_data *yd; |
| 2137 | struct yahoo_packet *pkt; | |
| 10400 | 2138 | |
|
5590
96f84b9aae41
[gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents:
5583
diff
changeset
|
2139 | if (!g_list_find(gaim_connections_get_all(), gc)) { |
| 2681 | 2140 | close(source); |
| 2141 | return; | |
| 2142 | } | |
| 2143 | ||
| 2144 | if (source < 0) { | |
| 8057 | 2145 | gaim_connection_error(gc, _("Unable to connect.")); |
| 2681 | 2146 | return; |
| 2147 | } | |
| 2148 | ||
| 2149 | yd = gc->proto_data; | |
| 2150 | yd->fd = source; | |
| 10400 | 2151 | |
| 3147 | 2152 | pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0); |
| 2681 | 2153 | |
| 10394 | 2154 | yahoo_packet_hash_str(pkt, 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc)))); |
| 10392 | 2155 | yahoo_packet_send_and_free(pkt, yd); |
| 2681 | 2156 | |
| 2157 | gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
| 2158 | } | |
| 9370 | 2159 | |
| 7134 | 2160 | static void yahoo_got_web_connected(gpointer data, gint source, GaimInputCondition cond) |
| 2161 | { | |
| 2162 | GaimConnection *gc = data; | |
| 2163 | struct yahoo_data *yd; | |
| 2164 | struct yahoo_packet *pkt; | |
| 2165 | ||
| 2166 | if (!g_list_find(gaim_connections_get_all(), gc)) { | |
| 2167 | close(source); | |
| 2168 | return; | |
| 2169 | } | |
| 2170 | ||
| 2171 | if (source < 0) { | |
| 8057 | 2172 | gaim_connection_error(gc, _("Unable to connect.")); |
| 7134 | 2173 | return; |
| 2174 | } | |
| 2175 | ||
| 2176 | yd = gc->proto_data; | |
| 2177 | yd->fd = source; | |
| 2178 | ||
| 2179 | pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0); | |
| 2180 | ||
| 10394 | 2181 | yahoo_packet_hash(pkt, "sss", 0, |
| 2182 | gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))), | |
| 2183 | 1, gaim_normalize(gc->account, gaim_account_get_username(gaim_connection_get_account(gc))), | |
| 2184 | 6, yd->auth); | |
| 10392 | 2185 | yahoo_packet_send_and_free(pkt, yd); |
| 2186 | ||
| 7134 | 2187 | g_free(yd->auth); |
| 2188 | gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc); | |
| 2189 | } | |
| 2190 | ||
| 2191 | static void yahoo_web_pending(gpointer data, gint source, GaimInputCondition cond) | |
| 2192 | { | |
| 2193 | GaimConnection *gc = data; | |
| 2194 | GaimAccount *account = gaim_connection_get_account(gc); | |
| 2195 | struct yahoo_data *yd = gc->proto_data; | |
| 8243 | 2196 | char buf[2048], *i = buf; |
| 8161 | 2197 | int len; |
| 2198 | GString *s; | |
| 7134 | 2199 | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
2200 | len = read(source, buf, sizeof(buf)-1); |
|
8216
9c4bc4d5a373
[gaim-migrate @ 8939]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
2201 | if (len <= 0 || (strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) && |
|
9c4bc4d5a373
[gaim-migrate @ 8939]
Christian Hammond <chipx86@chipx86.com>
parents:
8212
diff
changeset
|
2202 | strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) { |
| 7134 | 2203 | gaim_connection_error(gc, _("Unable to read")); |
| 2204 | return; | |
| 2205 | } | |
| 8161 | 2206 | |
| 2207 | s = g_string_sized_new(len); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
2208 | buf[sizeof(buf)-1] = '\0'; |
| 8161 | 2209 | |
| 2210 | while ((i = strstr(i, "Set-Cookie: "))) { | |
| 2211 | i += strlen("Set-Cookie: "); | |
| 8243 | 2212 | for (;*i != ';' && *i != '\0'; i++) |
| 8161 | 2213 | g_string_append_c(s, *i); |
| 2214 | ||
| 2215 | g_string_append(s, "; "); | |
| 7134 | 2216 | } |
| 8161 | 2217 | |
| 2218 | yd->auth = g_string_free(s, FALSE); | |
| 7134 | 2219 | gaim_input_remove(gc->inpa); |
| 2220 | close(source); | |
| 2221 | /* Now we have our cookies to login with. I'll go get the milk. */ | |
| 8045 | 2222 | if (gaim_proxy_connect(account, "wcs2.msg.dcn.yahoo.com", |
| 7134 | 2223 | gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), |
| 2224 | yahoo_got_web_connected, gc) != 0) { | |
| 2225 | gaim_connection_error(gc, _("Connection problem")); | |
| 2226 | return; | |
| 2227 | } | |
| 2228 | } | |
| 2229 | ||
| 2230 | static void yahoo_got_cookies(gpointer data, gint source, GaimInputCondition cond) | |
| 2231 | { | |
| 2232 | GaimConnection *gc = data; | |
| 2233 | struct yahoo_data *yd = gc->proto_data; | |
| 2234 | if (source < 0) { | |
| 8057 | 2235 | gaim_connection_error(gc, _("Unable to connect.")); |
| 7134 | 2236 | return; |
| 2237 | } | |
| 2238 | write(source, yd->auth, strlen(yd->auth)); | |
| 2239 | g_free(yd->auth); | |
| 2240 | gc->inpa = gaim_input_add(source, GAIM_INPUT_READ, yahoo_web_pending, gc); | |
| 2241 | } | |
| 2242 | ||
| 2243 | static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url) | |
| 2244 | { | |
| 2245 | if (!strcmp(key, "passwd")) | |
| 2246 | return; | |
| 2247 | url = g_string_append_c(url, '&'); | |
| 2248 | url = g_string_append(url, key); | |
| 2249 | url = g_string_append_c(url, '='); | |
| 2250 | if (!strcmp(key, ".save") || !strcmp(key, ".js")) | |
| 2251 | url = g_string_append_c(url, '1'); | |
| 2252 | else if (!strcmp(key, ".challenge")) | |
| 2253 | url = g_string_append(url, val); | |
| 2254 | else | |
| 2255 | url = g_string_append(url, gaim_url_encode(val)); | |
| 2256 | } | |
| 2257 | ||
| 2258 | static GHashTable *yahoo_login_page_hash(const char *buf, size_t len) | |
| 2259 | { | |
| 2260 | GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
|
7138
12b7979bce6e
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2261 | const char *c = buf; |
|
12b7979bce6e
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2262 | char *d; |
| 7134 | 2263 | char name[64], value[64]; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
2264 | int count = sizeof(name)-1; |
| 7134 | 2265 | while ((c < (buf + len)) && (c = strstr(c, "<input "))) { |
| 2266 | c = strstr(c, "name=\"") + strlen("name=\""); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
2267 | for (d = name; *c!='"' && count; c++, d++, count--) |
| 7134 | 2268 | *d = *c; |
| 2269 | *d = '\0'; | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
2270 | count = sizeof(value)-1; |
| 7134 | 2271 | d = strstr(c, "value=\"") + strlen("value=\""); |
| 2272 | if (strchr(c, '>') < d) | |
| 2273 | break; | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8113
diff
changeset
|
2274 | for (c = d, d = value; *c!='"' && count; c++, d++, count--) |
| 7134 | 2275 | *d = *c; |
| 2276 | *d = '\0'; | |
| 2277 | g_hash_table_insert(hash, g_strdup(name), g_strdup(value)); | |
| 2278 | } | |
| 2279 | return hash; | |
| 2280 | } | |
| 2281 | ||
|
7138
12b7979bce6e
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2282 | static void yahoo_login_page_cb(void *user_data, const char *buf, size_t len) |
| 7134 | 2283 | { |
|
7138
12b7979bce6e
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2284 | GaimConnection *gc = (GaimConnection *)user_data; |
| 7134 | 2285 | GaimAccount *account = gaim_connection_get_account(gc); |
| 2286 | struct yahoo_data *yd = gc->proto_data; | |
| 2287 | const char *sn = gaim_account_get_username(account); | |
|
10740
a1cb6b819a21
[gaim-migrate @ 12342]
Mark Doliner <markdoliner@pidgin.im>
parents:
10738
diff
changeset
|
2288 | const char *pass = gaim_connection_get_password(gc); |
| 7134 | 2289 | GHashTable *hash = yahoo_login_page_hash(buf, len); |
|
10575
f360d2dc8a1c
[gaim-migrate @ 11968]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10553
diff
changeset
|
2290 | GString *url = g_string_new("GET http://login.yahoo.com/config/login?login="); |
| 7134 | 2291 | char md5[33], *hashp = md5, *chal; |
| 2292 | int i; | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2293 | GaimCipher *cipher; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2294 | GaimCipherContext *context; |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2295 | guint8 digest[16]; |
|
7191
6c67ab87df26
[gaim-migrate @ 7760]
Herman Bloggs <herman@bluedigits.com>
parents:
7161
diff
changeset
|
2296 | |
|
6c67ab87df26
[gaim-migrate @ 7760]
Herman Bloggs <herman@bluedigits.com>
parents:
7161
diff
changeset
|
2297 | url = g_string_append(url, sn); |
|
6c67ab87df26
[gaim-migrate @ 7760]
Herman Bloggs <herman@bluedigits.com>
parents:
7161
diff
changeset
|
2298 | url = g_string_append(url, "&passwd="); |
|
6c67ab87df26
[gaim-migrate @ 7760]
Herman Bloggs <herman@bluedigits.com>
parents:
7161
diff
changeset
|
2299 | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2300 | cipher = gaim_ciphers_find_cipher("md5"); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2301 | context = gaim_cipher_context_new(cipher, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2302 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2303 | gaim_cipher_context_append(context, pass, strlen(pass)); |
| 10687 | 2304 | gaim_cipher_context_digest(context, sizeof(digest), digest, NULL); |
| 7134 | 2305 | for (i = 0; i < 16; ++i) { |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2306 | g_snprintf(hashp, 3, "%02x", digest[i]); |
| 7134 | 2307 | hashp += 2; |
| 2308 | } | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2309 | |
| 7134 | 2310 | chal = g_strconcat(md5, g_hash_table_lookup(hash, ".challenge"), NULL); |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2311 | gaim_cipher_context_reset(context, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2312 | gaim_cipher_context_append(context, chal, strlen(chal)); |
| 10687 | 2313 | gaim_cipher_context_digest(context, sizeof(digest), digest, NULL); |
| 7134 | 2314 | hashp = md5; |
| 2315 | for (i = 0; i < 16; ++i) { | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2316 | g_snprintf(hashp, 3, "%02x", digest[i]); |
| 7134 | 2317 | hashp += 2; |
| 2318 | } | |
| 2319 | /* | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2320 | * I dunno why this is here and commented out.. but in case it's needed |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2321 | * I updated it.. |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2322 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2323 | gaim_cipher_context_reset(context, NULL); |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2324 | gaim_cipher_context_append(context, md5, strlen(md5)); |
| 10687 | 2325 | gaim_cipher_context_digest(context, sizeof(digest), digest, NULL); |
| 7134 | 2326 | hashp = md5; |
| 2327 | for (i = 0; i < 16; ++i) { | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2328 | g_snprintf(hashp, 3, "%02x", digest[i]); |
| 7134 | 2329 | hashp += 2; |
| 2330 | } | |
| 2331 | */ | |
| 2332 | g_free(chal); | |
| 2333 | ||
| 2334 | url = g_string_append(url, md5); | |
|
7138
12b7979bce6e
[gaim-migrate @ 7705]
Christian Hammond <chipx86@chipx86.com>
parents:
7134
diff
changeset
|
2335 | g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url); |
| 7134 | 2336 | |
| 2337 | url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n" | |
| 2338 | "Host: login.yahoo.com\r\n\r\n"); | |
| 2339 | g_hash_table_destroy(hash); | |
| 2340 | yd->auth = g_string_free(url, FALSE); | |
| 2341 | if (gaim_proxy_connect(account, "login.yahoo.com", 80, yahoo_got_cookies, gc) != 0) { | |
| 2342 | gaim_connection_error(gc, _("Connection problem")); | |
| 2343 | return; | |
| 2344 | } | |
|
10684
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2345 | |
|
0325b164a7eb
[gaim-migrate @ 12231]
Luke Schierer <lschiere@pidgin.im>
parents:
10662
diff
changeset
|
2346 | gaim_cipher_context_destroy(context); |
| 7134 | 2347 | } |
| 2348 | ||
| 7883 | 2349 | static void yahoo_server_check(GaimAccount *account) |
| 2350 | { | |
| 2351 | const char *server; | |
| 2352 | ||
| 2353 | server = gaim_account_get_string(account, "server", YAHOO_PAGER_HOST); | |
| 2354 | ||
| 2355 | if (strcmp(server, "scs.yahoo.com") == 0) | |
| 2356 | gaim_account_set_string(account, "server", YAHOO_PAGER_HOST); | |
| 2357 | } | |
| 9306 | 2358 | |
| 2359 | static void yahoo_picture_check(GaimAccount *account) | |
| 2360 | { | |
| 2361 | GaimConnection *gc = gaim_account_get_connection(account); | |
| 2362 | const char *buddyicon; | |
| 2363 | ||
| 2364 | buddyicon = gaim_account_get_buddy_icon(account); | |
| 2365 | yahoo_set_buddy_icon(gc, buddyicon); | |
| 2366 | } | |
| 2367 | ||
| 7883 | 2368 | |
| 10400 | 2369 | static void yahoo_login(GaimAccount *account, GaimStatus *status) { |
| 5583 | 2370 | GaimConnection *gc = gaim_account_get_connection(account); |
| 2681 | 2371 | struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1); |
|
10401
51ae616ff395
[gaim-migrate @ 11638]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10400
diff
changeset
|
2372 | const char *id = gaim_status_get_id(status); |
| 9041 | 2373 | gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC; |
| 6629 | 2374 | |
| 5583 | 2375 | gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
| 2681 | 2376 | |
| 8235 | 2377 | gaim_connection_set_display_name(gc, gaim_account_get_username(account)); |
| 2378 | ||
| 2681 | 2379 | yd->fd = -1; |
| 6784 | 2380 | yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free); |
| 6729 | 2381 | yd->confs = NULL; |
| 2382 | yd->conf_id = 2; | |
| 10400 | 2383 | |
| 2384 | if (!strcmp(id, YAHOO_STATUS_TYPE_AVAILABLE) || !strcmp(id, YAHOO_STATUS_TYPE_ONLINE)) { | |
| 2385 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 2386 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_BRB)) { | |
| 2387 | yd->current_status = YAHOO_STATUS_BRB; | |
| 2388 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_BUSY)) { | |
| 2389 | yd->current_status = YAHOO_STATUS_BUSY; | |
| 2390 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTATHOME)) { | |
| 2391 | yd->current_status = YAHOO_STATUS_NOTATHOME; | |
| 2392 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTATDESK)) { | |
| 2393 | yd->current_status = YAHOO_STATUS_NOTATDESK; | |
| 2394 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTINOFFICE)) { | |
| 2395 | yd->current_status = YAHOO_STATUS_NOTINOFFICE; | |
| 2396 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_ONPHONE)) { | |
| 2397 | yd->current_status = YAHOO_STATUS_ONPHONE; | |
| 2398 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_ONVACATION)) { | |
| 2399 | yd->current_status = YAHOO_STATUS_ONVACATION; | |
| 2400 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_OUTTOLUNCH)) { | |
| 2401 | yd->current_status = YAHOO_STATUS_OUTTOLUNCH; | |
| 2402 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_STEPPEDOUT)) { | |
| 2403 | yd->current_status = YAHOO_STATUS_STEPPEDOUT; | |
| 2404 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_INVISIBLE)) { | |
| 2405 | yd->current_status = YAHOO_STATUS_INVISIBLE; | |
| 2406 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_AWAY)) { | |
| 2407 | yd->current_status = YAHOO_STATUS_CUSTOM; | |
| 2408 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_AVAILABLE_WM)) { | |
| 2409 | yd->current_status = YAHOO_STATUS_CUSTOM; | |
| 2410 | } else if (gc->is_idle) { /* i think this is broken */ | |
| 2411 | yd->current_status = YAHOO_STATUS_IDLE; | |
| 2412 | } else { | |
| 2413 | gaim_debug_error("yahoo", "Unexpected GaimStatus passed to yahoo_set_status!\n"); | |
| 2414 | yd->current_status = YAHOO_STATUS_AVAILABLE; | |
| 2415 | } | |
| 7883 | 2416 | yahoo_server_check(account); |
| 9306 | 2417 | yahoo_picture_check(account); |
| 7883 | 2418 | |
| 9164 | 2419 | if (gaim_account_get_bool(account, "yahoojp", FALSE)) { |
| 2420 | yd->jp = TRUE; | |
| 2421 | if (gaim_proxy_connect(account, | |
| 2422 | gaim_account_get_string(account, "serverjp", YAHOOJP_PAGER_HOST), | |
| 2423 | gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
| 2424 | yahoo_got_connected, gc) != 0) | |
| 2425 | { | |
| 2426 | gaim_connection_error(gc, _("Connection problem")); | |
| 2427 | return; | |
| 2428 | } | |
| 2429 | } else { | |
| 2430 | yd->jp = FALSE; | |
| 2431 | if (gaim_proxy_connect(account, | |
| 2432 | gaim_account_get_string(account, "server", YAHOO_PAGER_HOST), | |
| 2433 | gaim_account_get_int(account, "port", YAHOO_PAGER_PORT), | |
| 2434 | yahoo_got_connected, gc) != 0) | |
| 2435 | { | |
| 2436 | gaim_connection_error(gc, _("Connection problem")); | |
| 2437 | return; | |
| 2438 | } | |
| 2681 | 2439 | } |
| 9370 | 2440 | |
| 2681 | 2441 | |
| 2442 | } | |
| 2443 | ||
| 5583 | 2444 | static void yahoo_close(GaimConnection *gc) { |
| 2681 | 2445 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; |
| 9782 | 2446 | GSList *l; |
| 2447 | ||
| 2448 | for (l = yd->confs; l; l = l->next) { | |
| 2449 | GaimConversation *conv = l->data; | |
| 2450 | ||
| 2451 | yahoo_conf_leave(yd, gaim_conversation_get_name(conv), | |
| 2452 | gaim_connection_get_display_name(gc), | |
| 2453 | gaim_conv_chat_get_users(GAIM_CONV_CHAT(conv))); | |
| 2454 | } | |
| 2455 | g_slist_free(yd->confs); | |
| 6729 | 2456 | |
| 6784 | 2457 | g_hash_table_destroy(yd->friends); |
| 2458 | if (yd->chat_name) | |
| 2459 | g_free(yd->chat_name); | |
| 6729 | 2460 | |
| 7651 | 2461 | if (yd->cookie_y) |
| 2462 | g_free(yd->cookie_y); | |
| 2463 | if (yd->cookie_t) | |
| 2464 | g_free(yd->cookie_t); | |
| 2465 | ||
| 2681 | 2466 | if (yd->fd >= 0) |
| 2467 | close(yd->fd); | |
|
3720
dbba62e0d603
[gaim-migrate @ 3853]
Herman Bloggs <herman@bluedigits.com>
parents:
3642
diff
changeset
|
2468 | |
| 2681 | 2469 | if (yd->rxqueue) |
| 2470 | g_free(yd->rxqueue); | |
|
2687
664e22f507cf
[gaim-migrate @ 2700]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2686
diff
changeset
|
2471 | yd->rxlen = 0; |
| 9306 | 2472 | if (yd->picture_url) |
| 2473 | g_free(yd->picture_url); | |
| 2474 | if (yd->picture_upload_todo) | |
| 2475 | yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo); | |
| 9376 | 2476 | if (yd->ycht) |
| 2477 | ycht_connection_close(yd->ycht); | |
| 2681 | 2478 | if (gc->inpa) |
| 2479 | gaim_input_remove(gc->inpa); | |
| 2480 | g_free(yd); | |
| 2481 | } | |
| 2482 | ||
| 6695 | 2483 | static const char *yahoo_list_icon(GaimAccount *a, GaimBuddy *b) |
| 2681 | 2484 | { |
| 4687 | 2485 | return "yahoo"; |
| 2681 | 2486 | } |
| 4916 | 2487 | |
|
9972
f39adb92a177
[gaim-migrate @ 10883]
Mark Doliner <markdoliner@pidgin.im>
parents:
9943
diff
changeset
|
2488 | static void yahoo_list_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
| 4916 | 2489 | { |
| 2490 | int i = 0; | |
| 2491 | char *emblems[4] = {NULL,NULL,NULL,NULL}; | |
| 6784 | 2492 | GaimAccount *account; |
| 2493 | GaimConnection *gc; | |
| 2494 | struct yahoo_data *yd; | |
| 9278 | 2495 | YahooFriend *f; |
| 10126 | 2496 | GaimPresence *presence; |
| 2497 | GaimStatus *status; | |
| 2498 | const char *status_id; | |
| 6784 | 2499 | |
| 2500 | if (!b || !(account = b->account) || !(gc = gaim_account_get_connection(account)) || | |
| 2501 | !(yd = gc->proto_data)) | |
| 2502 | return; | |
| 2503 | ||
| 9279 | 2504 | f = yahoo_friend_find(gc, b->name); |
| 6784 | 2505 | if (!f) { |
| 2506 | *se = "notauthorized"; | |
| 2507 | return; | |
| 2508 | } | |
| 2509 | ||
| 10126 | 2510 | presence = gaim_buddy_get_presence(b); |
| 2511 | status = gaim_presence_get_active_status(presence); | |
| 2512 | status_id = gaim_status_get_id(status); | |
| 2513 | ||
| 2514 | if (gaim_presence_is_online(presence) == FALSE) { | |
| 4916 | 2515 | *se = "offline"; |
| 2516 | return; | |
| 2517 | } else { | |
| 6784 | 2518 | if (f->away) |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2519 | emblems[i++] = "away"; |
| 6784 | 2520 | if (f->sms) |
| 2521 | emblems[i++] = "wireless"; | |
| 9283 | 2522 | if (yahoo_friend_get_game(f)) |
| 4916 | 2523 | emblems[i++] = "game"; |
| 2524 | } | |
| 2525 | *se = emblems[0]; | |
| 2526 | *sw = emblems[1]; | |
| 2527 | *nw = emblems[2]; | |
| 2528 | *ne = emblems[3]; | |
| 2529 | } | |
| 2681 | 2530 | |
| 2531 | static char *yahoo_get_status_string(enum yahoo_status a) | |
| 2532 | { | |
| 2533 | switch (a) { | |
| 2534 | case YAHOO_STATUS_BRB: | |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2535 | return _("Be Right Back"); |
| 2681 | 2536 | case YAHOO_STATUS_BUSY: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2537 | return _("Busy"); |
| 2681 | 2538 | case YAHOO_STATUS_NOTATHOME: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2539 | return _("Not At Home"); |
| 2681 | 2540 | case YAHOO_STATUS_NOTATDESK: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2541 | return _("Not At Desk"); |
| 2681 | 2542 | case YAHOO_STATUS_NOTINOFFICE: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2543 | return _("Not In Office"); |
| 2681 | 2544 | case YAHOO_STATUS_ONPHONE: |
| 4606 | 2545 | return _("On The Phone"); |
| 2681 | 2546 | case YAHOO_STATUS_ONVACATION: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2547 | return _("On Vacation"); |
| 2681 | 2548 | case YAHOO_STATUS_OUTTOLUNCH: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2549 | return _("Out To Lunch"); |
| 2681 | 2550 | case YAHOO_STATUS_STEPPEDOUT: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2551 | return _("Stepped Out"); |
|
2873
9e56887eeb06
[gaim-migrate @ 2886]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2856
diff
changeset
|
2552 | case YAHOO_STATUS_INVISIBLE: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2553 | return _("Invisible"); |
| 4730 | 2554 | case YAHOO_STATUS_IDLE: |
| 2555 | return _("Idle"); | |
| 6784 | 2556 | case YAHOO_STATUS_OFFLINE: |
| 2557 | return _("Offline"); | |
|
2879
e417cf7111c4
[gaim-migrate @ 2892]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2878
diff
changeset
|
2558 | default: |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4491
diff
changeset
|
2559 | return _("Online"); |
| 2681 | 2560 | } |
| 2561 | } | |
| 2562 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2563 | static void yahoo_initiate_conference(GaimBlistNode *node, gpointer data) { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2564 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2565 | GaimBuddy *buddy; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2566 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2567 | |
| 6729 | 2568 | GHashTable *components; |
| 2569 | struct yahoo_data *yd; | |
| 2570 | int id; | |
| 2571 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2572 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2573 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2574 | buddy = (GaimBuddy *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2575 | gc = gaim_account_get_connection(buddy->account); |
| 6729 | 2576 | yd = gc->proto_data; |
| 2577 | id = yd->conf_id; | |
| 2578 | ||
| 2579 | components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 2580 | g_hash_table_replace(components, g_strdup("room"), | |
| 2581 | g_strdup_printf("%s-%d", gaim_connection_get_display_name(gc), id)); | |
| 2582 | g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference...")); | |
| 2583 | g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference")); | |
| 2584 | yahoo_c_join(gc, components); | |
| 2585 | g_hash_table_destroy(components); | |
| 2586 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2587 | yahoo_c_invite(gc, id, "Join my conference...", buddy->name); |
| 6729 | 2588 | } |
| 2589 | ||
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2590 | static void yahoo_stealth_settings(GaimBlistNode *node, gpointer data) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2591 | GaimBuddy *buddy; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2592 | GaimConnection *gc; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2593 | int stealth_val = GPOINTER_TO_INT(data); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2594 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2595 | buddy = (GaimBuddy *) node; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2596 | gc = gaim_account_get_connection(buddy->account); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2597 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2598 | yahoo_friend_update_stealth(gc, buddy->name, stealth_val); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2599 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2600 | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2601 | static void yahoo_game(GaimBlistNode *node, gpointer data) { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2602 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2603 | GaimBuddy *buddy; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2604 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2605 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2606 | struct yahoo_data *yd; |
| 9283 | 2607 | const char *game; |
| 2608 | char *game2; | |
| 3019 | 2609 | char *t; |
| 2610 | char url[256]; | |
| 9278 | 2611 | YahooFriend *f; |
| 3019 | 2612 | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2613 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2614 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2615 | buddy = (GaimBuddy *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2616 | gc = gaim_account_get_connection(buddy->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2617 | yd = (struct yahoo_data *) gc->proto_data; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2618 | |
| 9279 | 2619 | f = yahoo_friend_find(gc, buddy->name); |
| 6784 | 2620 | if (!f) |
| 2621 | return; | |
| 2622 | ||
| 9283 | 2623 | game = yahoo_friend_get_game(f); |
| 3019 | 2624 | if (!game) |
| 2625 | return; | |
| 6784 | 2626 | |
| 9283 | 2627 | t = game2 = g_strdup(strstr(game, "ante?room=")); |
| 2628 | while (*t && *t != '\t') | |
| 3019 | 2629 | t++; |
| 2630 | *t = 0; | |
| 9283 | 2631 | g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game2); |
|
10240
09342bc554d9
[gaim-migrate @ 11377]
Herman Bloggs <herman@bluedigits.com>
parents:
10209
diff
changeset
|
2632 | gaim_notify_uri(gc, url); |
| 9283 | 2633 | g_free(game2); |
| 3019 | 2634 | } |
| 4722 | 2635 | |
| 6695 | 2636 | static char *yahoo_status_text(GaimBuddy *b) |
| 4722 | 2637 | { |
| 9278 | 2638 | YahooFriend *f = NULL; |
| 9283 | 2639 | const char *msg; |
|
6691
fecdc585c292
[gaim-migrate @ 7217]
Christian Hammond <chipx86@chipx86.com>
parents:
6687
diff
changeset
|
2640 | |
| 9279 | 2641 | f = yahoo_friend_find(b->account->gc, b->name); |
| 6784 | 2642 | if (!f) |
| 2643 | return g_strdup(_("Not on server list")); | |
| 2644 | ||
| 2645 | switch (f->status) { | |
| 2646 | case YAHOO_STATUS_AVAILABLE: | |
| 2647 | return NULL; | |
| 2648 | case YAHOO_STATUS_IDLE: | |
| 2649 | if (f->idle == -1) | |
| 2650 | return g_strdup(yahoo_get_status_string(f->status)); | |
| 2651 | return NULL; | |
| 2652 | case YAHOO_STATUS_CUSTOM: | |
| 9283 | 2653 | if (!(msg = yahoo_friend_get_status_message(f))) |
| 6784 | 2654 | return NULL; |
| 9283 | 2655 | return g_markup_escape_text(msg, strlen(msg)); |
| 9224 | 2656 | |
| 6784 | 2657 | default: |
| 2658 | return g_strdup(yahoo_get_status_string(f->status)); | |
| 2659 | } | |
| 4722 | 2660 | } |
| 2661 | ||
| 9220 | 2662 | char *yahoo_tooltip_text(GaimBuddy *b) |
| 4724 | 2663 | { |
| 9278 | 2664 | YahooFriend *f; |
|
10992
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2665 | char *escaped, *status = NULL, *stealth = NULL; |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2666 | GString *s = g_string_new(""); |
| 6784 | 2667 | |
| 9279 | 2668 | f = yahoo_friend_find(b->account->gc, b->name); |
| 6784 | 2669 | if (!f) |
|
8591
ae42ad1cd127
[gaim-migrate @ 9342]
Mark Doliner <markdoliner@pidgin.im>
parents:
8589
diff
changeset
|
2670 | status = g_strdup_printf("\n%s", _("Not on server list")); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2671 | else { |
| 6784 | 2672 | switch (f->status) { |
| 2673 | case YAHOO_STATUS_IDLE: | |
| 2674 | if (f->idle == -1) { | |
| 2675 | status = g_strdup(yahoo_get_status_string(f->status)); | |
| 2676 | break; | |
| 2677 | } | |
| 2678 | return NULL; | |
| 2679 | case YAHOO_STATUS_CUSTOM: | |
| 9283 | 2680 | if (!yahoo_friend_get_status_message(f)) |
| 6784 | 2681 | return NULL; |
| 9283 | 2682 | status = g_strdup(yahoo_friend_get_status_message(f)); |
| 6784 | 2683 | break; |
|
10992
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2684 | case YAHOO_STATUS_OFFLINE: |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2685 | break; |
| 6784 | 2686 | default: |
| 2687 | status = g_strdup(yahoo_get_status_string(f->status)); | |
| 2688 | break; | |
| 4745 | 2689 | } |
| 6784 | 2690 | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2691 | switch (f->stealth) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2692 | case YAHOO_STEALTH_ONLINE: |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2693 | stealth = _("Appear Online"); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2694 | break; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2695 | case YAHOO_STEALTH_PERM_OFFLINE: |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2696 | stealth = _("Appear Permanently Offline"); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2697 | break; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2698 | case YAHOO_STEALTH_DEFAULT: |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2699 | default: |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2700 | stealth = _("None"); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2701 | break; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2702 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2703 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2704 | |
|
10992
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2705 | if (status != NULL) { |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2706 | escaped = g_markup_escape_text(status, strlen(status)); |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2707 | g_string_append_printf(s, _("\n<b>%s:</b> %s"), _("Status"), escaped); |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2708 | g_free(status); |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2709 | g_free(escaped); |
|
ccf59743dae4
[gaim-migrate @ 12830]
Daniel Atallah <datallah@pidgin.im>
parents:
10989
diff
changeset
|
2710 | } |
| 6784 | 2711 | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2712 | if (stealth != NULL) |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2713 | g_string_append_printf(s, _("\n<b>%s:</b> %s"), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2714 | _("Stealth"), stealth); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2715 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2716 | return g_string_free(s, FALSE); |
| 4729 | 2717 | } |
| 2718 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2719 | static void yahoo_addbuddyfrommenu_cb(GaimBlistNode *node, gpointer data) |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2720 | { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2721 | GaimBuddy *buddy; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2722 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2723 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2724 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2725 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2726 | buddy = (GaimBuddy *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2727 | gc = gaim_account_get_connection(buddy->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2728 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
2729 | yahoo_add_buddy(gc, buddy, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2730 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2731 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2732 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2733 | static void yahoo_chat_goto_menu(GaimBlistNode *node, gpointer data) |
| 6796 | 2734 | { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2735 | GaimBuddy *buddy; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2736 | GaimConnection *gc; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2737 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2738 | g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node)); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2739 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2740 | buddy = (GaimBuddy *) node; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2741 | gc = gaim_account_get_connection(buddy->account); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2742 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2743 | yahoo_chat_goto(gc, buddy->name); |
| 6796 | 2744 | } |
| 2745 | ||
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2746 | static GList *build_stealth_submenu(YahooFriend *f, GaimConnection *gc) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2747 | GList *m = NULL; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2748 | GaimBlistNodeAction *act; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2749 | struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2750 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2751 | if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2752 | if (f->stealth != YAHOO_STEALTH_ONLINE) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2753 | act = gaim_blist_node_action_new(_("Appear Online"), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2754 | yahoo_stealth_settings, |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2755 | GINT_TO_POINTER(YAHOO_STEALTH_ONLINE), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2756 | NULL); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2757 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2758 | } else if (f->stealth != YAHOO_STEALTH_DEFAULT) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2759 | act = gaim_blist_node_action_new(_("Appear Offline"), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2760 | yahoo_stealth_settings, |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2761 | GINT_TO_POINTER(YAHOO_STEALTH_DEFAULT), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2762 | NULL); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2763 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2764 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2765 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2766 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2767 | if (f->stealth == YAHOO_STEALTH_PERM_OFFLINE) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2768 | act = gaim_blist_node_action_new( |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2769 | _("Don't Appear Permanently Offline"), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2770 | yahoo_stealth_settings, |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2771 | GINT_TO_POINTER(YAHOO_STEALTH_DEFAULT), NULL); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2772 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2773 | } else { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2774 | act = gaim_blist_node_action_new( |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2775 | _("Appear Permanently Offline"), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2776 | yahoo_stealth_settings, |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2777 | GINT_TO_POINTER(YAHOO_STEALTH_PERM_OFFLINE), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2778 | NULL); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2779 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2780 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2781 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2782 | return m; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2783 | } |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2784 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2785 | static GList *yahoo_buddy_menu(GaimBuddy *buddy) |
| 2681 | 2786 | { |
| 2787 | GList *m = NULL; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2788 | GaimBlistNodeAction *act; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2789 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2790 | GaimConnection *gc = gaim_account_get_connection(buddy->account); |
| 9370 | 2791 | struct yahoo_data *yd = gc->proto_data; |
| 3019 | 2792 | static char buf2[1024]; |
| 9278 | 2793 | YahooFriend *f; |
| 6784 | 2794 | |
| 9279 | 2795 | f = yahoo_friend_find(gc, buddy->name); |
| 6784 | 2796 | |
| 9370 | 2797 | if (!f && !yd->wm) { |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2798 | act = gaim_blist_node_action_new(_("Add Buddy"), |
| 10662 | 2799 | yahoo_addbuddyfrommenu_cb, NULL, NULL); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2800 | m = g_list_append(m, act); |
| 6784 | 2801 | |
| 2802 | return m; | |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2803 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2804 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2805 | |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2806 | if (f && f->status != YAHOO_STATUS_OFFLINE) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2807 | if (!yd->wm) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2808 | act = gaim_blist_node_action_new(_("Join in Chat"), |
| 10662 | 2809 | yahoo_chat_goto_menu, NULL, NULL); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2810 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2811 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2812 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2813 | act = gaim_blist_node_action_new(_("Initiate Conference"), |
| 10662 | 2814 | yahoo_initiate_conference, NULL, NULL); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2815 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2816 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2817 | if (yahoo_friend_get_game(f)) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2818 | const char *game = yahoo_friend_get_game(f); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2819 | char *room; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2820 | char *t; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2821 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2822 | if ((room = strstr(game, "&follow="))) {/* skip ahead to the url */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2823 | while (*room && *room != '\t') /* skip to the tab */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2824 | room++; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2825 | t = room++; /* room as now at the name */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2826 | while (*t != '\n') |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2827 | t++; /* replace the \n with a space */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2828 | *t = ' '; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2829 | g_snprintf(buf2, sizeof buf2, "%s", room); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2830 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2831 | act = gaim_blist_node_action_new(buf2, yahoo_game, NULL, NULL); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2832 | m = g_list_append(m, act); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2833 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2834 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2835 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2836 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2837 | if (f) { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2838 | act = gaim_blist_node_action_new(_("Stealth Settings"), |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2839 | NULL, NULL, build_stealth_submenu(f, gc)); |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2840 | m = g_list_append(m, act); |
| 3019 | 2841 | } |
| 6729 | 2842 | |
| 2681 | 2843 | return m; |
| 2844 | } | |
| 2845 | ||
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2846 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2847 | static GList *yahoo_blist_node_menu(GaimBlistNode *node) |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2848 | { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2849 | if(GAIM_BLIST_NODE_IS_BUDDY(node)) { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2850 | return yahoo_buddy_menu((GaimBuddy *) node); |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2851 | } else { |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2852 | return NULL; |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2853 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2854 | } |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2855 | |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
2856 | |
| 5583 | 2857 | static void yahoo_act_id(GaimConnection *gc, const char *entry) |
| 2681 | 2858 | { |
| 2859 | struct yahoo_data *yd = gc->proto_data; | |
| 2860 | ||
| 2861 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 2862 | yahoo_packet_hash_str(pkt, 3, entry); |
| 10392 | 2863 | yahoo_packet_send_and_free(pkt, yd); |
| 2681 | 2864 | |
| 5583 | 2865 | gaim_connection_set_display_name(gc, entry); |
| 2681 | 2866 | } |
| 2867 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2868 | static void yahoo_show_act_id(GaimPluginAction *action) |
| 2681 | 2869 | { |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2870 | GaimConnection *gc = (GaimConnection *) action->context; |
|
5493
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2871 | gaim_request_input(gc, NULL, _("Active which ID?"), NULL, |
| 8697 | 2872 | gaim_connection_get_display_name(gc), FALSE, FALSE, NULL, |
|
5493
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2873 | _("OK"), G_CALLBACK(yahoo_act_id), |
|
f30de3b116ea
[gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents:
5436
diff
changeset
|
2874 | _("Cancel"), NULL, gc); |
| 2681 | 2875 | } |
| 2876 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2877 | static void yahoo_show_chat_goto(GaimPluginAction *action) |
| 7878 | 2878 | { |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2879 | GaimConnection *gc = (GaimConnection *) action->context; |
| 7878 | 2880 | gaim_request_input(gc, NULL, _("Join who in chat?"), NULL, |
| 8697 | 2881 | "", FALSE, FALSE, NULL, |
| 7878 | 2882 | _("OK"), G_CALLBACK(yahoo_chat_goto), |
| 2883 | _("Cancel"), NULL, gc); | |
| 2884 | } | |
| 2885 | ||
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2886 | static GList *yahoo_actions(GaimPlugin *plugin, gpointer context) { |
| 2681 | 2887 | GList *m = NULL; |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2888 | GaimPluginAction *act; |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2889 | |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2890 | act = gaim_plugin_action_new(_("Activate ID..."), |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2891 | yahoo_show_act_id); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2892 | m = g_list_append(m, act); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2893 | |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2894 | act = gaim_plugin_action_new(_("Join user in chat..."), |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2895 | yahoo_show_chat_goto); |
|
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
2896 | m = g_list_append(m, act); |
| 7878 | 2897 | |
| 2681 | 2898 | return m; |
| 2899 | } | |
| 2900 | ||
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7112
diff
changeset
|
2901 | static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, GaimConvImFlags flags) |
| 2681 | 2902 | { |
| 2903 | struct yahoo_data *yd = gc->proto_data; | |
| 2904 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0); | |
| 6629 | 2905 | char *msg = yahoo_html_to_codes(what); |
| 7827 | 2906 | char *msg2; |
| 2907 | gboolean utf8 = TRUE; | |
| 9828 | 2908 | int ret = 1; |
| 7827 | 2909 | |
| 2910 | msg2 = yahoo_string_encode(gc, msg, &utf8); | |
| 2681 | 2911 | |
| 10394 | 2912 | yahoo_packet_hash(pkt, "ss", 1, gaim_connection_get_display_name(gc), 5, who); |
| 7827 | 2913 | if (utf8) |
| 10394 | 2914 | yahoo_packet_hash_str(pkt, 97, "1"); |
| 2915 | yahoo_packet_hash_str(pkt, 14, msg2); | |
| 2916 | ||
| 2917 | yahoo_packet_hash_str(pkt, 63, ";0"); /* IMvironment */ | |
| 2918 | yahoo_packet_hash_str(pkt, 64, "0"); /* no idea */ | |
| 2919 | yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */ | |
| 9306 | 2920 | if (!yd->picture_url) |
| 10394 | 2921 | yahoo_packet_hash_str(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */ |
| 9306 | 2922 | else |
| 10394 | 2923 | yahoo_packet_hash_str(pkt, 206, "2"); |
| 2681 | 2924 | |
| 9828 | 2925 | /* We may need to not send any packets over 2000 bytes, but I'm not sure yet. */ |
| 2926 | if ((YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt)) <= 2000) | |
| 10392 | 2927 | yahoo_packet_send(pkt, yd); |
| 9828 | 2928 | else |
| 2929 | ret = -E2BIG; | |
| 2681 | 2930 | |
| 2931 | yahoo_packet_free(pkt); | |
| 6629 | 2932 | |
| 2933 | g_free(msg); | |
| 7827 | 2934 | g_free(msg2); |
| 6629 | 2935 | |
| 9828 | 2936 | return ret; |
| 2681 | 2937 | } |
| 2938 | ||
|
6059
9934c862ca14
[gaim-migrate @ 6509]
John Silvestri <john.silvestri@gmail.com>
parents:
6044
diff
changeset
|
2939 | int yahoo_send_typing(GaimConnection *gc, const char *who, int typ) |
| 2993 | 2940 | { |
| 2941 | struct yahoo_data *yd = gc->proto_data; | |
| 3019 | 2942 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0); |
| 10394 | 2943 | yahoo_packet_hash(pkt, "ssssss", 49, "TYPING", 1, gaim_connection_get_display_name(gc), |
| 2944 | 14, " ", 13, typ == GAIM_TYPING ? "1" : "0", | |
| 2945 | 5, who, 1002, "1"); | |
| 2993 | 2946 | |
| 10392 | 2947 | yahoo_packet_send_and_free(pkt, yd); |
| 2993 | 2948 | |
| 3001 | 2949 | return 0; |
| 2993 | 2950 | } |
| 2951 | ||
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2952 | static void yahoo_session_stealth_remove(gpointer key, gpointer value, gpointer data) |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2953 | { |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2954 | YahooFriend *f = value; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2955 | if (f && f->stealth == YAHOO_STEALTH_ONLINE) |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2956 | f->stealth = YAHOO_STEALTH_DEFAULT; |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2957 | } |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
2958 | |
| 9984 | 2959 | static void yahoo_set_status(GaimAccount *account, GaimStatus *status) |
| 2681 | 2960 | { |
| 9984 | 2961 | GaimConnection *gc = gaim_account_get_connection(account); |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
2962 | gboolean connected = gaim_account_is_connected(account); |
| 10400 | 2963 | struct yahoo_data *yd; |
| 2681 | 2964 | struct yahoo_packet *pkt; |
| 10400 | 2965 | int old_status; |
| 9984 | 2966 | const char *id; |
| 7827 | 2967 | char *conv_msg = NULL; |
| 8503 | 2968 | char *conv_msg2 = NULL; |
| 9984 | 2969 | |
| 2970 | id = gaim_status_get_id(status); | |
| 10400 | 2971 | if (!gaim_status_is_active(status)) |
| 2972 | return; | |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
2973 | if (strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && !connected) { |
|
10738
63ca8277c234
[gaim-migrate @ 12340]
Mark Doliner <markdoliner@pidgin.im>
parents:
10732
diff
changeset
|
2974 | gaim_account_connect(account); |
| 10400 | 2975 | return; |
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
2976 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_OFFLINE) && connected) { |
| 10400 | 2977 | gaim_account_disconnect(account); |
| 2978 | return; | |
| 2979 | } | |
| 2980 | ||
|
10755
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
2981 | if (!connected) |
|
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
2982 | return; |
|
a336a5d3102d
[gaim-migrate @ 12358]
Mark Doliner <markdoliner@pidgin.im>
parents:
10751
diff
changeset
|
2983 | |
| 10400 | 2984 | yd = (struct yahoo_data *)gc->proto_data; |
| 2985 | old_status = yd->current_status; | |
| 9984 | 2986 | |
| 10373 | 2987 | if (!strcmp(id, YAHOO_STATUS_TYPE_AVAILABLE)) { |
| 9984 | 2988 | yd->current_status = YAHOO_STATUS_AVAILABLE; |
| 10373 | 2989 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_BRB)) { |
| 9984 | 2990 | yd->current_status = YAHOO_STATUS_BRB; |
| 10373 | 2991 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_BUSY)) { |
| 9984 | 2992 | yd->current_status = YAHOO_STATUS_BUSY; |
| 10373 | 2993 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTATHOME)) { |
| 9984 | 2994 | yd->current_status = YAHOO_STATUS_NOTATHOME; |
| 10373 | 2995 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTATDESK)) { |
| 9984 | 2996 | yd->current_status = YAHOO_STATUS_NOTATDESK; |
| 10373 | 2997 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_NOTINOFFICE)) { |
| 9984 | 2998 | yd->current_status = YAHOO_STATUS_NOTINOFFICE; |
| 10373 | 2999 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_ONPHONE)) { |
| 9984 | 3000 | yd->current_status = YAHOO_STATUS_ONPHONE; |
| 10373 | 3001 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_ONVACATION)) { |
| 9984 | 3002 | yd->current_status = YAHOO_STATUS_ONVACATION; |
| 10373 | 3003 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_OUTTOLUNCH)) { |
| 9984 | 3004 | yd->current_status = YAHOO_STATUS_OUTTOLUNCH; |
| 10373 | 3005 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_STEPPEDOUT)) { |
| 9984 | 3006 | yd->current_status = YAHOO_STATUS_STEPPEDOUT; |
| 10373 | 3007 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_INVISIBLE)) { |
| 9984 | 3008 | yd->current_status = YAHOO_STATUS_INVISIBLE; |
| 10373 | 3009 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_AWAY)) { |
| 2681 | 3010 | yd->current_status = YAHOO_STATUS_CUSTOM; |
| 10373 | 3011 | } else if (!strcmp(id, YAHOO_STATUS_TYPE_AVAILABLE_WM)) { |
| 9984 | 3012 | yd->current_status = YAHOO_STATUS_CUSTOM; |
| 3013 | } else if (gc->is_idle) { /* i think this is broken */ | |
| 2681 | 3014 | yd->current_status = YAHOO_STATUS_IDLE; |
| 3015 | } else { | |
| 10400 | 3016 | gaim_debug_error("yahoo", "Unexpected GaimStatus passed to yahoo_login!\n"); |
| 2681 | 3017 | yd->current_status = YAHOO_STATUS_AVAILABLE; |
| 3018 | } | |
| 3019 | ||
| 10373 | 3020 | if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
| 3021 | pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3022 | yahoo_packet_hash_str(pkt, 13, "2"); |
| 10392 | 3023 | yahoo_packet_send_and_free(pkt, yd); |
| 10373 | 3024 | |
| 3025 | return; | |
| 3026 | } | |
| 3027 | ||
| 3028 | pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3029 | yahoo_packet_hash_int(pkt, 10, yd->current_status); |
| 6847 | 3030 | |
| 9984 | 3031 | if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
| 3032 | const char *msg = gaim_status_get_attr_string(status, "message"); | |
|
10195
18379f7920fa
[gaim-migrate @ 11310]
Mark Doliner <markdoliner@pidgin.im>
parents:
10143
diff
changeset
|
3033 | |
|
18379f7920fa
[gaim-migrate @ 11310]
Mark Doliner <markdoliner@pidgin.im>
parents:
10143
diff
changeset
|
3034 | if (msg == NULL) { |
|
18379f7920fa
[gaim-migrate @ 11310]
Mark Doliner <markdoliner@pidgin.im>
parents:
10143
diff
changeset
|
3035 | gaim_debug_info("yahoo", "Attempted to set a NULL status message.\n"); |
|
18379f7920fa
[gaim-migrate @ 11310]
Mark Doliner <markdoliner@pidgin.im>
parents:
10143
diff
changeset
|
3036 | msg = ""; |
|
18379f7920fa
[gaim-migrate @ 11310]
Mark Doliner <markdoliner@pidgin.im>
parents:
10143
diff
changeset
|
3037 | } |
|
18379f7920fa
[gaim-migrate @ 11310]
Mark Doliner <markdoliner@pidgin.im>
parents:
10143
diff
changeset
|
3038 | |
| 9984 | 3039 | conv_msg = yahoo_string_encode(gc, msg, NULL); |
| 3040 | conv_msg2 = gaim_markup_strip_html(conv_msg); | |
| 10394 | 3041 | yahoo_packet_hash_str(pkt, 19, conv_msg2); |
| 9984 | 3042 | |
| 10373 | 3043 | } else { |
| 10394 | 3044 | yahoo_packet_hash_str(pkt, 19, ""); |
| 10373 | 3045 | } |
| 3046 | ||
| 3047 | if (gc->is_idle) | |
| 10394 | 3048 | yahoo_packet_hash_str(pkt, 47, "2"); |
| 10373 | 3049 | else if (!gaim_status_type_is_available(gaim_status_get_type(status))) |
| 10394 | 3050 | yahoo_packet_hash_str(pkt, 47, "1"); |
| 2681 | 3051 | |
| 10392 | 3052 | yahoo_packet_send_and_free(pkt, yd); |
| 9984 | 3053 | |
| 3054 | g_free(conv_msg); | |
| 3055 | g_free(conv_msg2); | |
| 10373 | 3056 | |
| 3057 | if (old_status == YAHOO_STATUS_INVISIBLE) { | |
| 3058 | pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3059 | yahoo_packet_hash_str(pkt, 13, "1"); |
| 10392 | 3060 | yahoo_packet_send_and_free(pkt, yd); |
|
10989
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3061 | |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3062 | /* Any per-session stealth settings are removed */ |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3063 | g_hash_table_foreach(yd->friends, yahoo_session_stealth_remove, NULL); |
|
ea41b63cfea5
[gaim-migrate @ 12827]
Daniel Atallah <datallah@pidgin.im>
parents:
10963
diff
changeset
|
3064 | |
| 10373 | 3065 | } |
| 2681 | 3066 | } |
| 3067 | ||
| 5583 | 3068 | static void yahoo_set_idle(GaimConnection *gc, int idle) |
| 2681 | 3069 | { |
| 3070 | struct yahoo_data *yd = gc->proto_data; | |
| 3071 | struct yahoo_packet *pkt = NULL; | |
| 8503 | 3072 | char *msg = NULL, *msg2 = NULL; |
| 10373 | 3073 | |
| 3074 | if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) | |
| 2681 | 3075 | yd->current_status = YAHOO_STATUS_IDLE; |
| 10373 | 3076 | else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) |
| 2681 | 3077 | yd->current_status = YAHOO_STATUS_AVAILABLE; |
| 10373 | 3078 | |
| 3079 | ||
| 3080 | pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0); | |
| 3081 | ||
| 10394 | 3082 | yahoo_packet_hash_int(pkt, 10, yd->current_status); |
| 10373 | 3083 | if (yd->current_status == YAHOO_STATUS_CUSTOM) { |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3084 | const char *tmp; |
| 10373 | 3085 | GaimStatus *status = gaim_presence_get_active_status(gaim_account_get_presence(gaim_connection_get_account(gc))); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3086 | tmp = gaim_status_get_attr_string(status, "message"); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3087 | if (tmp != NULL) { |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3088 | msg = yahoo_string_encode(gc, tmp, NULL); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3089 | msg2 = gaim_unescape_html(msg); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3090 | yahoo_packet_hash_str(pkt, 19, msg2); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3091 | } else { |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3092 | yahoo_packet_hash_str(pkt, 19, ""); |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10401
diff
changeset
|
3093 | } |
| 6847 | 3094 | } else { |
| 10394 | 3095 | yahoo_packet_hash_str(pkt, 19, ""); |
| 2681 | 3096 | } |
| 3097 | ||
| 10373 | 3098 | if (idle) |
| 10394 | 3099 | yahoo_packet_hash_str(pkt, 47, "2"); |
| 10373 | 3100 | else if (!gaim_presence_is_available(gaim_account_get_presence(gaim_connection_get_account(gc)))) |
| 10394 | 3101 | yahoo_packet_hash_str(pkt, 47, "1"); |
| 10373 | 3102 | |
| 3103 | ||
| 10392 | 3104 | yahoo_packet_send_and_free(pkt, yd); |
| 10373 | 3105 | |
| 3106 | g_free(msg); | |
| 3107 | g_free(msg2); | |
| 2681 | 3108 | } |
| 3109 | ||
| 9979 | 3110 | static GList *yahoo_status_types(GaimAccount *account) |
| 2681 | 3111 | { |
| 9979 | 3112 | GaimConnection *gc = gaim_account_get_connection(account); |
| 3113 | struct yahoo_data *yd = NULL; | |
| 3114 | GaimStatusType *type; | |
| 3115 | GList *types = NULL; | |
| 3116 | ||
| 3117 | if (gc) | |
| 3118 | yd = gc->proto_data; | |
| 3119 | ||
| 10400 | 3120 | type = gaim_status_type_new(GAIM_STATUS_OFFLINE, YAHOO_STATUS_TYPE_OFFLINE, _("Offline"), TRUE); |
| 9979 | 3121 | types = g_list_append(types, type); |
| 3122 | ||
| 10400 | 3123 | type = gaim_status_type_new(GAIM_STATUS_ONLINE, YAHOO_STATUS_TYPE_ONLINE, _("Online"), TRUE); |
| 9979 | 3124 | types = g_list_append(types, type); |
| 3125 | ||
| 10373 | 3126 | type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, YAHOO_STATUS_TYPE_AVAILABLE, _("Available"), TRUE); |
| 9979 | 3127 | types = g_list_append(types, type); |
| 3128 | ||
| 3129 | if (!yd || !yd->wm) { | |
| 10373 | 3130 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, YAHOO_STATUS_TYPE_AVAILABLE_WM, |
| 9979 | 3131 | "Available With Message", TRUE, TRUE, FALSE, |
| 3132 | "message", _("Message"), | |
|
10009
8a4fcc043f47
[gaim-migrate @ 10926]
Mark Doliner <markdoliner@pidgin.im>
parents:
9984
diff
changeset
|
3133 | gaim_value_new(GAIM_TYPE_STRING), NULL); |
| 9979 | 3134 | types = g_list_append(types, type); |
| 3135 | ||
| 3136 | ||
| 10373 | 3137 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_BRB, _("Be Right Back"), TRUE); |
| 9979 | 3138 | types = g_list_append(types, type); |
| 3139 | ||
| 10373 | 3140 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_BUSY, _("Busy"), TRUE); |
| 9979 | 3141 | types = g_list_append(types, type); |
| 3142 | ||
| 10373 | 3143 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTATHOME, _("Not At Home"), TRUE); |
| 9979 | 3144 | types = g_list_append(types, type); |
| 3145 | ||
| 10373 | 3146 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTATDESK, _("Not At Desk"), TRUE); |
| 9979 | 3147 | types = g_list_append(types, type); |
| 3148 | ||
| 10373 | 3149 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTINOFFICE, _("Not In Office"), TRUE); |
| 9979 | 3150 | types = g_list_append(types, type); |
| 3151 | ||
| 10373 | 3152 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_ONPHONE, _("On The Phone"), TRUE); |
| 9979 | 3153 | types = g_list_append(types, type); |
| 3154 | ||
| 10373 | 3155 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_ONVACATION, _("On Vacation"), TRUE); |
| 9979 | 3156 | types = g_list_append(types, type); |
| 3157 | ||
| 10373 | 3158 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_OUTTOLUNCH, _("Out To Lunch"), TRUE); |
| 9979 | 3159 | types = g_list_append(types, type); |
| 3160 | ||
| 10373 | 3161 | type = gaim_status_type_new(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_STEPPEDOUT, _("Stepped Out"), TRUE); |
| 9979 | 3162 | types = g_list_append(types, type); |
| 3163 | ||
| 10373 | 3164 | type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, YAHOO_STATUS_TYPE_AWAY, |
|
10195
18379f7920fa
[gaim-migrate @ 11310]
Mark Doliner <markdoliner@pidgin.im>
parents:
10143
diff
changeset
|
3165 | _("Away"), TRUE, TRUE, FALSE, |
| 9979 | 3166 | "message", _("Message"), |
|
10009
8a4fcc043f47
[gaim-migrate @ 10926]
Mark Doliner <markdoliner@pidgin.im>
parents:
9984
diff
changeset
|
3167 | gaim_value_new(GAIM_TYPE_STRING), NULL); |
| 9979 | 3168 | types = g_list_append(types, type); |
| 9370 | 3169 | } |
| 10373 | 3170 | type = gaim_status_type_new(GAIM_STATUS_HIDDEN, YAHOO_STATUS_TYPE_INVISIBLE, _("Invisible"), TRUE); |
| 9979 | 3171 | types = g_list_append(types, type); |
| 3172 | ||
| 3173 | ||
| 3174 | return types; | |
| 2681 | 3175 | } |
| 3176 | ||
| 5583 | 3177 | static void yahoo_keepalive(GaimConnection *gc) |
| 2681 | 3178 | { |
| 3179 | struct yahoo_data *yd = gc->proto_data; | |
| 3180 | struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0); | |
| 10392 | 3181 | yahoo_packet_send_and_free(pkt, yd); |
| 6729 | 3182 | |
| 3183 | if (!yd->chat_online) | |
| 3184 | return; | |
| 3185 | ||
| 9376 | 3186 | if (yd->wm) { |
| 3187 | ycht_chat_send_keepalive(yd->ycht); | |
| 3188 | return; | |
| 3189 | } | |
| 3190 | ||
| 6729 | 3191 | pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0); |
| 10394 | 3192 | yahoo_packet_hash_str(pkt, 109, gaim_connection_get_display_name(gc)); |
| 3193 | yahoo_packet_send_and_free(pkt, yd); | |
| 2681 | 3194 | } |
| 3195 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3196 | /* XXX - What's the deal with GaimGroup *foo? */ |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3197 | static void yahoo_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *foo) |
| 2681 | 3198 | { |
| 3199 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 3200 | struct yahoo_packet *pkt; | |
| 6695 | 3201 | GaimGroup *g; |
| 2681 | 3202 | char *group = NULL; |
| 7829 | 3203 | char *group2 = NULL; |
| 2681 | 3204 | |
| 3205 | if (!yd->logged_in) | |
| 3206 | return; | |
| 3207 | ||
|
10963
8011e6bc10b5
[gaim-migrate @ 12768]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10944
diff
changeset
|
3208 | if (!yahoo_privacy_check(gc, gaim_buddy_get_name(buddy))) |
|
8011e6bc10b5
[gaim-migrate @ 12768]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10944
diff
changeset
|
3209 | return; |
|
8011e6bc10b5
[gaim-migrate @ 12768]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10944
diff
changeset
|
3210 | |
| 6840 | 3211 | if (foo) |
| 3212 | group = foo->name; | |
| 3213 | if (!group) { | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3214 | g = gaim_find_buddys_group(gaim_find_buddy(gc->account, buddy->name)); |
| 6840 | 3215 | if (g) |
| 3216 | group = g->name; | |
| 3217 | else | |
| 3218 | group = "Buddies"; | |
| 3219 | } | |
| 2681 | 3220 | |
| 7829 | 3221 | group2 = yahoo_string_encode(gc, group, NULL); |
| 2681 | 3222 | pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
| 10394 | 3223 | yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc), |
| 3224 | 7, buddy->name, 65, group2, 14, ""); | |
| 10392 | 3225 | yahoo_packet_send_and_free(pkt, yd); |
| 7829 | 3226 | g_free(group2); |
| 2681 | 3227 | } |
| 3228 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3229 | static void yahoo_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 2681 | 3230 | { |
| 3231 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 9278 | 3232 | YahooFriend *f; |
|
6795
396b24cfeeb6
[gaim-migrate @ 7334]
Herman Bloggs <herman@bluedigits.com>
parents:
6793
diff
changeset
|
3233 | struct yahoo_packet *pkt; |
| 6840 | 3234 | GSList *buddies, *l; |
| 3235 | GaimGroup *g; | |
| 3236 | gboolean remove = TRUE; | |
| 7827 | 3237 | char *cg; |
| 6784 | 3238 | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3239 | if (!(f = yahoo_friend_find(gc, buddy->name))) |
| 6784 | 3240 | return; |
| 3241 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3242 | buddies = gaim_find_buddies(gaim_connection_get_account(gc), buddy->name); |
| 6840 | 3243 | for (l = buddies; l; l = l->next) { |
| 3244 | g = gaim_find_buddys_group(l->data); | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3245 | if (gaim_utf8_strcasecmp(group->name, g->name)) { |
| 6840 | 3246 | remove = FALSE; |
| 3247 | break; | |
| 3248 | } | |
| 3249 | } | |
| 3250 | ||
| 3251 | g_slist_free(buddies); | |
| 3252 | ||
| 3253 | if (remove) | |
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3254 | g_hash_table_remove(yd->friends, buddy->name); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3255 | |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3256 | cg = yahoo_string_encode(gc, group->name, NULL); |
|
6795
396b24cfeeb6
[gaim-migrate @ 7334]
Herman Bloggs <herman@bluedigits.com>
parents:
6793
diff
changeset
|
3257 | pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); |
| 10394 | 3258 | yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), |
| 3259 | 7, buddy->name, 65, cg); | |
| 10392 | 3260 | yahoo_packet_send_and_free(pkt, yd); |
| 7827 | 3261 | g_free(cg); |
| 2681 | 3262 | } |
| 3263 | ||
| 6760 | 3264 | static void yahoo_add_deny(GaimConnection *gc, const char *who) { |
| 3265 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 3266 | struct yahoo_packet *pkt; | |
| 3267 | ||
| 3268 | if (!yd->logged_in) | |
| 3269 | return; | |
| 8057 | 3270 | /* It seems to work better without this */ |
| 3271 | ||
| 8113 | 3272 | /* if (gc->account->perm_deny != 4) |
| 3273 | return; */ | |
| 3274 | ||
| 3275 | if (!who || who[0] == '\0') | |
| 3276 | return; | |
| 3277 | ||
| 6760 | 3278 | pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); |
| 10394 | 3279 | yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), |
| 3280 | 7, who, 13, "1"); | |
| 10392 | 3281 | yahoo_packet_send_and_free(pkt, yd); |
| 6760 | 3282 | } |
| 3283 | ||
| 3284 | static void yahoo_rem_deny(GaimConnection *gc, const char *who) { | |
| 3285 | struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; | |
| 3286 | struct yahoo_packet *pkt; | |
| 3287 | ||
| 3288 | if (!yd->logged_in) | |
| 3289 | return; | |
| 3290 | ||
| 3291 | if (!who || who[0] == '\0') | |
| 3292 | return; | |
| 3293 | ||
| 3294 | pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3295 | yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), 7, who, 13, "2"); |
| 10392 | 3296 | yahoo_packet_send_and_free(pkt, yd); |
| 6760 | 3297 | } |
| 3298 | ||
| 3299 | static void yahoo_set_permit_deny(GaimConnection *gc) { | |
| 3300 | GaimAccount *acct; | |
| 3301 | GSList *deny; | |
| 3302 | ||
| 3303 | acct = gc->account; | |
| 3304 | ||
| 3305 | switch (acct->perm_deny) { | |
| 10105 | 3306 | /* privacy 1 */ |
| 3307 | case GAIM_PRIVACY_ALLOW_ALL: | |
| 10143 | 3308 | for (deny = acct->deny;deny;deny = deny->next) |
| 3309 | yahoo_rem_deny(gc, deny->data); | |
| 3310 | break; | |
| 10105 | 3311 | /* privacy 3 */ |
| 3312 | case GAIM_PRIVACY_ALLOW_USERS: | |
| 6760 | 3313 | for (deny = acct->deny;deny;deny = deny->next) |
| 3314 | yahoo_rem_deny(gc, deny->data); | |
| 3315 | break; | |
| 10105 | 3316 | /* privacy 5 */ |
| 3317 | case GAIM_PRIVACY_ALLOW_BUDDYLIST: | |
| 3318 | /* privacy 4 */ | |
| 3319 | case GAIM_PRIVACY_DENY_USERS: | |
| 6760 | 3320 | for (deny = acct->deny;deny;deny = deny->next) |
| 3321 | yahoo_add_deny(gc, deny->data); | |
| 3322 | break; | |
| 10105 | 3323 | /* privacy 2 */ |
| 3324 | case GAIM_PRIVACY_DENY_ALL: | |
| 6760 | 3325 | default: |
| 3326 | break; | |
| 3327 | } | |
| 3328 | } | |
| 3329 | ||
| 6513 | 3330 | static gboolean yahoo_unload_plugin(GaimPlugin *plugin) |
| 3331 | { | |
| 3332 | yahoo_dest_colorht(); | |
| 3333 | return TRUE; | |
| 3334 | } | |
| 3335 | ||
| 6793 | 3336 | static void yahoo_change_buddys_group(GaimConnection *gc, const char *who, |
| 3337 | const char *old_group, const char *new_group) | |
| 3338 | { | |
| 3339 | struct yahoo_data *yd = gc->proto_data; | |
| 3340 | struct yahoo_packet *pkt; | |
| 7827 | 3341 | char *gpn, *gpo; |
| 6793 | 3342 | |
| 3343 | /* Step 0: If they aren't on the server list anyway, | |
| 3344 | * don't bother letting the server know. | |
| 3345 | */ | |
| 9279 | 3346 | if (!yahoo_friend_find(gc, who)) |
| 6793 | 3347 | return; |
| 3348 | ||
| 7827 | 3349 | /* If old and new are the same, we would probably |
| 3350 | * end up deleting the buddy, which would be bad. | |
| 3351 | * This might happen because of the charset conversation. | |
| 3352 | */ | |
| 3353 | gpn = yahoo_string_encode(gc, new_group, NULL); | |
| 3354 | gpo = yahoo_string_encode(gc, old_group, NULL); | |
| 3355 | if (!strcmp(gpn, gpo)) { | |
| 3356 | g_free(gpn); | |
| 3357 | g_free(gpo); | |
| 3358 | return; | |
| 3359 | } | |
| 3360 | ||
| 6793 | 3361 | /* Step 1: Add buddy to new group. */ |
| 3362 | pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3363 | yahoo_packet_hash(pkt, "ssss", 1, gaim_connection_get_display_name(gc), |
| 3364 | 7, who, 65, gpn, 14, ""); | |
| 10392 | 3365 | yahoo_packet_send_and_free(pkt, yd); |
| 6793 | 3366 | |
| 3367 | /* Step 2: Remove buddy from old group */ | |
| 3368 | pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3369 | yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), 7, who, 65, gpo); |
| 10392 | 3370 | yahoo_packet_send_and_free(pkt, yd); |
| 7827 | 3371 | g_free(gpn); |
| 3372 | g_free(gpo); | |
| 6793 | 3373 | } |
| 3374 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3375 | static void yahoo_rename_group(GaimConnection *gc, const char *old_name, |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3376 | GaimGroup *group, GList *moved_buddies) |
| 6793 | 3377 | { |
| 3378 | struct yahoo_data *yd = gc->proto_data; | |
| 3379 | struct yahoo_packet *pkt; | |
| 7827 | 3380 | char *gpn, *gpo; |
| 3381 | ||
|
9285
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3382 | gpn = yahoo_string_encode(gc, group->name, NULL); |
|
9cedf5d26577
[gaim-migrate @ 10088]
Mark Doliner <markdoliner@pidgin.im>
parents:
9284
diff
changeset
|
3383 | gpo = yahoo_string_encode(gc, old_name, NULL); |
| 7827 | 3384 | if (!strcmp(gpn, gpo)) { |
| 3385 | g_free(gpn); | |
| 3386 | g_free(gpo); | |
| 3387 | return; | |
| 3388 | } | |
| 6793 | 3389 | |
| 3390 | pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0); | |
| 10394 | 3391 | yahoo_packet_hash(pkt, "sss", 1, gaim_connection_get_display_name(gc), |
| 3392 | 65, gpo, 67, gpn); | |
| 10392 | 3393 | yahoo_packet_send_and_free(pkt, yd); |
| 7827 | 3394 | g_free(gpn); |
| 3395 | g_free(gpo); | |
| 6793 | 3396 | } |
| 3397 | ||
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
3398 | /********************************* Commands **********************************/ |
|
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
3399 | |
| 10119 | 3400 | static GaimCmdRet |
| 3401 | yahoogaim_cmd_buzz(GaimConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) { | |
| 3402 | ||
| 3403 | GaimAccount *account = gaim_conversation_get_account(c); | |
| 3404 | const char *username = gaim_account_get_username(account); | |
| 3405 | ||
| 3406 | if (*args && args[0]) | |
| 3407 | return GAIM_CMD_RET_FAILED; | |
| 3408 | ||
| 3409 | gaim_debug(GAIM_DEBUG_INFO, "yahoo", | |
| 3410 | "Sending <ding> on account %s to buddy %s.\n", username, c->name); | |
| 3411 | gaim_conv_im_send(GAIM_CONV_IM(c), "<ding>"); | |
| 3412 | gaim_conv_im_write(GAIM_CONV_IM(c), "", _("Buzz!!"), GAIM_MESSAGE_NICK|GAIM_MESSAGE_RECV, time(NULL)); | |
| 3413 | return GAIM_CMD_RET_OK; | |
| 3414 | } | |
| 3415 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3416 | static GaimPlugin *my_protocol = NULL; |
| 2681 | 3417 | |
| 10119 | 3418 | |
| 3419 | static GaimCmdRet | |
| 3420 | yahoogaim_cmd_chat_join(GaimConversation *conv, const char *cmd, | |
| 3421 | char **args, char **error, void *data) | |
| 3422 | { | |
| 3423 | GHashTable *comp; | |
| 3424 | GaimConnection *gc; | |
| 3425 | struct yahoo_data *yd; | |
| 3426 | int id; | |
| 3427 | ||
| 3428 | if (!args || !args[0]) | |
| 3429 | return GAIM_CMD_RET_FAILED; | |
| 3430 | ||
| 3431 | gc = gaim_conversation_get_gc(conv); | |
| 3432 | yd = gc->proto_data; | |
| 3433 | id = yd->conf_id; | |
| 3434 | gaim_debug(GAIM_DEBUG_INFO, "yahoo", | |
| 3435 | "Trying to join %s \n", args[0]); | |
| 3436 | ||
| 3437 | comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 3438 | g_hash_table_replace(comp, g_strdup("room"), | |
| 3439 | g_strdup_printf("%s", g_ascii_strdown(args[0], strlen(args[0])))); | |
| 3440 | g_hash_table_replace(comp, g_strdup("type"), g_strdup("Chat")); | |
| 3441 | ||
| 3442 | yahoo_c_join(gc, comp); | |
| 3443 | ||
| 3444 | g_hash_table_destroy(comp); | |
| 3445 | return GAIM_CMD_RET_OK; | |
| 3446 | } | |
| 3447 | /************************** Plugin Initialization ****************************/ | |
| 3448 | static void | |
| 3449 | yahoogaim_register_commands(void) | |
| 3450 | { | |
| 3451 | gaim_cmd_register("join", "s", GAIM_CMD_P_PRPL, | |
| 3452 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | | |
| 3453 | GAIM_CMD_FLAG_PRPL_ONLY, | |
| 3454 | "prpl-yahoo", yahoogaim_cmd_chat_join, | |
| 3455 | _("join <room>: Join a chat room on the Yahoo network"), NULL); | |
| 10121 | 3456 | gaim_cmd_register("buzz", "", GAIM_CMD_P_PRPL, |
| 10119 | 3457 | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_PRPL_ONLY, |
| 3458 | "prpl-yahoo", yahoogaim_cmd_buzz, | |
| 3459 | _("buzz: Buzz a contact to get their attention"), NULL); | |
| 3460 | } | |
| 3461 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3462 | static GaimPluginProtocolInfo prpl_info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3463 | { |
| 9308 | 3464 | OPT_PROTO_MAIL_CHECK | OPT_PROTO_CHAT_TOPIC, |
| 6729 | 3465 | NULL, /* user_splits */ |
| 3466 | NULL, /* protocol_options */ | |
| 9318 | 3467 | {"png", 96, 96, 96, 96, GAIM_ICON_SCALE_SEND}, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3468 | yahoo_list_icon, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3469 | yahoo_list_emblems, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3470 | yahoo_status_text, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3471 | yahoo_tooltip_text, |
| 9979 | 3472 | yahoo_status_types, |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
3473 | yahoo_blist_node_menu, |
| 6729 | 3474 | yahoo_c_info, |
| 9768 | 3475 | yahoo_c_info_defaults, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3476 | yahoo_login, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3477 | yahoo_close, |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3478 | yahoo_send_im, |
| 6729 | 3479 | NULL, /* set info */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3480 | yahoo_send_typing, |
| 6514 | 3481 | yahoo_get_info, |
| 9984 | 3482 | yahoo_set_status, |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3483 | yahoo_set_idle, |
| 6729 | 3484 | NULL, /* change_passwd*/ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3485 | yahoo_add_buddy, |
| 6729 | 3486 | NULL, /* add_buddies */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3487 | yahoo_remove_buddy, |
| 6729 | 3488 | NULL, /*remove_buddies */ |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
3489 | yahoo_add_permit, |
| 6760 | 3490 | yahoo_add_deny, |
|
10937
1753f4709889
[gaim-migrate @ 12721]
Peter Lawler <pidgin@bleeter.id.au>
parents:
10784
diff
changeset
|
3491 | yahoo_rem_permit, |
| 6760 | 3492 | yahoo_rem_deny, |
| 3493 | yahoo_set_permit_deny, | |
| 6729 | 3494 | NULL, /* warn */ |
| 3495 | yahoo_c_join, | |
|
8562
7e73676d1772
[gaim-migrate @ 9306]
Christopher O'Brien <siege@pidgin.im>
parents:
8503
diff
changeset
|
3496 | NULL, /* reject chat invite */ |
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9888
diff
changeset
|
3497 | yahoo_get_chat_name, |
| 6729 | 3498 | yahoo_c_invite, |
| 3499 | yahoo_c_leave, | |
| 3500 | NULL, /* chat whisper */ | |
| 3501 | yahoo_c_send, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3502 | yahoo_keepalive, |
| 6729 | 3503 | NULL, /* register_user */ |
| 3504 | NULL, /* get_cb_info */ | |
| 3505 | NULL, /* get_cb_away */ | |
| 3506 | NULL, /* alias_buddy */ | |
| 6793 | 3507 | yahoo_change_buddys_group, |
| 3508 | yahoo_rename_group, | |
| 6729 | 3509 | NULL, /* buddy_free */ |
| 3510 | NULL, /* convo_closed */ | |
| 3511 | NULL, /* normalize */ | |
| 9306 | 3512 | yahoo_set_buddy_icon, |
| 7651 | 3513 | NULL, /* void (*remove_group)(GaimConnection *gc, const char *group);*/ |
| 3514 | NULL, /* char *(*get_cb_real_name)(GaimConnection *gc, int id, const char *who); */ | |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
3515 | NULL, /* set_chat_topic */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
3516 | NULL, /* find_blist_chat */ |
| 8113 | 3517 | yahoo_roomlist_get_list, |
| 3518 | yahoo_roomlist_cancel, | |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9410
diff
changeset
|
3519 | yahoo_roomlist_expand_category, |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
3520 | NULL, /* can_receive_file */ |
|
9466
b6425eab60ca
[gaim-migrate @ 10291]
Daniel Atallah <datallah@pidgin.im>
parents:
9410
diff
changeset
|
3521 | yahoo_send_file |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3522 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3523 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3524 | static GaimPluginInfo info = |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3525 | { |
| 9943 | 3526 | GAIM_PLUGIN_MAGIC, |
| 3527 | GAIM_MAJOR_VERSION, | |
| 3528 | GAIM_MINOR_VERSION, | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3529 | GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3530 | NULL, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3531 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3532 | NULL, /**< dependencies */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3533 | GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3534 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3535 | "prpl-yahoo", /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3536 | "Yahoo", /**< name */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3537 | VERSION, /**< version */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3538 | /** summary */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3539 | N_("Yahoo Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3540 | /** description */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3541 | N_("Yahoo Protocol Plugin"), |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3542 | NULL, /**< author */ |
|
6371
e92b66ee5518
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6321
diff
changeset
|
3543 | GAIM_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3544 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3545 | NULL, /**< load */ |
| 6513 | 3546 | yahoo_unload_plugin, /**< unload */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3547 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3548 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3549 | NULL, /**< ui_info */ |
| 8993 | 3550 | &prpl_info, /**< extra_info */ |
| 3551 | NULL, | |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
3552 | yahoo_actions |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3553 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3554 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3555 | static void |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
3556 | init_plugin(GaimPlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3557 | { |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5590
diff
changeset
|
3558 | GaimAccountOption *option; |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3559 | |
| 9164 | 3560 | option = gaim_account_option_bool_new(_("Yahoo Japan"), "yahoojp", FALSE); |
| 3561 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3562 | ||
| 7827 | 3563 | option = gaim_account_option_string_new(_("Pager host"), "server", YAHOO_PAGER_HOST); |
| 3564 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3565 | ||
| 9164 | 3566 | option = gaim_account_option_string_new(_("Japan Pager host"), "serverjp", YAHOOJP_PAGER_HOST); |
| 3567 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3568 | ||
| 7827 | 3569 | option = gaim_account_option_int_new(_("Pager port"), "port", YAHOO_PAGER_PORT); |
| 3570 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 7651 | 3571 | |
| 3572 | option = gaim_account_option_string_new(_("File transfer host"), "xfer_host", YAHOO_XFER_HOST); | |
| 3573 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3574 | ||
| 9164 | 3575 | option = gaim_account_option_string_new(_("Japan File transfer host"), "xferjp_host", YAHOOJP_XFER_HOST); |
| 3576 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3577 | ||
| 7651 | 3578 | option = gaim_account_option_int_new(_("File transfer port"), "xfer_port", YAHOO_XFER_PORT); |
| 3579 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3580 | ||
| 8113 | 3581 | option = gaim_account_option_string_new(_("Chat Room List Url"), "room_list", YAHOO_ROOMLIST_URL); |
| 3582 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 9376 | 3583 | #if 0 |
| 3584 | option = gaim_account_option_string_new(_("YCHT Host"), "ycht-server", YAHOO_YCHT_HOST); | |
| 3585 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3586 | ||
| 3587 | option = gaim_account_option_int_new(_("YCHT Port"), "ycht-port", YAHOO_YCHT_PORT); | |
| 3588 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 3589 | #endif | |
| 3590 | ||
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3591 | my_protocol = plugin; |
| 10119 | 3592 | yahoogaim_register_commands(); |
| 6513 | 3593 | yahoo_init_colorht(); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3594 | } |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5136
diff
changeset
|
3595 | |
|
5920
963bfdefee02
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
3596 | GAIM_INIT_PLUGIN(yahoo, init_plugin, info); |