annotate src/protocols/yahoo/yahoo.c @ 6514:64d952098596

[gaim-migrate @ 7031] Nathan Poznick implemented yahoo info :-) please test and submit patches for bugs committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 20 Aug 2003 01:35:03 +0000
parents 63c449a1022f
children 7c14b35bc984
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /*
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 * gaim
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 * Some code copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * libfaim code copyright 1998, 1999 Adam Fritzler <afritz@auk.cx>
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * This program is free software; you can redistribute it and/or modify
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * it under the terms of the GNU General Public License as published by
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * (at your option) any later version.
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * GNU General Public License for more details.
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * You should have received a copy of the GNU General Public License
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * along with this program; if not, write to the Free Software
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 *
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
22 #include "internal.h"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
24 #include "account.h"
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
25 #include "accountopt.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
26 #include "debug.h"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include "multi.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
28 #include "notify.h"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include "prpl.h"
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include "proxy.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
31 #include "request.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
32 #include "server.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
33 #include "util.h"
6115
11bedb793a44 [gaim-migrate @ 6578]
Christian Hammond <chipx86@chipx86.com>
parents: 6069
diff changeset
34 #include "html.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
35
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
36 #include "yahoo.h"
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
37 #include "md5.h"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
39 /* XXX */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6321
diff changeset
40 #include "gtkinternal.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
41 #include "ui.h"
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3596
diff changeset
42
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
43 extern char *yahoo_crypt(const char *, const char *);
2795
536bb833fdeb [gaim-migrate @ 2808]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2786
diff changeset
44
5493
3e8487580024 [gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
45 /* #define YAHOO_DEBUG */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 #define USEROPT_MAIL 0
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
49 #define YAHOO_PAGER_HOST "scs.yahoo.com"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 #define YAHOO_PAGER_PORT 5050
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
51 #define YAHOO_PROFILE_URL "http://profiles.yahoo.com/"
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
3467
79e0d2f8ad2b [gaim-migrate @ 3517]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
53 #define YAHOO_PROTO_VER 0x0900
79e0d2f8ad2b [gaim-migrate @ 3517]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
54
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
55 enum yahoo_service { /* these are easier to see in hex */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 YAHOO_SERVICE_LOGON = 1,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 YAHOO_SERVICE_LOGOFF,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 YAHOO_SERVICE_ISAWAY,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 YAHOO_SERVICE_ISBACK,
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
60 YAHOO_SERVICE_IDLE, /* 5 (placemarker) */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 YAHOO_SERVICE_MESSAGE,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 YAHOO_SERVICE_IDACT,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 YAHOO_SERVICE_IDDEACT,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 YAHOO_SERVICE_MAILSTAT,
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
65 YAHOO_SERVICE_USERSTAT, /* 0xa */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 YAHOO_SERVICE_NEWMAIL,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 YAHOO_SERVICE_CHATINVITE,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 YAHOO_SERVICE_CALENDAR,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 YAHOO_SERVICE_NEWPERSONALMAIL,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 YAHOO_SERVICE_NEWCONTACT,
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
71 YAHOO_SERVICE_ADDIDENT, /* 0x10 */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 YAHOO_SERVICE_ADDIGNORE,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 YAHOO_SERVICE_PING,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 YAHOO_SERVICE_GROUPRENAME,
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
75 YAHOO_SERVICE_SYSMESSAGE = 0x14,
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
76 YAHOO_SERVICE_PASSTHROUGH2 = 0x16,
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
77 YAHOO_SERVICE_CONFINVITE = 0x18,
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 YAHOO_SERVICE_CONFLOGON,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 YAHOO_SERVICE_CONFDECLINE,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 YAHOO_SERVICE_CONFLOGOFF,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 YAHOO_SERVICE_CONFADDINVITE,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 YAHOO_SERVICE_CONFMSG,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 YAHOO_SERVICE_CHATLOGON,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 YAHOO_SERVICE_CHATLOGOFF,
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
85 YAHOO_SERVICE_CHATMSG = 0x20,
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
86 YAHOO_SERVICE_GAMELOGON = 0x28,
2786
318f846120e2 [gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2772
diff changeset
87 YAHOO_SERVICE_GAMELOGOFF,
318f846120e2 [gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2772
diff changeset
88 YAHOO_SERVICE_GAMEMSG = 0x2a,
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
89 YAHOO_SERVICE_FILETRANSFER = 0x46,
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
90 YAHOO_SERVICE_NOTIFY = 0x4B,
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
91 YAHOO_SERVICE_AUTHRESP = 0x54,
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
92 YAHOO_SERVICE_LIST = 0x55,
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
93 YAHOO_SERVICE_AUTH = 0x57,
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
94 YAHOO_SERVICE_ADDBUDDY = 0x83,
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
95 YAHOO_SERVICE_REMBUDDY = 0x84
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 };
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 enum yahoo_status {
2686
7b21c5446baf [gaim-migrate @ 2699]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2683
diff changeset
99 YAHOO_STATUS_AVAILABLE = 0,
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 YAHOO_STATUS_BRB,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 YAHOO_STATUS_BUSY,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 YAHOO_STATUS_NOTATHOME,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 YAHOO_STATUS_NOTATDESK,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 YAHOO_STATUS_NOTINOFFICE,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 YAHOO_STATUS_ONPHONE,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 YAHOO_STATUS_ONVACATION,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 YAHOO_STATUS_OUTTOLUNCH,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 YAHOO_STATUS_STEPPEDOUT,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 YAHOO_STATUS_INVISIBLE = 12,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 YAHOO_STATUS_CUSTOM = 99,
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 YAHOO_STATUS_IDLE = 999,
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
112 YAHOO_STATUS_OFFLINE = 0x5a55aa56, /* don't ask */
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
113 YAHOO_STATUS_TYPING = 0x16
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 };
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
115 #define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 struct yahoo_data {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 int fd;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 guchar *rxqueue;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 int rxlen;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 GHashTable *hash;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
122 GHashTable *games;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 int current_status;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 gboolean logged_in;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 };
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 struct yahoo_pair {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 int key;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 char *value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 };
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 struct yahoo_packet {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 guint16 service;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 guint32 status;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 guint32 id;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 GSList *hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 };
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 #define YAHOO_PACKET_HDRLEN (4 + 2 + 2 + 2 + 2 + 4 + 4)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 static struct yahoo_packet *yahoo_packet_new(enum yahoo_service service, enum yahoo_status status, int id)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 struct yahoo_packet *pkt = g_new0(struct yahoo_packet, 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 pkt->service = service;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 pkt->status = status;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 pkt->id = id;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 return pkt;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151
3466
7a3f16a375a5 [gaim-migrate @ 3516]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
152 static void yahoo_packet_hash(struct yahoo_packet *pkt, int key, const char *value)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 pair->key = key;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 pair->value = g_strdup(value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 pkt->hash = g_slist_append(pkt->hash, pair);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 static int yahoo_packet_length(struct yahoo_packet *pkt)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 GSList *l;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 int len = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 int tmp = pair->key;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 do {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 tmp /= 10;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 len++;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 } while (tmp);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 len += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 len += strlen(pair->value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 len += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 return len;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 /* sometimes i wish prpls could #include things from other prpls. then i could just
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 * use the routines from libfaim and not have to admit to knowing how they work. */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 #define yahoo_put16(buf, data) ( \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 (*(buf) = (u_char)((data)>>8)&0xff), \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 (*((buf)+1) = (u_char)(data)&0xff), \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 2)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 #define yahoo_get16(buf) ((((*(buf))<<8)&0xff00) + ((*((buf)+1)) & 0xff))
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 #define yahoo_put32(buf, data) ( \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 (*((buf)) = (u_char)((data)>>24)&0xff), \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 (*((buf)+1) = (u_char)((data)>>16)&0xff), \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 (*((buf)+2) = (u_char)((data)>>8)&0xff), \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 (*((buf)+3) = (u_char)(data)&0xff), \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 4)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 #define yahoo_get32(buf) ((((*(buf))<<24)&0xff000000) + \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 (((*((buf)+1))<<16)&0x00ff0000) + \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 (((*((buf)+2))<< 8)&0x0000ff00) + \
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 (((*((buf)+3) )&0x000000ff)))
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 static void yahoo_packet_read(struct yahoo_packet *pkt, guchar *data, int len)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 int pos = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 while (pos + 1 < len) {
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
206 char key[64], *value = NULL;
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
207 int accept;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 int x;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 struct yahoo_pair *pair = g_new0(struct yahoo_pair, 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 x = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 while (pos + 1 < len) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 key[x++] = data[pos++];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 key[x] = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 pos += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 pair->key = strtol(key, NULL, 10);
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
221 accept = x; /* if x is 0 there was no key, so don't accept it */
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222
3996
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
223 if (len - pos + 1 <= 0) {
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
224 /* Truncated. Garbage or something. */
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
225 accept = 0;
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
226 }
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
227
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
228 if (accept) {
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
229 value = g_malloc(len - pos + 1);
3996
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
230 x = 0;
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
231 while (pos + 1 < len) {
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
232 if (data[pos] == 0xc0 && data[pos + 1] == 0x80)
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
233 break;
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
234 value[x++] = data[pos++];
3996
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
235 }
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
236 value[x] = 0;
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
237 pair->value = g_strdup(value);
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
238 g_free(value);
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
239 pkt->hash = g_slist_append(pkt->hash, pair);
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
240 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
241 "Key: %d \tValue: %s\n", pair->key, pair->value);
2724
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
242 } else {
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
243 g_free(pair);
7f3f4aa114ad [gaim-migrate @ 2737]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2723
diff changeset
244 }
3996
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
245 pos += 2;
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
246
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
247 /* Skip over garbage we've noticed in the mail notifications */
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
248 if (data[0] == '9' && data[pos] == 0x01)
3fdfe7872118 [gaim-migrate @ 4191]
Christian Hammond <chipx86@chipx86.com>
parents: 3768
diff changeset
249 pos++;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 static void yahoo_packet_write(struct yahoo_packet *pkt, guchar *data)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 int pos = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 guchar buf[100];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 g_snprintf(buf, sizeof(buf), "%d", pair->key);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 strcpy(data + pos, buf);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 pos += strlen(buf);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 data[pos++] = 0xc0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 data[pos++] = 0x80;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 strcpy(data + pos, pair->value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 pos += strlen(pair->value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 data[pos++] = 0xc0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 data[pos++] = 0x80;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 static void yahoo_packet_dump(guchar *data, int len)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 #ifdef YAHOO_DEBUG
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 int i;
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
281
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
282 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
283
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 for (i = 0; i + 1 < len; i += 2) {
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
285 if ((i % 16 == 0) && i) {
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
286 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
287 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
288 }
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
289
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
290 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x%02x ", data[i], data[i + 1]);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 if (i < len)
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
293 gaim_debug(GAIM_DEBUG_MISC, NULL, "%02x", data[i]);
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
294
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
295 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
296 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
297
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 for (i = 0; i < len; i++) {
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
299 if ((i % 16 == 0) && i) {
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
300 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
301 gaim_debug(GAIM_DEBUG_MISC, "yahoo", "");
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
302 }
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
303
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 if (isprint(data[i]))
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
305 gaim_debug(GAIM_DEBUG_MISC, NULL, "%c ", data[i]);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 else
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
307 gaim_debug(GAIM_DEBUG_MISC, NULL, ". ");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 }
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
309
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
310 gaim_debug(GAIM_DEBUG_MISC, NULL, "\n");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 #endif
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 static int yahoo_send_packet(struct yahoo_data *yd, struct yahoo_packet *pkt)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 int pktlen = yahoo_packet_length(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 int len = YAHOO_PACKET_HDRLEN + pktlen;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 int ret;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 guchar *data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 int pos = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 if (yd->fd < 0)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324 return -1;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 data = g_malloc0(len + 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 memcpy(data + pos, "YMSG", 4); pos += 4;
3467
79e0d2f8ad2b [gaim-migrate @ 3517]
Sean Egan <seanegan@gmail.com>
parents: 3466
diff changeset
329 pos += yahoo_put16(data + pos, YAHOO_PROTO_VER);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 pos += yahoo_put16(data + pos, 0x0000);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 pos += yahoo_put16(data + pos, pktlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 pos += yahoo_put16(data + pos, pkt->service);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 pos += yahoo_put32(data + pos, pkt->status);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 pos += yahoo_put32(data + pos, pkt->id);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 yahoo_packet_write(pkt, data + pos);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 yahoo_packet_dump(data, len);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 ret = write(yd->fd, data, len);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 g_free(data);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 return ret;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 static void yahoo_packet_free(struct yahoo_packet *pkt)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 while (pkt->hash) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 struct yahoo_pair *pair = pkt->hash->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 g_free(pair->value);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 g_free(pair);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 pkt->hash = g_slist_remove(pkt->hash, pair);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 g_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
356 static void yahoo_process_status(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 char *name = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 int state = 0;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
362 int gamestate = 0;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 char *msg = NULL;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
364
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 switch (pair->key) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 case 0: /* we won't actually do anything with this */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 case 1: /* we don't get the full buddy list here. */
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
372 if (!yd->logged_in) {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
373 gaim_connection_set_state(gc, GAIM_CONNECTED);
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
374 serv_finish_login(gc);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
375 gaim_connection_set_display_name(gc, pair->value);
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
376 yd->logged_in = TRUE;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
378 /* this requests the list. i have a feeling that this is very evil
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
379 *
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
380 * scs.yahoo.com sends you the list before this packet without it being
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
381 * requested
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
382 *
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
383 * do_import(gc, NULL);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
384 * newpkt = yahoo_packet_new(YAHOO_SERVICE_LIST, YAHOO_STATUS_OFFLINE, 0);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
385 * yahoo_send_packet(yd, newpkt);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
386 * yahoo_packet_free(newpkt);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
387 */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
388
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
389 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 case 8: /* how many online buddies we have */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 case 7: /* the current buddy */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 name = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 case 10: /* state */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 state = strtol(pair->value, NULL, 10);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 case 19: /* custom message */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 msg = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 case 11: /* i didn't know what this was in the old protocol either */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 case 17: /* in chat? */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 break;
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
406 case 13: /* in pager? */
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
407 if (pkt->service == YAHOO_SERVICE_LOGOFF ||
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
408 strtol(pair->value, NULL, 10) == 0) {
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
409 serv_got_update(gc, name, 0, 0, 0, 0, 0);
2807
f01e6a425136 [gaim-migrate @ 2820]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2805
diff changeset
410 break;
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
411 }
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
412 if (g_hash_table_lookup(yd->games, name))
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
413 gamestate = YAHOO_STATUS_GAME;
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
414 if (state == YAHOO_STATUS_CUSTOM) {
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
415 gpointer val = g_hash_table_lookup(yd->hash, name);
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
416 if (val) {
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
417 g_free(val);
2873
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
418 g_hash_table_insert(yd->hash, name,
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
419 msg ? g_strdup(msg) : g_malloc0(1));
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
420 } else
2873
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
421 g_hash_table_insert(yd->hash, g_strdup(name),
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
422 msg ? g_strdup(msg) : g_malloc0(1));
2771
450f4f9d2f23 [gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2741
diff changeset
423 }
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
424 if (state == YAHOO_STATUS_AVAILABLE)
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
425 serv_got_update(gc, name, 1, 0, 0, 0, gamestate);
5002
f78b24df83d5 [gaim-migrate @ 5337]
Sean Egan <seanegan@gmail.com>
parents: 4916
diff changeset
426 else if (state == YAHOO_STATUS_IDLE)
f78b24df83d5 [gaim-migrate @ 5337]
Sean Egan <seanegan@gmail.com>
parents: 4916
diff changeset
427 serv_got_update(gc, name, 1, 0, 0, -1, (state << 2) | UC_UNAVAILABLE | gamestate);
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
428 else
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
429 serv_got_update(gc, name, 1, 0, 0, 0, (state << 2) | UC_UNAVAILABLE | gamestate);
2771
450f4f9d2f23 [gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2741
diff changeset
430 break;
2805
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
431 case 60: /* no clue */
9b3c7d2a6e9a [gaim-migrate @ 2818]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2795
diff changeset
432 break;
2979
8e924e4aa256 [gaim-migrate @ 2992]
Rob Flynn <gaim@robflynn.com>
parents: 2951
diff changeset
433 case 16: /* Custom error message */
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5367
diff changeset
434 gaim_notify_error(gc, NULL, pair->value, NULL);
2951
b74f4f7165a1 [gaim-migrate @ 2964]
Rob Flynn <gaim@robflynn.com>
parents: 2918
diff changeset
435 break;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 default:
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
437 gaim_debug(GAIM_DEBUG_ERROR, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
438 "Unknown status key %d\n", pair->key);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
446 static void yahoo_process_list(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 gboolean export = FALSE;
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
450 struct buddy *b;
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
451 struct group *g;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 char **lines;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 char **split;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 char **buddies;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 char **tmp, **bud;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 if (pair->key != 87)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 continue;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 lines = g_strsplit(pair->value, "\n", -1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 for (tmp = lines; *tmp; tmp++) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 split = g_strsplit(*tmp, ":", 2);
2697
7759f914a009 [gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
468 if (!split)
7759f914a009 [gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
469 continue;
2702
94b4271b9567 [gaim-migrate @ 2715]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2697
diff changeset
470 if (!split[0] || !split[1]) {
2697
7759f914a009 [gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
471 g_strfreev(split);
7759f914a009 [gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
472 continue;
7759f914a009 [gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
473 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 buddies = g_strsplit(split[1], ",", -1);
2697
7759f914a009 [gaim-migrate @ 2710]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2688
diff changeset
475 for (bud = buddies; bud && *bud; bud++)
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
476 if (!(b = gaim_find_buddy(gc->account, *bud))) {
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
477 if (!(g = gaim_find_group(split[0]))) {
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
478 g = gaim_group_new(split[0]);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
479 gaim_blist_add_group(g, NULL);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
480 }
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
481 b = gaim_buddy_new(gc->account, *bud, NULL);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4745
diff changeset
482 gaim_blist_add_buddy(b, g, NULL);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 export = TRUE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 g_strfreev(buddies);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 g_strfreev(split);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 g_strfreev(lines);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 if (export)
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4333
diff changeset
492 gaim_blist_save();
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
495 static void yahoo_process_notify(GaimConnection *gc, struct yahoo_packet *pkt)
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
496 {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
497 char *msg = NULL;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
498 char *from = NULL;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
499 char *stat = NULL;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
500 char *game = NULL;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
501 GSList *l = pkt->hash;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
502 struct yahoo_data *yd = (struct yahoo_data*) gc->proto_data;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
503 while (l) {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
504 struct yahoo_pair *pair = l->data;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
505 if (pair->key == 4)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
506 from = pair->value;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
507 if (pair->key == 49)
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
508 msg = pair->value;
3001
87fff45fa36b [gaim-migrate @ 3014]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
509 if (pair->key == 13)
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
510 stat = pair->value;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
511 if (pair->key == 14)
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
512 game = pair->value;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
513 l = l->next;
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
514 }
3640
1c39909fb476 [gaim-migrate @ 3763]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
515
1c39909fb476 [gaim-migrate @ 3763]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
516 if (!msg)
1c39909fb476 [gaim-migrate @ 3763]
Sean Egan <seanegan@gmail.com>
parents: 3630
diff changeset
517 return;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
518
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4777
diff changeset
519 if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))) {
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
520 if (*stat == '1')
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
521 serv_got_typing(gc, from, 0, GAIM_TYPING);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
522 else
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
523 serv_got_typing_stopped(gc, from);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4777
diff changeset
524 } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4634
diff changeset
525 struct buddy *bud = gaim_find_buddy(gc->account, from);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
526 void *free1=NULL, *free2=NULL;
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
527 if (!bud) {
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
528 gaim_debug(GAIM_DEBUG_WARNING, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
529 "%s is playing a game, and doesn't want "
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
530 "you to know.\n", from);
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
531 }
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
532
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
533 if (*stat == '1') {
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
534 if (g_hash_table_lookup_extended (yd->games, from, free1, free2)) {
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
535 g_free(free1);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
536 g_free(free2);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
537 }
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
538 g_hash_table_insert (yd->games, g_strdup(from), g_strdup(game));
3020
c3a29bd2a2d7 [gaim-migrate @ 3033]
Sean Egan <seanegan@gmail.com>
parents: 3019
diff changeset
539 if (bud)
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
540 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc | YAHOO_STATUS_GAME);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
541 } else {
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
542 if (g_hash_table_lookup_extended (yd->games, from, free1, free2)) {
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
543 g_free(free1);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
544 g_free(free2);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
545 g_hash_table_remove (yd->games, from);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
546 }
3020
c3a29bd2a2d7 [gaim-migrate @ 3033]
Sean Egan <seanegan@gmail.com>
parents: 3019
diff changeset
547 if (bud)
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
548 serv_got_update(gc, from, 1, 0, 0, 0, bud->uc & ~YAHOO_STATUS_GAME);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
549 }
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
550 }
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
551 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
552
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
553 static void yahoo_process_message(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555 char *msg = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 char *from = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 time_t tm = time(NULL);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559
3021
18f0e61a6caf [gaim-migrate @ 3034]
Sean Egan <seanegan@gmail.com>
parents: 3020
diff changeset
560 if (pkt->status <= 1 || pkt->status == 5) {
6069
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
561 while (l) {
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
562 struct yahoo_pair *pair = l->data;
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
563 if (pair->key == 4)
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
564 from = pair->value;
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
565 if (pair->key == 15)
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
566 tm = strtol(pair->value, NULL, 10);
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
567 if (pair->key == 14) {
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
568 char *m;
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
569
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
570 msg = pair->value;
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
571
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
572 strip_linefeed(msg);
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
573 m = yahoo_codes_to_html(msg);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
574 serv_got_im(gc, from, m, 0, tm, -1);
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
575 g_free(m);
6069
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
576
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
577 tm = time(NULL);
2715
e901fd3ebbad [gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2708
diff changeset
578 }
6069
5ca86172352a [gaim-migrate @ 6519]
Luke Schierer <lschiere@pidgin.im>
parents: 6061
diff changeset
579 l = l->next;
2715
e901fd3ebbad [gaim-migrate @ 2728]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2708
diff changeset
580 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 } else if (pkt->status == 2) {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5367
diff changeset
582 gaim_notify_error(gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5367
diff changeset
583 _("Your Yahoo! message did not get sent."), NULL);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
584 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
586
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
588 static void yahoo_process_contact(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589 {
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
590 struct yahoo_data *yd = gc->proto_data;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
591 char *id = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
592 char *who = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
593 char *msg = NULL;
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
594 char *name = NULL;
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
595 int state = YAHOO_STATUS_AVAILABLE;
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
596 int online = FALSE;
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
597
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
599
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
601 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
602 if (pair->key == 1)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 id = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 else if (pair->key == 3)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
605 who = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606 else if (pair->key == 14)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 msg = pair->value;
5002
f78b24df83d5 [gaim-migrate @ 5337]
Sean Egan <seanegan@gmail.com>
parents: 4916
diff changeset
608 else if (pair->key == 7)
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
609 name = pair->value;
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
610 else if (pair->key == 10)
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
611 state = strtol(pair->value, NULL, 10);
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
612 else if (pair->key == 13)
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
613 online = strtol(pair->value, NULL, 10);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
615 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616
2682
db2b0b733732 [gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
617 if (id)
db2b0b733732 [gaim-migrate @ 2695]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2681
diff changeset
618 show_got_added(gc, id, who, NULL, msg);
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
619 if (name) {
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
620 if (state == YAHOO_STATUS_AVAILABLE)
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
621 serv_got_update(gc, name, 1, 0, 0, 0, 0);
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
622 else if (state == YAHOO_STATUS_IDLE)
5002
f78b24df83d5 [gaim-migrate @ 5337]
Sean Egan <seanegan@gmail.com>
parents: 4916
diff changeset
623 serv_got_update(gc, name, 1, 0, 0, -1, (state << 2));
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
624 else
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
625 serv_got_update(gc, name, 1, 0, 0, 0, (state << 2) | UC_UNAVAILABLE);
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
626 if (state == YAHOO_STATUS_CUSTOM) {
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
627 gpointer val = g_hash_table_lookup(yd->hash, name);
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
628 if (val) {
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
629 g_free(val);
2873
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
630 g_hash_table_insert(yd->hash, name,
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
631 msg ? g_strdup(msg) : g_malloc0(1));
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
632 } else
2873
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
633 g_hash_table_insert(yd->hash, g_strdup(name),
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
634 msg ? g_strdup(msg) : g_malloc0(1));
2683
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
635 }
4836eae8dd8c [gaim-migrate @ 2696]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2682
diff changeset
636 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
639 static void yahoo_process_mail(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640 {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
641 GaimAccount *account = gaim_connection_get_account(gc);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642 char *who = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 char *email = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
644 char *subj = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645 int count = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 GSList *l = pkt->hash;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
648 if (!gaim_account_get_check_mail(account))
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
649 return;
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
650
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 while (l) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652 struct yahoo_pair *pair = l->data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 if (pair->key == 9)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654 count = strtol(pair->value, NULL, 10);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
655 else if (pair->key == 43)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 who = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 else if (pair->key == 42)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 email = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 else if (pair->key == 18)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660 subj = pair->value;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661 l = l->next;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663
4001
9178da61c19f [gaim-migrate @ 4201]
Luke Schierer <lschiere@pidgin.im>
parents: 3996
diff changeset
664 if (who && subj && email && *email) {
2850
cbe6a1e63a72 [gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2813
diff changeset
665 char *from = g_strdup_printf("%s (%s)", who, email);
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
666
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
667 gaim_notify_email(gc, subj, from, gaim_account_get_username(account),
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
668 "http://mail.yahoo.com/", NULL, NULL);
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
669
2850
cbe6a1e63a72 [gaim-migrate @ 2863]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2813
diff changeset
670 g_free(from);
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
671 } else if (count > 0) {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
672 const char *to = gaim_account_get_username(account);
5521
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
673 const char *url = "http://mail.yahoo.com/";
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
674
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
675 gaim_notify_emails(gc, count, FALSE, NULL, NULL, &to, &url,
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
676 NULL, NULL);
76ec14ba51d7 [gaim-migrate @ 5921]
Christian Hammond <chipx86@chipx86.com>
parents: 5498
diff changeset
677 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 }
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
679 /* This is the y64 alphabet... it's like base64, but has a . and a _ */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
680 char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._";
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
681
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
682 /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
683 * in util.c, but it has a bug I don't feel like finding right now ;) */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
684 void to_y64(unsigned char *out, const unsigned char *in, int inlen)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
685 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
686 {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
687 for (; inlen >= 3; inlen -= 3)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
688 {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
689 *out++ = base64digits[in[0] >> 2];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
690 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
691 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
692 *out++ = base64digits[in[2] & 0x3f];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
693 in += 3;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
694 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
695 if (inlen > 0)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
696 {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
697 unsigned char fragment;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
698
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
699 *out++ = base64digits[in[0] >> 2];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
700 fragment = (in[0] << 4) & 0x30;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
701 if (inlen > 1)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
702 fragment |= in[1] >> 4;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
703 *out++ = base64digits[fragment];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
704 *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
705 *out++ = '-';
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
706 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
707 *out = '\0';
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
708 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
709
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
710 static void yahoo_process_auth(GaimConnection *gc, struct yahoo_packet *pkt)
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
711 {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
712 char *seed = NULL;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
713 char *sn = NULL;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
714 GSList *l = pkt->hash;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
715 struct yahoo_data *yd = gc->proto_data;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
716
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
717 while (l) {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
718 struct yahoo_pair *pair = l->data;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
719 if (pair->key == 94)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
720 seed = pair->value;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
721 if (pair->key == 1)
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
722 sn = pair->value;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
723 l = l->next;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
724 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
725
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
726 if (seed) {
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
727 struct yahoo_packet *pack;
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
728 GaimAccount *account = gaim_connection_get_account(gc);
5921
6a84a1892e26 [gaim-migrate @ 6361]
Sean Egan <seanegan@gmail.com>
parents: 5920
diff changeset
729 const char *name = normalize(gaim_account_get_username(account));
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
730 const char *pass = gaim_account_get_password(account);
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
731
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
732 /* So, Yahoo has stopped supporting its older clients in India, and undoubtedly
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
733 * will soon do so in the rest of the world.
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
734 *
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
735 * The new clients use this authentication method. I warn you in advance, it's
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
736 * bizzare, convoluted, inordinately complicated. It's also no more secure than
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
737 * crypt() was. The only purpose this scheme could serve is to prevent third
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
738 * part clients from connecting to their servers.
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
739 *
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
740 * Sorry, Yahoo.
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
741 */
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
742
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
743 md5_byte_t result[16];
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
744 md5_state_t ctx;
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
745
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
746 char *crypt_result;
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
747 char password_hash[25];
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
748 char crypt_hash[25];
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
749 char *hash_string_p = g_malloc(50 + strlen(sn));
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
750 char *hash_string_c = g_malloc(50 + strlen(sn));
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
751
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
752 char checksum;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
753
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
754 int sv;
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
755
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
756 char result6[25];
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
757 char result96[25];
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
758
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
759 sv = seed[15];
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
760 sv = sv % 8;
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
761
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
762 md5_init(&ctx);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
763 md5_append(&ctx, pass, strlen(pass));
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
764 md5_finish(&ctx, result);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
765 to_y64(password_hash, result, 16);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
766
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
767 md5_init(&ctx);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
768 crypt_result = yahoo_crypt(pass, "$1$_2S43d5f$");
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
769 md5_append(&ctx, crypt_result, strlen(crypt_result));
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
770 md5_finish(&ctx, result);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
771 to_y64(crypt_hash, result, 16);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
772
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
773 switch (sv) {
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
774 case 1:
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
775 case 6:
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
776 checksum = seed[seed[9] % 16];
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
777 g_snprintf(hash_string_p, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
778 "%c%s%s%s", checksum, name, seed, password_hash);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
779 g_snprintf(hash_string_c, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
780 "%c%s%s%s", checksum, name, seed, crypt_hash);
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
781 break;
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
782 case 2:
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
783 case 7:
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
784 checksum = seed[seed[15] % 16];
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
785 g_snprintf(hash_string_p, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
786 "%c%s%s%s", checksum, seed, password_hash, name);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
787 g_snprintf(hash_string_c, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
788 "%c%s%s%s", checksum, seed, crypt_hash, name);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
789 break;
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
790 case 3:
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
791 checksum = seed[seed[1] % 16];
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
792 g_snprintf(hash_string_p, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
793 "%c%s%s%s", checksum, name, password_hash, seed);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
794 g_snprintf(hash_string_c, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
795 "%c%s%s%s", checksum, name, crypt_hash, seed);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
796 break;
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
797 case 4:
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
798 checksum = seed[seed[3] % 16];
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
799 g_snprintf(hash_string_p, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
800 "%c%s%s%s", checksum, password_hash, seed, name);
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
801 g_snprintf(hash_string_c, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
802 "%c%s%s%s", checksum, crypt_hash, seed, name);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
803 break;
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
804 case 0:
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
805 case 5:
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
806 checksum = seed[seed[7] % 16];
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
807 g_snprintf(hash_string_p, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
808 "%c%s%s%s", checksum, password_hash, name, seed);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
809 g_snprintf(hash_string_c, strlen(sn) + 50,
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
810 "%c%s%s%s", checksum, crypt_hash, name, seed);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
811 break;
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
812 }
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
813
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
814 md5_init(&ctx);
3157
2bb8b7380814 [gaim-migrate @ 3173]
Sean Egan <seanegan@gmail.com>
parents: 3147
diff changeset
815 md5_append(&ctx, hash_string_p, strlen(hash_string_p));
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
816 md5_finish(&ctx, result);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
817 to_y64(result6, result, 16);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
818
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
819 md5_init(&ctx);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
820 md5_append(&ctx, hash_string_c, strlen(hash_string_c));
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
821 md5_finish(&ctx, result);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
822 to_y64(result96, result, 16);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
823
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
824 pack = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, YAHOO_STATUS_AVAILABLE, 0);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
825 yahoo_packet_hash(pack, 0, name);
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
826 yahoo_packet_hash(pack, 6, result6);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
827 yahoo_packet_hash(pack, 96, result96);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
828 yahoo_packet_hash(pack, 1, name);
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
829
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
830 yahoo_send_packet(yd, pack);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
831
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
832 g_free(hash_string_p);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
833 g_free(hash_string_c);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
834
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
835 yahoo_packet_free(pack);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
836 }
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
837 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
839 static void yahoo_packet_process(GaimConnection *gc, struct yahoo_packet *pkt)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
841 switch (pkt->service)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 case YAHOO_SERVICE_LOGON:
2771
450f4f9d2f23 [gaim-migrate @ 2784]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2741
diff changeset
844 case YAHOO_SERVICE_LOGOFF:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 case YAHOO_SERVICE_ISAWAY:
2737
f61c1f3a6afa [gaim-migrate @ 2750]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2724
diff changeset
846 case YAHOO_SERVICE_ISBACK:
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
847 case YAHOO_SERVICE_GAMELOGON:
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
848 case YAHOO_SERVICE_GAMELOGOFF:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
849 yahoo_process_status(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
850 break;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
851 case YAHOO_SERVICE_NOTIFY:
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
852 yahoo_process_notify(gc, pkt);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
853 break;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
854 case YAHOO_SERVICE_MESSAGE:
2786
318f846120e2 [gaim-migrate @ 2799]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2772
diff changeset
855 case YAHOO_SERVICE_GAMEMSG:
5939
3014de25a8a4 [gaim-migrate @ 6379]
Luke Schierer <lschiere@pidgin.im>
parents: 5921
diff changeset
856 case YAHOO_SERVICE_CHATMSG:
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857 yahoo_process_message(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
858 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
859 case YAHOO_SERVICE_NEWMAIL:
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
860 yahoo_process_mail(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
862 case YAHOO_SERVICE_NEWCONTACT:
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
863 yahoo_process_contact(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
864 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
865 case YAHOO_SERVICE_LIST:
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
866 yahoo_process_list(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
867 break;
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
868 case YAHOO_SERVICE_AUTH:
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
869 yahoo_process_auth(gc, pkt);
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
870 break;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871 default:
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
872 gaim_debug(GAIM_DEBUG_ERROR, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
873 "Unhandled service 0x%02x\n", pkt->service);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
874 break;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
875 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
876 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
877
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
878 static void yahoo_pending(gpointer data, gint source, GaimInputCondition cond)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879 {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
880 GaimConnection *gc = data;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
881 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882 char buf[1024];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 int len;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 len = read(yd->fd, buf, sizeof(buf));
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
887 if (len <= 0) {
6321
3613007cbb6e [gaim-migrate @ 6820]
Luke Schierer <lschiere@pidgin.im>
parents: 6115
diff changeset
888 gaim_connection_error(gc, _("Unable to read"));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 memcpy(yd->rxqueue + yd->rxlen, buf, len);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 yd->rxlen += len;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896 while (1) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
897 struct yahoo_packet *pkt;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
898 int pos = 0;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899 int pktlen;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 if (yd->rxlen < YAHOO_PACKET_HDRLEN)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904 pos += 4; /* YMSG */
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
905 pos += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
906 pos += 2;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
907
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
908 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2;
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
909 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
910 "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
911
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
912 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen))
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
913 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
914
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
915 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
916
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
917 pkt = yahoo_packet_new(0, 0, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
918
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
919 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2;
3021
18f0e61a6caf [gaim-migrate @ 3034]
Sean Egan <seanegan@gmail.com>
parents: 3020
diff changeset
920 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4;
5220
7b9d78fa051e [gaim-migrate @ 5590]
Christian Hammond <chipx86@chipx86.com>
parents: 5216
diff changeset
921 gaim_debug(GAIM_DEBUG_MISC, "yahoo",
5216
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
922 "Yahoo Service: 0x%02x Status: %d\n",
00bd3019749e [gaim-migrate @ 5586]
Christian Hammond <chipx86@chipx86.com>
parents: 5205
diff changeset
923 pkt->service, pkt->status);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
924 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
925
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
926 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
928 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
929 if (yd->rxlen) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930 char *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
931 g_free(yd->rxqueue);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
932 yd->rxqueue = tmp;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
933 } else {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
934 g_free(yd->rxqueue);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
935 yd->rxqueue = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938 yahoo_packet_process(gc, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
939
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
940 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
942 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
943
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
944 static void yahoo_got_connected(gpointer data, gint source, GaimInputCondition cond)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
945 {
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
946 GaimConnection *gc = data;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
947 struct yahoo_data *yd;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
948 struct yahoo_packet *pkt;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
949
5590
011a0a975060 [gaim-migrate @ 5994]
Christian Hammond <chipx86@chipx86.com>
parents: 5583
diff changeset
950 if (!g_list_find(gaim_connections_get_all(), gc)) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
951 close(source);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
952 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
954
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
955 if (source < 0) {
6321
3613007cbb6e [gaim-migrate @ 6820]
Luke Schierer <lschiere@pidgin.im>
parents: 6115
diff changeset
956 gaim_connection_error(gc, _("Unable to connect"));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
957 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
958 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
959
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
960 yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
961 yd->fd = source;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962
3147
3805d9d344f2 [gaim-migrate @ 3163]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
963 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, YAHOO_STATUS_AVAILABLE, 0);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964
5921
6a84a1892e26 [gaim-migrate @ 6361]
Sean Egan <seanegan@gmail.com>
parents: 5920
diff changeset
965 yahoo_packet_hash(pkt, 1, normalize(gaim_account_get_username(gaim_connection_get_account(gc))));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
966 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
968 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 gc->inpa = gaim_input_add(yd->fd, GAIM_INPUT_READ, yahoo_pending, gc);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
973 static void yahoo_login(GaimAccount *account) {
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
974 GaimConnection *gc = gaim_account_get_connection(account);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
977 gaim_connection_update_progress(gc, _("Connecting"), 1, 2);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
978
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
979 yd->fd = -1;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980 yd->hash = g_hash_table_new(g_str_hash, g_str_equal);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
981 yd->games = g_hash_table_new(g_str_hash, g_str_equal);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
982
5681
46d7ad0dfa26 [gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents: 5638
diff changeset
983 if (gaim_proxy_connect(account, gaim_account_get_string(account, "server", YAHOO_PAGER_HOST),
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
984 gaim_account_get_int(account, "port", YAHOO_PAGER_PORT),
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
985 yahoo_got_connected, gc) != 0) {
6321
3613007cbb6e [gaim-migrate @ 6820]
Luke Schierer <lschiere@pidgin.im>
parents: 6115
diff changeset
986 gaim_connection_error(gc, _("Connection problem"));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
987 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
988 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 static gboolean yahoo_destroy_hash(gpointer key, gpointer val, gpointer data)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 g_free(key);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995 g_free(val);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
996 return TRUE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
997 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
999 static void yahoo_close(GaimConnection *gc) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1001 g_hash_table_foreach_remove(yd->hash, yahoo_destroy_hash, NULL);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 g_hash_table_destroy(yd->hash);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1003 g_hash_table_foreach_remove(yd->games, yahoo_destroy_hash, NULL);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1004 g_hash_table_destroy(yd->games);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 if (yd->fd >= 0)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 close(yd->fd);
3720
34c95669952f [gaim-migrate @ 3853]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 3642
diff changeset
1007
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008 if (yd->rxqueue)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 g_free(yd->rxqueue);
2687
2d544f48146d [gaim-migrate @ 2700]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2686
diff changeset
1010 yd->rxlen = 0;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011 if (gc->inpa)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1012 gaim_input_remove(gc->inpa);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013 g_free(yd);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1014 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1016 static const char *yahoo_list_icon(GaimAccount *a, struct buddy *b)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4634
diff changeset
1018 return "yahoo";
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1019 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1020
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1021 static void yahoo_list_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne)
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1022 {
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1023 int i = 0;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1024 char *emblems[4] = {NULL,NULL,NULL,NULL};
5068
b37d7d09ec83 [gaim-migrate @ 5419]
Nathan Walp <nwalp@pidgin.im>
parents: 5002
diff changeset
1025 if (b->present == GAIM_BUDDY_OFFLINE) {
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1026 *se = "offline";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1027 return;
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1028 } else {
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1029 if (b->uc & UC_UNAVAILABLE)
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1030 emblems[i++] = "away";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1031 if (b->uc & YAHOO_STATUS_GAME)
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1032 emblems[i++] = "game";
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1033 }
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1034 *se = emblems[0];
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1035 *sw = emblems[1];
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1036 *nw = emblems[2];
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1037 *ne = emblems[3];
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
1038 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1039
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040 static char *yahoo_get_status_string(enum yahoo_status a)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1041 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1042 switch (a) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1043 case YAHOO_STATUS_BRB:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1044 return _("Be Right Back");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1045 case YAHOO_STATUS_BUSY:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1046 return _("Busy");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1047 case YAHOO_STATUS_NOTATHOME:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1048 return _("Not At Home");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049 case YAHOO_STATUS_NOTATDESK:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1050 return _("Not At Desk");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 case YAHOO_STATUS_NOTINOFFICE:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1052 return _("Not In Office");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053 case YAHOO_STATUS_ONPHONE:
4606
864518c3767d [gaim-migrate @ 4894]
Luke Schierer <lschiere@pidgin.im>
parents: 4596
diff changeset
1054 return _("On The Phone");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1055 case YAHOO_STATUS_ONVACATION:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1056 return _("On Vacation");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 case YAHOO_STATUS_OUTTOLUNCH:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1058 return _("Out To Lunch");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059 case YAHOO_STATUS_STEPPEDOUT:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1060 return _("Stepped Out");
2873
26be84883f91 [gaim-migrate @ 2886]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2856
diff changeset
1061 case YAHOO_STATUS_INVISIBLE:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1062 return _("Invisible");
4730
9d3b7b106def [gaim-migrate @ 5043]
Sean Egan <seanegan@gmail.com>
parents: 4729
diff changeset
1063 case YAHOO_STATUS_IDLE:
9d3b7b106def [gaim-migrate @ 5043]
Sean Egan <seanegan@gmail.com>
parents: 4729
diff changeset
1064 return _("Idle");
2879
5fc5123b7098 [gaim-migrate @ 2892]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2878
diff changeset
1065 default:
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1066 return _("Online");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1067 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1068 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1070 static void yahoo_game(GaimConnection *gc, const char *name) {
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1071 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1072 char *game = g_hash_table_lookup(yd->games, name);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1073 char *t;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1074 char url[256];
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1075
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1076 if (!game)
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1077 return;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1078 t = game = g_strdup(strstr(game, "ante?room="));
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1079 while (*t != '\t')
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1080 t++;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1081 *t = 0;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1082 g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game);
6465
fb64cc87bc96 [gaim-migrate @ 6974]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
1083 gaim_notify_uri(gc, url);
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1084 g_free(game);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1085 }
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
1086
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
1087 static char *yahoo_status_text(struct buddy *b)
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
1088 {
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
1089 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data;
4730
9d3b7b106def [gaim-migrate @ 5043]
Sean Egan <seanegan@gmail.com>
parents: 4729
diff changeset
1090 if (b->uc & UC_UNAVAILABLE) {
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
1091 if ((b->uc >> 2) != YAHOO_STATUS_CUSTOM)
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4731
diff changeset
1092 return g_strdup(yahoo_get_status_string(b->uc >> 2));
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1093 else {
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1094 char *stripped = strip_html(g_hash_table_lookup(yd->hash, b->name));
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1095 if(stripped) {
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1096 char *ret = g_markup_escape_text(stripped, strlen(stripped));
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1097 g_free(stripped);
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1098 return ret;
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1099 }
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1100 }
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
1101 }
4729
751c37a940dd [gaim-migrate @ 5042]
Nathan Walp <nwalp@pidgin.im>
parents: 4724
diff changeset
1102 return NULL;
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
1103 }
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
1104
4724
b9e7ccf21f9c [gaim-migrate @ 5037]
Sean Egan <seanegan@gmail.com>
parents: 4722
diff changeset
1105 static char *yahoo_tooltip_text(struct buddy *b)
b9e7ccf21f9c [gaim-migrate @ 5037]
Sean Egan <seanegan@gmail.com>
parents: 4722
diff changeset
1106 {
b9e7ccf21f9c [gaim-migrate @ 5037]
Sean Egan <seanegan@gmail.com>
parents: 4722
diff changeset
1107 struct yahoo_data *yd = (struct yahoo_data*)b->account->gc->proto_data;
4730
9d3b7b106def [gaim-migrate @ 5043]
Sean Egan <seanegan@gmail.com>
parents: 4729
diff changeset
1108 if (b->uc & UC_UNAVAILABLE) {
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
1109 char *status;
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
1110 char *ret;
4731
6f0ecc21db46 [gaim-migrate @ 5044]
Nathan Walp <nwalp@pidgin.im>
parents: 4730
diff changeset
1111 if ((b->uc >> 2) != YAHOO_STATUS_CUSTOM)
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
1112 status = g_strdup(yahoo_get_status_string(b->uc >> 2));
4724
b9e7ccf21f9c [gaim-migrate @ 5037]
Sean Egan <seanegan@gmail.com>
parents: 4722
diff changeset
1113 else
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
1114 status = strip_html(g_hash_table_lookup(yd->hash, b->name));
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
1115 if(status) {
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1116 char *escaped = g_markup_escape_text(status, strlen(status));
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1117 ret = g_strdup_printf(_("<b>Status:</b> %s"), escaped);
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
1118 g_free(status);
4777
e23a7e166680 [gaim-migrate @ 5097]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1119 g_free(escaped);
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
1120 return ret;
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4732
diff changeset
1121 }
4724
b9e7ccf21f9c [gaim-migrate @ 5037]
Sean Egan <seanegan@gmail.com>
parents: 4722
diff changeset
1122 }
4729
751c37a940dd [gaim-migrate @ 5042]
Nathan Walp <nwalp@pidgin.im>
parents: 4724
diff changeset
1123 return NULL;
751c37a940dd [gaim-migrate @ 5042]
Nathan Walp <nwalp@pidgin.im>
parents: 4724
diff changeset
1124 }
751c37a940dd [gaim-migrate @ 5042]
Nathan Walp <nwalp@pidgin.im>
parents: 4724
diff changeset
1125
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1126 static GList *yahoo_buddy_menu(GaimConnection *gc, const char *who)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128 GList *m = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129 struct proto_buddy_menu *pbm;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4634
diff changeset
1131 struct buddy *b = gaim_find_buddy(gc->account, who); /* this should never be null. if it is,
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 segfault and get the bug report. */
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1133 static char buf2[1024];
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
1134
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1135 if (b->uc | YAHOO_STATUS_GAME) {
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1136 char *game = g_hash_table_lookup(yd->games, b->name);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1137 char *room;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1138 if (!game)
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1139 return m;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1140 if (game) {
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1141 char *t;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1142 pbm = g_new0(struct proto_buddy_menu, 1);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1143 if (!(room = strstr(game, "&follow="))) /* skip ahead to the url */
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1144 return NULL;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1145 while (*room && *room != '\t') /* skip to the tab */
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1146 room++;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1147 t = room++; /* room as now at the name */
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1148 while (*t != '\n')
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1149 t++; /* replace the \n with a space */
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1150 *t = ' ';
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1151 g_snprintf(buf2, sizeof buf2, "%s", room);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1152 pbm->label = buf2;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1153 pbm->callback = yahoo_game;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1154 pbm->gc = gc;
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1155 m = g_list_append(m, pbm);
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1156 }
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1157 }
4722
534eaa4ead94 [gaim-migrate @ 5034]
Sean Egan <seanegan@gmail.com>
parents: 4690
diff changeset
1158
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159 return m;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1161
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1162 static void yahoo_act_id(GaimConnection *gc, const char *entry)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167 yahoo_packet_hash(pkt, 3, entry);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1168 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1171 gaim_connection_set_display_name(gc, entry);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1172 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1173
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1174 static void yahoo_show_act_id(GaimConnection *gc)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175 {
5493
3e8487580024 [gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1176 gaim_request_input(gc, NULL, _("Active which ID?"), NULL,
6035
8c44020a958e [gaim-migrate @ 6485]
Christian Hammond <chipx86@chipx86.com>
parents: 5939
diff changeset
1177 gaim_connection_get_display_name(gc), FALSE, FALSE,
5493
3e8487580024 [gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1178 _("OK"), G_CALLBACK(yahoo_act_id),
3e8487580024 [gaim-migrate @ 5889]
Christian Hammond <chipx86@chipx86.com>
parents: 5436
diff changeset
1179 _("Cancel"), NULL, gc);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1182 static GList *yahoo_actions(GaimConnection *gc) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183 GList *m = NULL;
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1184 struct proto_actions_menu *pam;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1186 pam = g_new0(struct proto_actions_menu, 1);
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1187 pam->label = _("Activate ID");
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1188 pam->callback = yahoo_show_act_id;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1189 pam->gc = gc;
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4201
diff changeset
1190 m = g_list_append(m, pam);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1192 return m;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1195 static int yahoo_send_im(GaimConnection *gc, const char *who, const char *what, int len, int flags)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1197 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1198 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0);
3642
5e50f6746509 [gaim-migrate @ 3766]
Luke Schierer <lschiere@pidgin.im>
parents: 3640
diff changeset
1199 char *msg = g_strdup(what);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1201 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202 yahoo_packet_hash(pkt, 5, who);
3493
4b204c262376 [gaim-migrate @ 3553]
Luke Schierer <lschiere@pidgin.im>
parents: 3467
diff changeset
1203 yahoo_packet_hash(pkt, 14, msg);
6044
8642749e55ca [gaim-migrate @ 6494]
Mark Doliner <mark@kingant.net>
parents: 6035
diff changeset
1204 yahoo_packet_hash(pkt, 97, "1");
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1205
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1207
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 yahoo_packet_free(pkt);
3493
4b204c262376 [gaim-migrate @ 3553]
Luke Schierer <lschiere@pidgin.im>
parents: 3467
diff changeset
1209
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 return 1;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 6044
diff changeset
1213 int yahoo_send_typing(GaimConnection *gc, const char *who, int typ)
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1214 {
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1215 struct yahoo_data *yd = gc->proto_data;
3019
304e8c376472 [gaim-migrate @ 3032]
Sean Egan <seanegan@gmail.com>
parents: 3001
diff changeset
1216 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0);
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1217 yahoo_packet_hash(pkt, 49, "TYPING");
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1218 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1219 yahoo_packet_hash(pkt, 14, " ");
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
1220 yahoo_packet_hash(pkt, 13, typ == GAIM_TYPING ? "1" : "0");
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1221 yahoo_packet_hash(pkt, 5, who);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1222 yahoo_packet_hash(pkt, 1002, "1");
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1223
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1224 yahoo_send_packet(yd, pkt);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1225
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1226 yahoo_packet_free(pkt);
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1227
3001
87fff45fa36b [gaim-migrate @ 3014]
Sean Egan <seanegan@gmail.com>
parents: 2993
diff changeset
1228 return 0;
2993
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1229 }
7239a392486c [gaim-migrate @ 3006]
Rob Flynn <gaim@robflynn.com>
parents: 2979
diff changeset
1230
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 6044
diff changeset
1231 static void yahoo_set_away(GaimConnection *gc, const char *state, const char *msg)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1234 struct yahoo_packet *pkt;
2772
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
1235 int service;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236 char s[4];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1237
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
1238 if (gc->away) {
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
1239 g_free(gc->away);
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
1240 gc->away = NULL;
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
1241 }
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 if (msg) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1244 yd->current_status = YAHOO_STATUS_CUSTOM;
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
1245 gc->away = g_strdup(msg);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1246 } else if (state) {
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
1247 gc->away = g_strdup("");
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1248 if (!strcmp(state, _("Available"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1249 yd->current_status = YAHOO_STATUS_AVAILABLE;
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
1250 g_free(gc->away);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1251 gc->away = NULL;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1252 } else if (!strcmp(state, _("Be Right Back"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 yd->current_status = YAHOO_STATUS_BRB;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1254 } else if (!strcmp(state, _("Busy"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255 yd->current_status = YAHOO_STATUS_BUSY;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1256 } else if (!strcmp(state, _("Not At Home"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 yd->current_status = YAHOO_STATUS_NOTATHOME;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1258 } else if (!strcmp(state, _("Not At Desk"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259 yd->current_status = YAHOO_STATUS_NOTATDESK;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1260 } else if (!strcmp(state, _("Not In Office"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1261 yd->current_status = YAHOO_STATUS_NOTINOFFICE;
4606
864518c3767d [gaim-migrate @ 4894]
Luke Schierer <lschiere@pidgin.im>
parents: 4596
diff changeset
1262 } else if (!strcmp(state, _("On The Phone"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1263 yd->current_status = YAHOO_STATUS_ONPHONE;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1264 } else if (!strcmp(state, _("On Vacation"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1265 yd->current_status = YAHOO_STATUS_ONVACATION;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1266 } else if (!strcmp(state, _("Out To Lunch"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1267 yd->current_status = YAHOO_STATUS_OUTTOLUNCH;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1268 } else if (!strcmp(state, _("Stepped Out"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1269 yd->current_status = YAHOO_STATUS_STEPPEDOUT;
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1270 } else if (!strcmp(state, _("Invisible"))) {
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 yd->current_status = YAHOO_STATUS_INVISIBLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1272 } else if (!strcmp(state, GAIM_AWAY_CUSTOM)) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1273 if (gc->is_idle) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1274 yd->current_status = YAHOO_STATUS_IDLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1275 } else {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1276 yd->current_status = YAHOO_STATUS_AVAILABLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1277 }
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4044
diff changeset
1278 g_free(gc->away);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1279 gc->away = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1280 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281 } else if (gc->is_idle) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1282 yd->current_status = YAHOO_STATUS_IDLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283 } else {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1284 yd->current_status = YAHOO_STATUS_AVAILABLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1285 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1286
2772
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
1287 if (yd->current_status == YAHOO_STATUS_AVAILABLE)
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
1288 service = YAHOO_SERVICE_ISBACK;
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
1289 else
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
1290 service = YAHOO_SERVICE_ISAWAY;
f9227268db25 [gaim-migrate @ 2785]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2771
diff changeset
1291 pkt = yahoo_packet_new(service, yd->current_status, 0);
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292 g_snprintf(s, sizeof(s), "%d", yd->current_status);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1293 yahoo_packet_hash(pkt, 10, s);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1294 if (yd->current_status == YAHOO_STATUS_CUSTOM)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 yahoo_packet_hash(pkt, 19, msg);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1298 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1301 static void yahoo_set_idle(GaimConnection *gc, int idle)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1303 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1304 struct yahoo_packet *pkt = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1305
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1306 if (idle && yd->current_status == YAHOO_STATUS_AVAILABLE) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1307 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_IDLE, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1308 yd->current_status = YAHOO_STATUS_IDLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1309 } else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1310 pkt = yahoo_packet_new(YAHOO_SERVICE_ISAWAY, YAHOO_STATUS_AVAILABLE, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1311 yd->current_status = YAHOO_STATUS_AVAILABLE;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1312 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1313
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314 if (pkt) {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1315 char buf[4];
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1316 g_snprintf(buf, sizeof(buf), "%d", yd->current_status);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1317 yahoo_packet_hash(pkt, 10, buf);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1318 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1319 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1321 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1322
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1323 static GList *yahoo_away_states(GaimConnection *gc)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1324 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1325 GList *m = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1326
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1327 m = g_list_append(m, _("Available"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1328 m = g_list_append(m, _("Be Right Back"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1329 m = g_list_append(m, _("Busy"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1330 m = g_list_append(m, _("Not At Home"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1331 m = g_list_append(m, _("Not At Desk"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1332 m = g_list_append(m, _("Not In Office"));
4606
864518c3767d [gaim-migrate @ 4894]
Luke Schierer <lschiere@pidgin.im>
parents: 4596
diff changeset
1333 m = g_list_append(m, _("On The Phone"));
4596
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1334 m = g_list_append(m, _("On Vacation"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1335 m = g_list_append(m, _("Out To Lunch"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1336 m = g_list_append(m, _("Stepped Out"));
7e1591c6d0d8 [gaim-migrate @ 4881]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
1337 m = g_list_append(m, _("Invisible"));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1338 m = g_list_append(m, GAIM_AWAY_CUSTOM);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1339
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1340 return m;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1341 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1342
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1343 static void yahoo_keepalive(GaimConnection *gc)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1344 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1345 struct yahoo_data *yd = gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1346 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1347 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1348 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1349 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1350
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1351 static void yahoo_add_buddy(GaimConnection *gc, const char *who)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1352 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1353 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1354 struct yahoo_packet *pkt;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1355 struct group *g;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1356 char *group = NULL;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1357
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1358 if (!yd->logged_in)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1359 return;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1360
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4634
diff changeset
1361 g = gaim_find_buddys_group(gaim_find_buddy(gc->account, who));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1362 if (g)
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1363 group = g->name;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1364 else
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1365 group = "Buddies";
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1366
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1367 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1368 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1369 yahoo_packet_hash(pkt, 7, who);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1370 yahoo_packet_hash(pkt, 65, group);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1371 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1372 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1373 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1374
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 6044
diff changeset
1375 static void yahoo_remove_buddy(GaimConnection *gc, const char *who, const char *group)
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1376 {
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1377 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1378
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1379 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0);
5583
e46efd264489 [gaim-migrate @ 5987]
Sean Egan <seanegan@gmail.com>
parents: 5521
diff changeset
1380 yahoo_packet_hash(pkt, 1, gaim_connection_get_display_name(gc));
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1381 yahoo_packet_hash(pkt, 7, who);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1382 yahoo_packet_hash(pkt, 65, group);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1383 yahoo_send_packet(yd, pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1384 yahoo_packet_free(pkt);
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1385 }
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1386
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1387 static gboolean yahoo_unload_plugin(GaimPlugin *plugin)
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1388 {
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1389 yahoo_dest_colorht();
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1390 return TRUE;
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1391 }
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1392
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1393 static void yahoo_got_info(gpointer data, char *url_text, unsigned long len)
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1394 {
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1395 char *stripped,*p;
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1396 char buf[1024];
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1397
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1398 /* we failed to grab the profile URL */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1399 if (!url_text) {
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1400 g_show_info_text(NULL, NULL, 2,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1401 "<html><body><b>Error retrieving profile</b></body></html>", NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1402 return;
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1403 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1404
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1405 /* we don't yet support the multiple link level of the warning page for
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1406 * 'adult' profiles, not to mention the fact that yahoo wants you to be
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1407 * logged in (on the website) to be able to view an 'adult' profile. for
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1408 * now, just tell them that we can't help them, and provide a link to the
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1409 * profile if they want to do the web browser thing.
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1410 */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1411 p = strstr(url_text, "Adult Profiles Warning Message");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1412 if (p) {
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1413 strcpy(buf, "<b>Sorry, profiles marked as containing adult content are ");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1414 strcat(buf, "not supported at this time.</b><br><br>\n");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1415 info_extract_field(url_text, buf, ".idname=", 0, "%26", 0, NULL,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1416 "If you wish to view this profile, you will need to visit this link in your web browser",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1417 1, YAHOO_PROFILE_URL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1418 strcat(buf, "</body></html>\n");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1419 g_show_info_text(NULL, NULL, 2, buf, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1420 return;
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1421 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1422
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1423 /* strip_html() doesn't strip out character entities like &nbsp; and &#183;
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1424 */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1425 while ((p = strstr(url_text, "&nbsp;")) != NULL) {
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1426 memmove(p, p + 6, strlen(p + 6));
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1427 url_text[strlen(url_text) - 6] = '\0';
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1428 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1429 while ((p = strstr(url_text, "&#183;")) != NULL) {
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1430 memmove(p, p + 6, strlen(p + 6));
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1431 url_text[strlen(url_text) - 6] = '\0';
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1432 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1433
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1434 /* nuke the nasty \r's */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1435 while ((p = strchr(url_text, '\r')) != NULL) {
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1436 memmove(p, p + 1, strlen(p + 1));
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1437 url_text[strlen(url_text) - 1] = '\0';
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1438 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1439
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1440 /* nuke the html, it's easier than trying to parse the horrid stuff */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1441 stripped = strip_html(url_text);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1442
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1443 /* gonna re-use the memory we've already got for url_text */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1444 strcpy(url_text, "<html><body>\n");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1445
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1446 /* extract their Yahoo! ID and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1447 info_extract_field(stripped, url_text, "Yahoo! ID:", 2, "\n", 0,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1448 NULL, "Yahoo! ID", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1449
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1450 /* extract their Email address and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1451 info_extract_field(stripped, url_text, "My Email", 5, "\n", 0,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1452 "Private", "Email", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1453
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1454 /* extract the Nickname if it exists */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1455 info_extract_field(stripped, url_text, "Nickname:", 1, "\n", '\n',
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1456 NULL, "Nickname", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1457
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1458 /* extract their RealName and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1459 info_extract_field(stripped, url_text, "RealName:", 1, "\n", '\n',
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1460 NULL, "Real Name", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1461
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1462 /* extract their Location and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1463 info_extract_field(stripped, url_text, "Location:", 2, "\n", '\n',
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1464 NULL, "Location", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1465
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1466 /* extract their Age and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1467 info_extract_field(stripped, url_text, "Age:", 3, "\n", '\n',
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1468 NULL, "Age", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1469
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1470 /* extract their MaritalStatus and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1471 info_extract_field(stripped, url_text, "MaritalStatus:", 3, "\n", '\n',
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1472 "No Answer", "Marital Status", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1473
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1474 /* extract their Gender and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1475 info_extract_field(stripped, url_text, "Gender:", 3, "\n", '\n',
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1476 "No Answer", "Gender", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1477
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1478 /* extract their Occupation and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1479 info_extract_field(stripped, url_text, "Occupation:", 2, "\n", '\n',
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1480 NULL, "Occupation", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1481
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1482 /* Hobbies, Latest News, and Favorite Quote are a bit different, since the
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1483 * values can contain embedded newlines... but any or all of them can also
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1484 * not appear. The way we delimit them is to successively look for the next
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1485 * one that _could_ appear, and if all else fails, we end the section by
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1486 * looking for the 'Links' heading, which is the next thing to follow this
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1487 * bunch.
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1488 */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1489 if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Latest News",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1490 '\n', NULL, "Hobbies", 0, NULL))
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1491 if (!info_extract_field(stripped, url_text, "Hobbies:", 1, "Favorite Quote",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1492 '\n', NULL, "Hobbies", 0, NULL))
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1493 info_extract_field(stripped, url_text, "Hobbies:", 1, "Links",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1494 '\n', NULL, "Hobbies", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1495 if (!info_extract_field(stripped, url_text, "Latest News:", 1, "Favorite Quote",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1496 '\n', NULL, "Latest News", 0, NULL))
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1497 info_extract_field(stripped, url_text, "Latest News:", 1, "Links",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1498 '\n', NULL, "Latest News", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1499 info_extract_field(stripped, url_text, "Favorite Quote:", 0, "Links",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1500 '\n', NULL, "Favorite Quote", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1501
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1502 /* Home Page will either be "No home page specified",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1503 * or "Home Page: " and a link. */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1504 p = strstr(stripped, "No home page specified");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1505 if (!p)
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1506 info_extract_field(stripped, url_text, "Home Page:", 1, " ", 0, NULL,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1507 "Home Page", 1, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1508
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1509 /* Cool Link {1,2,3} is also different. If "No cool link specified" exists,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1510 * then we have none. If we have one however, we'll need to check and see if
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1511 * we have a second one. If we have a second one, we have to check to see if
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1512 * we have a third one.
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1513 */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1514 p = strstr(stripped,"No cool link specified");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1515 if (!p)
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1516 if (info_extract_field(stripped, url_text, "Cool Link 1:", 1, " ", 0, NULL,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1517 "Cool Link 1", 1, NULL))
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1518 if (info_extract_field(stripped, url_text, "Cool Link 2:", 1, " ", 0, NULL,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1519 "Cool Link 2", 1, NULL))
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1520 info_extract_field(stripped, url_text, "Cool Link 3:", 1, " ", 0, NULL,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1521 "Cool Link 3", 1, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1522
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1523 /* see if Member Since is there, and if so, extract it. */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1524 info_extract_field(stripped, url_text, "Member Since:", 1, "Last Updated:",
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1525 '\n', NULL, "Member Since", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1526
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1527 /* extract the Last Updated date and put it in */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1528 info_extract_field(stripped, url_text, "Last Updated:", 1, "\n", '\n', NULL,
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1529 "Last Updated", 0, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1530
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1531 /* finish off the html */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1532 strcat(url_text, "</body></html>\n");
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1533 g_free(stripped);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1534
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1535 /* show it to the user */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1536 g_show_info_text(NULL, NULL, 2, url_text, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1537 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1538
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1539 static void yahoo_get_info(GaimConnection *gc, const char *name)
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1540 {
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1541 /* struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data; */
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1542 char url[256];
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1543 g_snprintf(url, sizeof url, "%s%s", YAHOO_PROFILE_URL, name);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1544 grab_url(url, FALSE, yahoo_got_info, NULL);
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1545 }
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1546
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1547 static GaimPlugin *my_protocol = NULL;
2681
37d80035e77f [gaim-migrate @ 2694]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1548
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1549 static GaimPluginProtocolInfo prpl_info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1550 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1551 GAIM_PROTO_YAHOO,
5367
fc0441fbf159 [gaim-migrate @ 5743]
Luke Schierer <lschiere@pidgin.im>
parents: 5220
diff changeset
1552 OPT_PROTO_MAIL_CHECK | OPT_PROTO_USE_POINTSIZE,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1553 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1554 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1555 yahoo_list_icon,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1556 yahoo_list_emblems,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1557 yahoo_status_text,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1558 yahoo_tooltip_text,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1559 yahoo_away_states,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1560 yahoo_actions,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1561 yahoo_buddy_menu,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1562 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1563 yahoo_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1564 yahoo_close,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1565 yahoo_send_im,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1566 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1567 yahoo_send_typing,
6514
64d952098596 [gaim-migrate @ 7031]
Luke Schierer <lschiere@pidgin.im>
parents: 6513
diff changeset
1568 yahoo_get_info,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1569 yahoo_set_away,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1570 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1571 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1572 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1573 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1574 yahoo_set_idle,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1575 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1576 yahoo_add_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1577 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1578 yahoo_remove_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1579 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1580 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1581 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1582 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1583 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1584 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1585 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1586 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1587 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1588 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1589 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1590 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1591 yahoo_keepalive,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1592 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1593 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1594 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1595 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1596 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1597 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1598 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1599 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1600 NULL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1601 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1602
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1603 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1604 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1605 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1606 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1607 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1608 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1609 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1610 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1611
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1612 "prpl-yahoo", /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1613 "Yahoo", /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1614 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1615 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1616 N_("Yahoo Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1617 /** description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1618 N_("Yahoo Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1619 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6321
diff changeset
1620 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1621
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1622 NULL, /**< load */
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1623 yahoo_unload_plugin, /**< unload */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1624 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1625
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1626 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1627 &prpl_info /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1628 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1629
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1630 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1631 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1632 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
1633 GaimAccountOption *option;
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1634
5685
43ea75092684 [gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1635 option = gaim_account_option_string_new(_("Pager host"), "server",
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
1636 YAHOO_PAGER_HOST);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
1637 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
1638 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1639
5685
43ea75092684 [gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1640 option = gaim_account_option_int_new(_("Pager port"), "port",
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
1641 YAHOO_PAGER_PORT);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
1642 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5590
diff changeset
1643 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1644
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1645 my_protocol = plugin;
6513
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1646
63c449a1022f [gaim-migrate @ 7030]
Luke Schierer <lschiere@pidgin.im>
parents: 6465
diff changeset
1647 yahoo_init_colorht();
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1648 }
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5136
diff changeset
1649
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1650 GAIM_INIT_PLUGIN(yahoo, init_plugin, info);