annotate libpurple/protocols/yahoo/libymsg.c @ 27398:7f008ce8604b

I believe this will correctly handle setting the yd->jp value under the new two-prpl model. I still need to put a migration path in for existing Yahoo! JAPAN accounts.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sun, 05 Jul 2009 14:31:37 +0000
parents 1f30c4a47e3d
children 31534ae3406a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27394
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1 /*
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2 * purple
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4 * Purple is the legal property of its developers, whose names are too numerous
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
6 * source distribution.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
7 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
11 * (at your option) any later version.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
12 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
16 * GNU General Public License for more details.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
17 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
21 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
22 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
23
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
24 #include "internal.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
25
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
26 #include "account.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
27 #include "accountopt.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
28 #include "blist.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
29 #include "cipher.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
30 #include "cmds.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
31 #include "core.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
32 #include "debug.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
33 #include "network.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
34 #include "notify.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
35 #include "privacy.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
36 #include "prpl.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
37 #include "proxy.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
38 #include "request.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
39 #include "server.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
40 #include "util.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
41 #include "version.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
42 #include "xmlnode.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
43
27395
ef5f0cde8d74 Update for file renames.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27394
diff changeset
44 #include "ymsg.h"
27394
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
45 #include "yahoochat.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
46 #include "yahoo_aliases.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
47 #include "yahoo_doodle.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
48 #include "yahoo_filexfer.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
49 #include "yahoo_friend.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
50 #include "yahoo_packet.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
51 #include "yahoo_picture.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
52 #include "ycht.h"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
53
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
54 /* #define YAHOO_DEBUG */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
55
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
56 /* #define TRY_WEBMESSENGER_LOGIN 0 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
57
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
58 /* One hour */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
59 #define PING_TIMEOUT 3600
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
60
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
61 /* One minute */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
62 #define KEEPALIVE_TIMEOUT 60
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
63
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
64 static void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *, PurpleGroup *);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
65 #ifdef TRY_WEBMESSENGER_LOGIN
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
66 static void yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *url_text, size_t len, const gchar *error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
67 #endif /* TRY_WEBMESSENGER_LOGIN */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
68 static void yahoo_set_status(PurpleAccount *account, PurpleStatus *status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
69
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
70 static void yahoo_update_status(PurpleConnection *gc, const char *name, YahooFriend *f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
71 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
72 char *status = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
73
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
74 if (!gc || !name || !f || !purple_find_buddy(purple_connection_get_account(gc), name))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
75 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
76
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
77 switch (f->status) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
78 case YAHOO_STATUS_OFFLINE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
79 status = YAHOO_STATUS_TYPE_OFFLINE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
80 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
81 case YAHOO_STATUS_AVAILABLE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
82 status = YAHOO_STATUS_TYPE_AVAILABLE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
83 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
84 case YAHOO_STATUS_BRB:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
85 status = YAHOO_STATUS_TYPE_BRB;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
86 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
87 case YAHOO_STATUS_BUSY:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
88 status = YAHOO_STATUS_TYPE_BUSY;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
89 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
90 case YAHOO_STATUS_NOTATHOME:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
91 status = YAHOO_STATUS_TYPE_NOTATHOME;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
92 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
93 case YAHOO_STATUS_NOTATDESK:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
94 status = YAHOO_STATUS_TYPE_NOTATDESK;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
95 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
96 case YAHOO_STATUS_NOTINOFFICE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
97 status = YAHOO_STATUS_TYPE_NOTINOFFICE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
98 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
99 case YAHOO_STATUS_ONPHONE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
100 status = YAHOO_STATUS_TYPE_ONPHONE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
101 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
102 case YAHOO_STATUS_ONVACATION:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
103 status = YAHOO_STATUS_TYPE_ONVACATION;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
104 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
105 case YAHOO_STATUS_OUTTOLUNCH:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
106 status = YAHOO_STATUS_TYPE_OUTTOLUNCH;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
107 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
108 case YAHOO_STATUS_STEPPEDOUT:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
109 status = YAHOO_STATUS_TYPE_STEPPEDOUT;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
110 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
111 case YAHOO_STATUS_INVISIBLE: /* this should never happen? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
112 status = YAHOO_STATUS_TYPE_INVISIBLE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
113 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
114 case YAHOO_STATUS_CUSTOM:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
115 case YAHOO_STATUS_IDLE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
116 if (!f->away)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
117 status = YAHOO_STATUS_TYPE_AVAILABLE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
118 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
119 status = YAHOO_STATUS_TYPE_AWAY;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
120 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
121 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
122 purple_debug_warning("yahoo", "Warning, unknown status %d\n", f->status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
123 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
124 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
125
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
126 if (status) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
127 if (f->status == YAHOO_STATUS_CUSTOM)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
128 purple_prpl_got_user_status(purple_connection_get_account(gc), name, status, "message",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
129 yahoo_friend_get_status_message(f), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
130 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
131 purple_prpl_got_user_status(purple_connection_get_account(gc), name, status, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
132 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
133
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
134 if (f->idle != 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
135 purple_prpl_got_user_idle(purple_connection_get_account(gc), name, TRUE, f->idle);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
136 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
137 purple_prpl_got_user_idle(purple_connection_get_account(gc), name, FALSE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
138
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
139 if (f->sms)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
140 purple_prpl_got_user_status(purple_connection_get_account(gc), name, YAHOO_STATUS_TYPE_MOBILE, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
141 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
142 purple_prpl_got_user_status_deactive(purple_connection_get_account(gc), name, YAHOO_STATUS_TYPE_MOBILE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
143 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
144
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
145 static void yahoo_process_status(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
146 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
147 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
148 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
149 YahooFriend *f = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
150 char *name = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
151 gboolean unicode = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
152 char *message = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
153 char *msn_name = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
154
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
155 if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
156 if (!purple_account_get_remember_password(account))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
157 purple_account_set_password(account, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
158 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NAME_IN_USE,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
159 _("You have signed on from another location."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
160 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
161 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
162
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
163 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
164 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
165
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
166 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
167 case 0: /* we won't actually do anything with this */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
168 case 1: /* we won't actually do anything with this */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
169 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
170 case 8: /* how many online buddies we have */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
171 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
172 case 7: /* the current buddy */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
173 /* update the previous buddy before changing the variables */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
174 if (f) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
175 if (message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
176 yahoo_friend_set_status_message(f, yahoo_string_decode(gc, message, unicode));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
177 if (name)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
178 yahoo_update_status(gc, name, f);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
179 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
180 name = message = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
181 f = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
182 if (pair->value && g_utf8_validate(pair->value, -1, NULL)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
183 GSList *tmplist;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
184 int protocol = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
185
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
186 name = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
187
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
188 /* Look ahead to see if we have the protocol info about the buddy */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
189 for (tmplist = l->next; tmplist; tmplist = tmplist->next) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
190 struct yahoo_pair *p = tmplist->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
191 if (p->key == 7)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
192 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
193 if (p->key == 241) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
194 if(strtol(p->value, NULL, 10) == 2) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
195 g_free(msn_name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
196 msn_name = g_strconcat("msn/", name, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
197 name = msn_name;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
198 protocol = 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
199 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
200 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
201 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
202 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
203 f = yahoo_friend_find_or_new(gc, name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
204 f->protocol = protocol;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
205 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
206 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
207 case 10: /* state */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
208 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
209 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
210
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
211 f->status = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
212 if ((f->status >= YAHOO_STATUS_BRB) && (f->status <= YAHOO_STATUS_STEPPEDOUT))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
213 f->away = 1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
214 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
215 f->away = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
216
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
217 if (f->status == YAHOO_STATUS_IDLE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
218 /* Idle may have already been set in a more precise way in case 137 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
219 if (f->idle == 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
220 f->idle = time(NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
221 } else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
222 f->idle = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
223
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
224 if (f->status != YAHOO_STATUS_CUSTOM)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
225 yahoo_friend_set_status_message(f, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
226
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
227 f->sms = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
228 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
229 case 19: /* custom message */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
230 if (f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
231 message = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
232 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
233 case 11: /* this is the buddy's session id */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
234 if (f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
235 f->session_id = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
236 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
237 case 17: /* in chat? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
238 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
239 case 47: /* is custom status away or not? 2=idle*/
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
240 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
241 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
242
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
243 /* I have no idea what it means when this is
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
244 * set when someone's available, but it doesn't
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
245 * mean idle. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
246 if (f->status == YAHOO_STATUS_AVAILABLE)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
247 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
248
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
249 f->away = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
250 if (f->away == 2) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
251 /* Idle may have already been set in a more precise way in case 137 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
252 if (f->idle == 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
253 f->idle = time(NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
254 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
255
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
256 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
257 case 138: /* either we're not idle, or we are but won't say how long */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
258 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
259 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
260
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
261 if (f->idle)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
262 f->idle = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
263 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
264 case 137: /* usually idle time in seconds, sometimes login time */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
265 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
266 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
267
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
268 if (f->status != YAHOO_STATUS_AVAILABLE)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
269 f->idle = time(NULL) - strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
270 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
271 case 13: /* bitmask, bit 0 = pager, bit 1 = chat, bit 2 = game */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
272 if (strtol(pair->value, NULL, 10) == 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
273 if (f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
274 f->status = YAHOO_STATUS_OFFLINE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
275 if (name) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
276 purple_prpl_got_user_status(account, name, "offline", NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
277 purple_prpl_got_user_status_deactive(account, name, YAHOO_STATUS_TYPE_MOBILE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
278 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
279 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
280 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
281 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
282 case 60: /* SMS */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
283 if (f) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
284 f->sms = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
285 yahoo_update_status(gc, name, f);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
286 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
287 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
288 case 197: /* Avatars */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
289 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
290 guchar *decoded;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
291 char *tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
292 gsize len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
293
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
294 if (pair->value) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
295 decoded = purple_base64_decode(pair->value, &len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
296 if (len) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
297 tmp = purple_str_binary_to_ascii(decoded, len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
298 purple_debug_info("yahoo", "Got key 197, value = %s\n", tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
299 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
300 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
301 g_free(decoded);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
302 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
303 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
304 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
305 case 192: /* Pictures, aka Buddy Icons, checksum */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
306 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
307 /* FIXME: Please, if you know this protocol,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
308 * FIXME: fix up the strtol() stuff if possible. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
309 int cksum = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
310 const char *locksum = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
311 PurpleBuddy *b;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
312
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
313 if (!name)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
314 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
315
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
316 b = purple_find_buddy(gc->account, name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
317
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
318 if (!cksum || (cksum == -1)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
319 if (f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
320 yahoo_friend_set_buddy_icon_need_request(f, TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
321 purple_buddy_icons_set_for_user(gc->account, name, NULL, 0, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
322 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
323 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
324
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
325 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
326 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
327
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
328 yahoo_friend_set_buddy_icon_need_request(f, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
329 if (b) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
330 locksum = purple_buddy_icons_get_checksum_for_user(b);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
331 if (!locksum || (cksum != strtol(locksum, NULL, 10)))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
332 yahoo_send_picture_request(gc, name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
333 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
334
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
335 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
336 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
337 case 16: /* Custom error message */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
338 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
339 char *tmp = yahoo_string_decode(gc, pair->value, TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
340 purple_notify_error(gc, NULL, tmp, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
341 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
342 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
343 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
344 case 97: /* Unicode status message */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
345 unicode = !strcmp(pair->value, "1");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
346 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
347 case 244: /* client version number. Yahoo Client Detection */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
348 if(f && strtol(pair->value, NULL, 10))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
349 f->version_id = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
350 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
351 case 241: /* protocol buddy belongs to */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
352 break; /* We process this when get '7' */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
353 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
354 purple_debug_warning("yahoo",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
355 "Unknown status key %d\n", pair->key);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
356 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
357 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
358
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
359 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
360 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
361
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
362 if (f) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
363 if (pkt->service == YAHOO_SERVICE_LOGOFF)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
364 f->status = YAHOO_STATUS_OFFLINE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
365 if (message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
366 yahoo_friend_set_status_message(f, yahoo_string_decode(gc, message, unicode));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
367
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
368 if (name) /* update the last buddy */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
369 yahoo_update_status(gc, name, f);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
370 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
371 g_free(msn_name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
372 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
373
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
374 static void yahoo_do_group_check(PurpleAccount *account, GHashTable *ht, const char *name, const char *group)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
375 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
376 PurpleBuddy *b;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
377 PurpleGroup *g;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
378 GSList *list, *i;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
379 gboolean onlist = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
380 char *oname = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
381 char **oname_p = &oname;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
382 GSList **list_p = &list;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
383
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
384 if (!g_hash_table_lookup_extended(ht, purple_normalize(account, name), (gpointer *) oname_p, (gpointer *) list_p))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
385 list = purple_find_buddies(account, name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
386 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
387 g_hash_table_steal(ht, name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
388
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
389 for (i = list; i; i = i->next) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
390 b = i->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
391 g = purple_buddy_get_group(b);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
392 if (!purple_utf8_strcasecmp(group, purple_group_get_name(g))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
393 purple_debug_misc("yahoo",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
394 "Oh good, %s is in the right group (%s).\n", name, group);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
395 list = g_slist_delete_link(list, i);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
396 onlist = 1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
397 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
398 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
399 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
400
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
401 if (!onlist) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
402 purple_debug_misc("yahoo",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
403 "Uhoh, %s isn't on the list (or not in this group), adding him to group %s.\n", name, group);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
404 if (!(g = purple_find_group(group))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
405 g = purple_group_new(group);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
406 purple_blist_add_group(g, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
407 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
408 b = purple_buddy_new(account, name, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
409 purple_blist_add_buddy(b, NULL, g, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
410 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
411
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
412 if (list) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
413 if (!oname)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
414 oname = g_strdup(purple_normalize(account, name));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
415 g_hash_table_insert(ht, oname, list);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
416 } else if (oname)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
417 g_free(oname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
418 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
419
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
420 static void yahoo_do_group_cleanup(gpointer key, gpointer value, gpointer user_data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
421 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
422 char *name = key;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
423 GSList *list = value, *i;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
424 PurpleBuddy *b;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
425 PurpleGroup *g;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
426
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
427 for (i = list; i; i = i->next) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
428 b = i->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
429 g = purple_buddy_get_group(b);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
430 purple_debug_misc("yahoo", "Deleting Buddy %s from group %s.\n", name,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
431 purple_group_get_name(g));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
432 purple_blist_remove_buddy(b);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
433 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
434 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
435
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
436 static char *_getcookie(char *rawcookie)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
437 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
438 char *cookie = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
439 char *tmpcookie;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
440 char *cookieend;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
441
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
442 if (strlen(rawcookie) < 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
443 return NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
444 tmpcookie = g_strdup(rawcookie+2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
445 cookieend = strchr(tmpcookie, ';');
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
446
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
447 if (cookieend)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
448 *cookieend = '\0';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
449
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
450 cookie = g_strdup(tmpcookie);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
451 g_free(tmpcookie);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
452
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
453 return cookie;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
454 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
455
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
456 static void yahoo_process_cookie(struct yahoo_data *yd, char *c)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
457 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
458 if (c[0] == 'Y') {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
459 if (yd->cookie_y)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
460 g_free(yd->cookie_y);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
461 yd->cookie_y = _getcookie(c);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
462 } else if (c[0] == 'T') {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
463 if (yd->cookie_t)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
464 g_free(yd->cookie_t);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
465 yd->cookie_t = _getcookie(c);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
466 } else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
467 purple_debug_info("yahoo", "Unrecognized cookie '%c'\n", c[0]);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
468 yd->cookies = g_slist_prepend(yd->cookies, g_strdup(c));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
469 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
470
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
471 static void yahoo_process_list_15(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
472 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
473 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
474
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
475 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
476 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
477 GHashTable *ht;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
478 char *norm_bud = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
479 char *temp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
480 YahooFriend *f = NULL; /* It's your friends. They're going to want you to share your StarBursts. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
481 /* But what if you had no friends? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
482 PurpleBuddy *b;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
483 PurpleGroup *g;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
484 int protocol = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
485 int stealth = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
486
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
487
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
488 ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
489
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
490 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
491 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
492 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
493
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
494 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
495 case 302:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
496 /* This is always 318 before a group, 319 before the first s/n in a group, 320 before any ignored s/n.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
497 * It is not sent for s/n's in a group after the first.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
498 * All ignored s/n's are listed last, so when we see a 320 we clear the group and begin marking the
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
499 * s/n's as ignored. It is always followed by an identical 300 key.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
500 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
501 if (pair->value && !strcmp(pair->value, "320")) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
502 /* No longer in any group; this indicates the start of the ignore list. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
503 g_free(yd->current_list15_grp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
504 yd->current_list15_grp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
505 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
506
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
507 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
508 case 301: /* This is 319 before all s/n's in a group after the first. It is followed by an identical 300. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
509 if(temp != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
510 if(protocol == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
511 norm_bud = g_strconcat("msn/", temp, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
512 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
513 norm_bud = g_strdup(temp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
514
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
515 if (yd->current_list15_grp) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
516 /* This buddy is in a group */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
517 f = yahoo_friend_find_or_new(gc, norm_bud);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
518 if (!(b = purple_find_buddy(account, norm_bud))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
519 if (!(g = purple_find_group(yd->current_list15_grp))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
520 g = purple_group_new(yd->current_list15_grp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
521 purple_blist_add_group(g, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
522 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
523 b = purple_buddy_new(account, norm_bud, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
524 purple_blist_add_buddy(b, NULL, g, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
525 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
526 yahoo_do_group_check(account, ht, norm_bud, yd->current_list15_grp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
527 if(protocol != 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
528 f->protocol = protocol;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
529 purple_debug_info("yahoo", "Setting protocol to %d\n", f->protocol);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
530 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
531 if(stealth == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
532 f->presence = YAHOO_PRESENCE_PERM_OFFLINE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
533
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
534 /* set p2p status not connected and no p2p packet sent */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
535 if(protocol == 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
536 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
537 f->p2p_packet_sent = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
538 } else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
539 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_DO_NOT_CONNECT);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
540 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
541 /* This buddy is on the ignore list (and therefore in no group) */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
542 purple_debug_info("yahoo", "%s adding %s to the deny list because of the ignore list / no group was found\n",account->username, norm_bud);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
543 purple_privacy_deny_add(account, norm_bud, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
544 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
545
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
546 protocol = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
547 stealth = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
548 norm_bud = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
549 temp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
550 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
551 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
552 case 300: /* This is 318 before a group, 319 before any s/n in a group, and 320 before any ignored s/n. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
553 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
554 case 65: /* This is the group */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
555 g_free(yd->current_list15_grp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
556 yd->current_list15_grp = yahoo_string_decode(gc, pair->value, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
557 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
558 case 7: /* buddy's s/n */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
559 temp = g_strdup(purple_normalize(account, pair->value));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
560 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
561 case 241: /* another protocol user */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
562 protocol = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
563 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
564 case 59: /* somebody told cookies come here too, but im not sure */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
565 yahoo_process_cookie(yd, pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
566 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
567 case 317: /* Stealth Setting */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
568 stealth = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
569 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
570 /* case 242: */ /* this seems related to 241 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
571 /* break; */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
572 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
573 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
574
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
575 g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
576
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
577 /* Now that we have processed the buddy list, we can say yahoo has connected */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
578 purple_connection_set_display_name(gc, purple_normalize(account, purple_account_get_username(account)));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
579 purple_connection_set_state(gc, PURPLE_CONNECTED);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
580 yd->logged_in = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
581 if (yd->picture_upload_todo) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
582 yahoo_buddy_icon_upload(gc, yd->picture_upload_todo);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
583 yd->picture_upload_todo = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
584 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
585 yahoo_set_status(account, purple_account_get_active_status(account));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
586 purple_debug_info("yahoo","Authentication: Connection established\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
587
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
588 g_hash_table_destroy(ht);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
589 g_free(norm_bud);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
590 g_free(temp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
591 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
592
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
593 static void yahoo_process_list(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
594 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
595 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
596 gboolean export = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
597 gboolean got_serv_list = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
598 PurpleBuddy *b;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
599 PurpleGroup *g;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
600 YahooFriend *f = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
601 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
602 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
603 GHashTable *ht;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
604
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
605 char **lines;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
606 char **split;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
607 char **buddies;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
608 char **tmp, **bud, *norm_bud;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
609 char *grp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
610
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
611 if (pkt->id)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
612 yd->session_id = pkt->id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
613
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
614 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
615 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
616 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
617
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
618 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
619 case 87:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
620 if (!yd->tmp_serv_blist)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
621 yd->tmp_serv_blist = g_string_new(pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
622 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
623 g_string_append(yd->tmp_serv_blist, pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
624 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
625 case 88:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
626 if (!yd->tmp_serv_ilist)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
627 yd->tmp_serv_ilist = g_string_new(pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
628 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
629 g_string_append(yd->tmp_serv_ilist, pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
630 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
631 case 89:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
632 yd->profiles = g_strsplit(pair->value, ",", -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
633 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
634 case 59: /* cookies, yum */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
635 yahoo_process_cookie(yd, pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
636 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
637 case YAHOO_SERVICE_PRESENCE_PERM:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
638 if (!yd->tmp_serv_plist)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
639 yd->tmp_serv_plist = g_string_new(pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
640 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
641 g_string_append(yd->tmp_serv_plist, pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
642 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
643 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
644 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
645
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
646 if (pkt->status != 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
647 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
648
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
649 if (yd->tmp_serv_blist) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
650 ht = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_slist_free);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
651
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
652 lines = g_strsplit(yd->tmp_serv_blist->str, "\n", -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
653 for (tmp = lines; *tmp; tmp++) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
654 split = g_strsplit(*tmp, ":", 2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
655 if (!split)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
656 continue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
657 if (!split[0] || !split[1]) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
658 g_strfreev(split);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
659 continue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
660 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
661 grp = yahoo_string_decode(gc, split[0], FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
662 buddies = g_strsplit(split[1], ",", -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
663 for (bud = buddies; bud && *bud; bud++) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
664 norm_bud = g_strdup(purple_normalize(account, *bud));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
665 f = yahoo_friend_find_or_new(gc, norm_bud);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
666
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
667 if (!(b = purple_find_buddy(account, norm_bud))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
668 if (!(g = purple_find_group(grp))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
669 g = purple_group_new(grp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
670 purple_blist_add_group(g, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
671 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
672 b = purple_buddy_new(account, norm_bud, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
673 purple_blist_add_buddy(b, NULL, g, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
674 export = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
675 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
676
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
677 yahoo_do_group_check(account, ht, norm_bud, grp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
678 /* set p2p status not connected and no p2p packet sent */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
679 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
680 f->p2p_packet_sent = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
681
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
682 g_free(norm_bud);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
683 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
684 g_strfreev(buddies);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
685 g_strfreev(split);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
686 g_free(grp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
687 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
688 g_strfreev(lines);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
689
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
690 g_string_free(yd->tmp_serv_blist, TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
691 yd->tmp_serv_blist = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
692 g_hash_table_foreach(ht, yahoo_do_group_cleanup, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
693 g_hash_table_destroy(ht);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
694 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
695
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
696 if (yd->tmp_serv_ilist) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
697 buddies = g_strsplit(yd->tmp_serv_ilist->str, ",", -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
698 for (bud = buddies; bud && *bud; bud++) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
699 /* The server is already ignoring the user */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
700 got_serv_list = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
701 purple_privacy_deny_add(account, *bud, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
702 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
703 g_strfreev(buddies);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
704
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
705 g_string_free(yd->tmp_serv_ilist, TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
706 yd->tmp_serv_ilist = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
707 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
708
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
709 if (got_serv_list &&
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
710 ((account->perm_deny != PURPLE_PRIVACY_ALLOW_BUDDYLIST) &&
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
711 (account->perm_deny != PURPLE_PRIVACY_DENY_ALL) &&
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
712 (account->perm_deny != PURPLE_PRIVACY_ALLOW_USERS)))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
713 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
714 account->perm_deny = PURPLE_PRIVACY_DENY_USERS;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
715 purple_debug_info("yahoo", "%s privacy defaulting to PURPLE_PRIVACY_DENY_USERS.\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
716 account->username);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
717 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
718
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
719 if (yd->tmp_serv_plist) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
720 buddies = g_strsplit(yd->tmp_serv_plist->str, ",", -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
721 for (bud = buddies; bud && *bud; bud++) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
722 f = yahoo_friend_find(gc, *bud);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
723 if (f) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
724 purple_debug_info("yahoo", "%s setting presence for %s to PERM_OFFLINE\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
725 account->username, *bud);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
726 f->presence = YAHOO_PRESENCE_PERM_OFFLINE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
727 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
728 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
729 g_strfreev(buddies);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
730 g_string_free(yd->tmp_serv_plist, TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
731 yd->tmp_serv_plist = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
732
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
733 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
734 /* Now that we've got the list, request aliases */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
735 yahoo_fetch_aliases(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
736 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
737
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
738 /* pkt_type is YAHOO_PKT_TYPE_SERVER if pkt arrives from yahoo server, YAHOO_PKT_TYPE_P2P if pkt arrives through p2p */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
739 static void yahoo_process_notify(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
740 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
741 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
742 char *msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
743 char *from = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
744 char *stat = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
745 char *game = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
746 YahooFriend *f = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
747 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
748 gint val_11 = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
749 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
750 gboolean msn = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
751
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
752 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
753
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
754 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
755 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
756 if (pair->key == 4 || pair->key == 1)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
757 from = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
758 if (pair->key == 49)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
759 msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
760 if (pair->key == 13)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
761 stat = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
762 if (pair->key == 14)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
763 game = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
764 if (pair->key == 11)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
765 val_11 = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
766 if (pair->key == 241)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
767 if(strtol(pair->value, NULL, 10) == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
768 msn = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
769 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
770 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
771
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
772 if (!from || !msg)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
773 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
774
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
775 /* disconnect the peer if connected through p2p and sends wrong value for session id */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
776 if( (pkt_type == YAHOO_PKT_TYPE_P2P) && (val_11 != yd->session_id) ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
777 purple_debug_warning("yahoo","p2p: %s sent us notify with wrong session id. Disconnecting p2p connection to peer\n", from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
778 /* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
779 g_hash_table_remove(yd->peers, from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
780 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
781 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
782
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
783 if (!g_ascii_strncasecmp(msg, "TYPING", strlen("TYPING"))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
784 && (purple_privacy_check(account, from)))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
785 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
786 if(msn) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
787 char *msn_from = g_strconcat("msn/", from, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
788 if (*stat == '1')
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
789 serv_got_typing(gc, msn_from, 0, PURPLE_TYPING);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
790 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
791 serv_got_typing_stopped(gc, msn_from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
792 g_free(msn_from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
793 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
794 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
795 if (*stat == '1')
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
796 serv_got_typing(gc, from, 0, PURPLE_TYPING);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
797 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
798 serv_got_typing_stopped(gc, from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
799 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
800 } else if (!g_ascii_strncasecmp(msg, "GAME", strlen("GAME"))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
801 PurpleBuddy *bud = purple_find_buddy(account, from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
802
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
803 if (!bud) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
804 purple_debug_warning("yahoo",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
805 "%s is playing a game, and doesn't want you to know.\n", from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
806 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
807
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
808 f = yahoo_friend_find(gc, from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
809 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
810 return; /* if they're not on the list, don't bother */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
811
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
812 yahoo_friend_set_game(f, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
813
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
814 if (*stat == '1') {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
815 yahoo_friend_set_game(f, game);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
816 if (bud)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
817 yahoo_update_status(gc, from, f);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
818 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
819 } else if (!g_ascii_strncasecmp(msg, "WEBCAMINVITE", strlen("WEBCAMINVITE"))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
820 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
821 char *buf = g_strdup_printf(_("%s has sent you a webcam invite, which is not yet supported."), from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
822 purple_conversation_write(conv, NULL, buf, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
823 g_free(buf);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
824 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
825 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
826
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
827
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
828 struct _yahoo_im {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
829 char *from;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
830 char *active_id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
831 int time;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
832 int utf8;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
833 int buddy_icon;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
834 char *id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
835 char *msg;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
836 gboolean msn;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
837 };
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
838
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
839 static void yahoo_process_sms_message(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
840 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
841 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
842 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
843 struct _yahoo_im *sms = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
844 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
845 char *server_msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
846 char *m;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
847
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
848 yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
849 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
850
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
851 while (l != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
852 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
853 if (pair->key == 4) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
854 sms = g_new0(struct _yahoo_im, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
855 sms->from = g_strdup_printf("+%s", pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
856 sms->time = time(NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
857 sms->utf8 = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
858 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
859 if (pair->key == 14) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
860 if (sms)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
861 sms->msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
862 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
863 if (pair->key == 68)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
864 if(sms)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
865 g_hash_table_insert(yd->sms_carrier, g_strdup(sms->from), g_strdup(pair->value));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
866 if (pair->key == 16)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
867 server_msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
868 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
869 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
870
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
871 if( (pkt->status == -1) || (pkt->status == YAHOO_STATUS_DISCONNECTED) ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
872 if (server_msg) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
873 PurpleConversation *c;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
874 c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms->from, account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
875 if (c == NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
876 c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, sms->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
877 purple_conversation_write(c, NULL, server_msg, PURPLE_MESSAGE_SYSTEM, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
878 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
879 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
880 purple_notify_error(gc, NULL, _("Your SMS was not delivered"), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
881
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
882 g_free(sms->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
883 g_free(sms);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
884 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
885 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
886
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
887 if (!sms->from || !sms->msg) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
888 g_free(sms);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
889 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
890 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
891
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
892 m = yahoo_string_decode(gc, sms->msg, sms->utf8);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
893 serv_got_im(gc, sms->from, m, 0, sms->time);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
894
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
895 g_free(m);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
896 g_free(sms->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
897 g_free(sms);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
898 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
899
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
900 /* pkt_type is YAHOO_PKT_TYPE_SERVER if pkt arrives from yahoo server, YAHOO_PKT_TYPE_P2P if pkt arrives through p2p */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
901 static void yahoo_process_message(PurpleConnection *gc, struct yahoo_packet *pkt, yahoo_pkt_type pkt_type)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
902 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
903 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
904 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
905 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
906 GSList *list = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
907 struct _yahoo_im *im = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
908 const char *imv = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
909 gint val_11 = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
910
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
911 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
912
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
913 if (pkt->status <= 1 || pkt->status == 5 || pkt->status == YAHOO_STATUS_OFFLINE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
914 /* messages are received with status YAHOO_STATUS_OFFLINE in case of p2p */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
915 while (l != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
916 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
917 if (pair->key == 4 || pair->key == 1) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
918 im = g_new0(struct _yahoo_im, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
919 list = g_slist_append(list, im);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
920 im->from = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
921 im->time = time(NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
922 im->utf8 = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
923 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
924 if (im && pair->key == 5)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
925 im->active_id = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
926 if (pair->key == 97)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
927 if (im)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
928 im->utf8 = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
929 if (pair->key == 15)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
930 if (im)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
931 im->time = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
932 if (pair->key == 206)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
933 if (im)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
934 im->buddy_icon = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
935 if (pair->key == 14) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
936 if (im)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
937 im->msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
938 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
939 if (im && pair->key == 241) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
940 if(strtol(pair->value, NULL, 10) == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
941 im->msn = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
942 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
943 /* peer session id */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
944 if (pair->key == 11) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
945 if (im)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
946 val_11 = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
947 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
948 /* IMV key */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
949 if (pair->key == 63)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
950 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
951 imv = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
952 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
953 if (pair->key == 429)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
954 if (im)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
955 im->id = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
956 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
957 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
958 } else if (pkt->status == 2) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
959 purple_notify_error(gc, NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
960 _("Your Yahoo! message did not get sent."), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
961 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
962
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
963 /* disconnect the peer if connected through p2p and sends wrong value for session id */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
964 if( (pkt_type == YAHOO_PKT_TYPE_P2P) && (val_11 != yd->session_id) ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
965 purple_debug_warning("yahoo","p2p: %s sent us message with wrong session id. Disconnecting p2p connection to peer\n", im->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
966 /* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
967 g_hash_table_remove(yd->peers, im->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
968 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
969 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
970
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
971 /** TODO: It seems that this check should be per IM, not global */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
972 /* Check for the Doodle IMV */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
973 if (im != NULL && imv!= NULL && im->from != NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
974 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
975 g_hash_table_replace(yd->imvironments, g_strdup(im->from), g_strdup(imv));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
976
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
977 if (strstr(imv, "doodle;") != NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
978 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
979 PurpleWhiteboard *wb;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
980
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
981 if (!purple_privacy_check(account, im->from)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
982 purple_debug_info("yahoo", "Doodle request from %s dropped.\n", im->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
983 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
984 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
985
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
986 /* I'm not sure the following ever happens -DAA */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
987
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
988 wb = purple_whiteboard_get_session(account, im->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
989
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
990 /* If a Doodle session doesn't exist between this user */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
991 if(wb == NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
992 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
993 doodle_session *ds;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
994 wb = purple_whiteboard_create(account, im->from, DOODLE_STATE_REQUESTED);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
995 ds = wb->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
996 ds->imv_key = g_strdup(imv);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
997
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
998 yahoo_doodle_command_send_request(gc, im->from, imv);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
999 yahoo_doodle_command_send_ready(gc, im->from, imv);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1000 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1001 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1002 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1003
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1004 for (l = list; l; l = l->next) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1005 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1006 char *m, *m2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1007 char *msn_from = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1008 const char *from;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1009 PurpleConversation *c;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1010 im = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1011
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1012 if (!im->from || !im->msg) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1013 g_free(im);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1014 continue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1015 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1016
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1017 if (!purple_privacy_check(account, im->from)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1018 purple_debug_info("yahoo", "Message from %s dropped.\n", im->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1019 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1020 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1021
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1022 /*
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1023 * TODO: Is there anything else we should check when determining whether
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1024 * we should send an acknowledgement?
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1025 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1026 if (im->id != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1027 /* Send acknowledgement. If we don't do this then the official
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1028 * Yahoo Messenger client for Windows will send us the same
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1029 * message 7 seconds later as an offline message. This is true
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1030 * for at least version 9.0.0.2162 on Windows XP. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1031 struct yahoo_packet *pkt2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1032 pkt2 = yahoo_packet_new(YAHOO_SERVICE_MESSAGE_ACK,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1033 YAHOO_STATUS_AVAILABLE, pkt->id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1034 yahoo_packet_hash(pkt2, "ssisii",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1035 1, im->active_id, /* May not always be the connection's display name */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1036 5, im->from,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1037 302, 430,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1038 430, im->id,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1039 303, 430,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1040 450, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1041 yahoo_packet_send_and_free(pkt2, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1042 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1043
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1044 m = yahoo_string_decode(gc, im->msg, im->utf8);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1045 /* This may actually not be necessary, but it appears
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1046 * that at least at one point some clients were sending
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1047 * "\r\n" as line delimiters, so we want to avoid double
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1048 * lines. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1049 m2 = purple_strreplace(m, "\r\n", "\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1050 g_free(m);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1051 m = m2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1052 purple_util_chrreplace(m, '\r', '\n');
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1053
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1054 if (im->msn) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1055 msn_from = g_strconcat("msn/", im->from, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1056 from = msn_from;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1057 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1058 from = im->from;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1059 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1060
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1061 c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1062
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1063 if (!strcmp(m, "<ding>")) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1064 char *username;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1065
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1066 if (c == NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1067 c = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1068 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1069 username = g_markup_escape_text(from, -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1070 purple_prpl_got_attention(gc, username, YAHOO_BUZZ);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1071 g_free(username);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1072 g_free(m);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1073 g_free(im);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1074 g_free(msn_from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1075 continue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1076 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1077
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1078 m2 = yahoo_codes_to_html(m);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1079 g_free(m);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1080
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1081 serv_got_im(gc, from, m2, 0, im->time);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1082 g_free(m2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1083
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1084 /* laters : implement buddy icon for msn friends */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1085 if (!im->msn) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1086 if ((f = yahoo_friend_find(gc, im->from)) && im->buddy_icon == 2) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1087 if (yahoo_friend_get_buddy_icon_need_request(f)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1088 yahoo_send_picture_request(gc, im->from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1089 yahoo_friend_set_buddy_icon_need_request(f, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1090 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1091 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1092 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1093
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1094 g_free(im);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1095 g_free(msn_from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1096 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1097 g_slist_free(list);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1098 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1099
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1100 static void yahoo_process_sysmessage(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1101 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1102 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1103 char *prim, *me = NULL, *msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1104
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1105 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1106 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1107
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1108 if (pair->key == 5)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1109 me = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1110 if (pair->key == 14)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1111 msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1112
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1113 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1114 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1115
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1116 if (!msg || !g_utf8_validate(msg, -1, NULL))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1117 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1118
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1119 prim = g_strdup_printf(_("Yahoo! system message for %s:"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1120 me?me:purple_connection_get_display_name(gc));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1121 purple_notify_info(NULL, NULL, prim, msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1122 g_free(prim);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1123 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1124
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1125 struct yahoo_add_request {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1126 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1127 char *id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1128 char *who;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1129 int protocol;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1130 };
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1131
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1132 static void
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1133 yahoo_buddy_add_authorize_cb(gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1134 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1135 struct yahoo_add_request *add_req = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1136 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1137 struct yahoo_data *yd = add_req->gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1138 const char *who = add_req->who;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1139
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1140 if (add_req->protocol == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1141 who += 4;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1142
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1143 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1144 yahoo_packet_hash(pkt, "ssiii",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1145 1, add_req->id,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1146 5, who,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1147 241, add_req->protocol,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1148 13, 1,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1149 334, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1150 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1151
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1152 g_free(add_req->id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1153 g_free(add_req->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1154 g_free(add_req);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1155 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1156
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1157 static void
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1158 yahoo_buddy_add_deny_cb(struct yahoo_add_request *add_req, const char *msg)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1159 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1160 struct yahoo_data *yd = add_req->gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1161 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1162 char *encoded_msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1163 PurpleAccount *account = purple_connection_get_account(add_req->gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1164
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1165 if (msg && *msg)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1166 encoded_msg = yahoo_string_encode(add_req->gc, msg, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1167
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1168 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH_REQ_15,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1169 YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1170
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1171 yahoo_packet_hash(pkt, "ssiiis",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1172 1, purple_normalize(account, purple_account_get_username(account)),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1173 5, add_req->who,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1174 13, 2,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1175 334, 0,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1176 97, 1,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1177 14, encoded_msg ? encoded_msg : "");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1178
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1179 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1180
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1181 g_free(encoded_msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1182
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1183 g_free(add_req->id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1184 g_free(add_req->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1185 g_free(add_req);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1186 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1187
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1188 static void
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1189 yahoo_buddy_add_deny_noreason_cb(struct yahoo_add_request *add_req, const char*msg)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1190 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1191 yahoo_buddy_add_deny_cb(add_req, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1192 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1193
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1194 static void
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1195 yahoo_buddy_add_deny_reason_cb(gpointer data) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1196 struct yahoo_add_request *add_req = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1197 purple_request_input(add_req->gc, NULL, _("Authorization denied message:"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1198 NULL, _("No reason given."), TRUE, FALSE, NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1199 _("OK"), G_CALLBACK(yahoo_buddy_add_deny_cb),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1200 _("Cancel"), G_CALLBACK(yahoo_buddy_add_deny_noreason_cb),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1201 purple_connection_get_account(add_req->gc), add_req->who, NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1202 add_req);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1203 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1204
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1205 static void yahoo_buddy_denied_our_add(PurpleConnection *gc, const char *who, const char *reason)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1206 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1207 char *notify_msg;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1208 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1209
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1210 if (who == NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1211 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1212
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1213 if (reason != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1214 char *msg2 = yahoo_string_decode(gc, reason, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1215 notify_msg = g_strdup_printf(_("%s has (retroactively) denied your request to add them to your list for the following reason: %s."), who, msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1216 g_free(msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1217 } else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1218 notify_msg = g_strdup_printf(_("%s has (retroactively) denied your request to add them to your list."), who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1219
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1220 purple_notify_info(gc, NULL, _("Add buddy rejected"), notify_msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1221 g_free(notify_msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1222
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1223 g_hash_table_remove(yd->friends, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1224 purple_prpl_got_user_status(purple_connection_get_account(gc), who, "offline", NULL); /* FIXME: make this set not on list status instead */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1225 /* TODO: Shouldn't we remove the buddy from our local list? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1226 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1227
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1228 static void yahoo_buddy_auth_req_15(PurpleConnection *gc, struct yahoo_packet *pkt) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1229 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1230 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1231 const char *msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1232 int protocol = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1233
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1234 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1235
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1236 /* Buddy authorized/declined our addition */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1237 if (pkt->status == 1) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1238 char *temp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1239 char *who = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1240 int response = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1241
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1242 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1243 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1244
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1245 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1246 case 4:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1247 temp = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1248 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1249 case 13:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1250 response = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1251 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1252 case 14:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1253 msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1254 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1255 case 241:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1256 protocol = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1257 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1258 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1259 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1260 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1261
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1262 if(protocol == 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1263 who = g_strdup(temp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1264 else if(protocol == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1265 who = g_strconcat("msn/", temp, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1266
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1267 if (response == 1) /* Authorized */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1268 purple_debug_info("yahoo", "Received authorization from buddy '%s'.\n", who ? who : "(Unknown Buddy)");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1269 else if (response == 2) { /* Declined */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1270 purple_debug_info("yahoo", "Received authorization decline from buddy '%s'.\n", who ? who : "(Unknown Buddy)");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1271 yahoo_buddy_denied_our_add(gc, who, msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1272 } else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1273 purple_debug_error("yahoo", "Received unknown authorization response of %d from buddy '%s'.\n", response, who ? who : "(Unknown Buddy)");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1274 g_free(who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1275 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1276 /* Buddy requested authorization to add us. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1277 else if (pkt->status == 3) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1278 struct yahoo_add_request *add_req;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1279 const char *firstname = NULL, *lastname = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1280 char *temp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1281
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1282 add_req = g_new0(struct yahoo_add_request, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1283 add_req->gc = gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1284
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1285 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1286 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1287
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1288 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1289 case 4:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1290 temp = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1291 add_req->who = g_strdup(pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1292 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1293 case 5:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1294 add_req->id = g_strdup(pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1295 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1296 case 14:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1297 msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1298 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1299 case 216:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1300 firstname = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1301 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1302 case 241:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1303 add_req->protocol = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1304 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1305 case 254:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1306 lastname = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1307 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1308
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1309 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1310 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1311 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1312 if(add_req->protocol == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1313 add_req->who = g_strconcat("msn/", temp, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1314 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1315 add_req->who = g_strdup(temp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1316
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1317 if (add_req->id && add_req->who) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1318 char *alias = NULL, *dec_msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1319
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1320 if (!purple_privacy_check(account, add_req->who))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1321 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1322 purple_debug_misc("yahoo", "Auth. request from %s dropped and automatically denied due to privacy settings!\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1323 add_req->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1324 yahoo_buddy_add_deny_cb(add_req, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1325 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1326 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1327
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1328 if (msg)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1329 dec_msg = yahoo_string_decode(gc, msg, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1330
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1331 if (firstname && lastname)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1332 alias = g_strdup_printf("%s %s", firstname, lastname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1333 else if (firstname)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1334 alias = g_strdup(firstname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1335 else if (lastname)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1336 alias = g_strdup(lastname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1337
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1338 /* DONE! this is almost exactly the same as what MSN does,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1339 * this should probably be moved to the core.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1340 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1341 purple_account_request_authorization(account, add_req->who, add_req->id,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1342 alias, dec_msg,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1343 purple_find_buddy(account, add_req->who) != NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1344 yahoo_buddy_add_authorize_cb,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1345 yahoo_buddy_add_deny_reason_cb,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1346 add_req);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1347 g_free(alias);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1348 g_free(dec_msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1349 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1350 g_free(add_req->id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1351 g_free(add_req->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1352 g_free(add_req);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1353 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1354 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1355 purple_debug_error("yahoo", "Received authorization of unknown status (%d).\n", pkt->status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1356 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1357 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1358
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1359 /* I don't think this happens anymore in Version 15 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1360 static void yahoo_buddy_added_us(PurpleConnection *gc, struct yahoo_packet *pkt) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1361 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1362 struct yahoo_add_request *add_req;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1363 char *msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1364 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1365
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1366 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1367
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1368 add_req = g_new0(struct yahoo_add_request, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1369 add_req->gc = gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1370
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1371 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1372 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1373
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1374 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1375 case 1:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1376 add_req->id = g_strdup(pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1377 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1378 case 3:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1379 add_req->who = g_strdup(pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1380 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1381 case 15: /* time, for when they add us and we're offline */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1382 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1383 case 14:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1384 msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1385 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1386 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1387 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1388 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1389
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1390 if (add_req->id && add_req->who) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1391 char *dec_msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1392
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1393 if (!purple_privacy_check(account, add_req->who)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1394 purple_debug_misc("yahoo", "Auth. request from %s dropped and automatically denied due to privacy settings!\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1395 add_req->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1396 yahoo_buddy_add_deny_cb(add_req, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1397 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1398 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1399
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1400 if (msg)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1401 dec_msg = yahoo_string_decode(gc, msg, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1402
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1403 /* DONE! this is almost exactly the same as what MSN does,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1404 * this should probably be moved to the core.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1405 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1406 purple_account_request_authorization(account, add_req->who, add_req->id,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1407 NULL, dec_msg,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1408 purple_find_buddy(account,add_req->who) != NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1409 yahoo_buddy_add_authorize_cb,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1410 yahoo_buddy_add_deny_reason_cb, add_req);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1411 g_free(dec_msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1412 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1413 g_free(add_req->id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1414 g_free(add_req->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1415 g_free(add_req);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1416 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1417 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1418
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1419 /* I have no idea if this every gets called in version 15 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1420 static void yahoo_buddy_denied_our_add_old(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1421 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1422 char *who = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1423 char *msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1424 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1425
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1426 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1427 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1428
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1429 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1430 case 3:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1431 who = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1432 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1433 case 14:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1434 msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1435 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1436 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1437 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1438 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1439
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1440 yahoo_buddy_denied_our_add(gc, who, msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1441 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1442
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1443 static void yahoo_process_contact(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1444 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1445 switch (pkt->status) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1446 case 1:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1447 yahoo_process_status(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1448 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1449 case 3:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1450 yahoo_buddy_added_us(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1451 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1452 case 7:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1453 yahoo_buddy_denied_our_add_old(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1454 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1455 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1456 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1457 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1458 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1459
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1460 #define OUT_CHARSET "utf-8"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1461
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1462 static char *yahoo_decode(const char *text)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1463 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1464 char *converted = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1465 char *n, *new;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1466 const char *end, *p;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1467 int i, k;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1468
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1469 n = new = g_malloc(strlen (text) + 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1470 end = text + strlen(text);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1471
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1472 for (p = text; p < end; p++, n++) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1473 if (*p == '\\') {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1474 if (p[1] >= '0' && p[1] <= '7') {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1475 p += 1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1476 for (i = 0, k = 0; k < 3; k += 1) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1477 char c = p[k];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1478 if (c < '0' || c > '7') break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1479 i *= 8;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1480 i += c - '0';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1481 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1482 *n = i;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1483 p += k - 1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1484 } else { /* bug 959248 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1485 /* If we see a \ not followed by an octal number,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1486 * it means that it is actually a \\ with one \
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1487 * already eaten by some unknown function.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1488 * This is arguably broken.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1489 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1490 * I think wing is wrong here, there is no function
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1491 * called that I see that could have done it. I guess
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1492 * it is just really sending single \'s. That's yahoo
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1493 * for you.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1494 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1495 *n = *p;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1496 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1497 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1498 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1499 *n = *p;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1500 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1501
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1502 *n = '\0';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1503
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1504 if (strstr(text, "\033$B"))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1505 converted = g_convert(new, n - new, OUT_CHARSET, "iso-2022-jp", NULL, NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1506 if (!converted)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1507 converted = g_convert(new, n - new, OUT_CHARSET, "iso-8859-1", NULL, NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1508 g_free(new);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1509
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1510 return converted;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1511 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1512
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1513 static void yahoo_process_mail(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1514 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1515 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1516 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1517 const char *who = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1518 const char *email = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1519 const char *subj = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1520 const char *yahoo_mail_url = (yd->jp? YAHOOJP_MAIL_URL: YAHOO_MAIL_URL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1521 int count = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1522 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1523
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1524 if (!purple_account_get_check_mail(account))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1525 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1526
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1527 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1528 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1529 if (pair->key == 9)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1530 count = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1531 else if (pair->key == 43)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1532 who = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1533 else if (pair->key == 42)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1534 email = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1535 else if (pair->key == 18)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1536 subj = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1537 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1538 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1539
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1540 if (who && subj && email && *email) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1541 char *dec_who = yahoo_decode(who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1542 char *dec_subj = yahoo_decode(subj);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1543 char *from = g_strdup_printf("%s (%s)", dec_who, email);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1544
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1545 purple_notify_email(gc, dec_subj, from, purple_account_get_username(account),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1546 yahoo_mail_url, NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1547
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1548 g_free(dec_who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1549 g_free(dec_subj);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1550 g_free(from);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1551 } else if (count > 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1552 const char *tos[2] = { purple_account_get_username(account) };
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1553 const char *urls[2] = { yahoo_mail_url };
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1554
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1555 purple_notify_emails(gc, count, FALSE, NULL, NULL, tos, urls,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1556 NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1557 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1558 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1559
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1560 /* We use this structure once while we authenticate */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1561 struct yahoo_auth_data
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1562 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1563 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1564 char *seed;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1565 };
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1566
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1567 /* This is the y64 alphabet... it's like base64, but has a . and a _ */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1568 static const char base64digits[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789._";
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1569
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1570 /* This is taken from Sylpheed by Hiroyuki Yamamoto. We have our own tobase64 function
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1571 * in util.c, but it is different from the one yahoo uses */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1572 static void to_y64(char *out, const unsigned char *in, gsize inlen)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1573 /* raw bytes in quasi-big-endian order to base 64 string (NUL-terminated) */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1574 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1575 for (; inlen >= 3; inlen -= 3)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1576 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1577 *out++ = base64digits[in[0] >> 2];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1578 *out++ = base64digits[((in[0] << 4) & 0x30) | (in[1] >> 4)];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1579 *out++ = base64digits[((in[1] << 2) & 0x3c) | (in[2] >> 6)];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1580 *out++ = base64digits[in[2] & 0x3f];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1581 in += 3;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1582 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1583 if (inlen > 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1584 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1585 unsigned char fragment;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1586
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1587 *out++ = base64digits[in[0] >> 2];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1588 fragment = (in[0] << 4) & 0x30;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1589 if (inlen > 1)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1590 fragment |= in[1] >> 4;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1591 *out++ = base64digits[fragment];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1592 *out++ = (inlen < 2) ? '-' : base64digits[(in[1] << 2) & 0x3c];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1593 *out++ = '-';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1594 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1595 *out = '\0';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1596 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1597
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1598 static void yahoo_auth16_stage3(PurpleConnection *gc, const char *crypt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1599 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1600 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1601 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1602 const char *name = purple_normalize(account, purple_account_get_username(account));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1603 PurpleCipher *md5_cipher;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1604 PurpleCipherContext *md5_ctx;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1605 guchar md5_digest[16];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1606 gchar base64_string[25];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1607 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1608
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1609 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage3\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1610
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1611 md5_cipher = purple_ciphers_find_cipher("md5");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1612 md5_ctx = purple_cipher_context_new(md5_cipher, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1613 purple_cipher_context_append(md5_ctx, (guchar *)crypt, strlen(crypt));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1614 purple_cipher_context_digest(md5_ctx, sizeof(md5_digest), md5_digest, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1615
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1616 to_y64(base64_string, md5_digest, 16);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1617
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1618 purple_debug_info("yahoo", "yahoo status: %d\n", yd->current_status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1619 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTHRESP, yd->current_status, yd->session_id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1620 if(yd->jp) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1621 yahoo_packet_hash(pkt, "ssssssss",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1622 1, name,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1623 0, name,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1624 277, yd->cookie_y,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1625 278, yd->cookie_t,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1626 307, base64_string,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1627 2, name,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1628 2, "1",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1629 135, YAHOOJP_CLIENT_VERSION);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1630 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1631 yahoo_packet_hash(pkt, "sssssssss",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1632 1, name,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1633 0, name,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1634 277, yd->cookie_y,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1635 278, yd->cookie_t,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1636 307, base64_string,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1637 244, YAHOO_CLIENT_VERSION_ID,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1638 2, name,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1639 2, "1",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1640 135, YAHOO_CLIENT_VERSION);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1641 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1642 if (yd->picture_checksum)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1643 yahoo_packet_hash_int(pkt, 192, yd->picture_checksum);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1644 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1645
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1646 purple_cipher_context_destroy(md5_ctx);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1647 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1648
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1649 static void yahoo_auth16_stage2(PurpleUtilFetchUrlData *unused, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1650 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1651 struct yahoo_auth_data *auth_data = user_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1652 PurpleConnection *gc = auth_data->gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1653 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1654 gboolean try_login_on_error = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1655
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1656 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage2\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1657
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1658 if (!PURPLE_CONNECTION_IS_VALID(gc)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1659 g_free(auth_data->seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1660 g_free(auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1661 g_return_if_reached();
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1662 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1663
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1664 yd = (struct yahoo_data *)gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1665
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1666 if (error_message != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1667 purple_debug_error("yahoo", "Login Failed, unable to retrieve stage 2 url: %s\n", error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1668 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1669 g_free(auth_data->seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1670 g_free(auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1671 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1672 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1673 else if (len > 0 && ret_data && *ret_data) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1674 gchar **split_data = g_strsplit(ret_data, "\r\n", -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1675 int totalelements = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1676 int response_no = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1677 char *crumb = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1678 char *crypt = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1679
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1680 #if GLIB_CHECK_VERSION(2,6,0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1681 totalelements = g_strv_length(split_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1682 #else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1683 while (split_data[++totalelements] != NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1684 #endif
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1685 if (totalelements >= 4) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1686 response_no = strtol(split_data[0], NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1687 crumb = g_strdup(split_data[1] + strlen("crumb="));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1688 yd->cookie_y = g_strdup(split_data[2] + strlen("Y="));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1689 yd->cookie_t = g_strdup(split_data[3] + strlen("T="));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1690 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1691
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1692 g_strfreev(split_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1693
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1694 if(response_no != 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1695 /* Some error in the login process */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1696 PurpleConnectionError error;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1697 char *error_reason = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1698
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1699 switch(response_no) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1700 case -1:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1701 /* Some error in the received stream */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1702 error_reason = g_strdup(_("Received invalid data"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1703 error = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1704 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1705 case 100:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1706 /* Unknown error */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1707 error_reason = g_strdup(_("Unknown error"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1708 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1709 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1710 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1711 /* if we have everything we need, why not try to login irrespective of response */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1712 if((crumb != NULL) && (yd->cookie_y != NULL) && (yd->cookie_t != NULL)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1713 try_login_on_error = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1714 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1715 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1716 error_reason = g_strdup(_("Unknown error"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1717 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1718 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1719 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1720 if(error_reason) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1721 purple_debug_error("yahoo", "Authentication error: %s\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1722 error_reason);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1723 purple_connection_error_reason(gc, error, error_reason);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1724 g_free(error_reason);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1725 g_free(auth_data->seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1726 g_free(auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1727 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1728 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1729 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1730
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1731 crypt = g_strconcat(crumb, auth_data->seed, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1732 yahoo_auth16_stage3(gc, crypt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1733 g_free(crypt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1734 g_free(crumb);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1735 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1736 g_free(auth_data->seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1737 g_free(auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1738 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1739
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1740 static void yahoo_auth16_stage1_cb(PurpleUtilFetchUrlData *unused, gpointer user_data, const gchar *ret_data, size_t len, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1741 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1742 struct yahoo_auth_data *auth_data = user_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1743 PurpleConnection *gc = auth_data->gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1744
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1745 purple_debug_info("yahoo","Authentication: In yahoo_auth16_stage1_cb\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1746
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1747 if (!PURPLE_CONNECTION_IS_VALID(gc)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1748 g_free(auth_data->seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1749 g_free(auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1750 g_return_if_reached();
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1751 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1752
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1753 if (error_message != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1754 purple_debug_error("yahoo", "Login Failed, unable to retrieve login url: %s\n", error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1755 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1756 g_free(auth_data->seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1757 g_free(auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1758 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1759 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1760 else if (len > 0 && ret_data && *ret_data) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1761 gchar **split_data = g_strsplit(ret_data, "\r\n", -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1762 int totalelements = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1763 int response_no = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1764 char *token = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1765
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1766 #if GLIB_CHECK_VERSION(2,6,0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1767 totalelements = g_strv_length(split_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1768 #else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1769 while (split_data[++totalelements] != NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1770 #endif
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1771 if(totalelements == 1)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1772 response_no = strtol(split_data[0], NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1773 else if(totalelements >= 2) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1774 response_no = strtol(split_data[0], NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1775 token = g_strdup(split_data[1] + strlen("ymsgr="));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1776 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1777
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1778 g_strfreev(split_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1779
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1780 if(response_no != 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1781 /* Some error in the login process */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1782 PurpleConnectionError error;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1783 char *error_reason;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1784
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1785 switch(response_no) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1786 case -1:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1787 /* Some error in the received stream */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1788 error_reason = g_strdup(_("Received invalid data"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1789 error = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1790 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1791 case 1212:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1792 /* Password incorrect */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1793 /* Set password to NULL. Avoids account locking. Brings dialog to enter password if clicked on Re-enable account */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1794 if (!purple_account_get_remember_password(purple_connection_get_account(gc)))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1795 purple_account_set_password(purple_connection_get_account(gc), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1796 error_reason = g_strdup(_("Incorrect Password"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1797 error = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1798 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1799 case 1213:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1800 /* security lock from too many failed login attempts */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1801 error_reason = g_strdup(_("Account locked: Too many failed login attempts.\nLogging into the Yahoo! website may fix this."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1802 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1803 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1804 case 1235:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1805 /* the username does not exist */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1806 error_reason = g_strdup(_("Username does not exist"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1807 error = PURPLE_CONNECTION_ERROR_INVALID_USERNAME;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1808 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1809 case 1214:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1810 case 1236:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1811 /* indicates a lock of some description */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1812 error_reason = g_strdup(_("Account locked: Unknown reason.\nLogging into the Yahoo! website may fix this."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1813 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1814 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1815 case 100:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1816 /* username or password missing */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1817 error_reason = g_strdup(_("Username or password missing"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1818 error = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1819 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1820 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1821 /* Unknown error! */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1822 error_reason = g_strdup(_("Unknown error"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1823 error = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1824 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1825 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1826 purple_debug_error("yahoo", "Authentication error: %s\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1827 error_reason);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1828 purple_connection_error_reason(gc, error, error_reason);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1829 g_free(error_reason);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1830 g_free(auth_data->seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1831 g_free(auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1832 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1833 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1834 /* OK to login, correct information provided */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1835 PurpleUtilFetchUrlData *url_data = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1836 char *url = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1837 gboolean yahoojp = purple_account_get_bool(purple_connection_get_account(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1838 "yahoojp", 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1839
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1840 url = g_strdup_printf(yahoojp ? YAHOOJP_LOGIN_URL : YAHOO_LOGIN_URL, token);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1841 url_data = purple_util_fetch_url_request_len_with_account(
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1842 purple_connection_get_account(gc), url, TRUE,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1843 YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1844 yahoo_auth16_stage2, auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1845 g_free(url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1846 g_free(token);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1847 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1848 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1849 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1850
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1851 static void yahoo_auth16_stage1(PurpleConnection *gc, const char *seed)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1852 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1853 PurpleUtilFetchUrlData *url_data = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1854 struct yahoo_auth_data *auth_data = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1855 char *url = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1856 char *encoded_username;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1857 char *encoded_password;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1858 gboolean yahoojp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1859
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1860 purple_debug_info("yahoo", "Authentication: In yahoo_auth16_stage1\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1861
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1862 if(!purple_ssl_is_supported()) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1863 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, _("SSL support unavailable"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1864 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1865 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1866
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1867 yahoojp = purple_account_get_bool(purple_connection_get_account(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1868 "yahoojp", 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1869 auth_data = g_new0(struct yahoo_auth_data, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1870 auth_data->gc = gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1871 auth_data->seed = g_strdup(seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1872
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1873 encoded_username = g_strdup(purple_url_encode(purple_account_get_username(purple_connection_get_account(gc))));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1874 encoded_password = g_strdup(purple_url_encode(purple_connection_get_password(gc)));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1875 url = g_strdup_printf(yahoojp ? YAHOOJP_TOKEN_URL : YAHOO_TOKEN_URL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1876 encoded_username, encoded_password, purple_url_encode(seed));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1877 g_free(encoded_password);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1878 g_free(encoded_username);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1879
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1880 url_data = purple_util_fetch_url_request_len_with_account(
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1881 purple_connection_get_account(gc), url, TRUE,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1882 YAHOO_CLIENT_USERAGENT, TRUE, NULL, FALSE, -1,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1883 yahoo_auth16_stage1_cb, auth_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1884
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1885 g_free(url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1886 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1887
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1888 static void yahoo_process_auth(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1889 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1890 char *seed = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1891 char *sn = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1892 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1893 int m = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1894 gchar *buf;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1895
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1896 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1897 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1898 if (pair->key == 94)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1899 seed = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1900 if (pair->key == 1)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1901 sn = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1902 if (pair->key == 13)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1903 m = atoi(pair->value);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1904 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1905 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1906
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1907 if (seed) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1908 switch (m) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1909 case 0:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1910 /* used to be for really old auth routine, dont support now */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1911 case 1:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1912 case 2: /* Yahoo ver 16 authentication */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1913 yahoo_auth16_stage1(gc, seed);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1914 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1915 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1916 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1917 GHashTable *ui_info = purple_core_get_ui_info();
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1918
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1919 buf = g_strdup_printf(_("The Yahoo server has requested the use of an unrecognized "
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1920 "authentication method. You will probably not be able "
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1921 "to successfully sign on to Yahoo. Check %s for updates."),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1922 ((ui_info && g_hash_table_lookup(ui_info, "website")) ? (char *)g_hash_table_lookup(ui_info, "website") : PURPLE_WEBSITE));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1923 purple_notify_error(gc, "", _("Failed Yahoo! Authentication"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1924 buf);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1925 g_free(buf);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1926 yahoo_auth16_stage1(gc, seed); /* Can't hurt to try it anyway. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1927 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1928 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1929 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1930 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1931 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1932
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1933 static void ignore_buddy(PurpleBuddy *buddy) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1934 PurpleGroup *group;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1935 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1936 gchar *name;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1937
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1938 if (!buddy)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1939 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1940
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1941 group = purple_buddy_get_group(buddy);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1942 name = g_strdup(purple_buddy_get_name(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1943 account = purple_buddy_get_account(buddy);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1944
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1945 purple_debug_info("yahoo", "blist: Removing '%s' from buddy list.\n", name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1946 purple_account_remove_buddy(account, buddy, group);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1947 purple_blist_remove_buddy(buddy);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1948
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1949 serv_add_deny(purple_account_get_connection(account), name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1950
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1951 g_free(name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1952 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1953
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1954 static void keep_buddy(PurpleBuddy *b)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1955 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1956 purple_privacy_deny_remove(purple_buddy_get_account(b),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1957 purple_buddy_get_name(b), 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1958 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1959
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1960 static void yahoo_process_ignore(PurpleConnection *gc, struct yahoo_packet *pkt) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1961 PurpleBuddy *b;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1962 GSList *l;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1963 gchar *who = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1964 gchar *me = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1965 gchar buf[BUF_LONG];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1966 gboolean ignore = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1967 gint status = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1968
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1969 for (l = pkt->hash; l; l = l->next) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1970 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1971 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1972 case 0:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1973 who = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1974 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1975 case 1:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1976 me = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1977 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1978 case 13:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1979 /* 1 == ignore, 2 == unignore */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1980 ignore = (strtol(pair->value, NULL, 10) == 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1981 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1982 case 66:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1983 status = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1984 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1985 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1986 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1987 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1988 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1989
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1990 /*
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1991 * status
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1992 * 0 - ok
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1993 * 2 - already in ignore list, could not add
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1994 * 3 - not in ignore list, could not delete
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1995 * 12 - is a buddy, could not add (and possibly also a not-in-ignore list condition?)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1996 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1997 switch (status) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1998 case 12:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
1999 purple_debug_info("yahoo", "Server reported \"is a buddy\" for %s while %s",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2000 who, (ignore ? "ignoring" : "unignoring"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2001
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2002 if (ignore) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2003 b = purple_find_buddy(gc->account, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2004 g_snprintf(buf, sizeof(buf), _("You have tried to ignore %s, but the "
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2005 "user is on your buddy list. Clicking \"Yes\" "
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2006 "will remove and ignore the buddy."), who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2007 purple_request_yes_no(gc, NULL, _("Ignore buddy?"), buf, 0,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2008 gc->account, who, NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2009 b,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2010 G_CALLBACK(ignore_buddy),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2011 G_CALLBACK(keep_buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2012 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2013 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2014 case 2:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2015 purple_debug_info("yahoo", "Server reported that %s is already in the ignore list.",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2016 who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2017 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2018 case 3:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2019 purple_debug_info("yahoo", "Server reported that %s is not in the ignore list; could not delete",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2020 who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2021 case 0:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2022 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2023 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2024 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2025 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2026
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2027 static void yahoo_process_authresp(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2028 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2029 #ifdef TRY_WEBMESSENGER_LOGIN
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2030 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2031 #endif /* TRY_WEBMESSENGER_LOGIN */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2032 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2033 int err = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2034 char *msg;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2035 char *url = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2036 char *fullmsg;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2037 PurpleAccount *account = gc->account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2038 PurpleConnectionError reason = PURPLE_CONNECTION_ERROR_OTHER_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2039
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2040 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2041 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2042
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2043 if (pair->key == 66)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2044 err = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2045 else if (pair->key == 20)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2046 url = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2047
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2048 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2049 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2050
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2051 switch (err) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2052 case 0:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2053 msg = g_strdup(_("Unknown error."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2054 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2055 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2056 case 3:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2057 msg = g_strdup(_("Invalid username."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2058 reason = PURPLE_CONNECTION_ERROR_INVALID_USERNAME;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2059 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2060 case 13:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2061 #ifdef TRY_WEBMESSENGER_LOGIN
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2062 if (!yd->wm) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2063 PurpleUtilFetchUrlData *url_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2064 yd->wm = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2065 if (yd->fd >= 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2066 close(yd->fd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2067 if (gc->inpa)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2068 purple_input_remove(gc->inpa);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2069 url_data = purple_util_fetch_url(WEBMESSENGER_URL, TRUE,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2070 "Purple/" VERSION, FALSE, yahoo_login_page_cb, gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2071 if (url_data != NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2072 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2073 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2074 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2075 #endif /* TRY_WEBMESSENGER_LOGIN */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2076 if (!purple_account_get_remember_password(account))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2077 purple_account_set_password(account, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2078
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2079 msg = g_strdup(_("Incorrect password."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2080 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2081 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2082 case 14:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2083 msg = g_strdup(_("Your account is locked, please log in to the Yahoo! website."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2084 reason = PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2085 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2086 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2087 msg = g_strdup_printf(_("Unknown error number %d. Logging into the Yahoo! website may fix this."), err);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2088 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2089
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2090 if (url)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2091 fullmsg = g_strdup_printf("%s\n%s", msg, url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2092 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2093 fullmsg = g_strdup(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2094
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2095 purple_connection_error_reason(gc, reason, fullmsg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2096 g_free(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2097 g_free(fullmsg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2098 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2099
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2100 static void yahoo_process_addbuddy(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2101 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2102 int err = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2103 char *who = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2104 char *temp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2105 char *group = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2106 char *decoded_group;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2107 char *buf;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2108 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2109 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2110 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2111 int protocol = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2112 gboolean msn = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2113
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2114 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2115 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2116
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2117 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2118 case 66:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2119 err = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2120 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2121 case 7:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2122 temp = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2123 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2124 case 65:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2125 group = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2126 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2127 case 241:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2128 protocol = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2129 if(protocol == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2130 msn = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2131 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2132 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2133
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2134 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2135 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2136
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2137 if (!temp)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2138 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2139 if (!group)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2140 group = "";
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2141
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2142 if(msn)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2143 who = g_strconcat("msn/", temp, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2144 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2145 who = g_strdup(temp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2146
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2147 if (!err || (err == 2)) { /* 0 = ok, 2 = already on serv list */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2148 f = yahoo_friend_find_or_new(gc, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2149 yahoo_update_status(gc, who, f);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2150 if(protocol)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2151 f->protocol = protocol;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2152
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2153 if( !g_hash_table_lookup(yd->peers, who) ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2154 /* we are not connected as client, so set friend to not connected */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2155 if(msn)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2156 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_DO_NOT_CONNECT);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2157 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2158 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2159 f->p2p_packet_sent = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2160 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2161 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2162 else /* we are already connected. set friend to YAHOO_P2PSTATUS_WE_ARE_CLIENT */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2163 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_CLIENT);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2164 g_free(who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2165 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2166 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2167
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2168 decoded_group = yahoo_string_decode(gc, group, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2169 buf = g_strdup_printf(_("Could not add buddy %s to group %s to the server list on account %s."),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2170 who, decoded_group, purple_connection_get_display_name(gc));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2171 if (!purple_conv_present_error(who, purple_connection_get_account(gc), buf))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2172 purple_notify_error(gc, NULL, _("Could not add buddy to server list"), buf);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2173 g_free(buf);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2174 g_free(decoded_group);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2175 g_free(who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2176 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2177
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2178 /* write pkt to the source */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2179 static void yahoo_p2p_write_pkt(gint source, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2180 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2181 size_t pkt_len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2182 guchar *raw_packet;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2183
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2184 /*build the raw packet and send it to the host*/
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2185 pkt_len = yahoo_packet_build(pkt, 0, 0, 0, &raw_packet);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2186 if(write(source, raw_packet, pkt_len) != pkt_len)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2187 purple_debug_warning("yahoo","p2p: couldn't write to the source\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2188 g_free(raw_packet);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2189 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2190
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2191 static void yahoo_p2p_keepalive_cb(gpointer key, gpointer value, gpointer user_data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2192 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2193 struct yahoo_p2p_data *p2p_data = value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2194 PurpleConnection *gc = user_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2195 struct yahoo_packet *pkt_to_send;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2196 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2197 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2198
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2199 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2200
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2201 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2202 yahoo_packet_hash(pkt_to_send, "ssisi",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2203 4, purple_normalize(account, purple_account_get_username(account)),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2204 5, p2p_data->host_username,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2205 241, 0, /* Protocol identifier */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2206 49, "PEERTOPEER",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2207 13, 7);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2208 yahoo_p2p_write_pkt(p2p_data->source, pkt_to_send);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2209
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2210 yahoo_packet_free(pkt_to_send);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2211 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2212
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2213 static gboolean yahoo_p2p_keepalive(gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2214 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2215 PurpleConnection *gc = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2216 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2217
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2218 g_hash_table_foreach(yd->peers, yahoo_p2p_keepalive_cb, gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2219
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2220 return TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2221 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2222
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2223 /* destroy p2p_data associated with a peer and close p2p connection.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2224 * g_hash_table_remove() calls this function to destroy p2p_data associated with the peer,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2225 * call g_hash_table_remove() instead of this fucntion if peer has an entry in the table */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2226 static void yahoo_p2p_disconnect_destroy_data(gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2227 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2228 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2229 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2230
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2231 if(!(p2p_data = data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2232 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2233
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2234 /* If friend, set him not connected */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2235 f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2236 if (f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2237 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_NOT_CONNECTED);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2238
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2239 if(p2p_data->source >= 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2240 close(p2p_data->source);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2241 purple_input_remove(p2p_data->input_event);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2242 g_free(p2p_data->host_ip);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2243 g_free(p2p_data->host_username);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2244 g_free(p2p_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2245 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2246
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2247 /* exchange of initial p2pfilexfer packets, service type YAHOO_SERVICE_P2PFILEXFER */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2248 static void yahoo_p2p_process_p2pfilexfer(gpointer data, gint source, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2249 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2250 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2251 char *who = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2252 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2253 struct yahoo_packet *pkt_to_send;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2254 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2255 int val_13_to_send = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2256 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2257 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2258
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2259 if(!(p2p_data = data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2260 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2261
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2262 yd = p2p_data->gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2263
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2264 /* lets see whats in the packet */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2265 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2266 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2267
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2268 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2269 case 4:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2270 who = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2271 if(strncmp(who, p2p_data->host_username, strlen(p2p_data->host_username)) != 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2272 /* from whom are we receiving the packets ?? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2273 purple_debug_warning("yahoo","p2p: received data from wrong user\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2274 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2275 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2276 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2277 case 13:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2278 p2p_data->val_13 = strtol(pair->value, NULL, 10); /* Value should be 5-7 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2279 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2280 /* case 5, 49 look laters, no use right now */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2281 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2282 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2283 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2284
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2285 account = purple_connection_get_account(p2p_data->gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2286
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2287 /* key_13: sort of a counter.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2288 * WHEN WE ARE CLIENT: yahoo server sends val_13 = 0, we send to peer val_13 = 1, receive back val_13 = 5,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2289 * we send val_13=6, receive val_13=7, we send val_13=7, HALT. Keep sending val_13 = 7 as keep alive.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2290 * WHEN WE ARE SERVER: we send val_13 = 0 to yahoo server, peer sends us val_13 = 1, we send val_13 = 5,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2291 * receive val_13 = 6, send val_13 = 7, receive val_13 = 7. HALT. Keep sending val_13 = 7 as keep alive. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2292
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2293 switch(p2p_data->val_13) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2294 case 1 : val_13_to_send = 5; break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2295 case 5 : val_13_to_send = 6; break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2296 case 6 : val_13_to_send = 7; break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2297 case 7 : if( g_hash_table_lookup(yd->peers, p2p_data->host_username) )
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2298 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2299 val_13_to_send = 7; break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2300 default: purple_debug_warning("yahoo","p2p:Unknown value for key 13\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2301 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2302 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2303
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2304 /* Build the yahoo packet */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2305 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2306 yahoo_packet_hash(pkt_to_send, "ssisi",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2307 4, purple_normalize(account, purple_account_get_username(account)),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2308 5, p2p_data->host_username,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2309 241, 0, /* Protocol identifier */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2310 49, "PEERTOPEER",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2311 13, val_13_to_send);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2312
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2313 /* build the raw packet and send it to the host */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2314 yahoo_p2p_write_pkt(source, pkt_to_send);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2315 yahoo_packet_free(pkt_to_send);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2316
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2317 if( val_13_to_send == 7 )
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2318 if( !g_hash_table_lookup(yd->peers, p2p_data->host_username) ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2319 g_hash_table_insert(yd->peers, g_strdup(p2p_data->host_username), p2p_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2320 /* If the peer is a friend, set him connected */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2321 f = yahoo_friend_find(p2p_data->gc, p2p_data->host_username);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2322 if (f) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2323 if(p2p_data->connection_type == YAHOO_P2P_WE_ARE_SERVER) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2324 p2p_data->session_id = f->session_id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2325 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_SERVER);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2326 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2327 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2328 yahoo_friend_set_p2p_status(f, YAHOO_P2PSTATUS_WE_ARE_CLIENT);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2329 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2330 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2331 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2332
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2333 /* callback function associated with receiving of data, not considering receipt of multiple YMSG packets in a single TCP packet */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2334 static void yahoo_p2p_read_pkt_cb(gpointer data, gint source, PurpleInputCondition cond)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2335 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2336 guchar buf[1024]; /* is it safe to assume a fixed array length of 1024 ?? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2337 int len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2338 int pos = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2339 int pktlen;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2340 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2341 guchar *start = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2342 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2343 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2344
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2345 if(!(p2p_data = data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2346 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2347 yd = p2p_data->gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2348
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2349 len = read(source, buf, sizeof(buf));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2350 if ((len < 0) && ((errno == EAGAIN) || (errno == EWOULDBLOCK)))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2351 return ; /* No Worries*/
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2352 else if (len <= 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2353 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2354 purple_debug_warning("yahoo","p2p: Error in connection, or host disconnected\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2355 /* remove from p2p connection lists, also calls yahoo_p2p_disconnect_destroy_data */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2356 if( g_hash_table_lookup(yd->peers, p2p_data->host_username) )
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2357 g_hash_table_remove(yd->peers,p2p_data->host_username);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2358 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2359 yahoo_p2p_disconnect_destroy_data(data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2360 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2361 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2362
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2363 if(len < YAHOO_PACKET_HDRLEN)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2364 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2365
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2366 if(strncmp((char *)buf, "YMSG", MIN(4, len)) != 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2367 /* Not a YMSG packet */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2368 purple_debug_warning("yahoo","p2p: Got something other than YMSG packet\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2369
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2370 start = memchr(buf + 1, 'Y', len - 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2371 if (start == NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2372 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2373
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2374 g_memmove(buf, start, len - (start - buf));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2375 len -= start - buf;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2376 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2377
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2378 pos += 4; /* YMSG */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2379 pos += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2380 pos += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2381
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2382 pktlen = yahoo_get16(buf + pos); pos += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2383 purple_debug_misc("yahoo", "p2p: %d bytes to read\n", len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2384
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2385 pkt = yahoo_packet_new(0, 0, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2386 pkt->service = yahoo_get16(buf + pos); pos += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2387 pkt->status = yahoo_get32(buf + pos); pos += 4;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2388 pkt->id = yahoo_get32(buf + pos); pos += 4;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2389
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2390 purple_debug_misc("yahoo", "p2p: Yahoo Service: 0x%02x Status: %d\n",pkt->service, pkt->status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2391 yahoo_packet_read(pkt, buf + pos, pktlen);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2392
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2393 /* packet processing */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2394 switch(pkt->service) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2395 case YAHOO_SERVICE_P2PFILEXFER:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2396 yahoo_p2p_process_p2pfilexfer(data, source, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2397 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2398 case YAHOO_SERVICE_MESSAGE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2399 yahoo_process_message(p2p_data->gc, pkt, YAHOO_PKT_TYPE_P2P);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2400 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2401 case YAHOO_SERVICE_NOTIFY:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2402 yahoo_process_notify(p2p_data->gc, pkt, YAHOO_PKT_TYPE_P2P);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2403 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2404 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2405 purple_debug_warning("yahoo","p2p: p2p service %d Unhandled\n",pkt->service);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2406 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2407
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2408 yahoo_packet_free(pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2409 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2410
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2411 static void yahoo_p2p_server_send_connected_cb(gpointer data, gint source, PurpleInputCondition cond)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2412 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2413 int acceptfd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2414 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2415 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2416
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2417 if(!(p2p_data = data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2418 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2419 yd = p2p_data->gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2420
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2421 acceptfd = accept(source, NULL, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2422 if(acceptfd == -1 && (errno == EAGAIN || errno == EWOULDBLOCK))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2423 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2424 else if(acceptfd == -1) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2425 purple_debug_warning("yahoo","yahoo_p2p_server_send_connected_cb: accept: %s\n", g_strerror(errno));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2426 yahoo_p2p_disconnect_destroy_data(data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2427 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2428 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2429
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2430 /* remove timeout */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2431 if (yd->yahoo_p2p_server_timeout_handle) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2432 purple_timeout_remove(yd->yahoo_p2p_server_timeout_handle);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2433 yd->yahoo_p2p_server_timeout_handle = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2434 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2435
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2436 /* remove watcher and close p2p server */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2437 if (yd->yahoo_p2p_server_watcher) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2438 purple_input_remove(yd->yahoo_p2p_server_watcher);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2439 yd->yahoo_p2p_server_watcher = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2440 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2441 if (yd->yahoo_local_p2p_server_fd >= 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2442 close(yd->yahoo_local_p2p_server_fd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2443 yd->yahoo_local_p2p_server_fd = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2444 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2445
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2446 /* Add an Input Read event to the file descriptor */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2447 p2p_data->input_event = purple_input_add(acceptfd, PURPLE_INPUT_READ, yahoo_p2p_read_pkt_cb, data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2448 p2p_data->source = acceptfd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2449 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2450
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2451 static gboolean yahoo_cancel_p2p_server_listen_cb(gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2452 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2453 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2454 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2455
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2456 if(!(p2p_data = data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2457 return FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2458
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2459 yd = p2p_data->gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2460
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2461 purple_debug_warning("yahoo","yahoo p2p server timeout, peer failed to connect");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2462 yahoo_p2p_disconnect_destroy_data(data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2463 purple_input_remove(yd->yahoo_p2p_server_watcher);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2464 yd->yahoo_p2p_server_watcher = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2465 close(yd->yahoo_local_p2p_server_fd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2466 yd->yahoo_local_p2p_server_fd = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2467 yd->yahoo_p2p_server_timeout_handle = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2468
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2469 return FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2470 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2471
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2472 static void yahoo_p2p_server_listen_cb(int listenfd, gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2473 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2474 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2475 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2476
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2477 if(!(p2p_data = data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2478 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2479
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2480 if(listenfd == -1) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2481 purple_debug_warning("yahoo","p2p: error starting p2p server\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2482 yahoo_p2p_disconnect_destroy_data(data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2483 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2484 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2485
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2486 yd = p2p_data->gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2487
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2488 /* Add an Input Read event to the file descriptor */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2489 yd->yahoo_local_p2p_server_fd = listenfd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2490 yd->yahoo_p2p_server_watcher = purple_input_add(listenfd, PURPLE_INPUT_READ, yahoo_p2p_server_send_connected_cb,data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2491
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2492 /* add timeout */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2493 yd->yahoo_p2p_server_timeout_handle = purple_timeout_add_seconds(YAHOO_P2P_SERVER_TIMEOUT, yahoo_cancel_p2p_server_listen_cb, data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2494 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2495
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2496 /* send p2p pkt containing our encoded ip, asking peer to connect to us */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2497 void yahoo_send_p2p_pkt(PurpleConnection *gc, const char *who, int val_13)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2498 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2499 const char *public_ip;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2500 guint32 temp[4];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2501 guint32 ip;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2502 char temp_str[100];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2503 gchar *base64_ip = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2504 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2505 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2506 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2507 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2508 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2509
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2510 f = yahoo_friend_find(gc, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2511 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2512
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2513 /* Do not send invitation if already listening for other connection */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2514 if(yd->yahoo_local_p2p_server_fd >= 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2515 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2516
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2517 /* One shouldn't try to connect to self */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2518 if( strcmp(purple_normalize(account, purple_account_get_username(account)), who) == 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2519 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2520
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2521 /* send packet to only those friends who arent p2p connected and to whom we havent already sent. Do not send if this condition doesn't hold good */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2522 if( !( f && (yahoo_friend_get_p2p_status(f) == YAHOO_P2PSTATUS_NOT_CONNECTED) && (f->p2p_packet_sent == 0)) )
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2523 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2524
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2525 /* Dont send p2p packet to buddies of other protocols */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2526 if(f->protocol)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2527 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2528
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2529 /* Finally, don't try to connect to buddies not online or on sms */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2530 if( (f->status == YAHOO_STATUS_OFFLINE) || f->sms )
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2531 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2532
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2533 public_ip = purple_network_get_public_ip();
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2534 if( (sscanf(public_ip, "%u.%u.%u.%u", &temp[0], &temp[1], &temp[2], &temp[3])) !=4 )
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2535 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2536
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2537 ip = (temp[3] << 24) | (temp[2] <<16) | (temp[1] << 8) | temp[0];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2538 sprintf(temp_str, "%d", ip);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2539 base64_ip = purple_base64_encode( (guchar *)temp_str, strlen(temp_str) );
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2540
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2541 pkt = yahoo_packet_new(YAHOO_SERVICE_PEERTOPEER, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2542 yahoo_packet_hash(pkt, "sssissis",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2543 1, purple_normalize(account, purple_account_get_username(account)),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2544 4, purple_normalize(account, purple_account_get_username(account)),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2545 12, base64_ip, /* base64 encode ip */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2546 61, 0, /* To-do : figure out what is 61 for?? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2547 2, "",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2548 5, who,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2549 13, val_13,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2550 49, "PEERTOPEER");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2551 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2552
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2553 f->p2p_packet_sent = 1; /* set p2p_packet_sent to sent */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2554
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2555 p2p_data = g_new0(struct yahoo_p2p_data, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2556
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2557 p2p_data->gc = gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2558 p2p_data->host_ip = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2559 p2p_data->host_username = g_strdup(who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2560 p2p_data->val_13 = val_13;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2561 p2p_data->connection_type = YAHOO_P2P_WE_ARE_SERVER;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2562 p2p_data->source = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2563
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2564 purple_network_listen(YAHOO_PAGER_PORT_P2P, SOCK_STREAM, yahoo_p2p_server_listen_cb, p2p_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2565
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2566 g_free(base64_ip);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2567 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2568
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2569 /* function called when connection to p2p host is setup */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2570 static void yahoo_p2p_init_cb(gpointer data, gint source, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2571 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2572 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2573 struct yahoo_packet *pkt_to_send;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2574 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2575 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2576
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2577 if(!(p2p_data = data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2578 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2579 yd = p2p_data->gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2580
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2581 if(error_message != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2582 purple_debug_warning("yahoo","p2p: %s\n",error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2583 yahoo_send_p2p_pkt(p2p_data->gc, p2p_data->host_username, 2);/* send p2p init packet with val_13=2 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2584
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2585 yahoo_p2p_disconnect_destroy_data(p2p_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2586 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2587 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2588
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2589 /* Add an Input Read event to the file descriptor */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2590 p2p_data->input_event = purple_input_add(source, PURPLE_INPUT_READ, yahoo_p2p_read_pkt_cb, data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2591 p2p_data->source = source;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2592
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2593 account = purple_connection_get_account(p2p_data->gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2594
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2595 /* Build the yahoo packet */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2596 pkt_to_send = yahoo_packet_new(YAHOO_SERVICE_P2PFILEXFER, YAHOO_STATUS_AVAILABLE, yd->session_id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2597 yahoo_packet_hash(pkt_to_send, "ssisi",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2598 4, purple_normalize(account, purple_account_get_username(account)),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2599 5, p2p_data->host_username,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2600 241, 0, /* Protocol identifier */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2601 49, "PEERTOPEER",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2602 13, 1); /* we receive key13= 0 or 2, we send key13=1 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2603
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2604 yahoo_p2p_write_pkt(source, pkt_to_send); /* build raw packet and send */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2605 yahoo_packet_free(pkt_to_send);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2606 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2607
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2608 static void yahoo_process_p2p(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2609 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2610 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2611 char *who = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2612 char *base64 = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2613 guchar *decoded;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2614 gsize len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2615 gint val_13 = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2616 gint val_11 = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2617 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2618 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2619
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2620 /* if status is not 1 ie YAHOO_STATUS_BRB, the packet bounced back, so contains our own ip */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2621 if(!(pkt->status == YAHOO_STATUS_BRB))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2622 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2623
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2624 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2625 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2626
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2627 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2628 case 5:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2629 /* our identity */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2630 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2631 case 4:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2632 who = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2633 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2634 case 1:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2635 /* who again, the master identity this time? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2636 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2637 case 12:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2638 base64 = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2639 /* so, this is an ip address. in base64. decoded it's in ascii.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2640 after strtol, it's in reversed byte order. Who thought this up?*/
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2641 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2642 case 13:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2643 val_13 = strtol(pair->value, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2644 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2645 case 11:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2646 val_11 = strtol(pair->value, NULL, 10); /* session id of peer */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2647 if( (f = yahoo_friend_find(gc, who)) )
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2648 f->session_id = val_11;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2649 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2650 /*
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2651 TODO: figure these out
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2652 yahoo: Key: 61 Value: 0
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2653 yahoo: Key: 2 Value:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2654 yahoo: Key: 13 Value: 0 packet count ??
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2655 yahoo: Key: 49 Value: PEERTOPEER
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2656 yahoo: Key: 140 Value: 1
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2657 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2658
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2659 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2660
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2661 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2662 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2663
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2664 if (base64) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2665 guint32 ip;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2666 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2667 char *host_ip;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2668 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2669
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2670 decoded = purple_base64_decode(base64, &len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2671 if (len) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2672 char *tmp = purple_str_binary_to_ascii(decoded, len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2673 purple_debug_info("yahoo", "Got P2P service packet (from server): who = %s, ip = %s\n", who, tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2674 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2675 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2676
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2677 ip = strtol((gchar *)decoded, NULL, 10);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2678 g_free(decoded);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2679 host_ip = g_strdup_printf("%u.%u.%u.%u", ip & 0xff, (ip >> 8) & 0xff, (ip >> 16) & 0xff,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2680 (ip >> 24) & 0xff);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2681 f = yahoo_friend_find(gc, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2682 if (f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2683 yahoo_friend_set_ip(f, host_ip);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2684 purple_debug_info("yahoo", "IP : %s\n", host_ip);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2685
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2686 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2687
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2688 if(val_11==0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2689 if(!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2690 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2691 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2692 val_11 = f->session_id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2693 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2694
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2695 p2p_data = g_new0(struct yahoo_p2p_data, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2696 p2p_data->host_username = g_strdup(who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2697 p2p_data->val_13 = val_13;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2698 p2p_data->session_id = val_11;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2699 p2p_data->host_ip = host_ip;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2700 p2p_data->gc = gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2701 p2p_data->connection_type = YAHOO_P2P_WE_ARE_CLIENT;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2702 p2p_data->source = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2703
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2704 /* connect to host */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2705 if((purple_proxy_connect(gc, account, host_ip, YAHOO_PAGER_PORT_P2P, yahoo_p2p_init_cb, p2p_data))==NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2706 purple_debug_info("yahoo","p2p: Connection to %s failed\n", host_ip);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2707 g_free(p2p_data->host_ip);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2708 g_free(p2p_data->host_username);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2709 g_free(p2p_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2710 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2711 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2712 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2713
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2714 static void yahoo_process_audible(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2715 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2716 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2717 char *who = NULL, *msg = NULL, *id = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2718 GSList *l = pkt->hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2719
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2720 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2721
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2722 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2723 struct yahoo_pair *pair = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2724
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2725 switch (pair->key) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2726 case 4:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2727 who = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2728 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2729 case 5:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2730 /* us */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2731 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2732 case 230:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2733 /* the audible, in foo.locale.bar.baz format
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2734 eg: base.tw.smiley.smiley43 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2735 id = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2736 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2737 case 231:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2738 /* the text of the audible */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2739 msg = pair->value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2740 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2741 case 232:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2742 /* weird number (md5 hash?), like 8ebab9094156135f5dcbaccbeee662a5c5fd1420 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2743 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2744 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2745
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2746 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2747 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2748
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2749 if (!msg)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2750 msg = id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2751 if (!who || !msg)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2752 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2753 if (!g_utf8_validate(msg, -1, NULL)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2754 purple_debug_misc("yahoo", "Warning, nonutf8 audible, ignoring!\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2755 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2756 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2757 if (!purple_privacy_check(account, who)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2758 purple_debug_misc("yahoo", "Audible message from %s for %s dropped!\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2759 purple_account_get_username(account), who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2760 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2761 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2762 if (id) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2763 /* "http://us.dl1.yimg.com/download.yahoo.com/dl/aud/"+locale+"/"+id+".swf" */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2764 char **audible_locale = g_strsplit(id, ".", 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2765 char *buf = g_strdup_printf(_("[ Audible %s/%s/%s.swf ] %s"), YAHOO_AUDIBLE_URL, audible_locale[1], id, msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2766 g_strfreev(audible_locale);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2767
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2768 serv_got_im(gc, who, buf, 0, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2769 g_free(buf);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2770 } else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2771 serv_got_im(gc, who, msg, 0, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2772 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2773
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2774 static void yahoo_packet_process(PurpleConnection *gc, struct yahoo_packet *pkt)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2775 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2776 switch (pkt->service) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2777 case YAHOO_SERVICE_LOGON:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2778 case YAHOO_SERVICE_LOGOFF:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2779 case YAHOO_SERVICE_ISAWAY:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2780 case YAHOO_SERVICE_ISBACK:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2781 case YAHOO_SERVICE_GAMELOGON:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2782 case YAHOO_SERVICE_GAMELOGOFF:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2783 case YAHOO_SERVICE_CHATLOGON:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2784 case YAHOO_SERVICE_CHATLOGOFF:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2785 case YAHOO_SERVICE_Y6_STATUS_UPDATE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2786 case YAHOO_SERVICE_STATUS_15:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2787 yahoo_process_status(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2788 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2789 case YAHOO_SERVICE_NOTIFY:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2790 yahoo_process_notify(gc, pkt, YAHOO_PKT_TYPE_SERVER);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2791 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2792 case YAHOO_SERVICE_MESSAGE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2793 case YAHOO_SERVICE_GAMEMSG:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2794 case YAHOO_SERVICE_CHATMSG:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2795 yahoo_process_message(gc, pkt, YAHOO_PKT_TYPE_SERVER);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2796 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2797 case YAHOO_SERVICE_SYSMESSAGE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2798 yahoo_process_sysmessage(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2799 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2800 case YAHOO_SERVICE_NEWMAIL:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2801 yahoo_process_mail(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2802 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2803 case YAHOO_SERVICE_NEWCONTACT:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2804 yahoo_process_contact(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2805 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2806 case YAHOO_SERVICE_AUTHRESP:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2807 yahoo_process_authresp(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2808 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2809 case YAHOO_SERVICE_LIST:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2810 yahoo_process_list(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2811 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2812 case YAHOO_SERVICE_LIST_15:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2813 yahoo_process_list_15(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2814 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2815 case YAHOO_SERVICE_AUTH:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2816 yahoo_process_auth(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2817 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2818 case YAHOO_SERVICE_AUTH_REQ_15:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2819 yahoo_buddy_auth_req_15(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2820 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2821 case YAHOO_SERVICE_ADDBUDDY:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2822 yahoo_process_addbuddy(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2823 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2824 case YAHOO_SERVICE_IGNORECONTACT:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2825 yahoo_process_ignore(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2826 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2827 case YAHOO_SERVICE_CONFINVITE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2828 case YAHOO_SERVICE_CONFADDINVITE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2829 yahoo_process_conference_invite(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2830 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2831 case YAHOO_SERVICE_CONFDECLINE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2832 yahoo_process_conference_decline(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2833 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2834 case YAHOO_SERVICE_CONFLOGON:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2835 yahoo_process_conference_logon(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2836 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2837 case YAHOO_SERVICE_CONFLOGOFF:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2838 yahoo_process_conference_logoff(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2839 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2840 case YAHOO_SERVICE_CONFMSG:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2841 yahoo_process_conference_message(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2842 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2843 case YAHOO_SERVICE_CHATONLINE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2844 yahoo_process_chat_online(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2845 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2846 case YAHOO_SERVICE_CHATLOGOUT:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2847 yahoo_process_chat_logout(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2848 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2849 case YAHOO_SERVICE_CHATGOTO:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2850 yahoo_process_chat_goto(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2851 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2852 case YAHOO_SERVICE_CHATJOIN:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2853 yahoo_process_chat_join(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2854 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2855 case YAHOO_SERVICE_CHATLEAVE: /* XXX is this right? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2856 case YAHOO_SERVICE_CHATEXIT:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2857 yahoo_process_chat_exit(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2858 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2859 case YAHOO_SERVICE_CHATINVITE: /* XXX never seen this one, might not do it right */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2860 case YAHOO_SERVICE_CHATADDINVITE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2861 yahoo_process_chat_addinvite(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2862 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2863 case YAHOO_SERVICE_COMMENT:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2864 yahoo_process_chat_message(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2865 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2866 case YAHOO_SERVICE_PRESENCE_PERM:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2867 case YAHOO_SERVICE_PRESENCE_SESSION:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2868 yahoo_process_presence(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2869 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2870 case YAHOO_SERVICE_P2PFILEXFER:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2871 /* This case had no break and continued; thus keeping it this way.*/
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2872 yahoo_process_p2p(gc, pkt); /* P2PFILEXFER handled the same way as process_p2p */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2873 yahoo_process_p2pfilexfer(gc, pkt); /* redundant ??, need to have a break now */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2874 case YAHOO_SERVICE_FILETRANSFER:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2875 yahoo_process_filetransfer(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2876 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2877 case YAHOO_SERVICE_PEERTOPEER:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2878 yahoo_process_p2p(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2879 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2880 case YAHOO_SERVICE_PICTURE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2881 yahoo_process_picture(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2882 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2883 case YAHOO_SERVICE_PICTURE_CHECKSUM:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2884 yahoo_process_picture_checksum(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2885 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2886 case YAHOO_SERVICE_PICTURE_UPLOAD:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2887 yahoo_process_picture_upload(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2888 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2889 case YAHOO_SERVICE_PICTURE_UPDATE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2890 case YAHOO_SERVICE_AVATAR_UPDATE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2891 yahoo_process_avatar_update(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2892 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2893 case YAHOO_SERVICE_AUDIBLE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2894 yahoo_process_audible(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2895 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2896 case YAHOO_SERVICE_FILETRANS_15:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2897 yahoo_process_filetrans_15(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2898 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2899 case YAHOO_SERVICE_FILETRANS_INFO_15:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2900 yahoo_process_filetrans_info_15(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2901 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2902 case YAHOO_SERVICE_FILETRANS_ACC_15:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2903 yahoo_process_filetrans_acc_15(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2904 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2905 case YAHOO_SERVICE_SMS_MSG:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2906 yahoo_process_sms_message(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2907 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2908
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2909 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2910 purple_debug_error("yahoo", "Unhandled service 0x%02x\n", pkt->service);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2911 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2912 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2913 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2914
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2915 static void yahoo_pending(gpointer data, gint source, PurpleInputCondition cond)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2916 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2917 PurpleConnection *gc = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2918 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2919 char buf[1024];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2920 int len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2921
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2922 len = read(yd->fd, buf, sizeof(buf));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2923
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2924 if (len < 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2925 gchar *tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2926
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2927 if (errno == EAGAIN)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2928 /* No worries */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2929 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2930
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2931 tmp = g_strdup_printf(_("Lost connection with server:\n%s"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2932 g_strerror(errno));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2933 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2934 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2935 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2936 } else if (len == 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2937 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2938 _("Server closed the connection."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2939 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2940 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2941 gc->last_received = time(NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2942 yd->rxqueue = g_realloc(yd->rxqueue, len + yd->rxlen);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2943 memcpy(yd->rxqueue + yd->rxlen, buf, len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2944 yd->rxlen += len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2945
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2946 while (1) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2947 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2948 int pos = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2949 int pktlen;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2950
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2951 if (yd->rxlen < YAHOO_PACKET_HDRLEN)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2952 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2953
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2954 if (strncmp((char *)yd->rxqueue, "YMSG", MIN(4, yd->rxlen)) != 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2955 /* HEY! This isn't even a YMSG packet. What
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2956 * are you trying to pull? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2957 guchar *start;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2958
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2959 purple_debug_warning("yahoo", "Error in YMSG stream, got something not a YMSG packet!\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2960
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2961 start = memchr(yd->rxqueue + 1, 'Y', yd->rxlen - 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2962 if (start) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2963 g_memmove(yd->rxqueue, start, yd->rxlen - (start - yd->rxqueue));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2964 yd->rxlen -= start - yd->rxqueue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2965 continue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2966 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2967 g_free(yd->rxqueue);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2968 yd->rxqueue = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2969 yd->rxlen = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2970 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2971 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2972 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2973
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2974 pos += 4; /* YMSG */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2975 pos += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2976 pos += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2977
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2978 pktlen = yahoo_get16(yd->rxqueue + pos); pos += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2979 purple_debug_misc("yahoo", "%d bytes to read, rxlen is %d\n", pktlen, yd->rxlen);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2980
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2981 if (yd->rxlen < (YAHOO_PACKET_HDRLEN + pktlen))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2982 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2983
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2984 yahoo_packet_dump(yd->rxqueue, YAHOO_PACKET_HDRLEN + pktlen);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2985
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2986 pkt = yahoo_packet_new(0, 0, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2987
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2988 pkt->service = yahoo_get16(yd->rxqueue + pos); pos += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2989 pkt->status = yahoo_get32(yd->rxqueue + pos); pos += 4;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2990 purple_debug_misc("yahoo", "Yahoo Service: 0x%02x Status: %d\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2991 pkt->service, pkt->status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2992 pkt->id = yahoo_get32(yd->rxqueue + pos); pos += 4;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2993
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2994 yahoo_packet_read(pkt, yd->rxqueue + pos, pktlen);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2995
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2996 yd->rxlen -= YAHOO_PACKET_HDRLEN + pktlen;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2997 if (yd->rxlen) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2998 guchar *tmp = g_memdup(yd->rxqueue + YAHOO_PACKET_HDRLEN + pktlen, yd->rxlen);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
2999 g_free(yd->rxqueue);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3000 yd->rxqueue = tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3001 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3002 g_free(yd->rxqueue);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3003 yd->rxqueue = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3004 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3005
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3006 yahoo_packet_process(gc, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3007
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3008 yahoo_packet_free(pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3009 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3010 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3011
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3012 static void yahoo_got_connected(gpointer data, gint source, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3013 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3014 PurpleConnection *gc = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3015 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3016 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3017
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3018 if (source < 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3019 gchar *tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3020 tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3021 error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3022 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3023 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3024 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3025 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3026
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3027 yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3028 yd->fd = source;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3029
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3030 pkt = yahoo_packet_new(YAHOO_SERVICE_AUTH, yd->current_status, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3031
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3032 yahoo_packet_hash_str(pkt, 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3033 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3034
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3035 gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3036 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3037
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3038 #ifdef TRY_WEBMESSENGER_LOGIN
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3039 static void yahoo_got_web_connected(gpointer data, gint source, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3040 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3041 PurpleConnection *gc = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3042 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3043 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3044
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3045 if (source < 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3046 gchar *tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3047 tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3048 error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3049 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3050 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3051 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3052 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3053
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3054 yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3055 yd->fd = source;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3056
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3057 pkt = yahoo_packet_new(YAHOO_SERVICE_WEBLOGIN, YAHOO_STATUS_WEBLOGIN, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3058
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3059 yahoo_packet_hash(pkt, "sss", 0,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3060 purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3061 1, purple_normalize(gc->account, purple_account_get_username(purple_connection_get_account(gc))),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3062 6, yd->auth);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3063 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3064
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3065 g_free(yd->auth);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3066 gc->inpa = purple_input_add(yd->fd, PURPLE_INPUT_READ, yahoo_pending, gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3067 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3068
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3069 static void yahoo_web_pending(gpointer data, gint source, PurpleInputCondition cond)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3070 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3071 PurpleConnection *gc = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3072 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3073 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3074 char bufread[2048], *i = bufread, *buf = bufread;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3075 int len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3076 GString *s;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3077
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3078 len = read(source, bufread, sizeof(bufread) - 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3079
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3080 if (len < 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3081 gchar *tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3082
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3083 if (errno == EAGAIN)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3084 /* No worries */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3085 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3086
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3087 tmp = g_strdup_printf(_("Lost connection with server:\n%s"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3088 g_strerror(errno));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3089 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3090 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3091 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3092 } else if (len == 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3093 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3094 _("Server closed the connection."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3095 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3096 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3097
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3098 if (yd->rxlen > 0 || !g_strstr_len(buf, len, "\r\n\r\n")) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3099 yd->rxqueue = g_realloc(yd->rxqueue, yd->rxlen + len + 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3100 memcpy(yd->rxqueue + yd->rxlen, buf, len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3101 yd->rxlen += len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3102 i = buf = (char *)yd->rxqueue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3103 len = yd->rxlen;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3104 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3105 buf[len] = '\0';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3106
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3107 if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) &&
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3108 strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3109 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3110 _("Received unexpected HTTP response from server."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3111 purple_debug_misc("yahoo", "Unexpected HTTP response: %s\n", buf);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3112 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3113 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3114
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3115 s = g_string_sized_new(len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3116
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3117 while ((i = strstr(i, "Set-Cookie: "))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3118
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3119 i += strlen("Set-Cookie: ");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3120 for (;*i != ';' && *i != '\0'; i++)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3121 g_string_append_c(s, *i);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3122
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3123 g_string_append(s, "; ");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3124 /* Should these cookies be included too when trying for xfer?
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3125 * It seems to work without these
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3126 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3127 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3128
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3129 yd->auth = g_string_free(s, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3130 purple_input_remove(gc->inpa);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3131 close(source);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3132 g_free(yd->rxqueue);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3133 yd->rxqueue = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3134 yd->rxlen = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3135 /* Now we have our cookies to login with. I'll go get the milk. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3136 if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3137 purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3138 yahoo_got_web_connected, gc) == NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3139 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3140 _("Connection problem"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3141 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3142 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3143 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3144
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3145 static void yahoo_got_cookies_send_cb(gpointer data, gint source, PurpleInputCondition cond)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3146 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3147 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3148 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3149 int written, remaining;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3150
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3151 gc = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3152 yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3153
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3154 remaining = strlen(yd->auth) - yd->auth_written;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3155 written = write(source, yd->auth + yd->auth_written, remaining);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3156
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3157 if (written < 0 && errno == EAGAIN)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3158 written = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3159 else if (written <= 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3160 gchar *tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3161 g_free(yd->auth);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3162 yd->auth = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3163 if (gc->inpa)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3164 purple_input_remove(gc->inpa);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3165 gc->inpa = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3166 tmp = g_strdup_printf(_("Lost connection with %s:\n%s"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3167 "login.yahoo.com:80", g_strerror(errno));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3168 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3169 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3170 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3171 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3172
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3173 if (written < remaining) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3174 yd->auth_written += written;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3175 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3176 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3177
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3178 g_free(yd->auth);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3179 yd->auth = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3180 yd->auth_written = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3181 purple_input_remove(gc->inpa);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3182 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, yahoo_web_pending, gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3183 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3184
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3185 static void yahoo_got_cookies(gpointer data, gint source, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3186 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3187 PurpleConnection *gc = data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3188
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3189 if (source < 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3190 gchar *tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3191 tmp = g_strdup_printf(_("Could not establish a connection with %s:\n%s"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3192 "login.yahoo.com:80", error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3193 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3194 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3195 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3196 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3197
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3198 if (gc->inpa == 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3199 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3200 gc->inpa = purple_input_add(source, PURPLE_INPUT_WRITE,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3201 yahoo_got_cookies_send_cb, gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3202 yahoo_got_cookies_send_cb(gc, source, PURPLE_INPUT_WRITE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3203 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3204 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3205
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3206 static void yahoo_login_page_hash_iter(const char *key, const char *val, GString *url)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3207 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3208 if (!strcmp(key, "passwd") || !strcmp(key, "login"))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3209 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3210 g_string_append_c(url, '&');
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3211 g_string_append(url, key);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3212 g_string_append_c(url, '=');
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3213 if (!strcmp(key, ".save") || !strcmp(key, ".js"))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3214 g_string_append_c(url, '1');
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3215 else if (!strcmp(key, ".challenge"))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3216 g_string_append(url, val);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3217 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3218 g_string_append(url, purple_url_encode(val));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3219 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3220
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3221 static GHashTable *yahoo_login_page_hash(const char *buf, size_t len)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3222 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3223 GHashTable *hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3224 const char *c = buf;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3225 char *d;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3226 char name[64], value[64];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3227 int count;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3228 int input_len = strlen("<input ");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3229 int name_len = strlen("name=\"");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3230 int value_len = strlen("value=\"");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3231 while ((len > ((c - buf) + input_len))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3232 && (c = strstr(c, "<input "))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3233 if (!(c = g_strstr_len(c, len - (c - buf), "name=\"")))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3234 continue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3235 c += name_len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3236 count = sizeof(name)-1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3237 for (d = name; (len > ((c - buf) + 1)) && *c!='"'
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3238 && count; c++, d++, count--)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3239 *d = *c;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3240 *d = '\0';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3241 count = sizeof(value)-1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3242 if (!(d = g_strstr_len(c, len - (c - buf), "value=\"")))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3243 continue;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3244 d += value_len;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3245 if (strchr(c, '>') < d)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3246 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3247 for (c = d, d = value; (len > ((c - buf) + 1))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3248 && *c!='"' && count; c++, d++, count--)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3249 *d = *c;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3250 *d = '\0';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3251 g_hash_table_insert(hash, g_strdup(name), g_strdup(value));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3252 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3253 return hash;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3254 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3255
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3256 static void
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3257 yahoo_login_page_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3258 const gchar *url_text, size_t len, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3259 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3260 PurpleConnection *gc = (PurpleConnection *)user_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3261 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3262 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3263 const char *sn = purple_account_get_username(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3264 const char *pass = purple_connection_get_password(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3265 GHashTable *hash = yahoo_login_page_hash(url_text, len);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3266 GString *url = g_string_new("GET http://login.yahoo.com/config/login?login=");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3267 char md5[33], *hashp = md5, *chal;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3268 int i;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3269 PurpleCipher *cipher;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3270 PurpleCipherContext *context;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3271 guchar digest[16];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3272
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3273 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3274
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3275 if (error_message != NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3276 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3277 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3278 error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3279 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3280 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3281
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3282 url = g_string_append(url, sn);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3283 url = g_string_append(url, "&passwd=");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3284
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3285 cipher = purple_ciphers_find_cipher("md5");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3286 context = purple_cipher_context_new(cipher, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3287
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3288 purple_cipher_context_append(context, (const guchar *)pass, strlen(pass));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3289 purple_cipher_context_digest(context, sizeof(digest), digest, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3290 for (i = 0; i < 16; ++i) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3291 g_snprintf(hashp, 3, "%02x", digest[i]);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3292 hashp += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3293 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3294
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3295 chal = g_strconcat(md5, g_hash_table_lookup(hash, ".challenge"), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3296 purple_cipher_context_reset(context, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3297 purple_cipher_context_append(context, (const guchar *)chal, strlen(chal));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3298 purple_cipher_context_digest(context, sizeof(digest), digest, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3299 hashp = md5;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3300 for (i = 0; i < 16; ++i) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3301 g_snprintf(hashp, 3, "%02x", digest[i]);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3302 hashp += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3303 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3304 /*
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3305 * I dunno why this is here and commented out.. but in case it's needed
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3306 * I updated it..
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3307
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3308 purple_cipher_context_reset(context, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3309 purple_cipher_context_append(context, md5, strlen(md5));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3310 purple_cipher_context_digest(context, sizeof(digest), digest, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3311 hashp = md5;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3312 for (i = 0; i < 16; ++i) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3313 g_snprintf(hashp, 3, "%02x", digest[i]);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3314 hashp += 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3315 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3316 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3317 g_free(chal);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3318
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3319 url = g_string_append(url, md5);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3320 g_hash_table_foreach(hash, (GHFunc)yahoo_login_page_hash_iter, url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3321
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3322 url = g_string_append(url, "&.hash=1&.md5=1 HTTP/1.1\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3323 "Host: login.yahoo.com\r\n\r\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3324 g_hash_table_destroy(hash);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3325 yd->auth = g_string_free(url, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3326 if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3327 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3328 _("Connection problem"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3329 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3330 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3331
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3332 purple_cipher_context_destroy(context);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3333 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3334 #endif /* TRY_WEBMESSENGER_LOGIN */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3335
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3336 static void yahoo_server_check(PurpleAccount *account)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3337 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3338 const char *server;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3339
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3340 server = purple_account_get_string(account, "server", YAHOO_PAGER_HOST);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3341
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3342 if (*server == '\0' || g_str_equal(server, "scs.yahoo.com") ||
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3343 g_str_equal(server, "scs.msg.yahoo.com"))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3344 purple_account_set_string(account, "server", YAHOO_PAGER_HOST);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3345 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3346
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3347 static void yahoo_picture_check(PurpleAccount *account)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3348 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3349 PurpleConnection *gc = purple_account_get_connection(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3350 PurpleStoredImage *img = purple_buddy_icons_find_account_icon(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3351
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3352 yahoo_set_buddy_icon(gc, img);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3353 purple_imgstore_unref(img);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3354 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3355
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3356 static int get_yahoo_status_from_purple_status(PurpleStatus *status)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3357 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3358 PurplePresence *presence;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3359 const char *status_id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3360 const char *msg;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3361
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3362 presence = purple_status_get_presence(status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3363 status_id = purple_status_get_id(status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3364 msg = purple_status_get_attr_string(status, "message");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3365
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3366 if (!strcmp(status_id, YAHOO_STATUS_TYPE_AVAILABLE)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3367 if ((msg != NULL) && (*msg != '\0'))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3368 return YAHOO_STATUS_CUSTOM;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3369 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3370 return YAHOO_STATUS_AVAILABLE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3371 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_BRB)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3372 return YAHOO_STATUS_BRB;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3373 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_BUSY)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3374 return YAHOO_STATUS_BUSY;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3375 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_NOTATHOME)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3376 return YAHOO_STATUS_NOTATHOME;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3377 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_NOTATDESK)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3378 return YAHOO_STATUS_NOTATDESK;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3379 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_NOTINOFFICE)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3380 return YAHOO_STATUS_NOTINOFFICE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3381 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_ONPHONE)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3382 return YAHOO_STATUS_ONPHONE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3383 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_ONVACATION)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3384 return YAHOO_STATUS_ONVACATION;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3385 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_OUTTOLUNCH)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3386 return YAHOO_STATUS_OUTTOLUNCH;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3387 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_STEPPEDOUT)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3388 return YAHOO_STATUS_STEPPEDOUT;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3389 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_INVISIBLE)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3390 return YAHOO_STATUS_INVISIBLE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3391 } else if (!strcmp(status_id, YAHOO_STATUS_TYPE_AWAY)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3392 return YAHOO_STATUS_CUSTOM;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3393 } else if (purple_presence_is_idle(presence)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3394 return YAHOO_STATUS_IDLE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3395 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3396 purple_debug_error("yahoo", "Unexpected PurpleStatus!\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3397 return YAHOO_STATUS_AVAILABLE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3398 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3399 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3400
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3401 static void yahoo_login(PurpleAccount *account) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3402 PurpleConnection *gc = purple_account_get_connection(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3403 struct yahoo_data *yd = gc->proto_data = g_new0(struct yahoo_data, 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3404 PurpleStatus *status = purple_account_get_active_status(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3405 gc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_URLDESC;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3406
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3407 purple_connection_update_progress(gc, _("Connecting"), 1, 2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3408
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3409 purple_connection_set_display_name(gc, purple_account_get_username(account));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3410
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3411 yd->yahoo_local_p2p_server_fd = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3412 yd->fd = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3413 yd->txhandler = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3414 /* TODO: Is there a good grow size for the buffer? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3415 yd->txbuf = purple_circ_buffer_new(0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3416 yd->friends = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_friend_free);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3417 yd->imvironments = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3418 yd->xfer_peer_idstring_map = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3419 yd->peers = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, yahoo_p2p_disconnect_destroy_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3420 yd->sms_carrier = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3421 yd->yahoo_p2p_timer = purple_timeout_add_seconds(YAHOO_P2P_KEEPALIVE_SECS, yahoo_p2p_keepalive, gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3422 yd->confs = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3423 yd->conf_id = 2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3424 yd->last_keepalive = yd->last_ping = time(NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3425
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3426 yd->current_status = get_yahoo_status_from_purple_status(status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3427
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3428 yahoo_server_check(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3429 yahoo_picture_check(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3430
27398
7f008ce8604b I believe this will correctly handle setting the yd->jp value under the new
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27397
diff changeset
3431 if (purple_strequal(purple_account_get_protocol_id(account), "yahoojp")) {
27394
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3432 yd->jp = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3433 if (purple_proxy_connect(gc, account,
27398
7f008ce8604b I believe this will correctly handle setting the yd->jp value under the new
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 27397
diff changeset
3434 purple_account_get_string(account, "server", YAHOOJP_PAGER_HOST),
27394
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3435 purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3436 yahoo_got_connected, gc) == NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3437 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3438 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3439 _("Connection problem"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3440 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3441 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3442 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3443 yd->jp = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3444 if (purple_proxy_connect(gc, account,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3445 purple_account_get_string(account, "server", YAHOO_PAGER_HOST),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3446 purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3447 yahoo_got_connected, gc) == NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3448 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3449 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3450 _("Connection problem"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3451 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3452 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3453 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3454 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3455
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3456 static void yahoo_close(PurpleConnection *gc) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3457 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3458 GSList *l;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3459
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3460 if (gc->inpa)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3461 purple_input_remove(gc->inpa);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3462
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3463 while (yd->url_datas) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3464 purple_util_fetch_url_cancel(yd->url_datas->data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3465 yd->url_datas = g_slist_delete_link(yd->url_datas, yd->url_datas);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3466 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3467
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3468 for (l = yd->confs; l; l = l->next) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3469 PurpleConversation *conv = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3470
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3471 yahoo_conf_leave(yd, purple_conversation_get_name(conv),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3472 purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3473 purple_conv_chat_get_users(PURPLE_CONV_CHAT(conv)));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3474 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3475 g_slist_free(yd->confs);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3476
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3477 for (l = yd->cookies; l; l = l->next) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3478 g_free(l->data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3479 l->data=NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3480 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3481 g_slist_free(yd->cookies);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3482
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3483 yd->chat_online = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3484 if (yd->in_chat)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3485 yahoo_c_leave(gc, 1); /* 1 = YAHOO_CHAT_ID */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3486
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3487 purple_timeout_remove(yd->yahoo_p2p_timer);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3488 if(yd->yahoo_p2p_server_timeout_handle != 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3489 purple_timeout_remove(yd->yahoo_p2p_server_timeout_handle);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3490 yd->yahoo_p2p_server_timeout_handle = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3491 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3492
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3493 /* close p2p server if it is waiting for a peer to connect */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3494 if (yd->yahoo_p2p_server_watcher) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3495 purple_input_remove(yd->yahoo_p2p_server_watcher);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3496 yd->yahoo_p2p_server_watcher = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3497 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3498 if (yd->yahoo_local_p2p_server_fd >= 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3499 close(yd->yahoo_local_p2p_server_fd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3500 yd->yahoo_local_p2p_server_fd = -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3501 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3502
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3503 g_hash_table_destroy(yd->sms_carrier);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3504 g_hash_table_destroy(yd->peers);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3505 g_hash_table_destroy(yd->friends);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3506 g_hash_table_destroy(yd->imvironments);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3507 g_hash_table_destroy(yd->xfer_peer_idstring_map);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3508 g_free(yd->chat_name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3509
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3510 g_free(yd->cookie_y);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3511 g_free(yd->cookie_t);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3512
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3513 if (yd->txhandler)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3514 purple_input_remove(yd->txhandler);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3515
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3516 purple_circ_buffer_destroy(yd->txbuf);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3517
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3518 if (yd->fd >= 0)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3519 close(yd->fd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3520
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3521 g_free(yd->rxqueue);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3522 yd->rxlen = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3523 g_free(yd->picture_url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3524
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3525 if (yd->buddy_icon_connect_data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3526 purple_proxy_connect_cancel(yd->buddy_icon_connect_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3527 if (yd->picture_upload_todo)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3528 yahoo_buddy_icon_upload_data_free(yd->picture_upload_todo);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3529 if (yd->ycht)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3530 ycht_connection_close(yd->ycht);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3531
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3532 g_free(yd->pending_chat_room);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3533 g_free(yd->pending_chat_id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3534 g_free(yd->pending_chat_topic);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3535 g_free(yd->pending_chat_goto);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3536 g_strfreev(yd->profiles);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3537
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3538 g_free(yd->current_list15_grp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3539
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3540 g_free(yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3541 gc->proto_data = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3542 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3543
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3544 static const char *yahoo_list_icon(PurpleAccount *a, PurpleBuddy *b)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3545 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3546 return "yahoo";
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3547 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3548
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3549 static const char *yahoo_list_emblem(PurpleBuddy *b)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3550 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3551 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3552 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3553 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3554 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3555 PurplePresence *presence;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3556
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3557 if (!b || !(account = purple_buddy_get_account(b)) ||
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3558 !(gc = purple_account_get_connection(account)) ||
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3559 !(yd = gc->proto_data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3560 return NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3561
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3562 f = yahoo_friend_find(gc, purple_buddy_get_name(b));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3563 if (!f) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3564 return "not-authorized";
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3565 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3566
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3567 presence = purple_buddy_get_presence(b);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3568
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3569 if (purple_presence_is_online(presence)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3570 if (yahoo_friend_get_game(f))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3571 return "game";
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3572 if (f->protocol == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3573 return "msn";
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3574 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3575 return NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3576 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3577
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3578 static const char *yahoo_get_status_string(enum yahoo_status a)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3579 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3580 switch (a) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3581 case YAHOO_STATUS_BRB:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3582 return _("Be Right Back");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3583 case YAHOO_STATUS_BUSY:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3584 return _("Busy");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3585 case YAHOO_STATUS_NOTATHOME:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3586 return _("Not at Home");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3587 case YAHOO_STATUS_NOTATDESK:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3588 return _("Not at Desk");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3589 case YAHOO_STATUS_NOTINOFFICE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3590 return _("Not in Office");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3591 case YAHOO_STATUS_ONPHONE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3592 return _("On the Phone");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3593 case YAHOO_STATUS_ONVACATION:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3594 return _("On Vacation");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3595 case YAHOO_STATUS_OUTTOLUNCH:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3596 return _("Out to Lunch");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3597 case YAHOO_STATUS_STEPPEDOUT:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3598 return _("Stepped Out");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3599 case YAHOO_STATUS_INVISIBLE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3600 return _("Invisible");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3601 case YAHOO_STATUS_IDLE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3602 return _("Idle");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3603 case YAHOO_STATUS_OFFLINE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3604 return _("Offline");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3605 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3606 return _("Available");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3607 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3608 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3609
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3610 static void yahoo_initiate_conference(PurpleBlistNode *node, gpointer data) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3611
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3612 PurpleBuddy *buddy;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3613 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3614
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3615 GHashTable *components;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3616 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3617 int id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3618
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3619 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3620
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3621 buddy = (PurpleBuddy *) node;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3622 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3623 yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3624 id = yd->conf_id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3625
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3626 components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3627 g_hash_table_replace(components, g_strdup("room"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3628 g_strdup_printf("%s-%d", purple_connection_get_display_name(gc), id));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3629 g_hash_table_replace(components, g_strdup("topic"), g_strdup("Join my conference..."));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3630 g_hash_table_replace(components, g_strdup("type"), g_strdup("Conference"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3631 yahoo_c_join(gc, components);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3632 g_hash_table_destroy(components);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3633
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3634 yahoo_c_invite(gc, id, "Join my conference...", purple_buddy_get_name(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3635 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3636
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3637 static void yahoo_presence_settings(PurpleBlistNode *node, gpointer data) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3638 PurpleBuddy *buddy;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3639 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3640 int presence_val = GPOINTER_TO_INT(data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3641
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3642 buddy = (PurpleBuddy *) node;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3643 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3644
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3645 yahoo_friend_update_presence(gc, purple_buddy_get_name(buddy), presence_val);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3646 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3647
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3648 static void yahoo_game(PurpleBlistNode *node, gpointer data) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3649
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3650 PurpleBuddy *buddy;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3651 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3652
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3653 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3654 const char *game;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3655 char *game2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3656 char *t;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3657 char url[256];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3658 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3659
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3660 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3661
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3662 buddy = (PurpleBuddy *) node;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3663 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3664 yd = (struct yahoo_data *) gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3665
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3666 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3667 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3668 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3669
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3670 game = yahoo_friend_get_game(f);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3671 if (!game)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3672 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3673
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3674 t = game2 = g_strdup(strstr(game, "ante?room="));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3675 while (*t && *t != '\t')
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3676 t++;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3677 *t = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3678 g_snprintf(url, sizeof url, "http://games.yahoo.com/games/%s", game2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3679 purple_notify_uri(gc, url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3680 g_free(game2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3681 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3682
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3683 static char *yahoo_status_text(PurpleBuddy *b)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3684 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3685 YahooFriend *f = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3686 const char *msg;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3687 char *msg2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3688 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3689
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3690 account = purple_buddy_get_account(b);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3691 f = yahoo_friend_find(purple_account_get_connection(account), purple_buddy_get_name(b));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3692 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3693 return g_strdup(_("Not on server list"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3694
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3695 switch (f->status) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3696 case YAHOO_STATUS_AVAILABLE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3697 return NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3698 case YAHOO_STATUS_IDLE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3699 if (f->idle == -1)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3700 return g_strdup(yahoo_get_status_string(f->status));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3701 return NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3702 case YAHOO_STATUS_CUSTOM:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3703 if (!(msg = yahoo_friend_get_status_message(f)))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3704 return NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3705 msg2 = g_markup_escape_text(msg, strlen(msg));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3706 purple_util_chrreplace(msg2, '\n', ' ');
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3707 return msg2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3708
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3709 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3710 return g_strdup(yahoo_get_status_string(f->status));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3711 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3712 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3713
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3714 void yahoo_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3715 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3716 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3717 char *escaped;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3718 char *status = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3719 const char *presence = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3720 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3721
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3722 account = purple_buddy_get_account(b);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3723 f = yahoo_friend_find(purple_account_get_connection(account), purple_buddy_get_name(b));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3724 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3725 status = g_strdup_printf("\n%s", _("Not on server list"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3726 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3727 switch (f->status) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3728 case YAHOO_STATUS_CUSTOM:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3729 if (!yahoo_friend_get_status_message(f))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3730 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3731 status = g_strdup(yahoo_friend_get_status_message(f));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3732 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3733 case YAHOO_STATUS_OFFLINE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3734 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3735 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3736 status = g_strdup(yahoo_get_status_string(f->status));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3737 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3738 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3739
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3740 switch (f->presence) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3741 case YAHOO_PRESENCE_ONLINE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3742 presence = _("Appear Online");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3743 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3744 case YAHOO_PRESENCE_PERM_OFFLINE:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3745 presence = _("Appear Permanently Offline");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3746 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3747 case YAHOO_PRESENCE_DEFAULT:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3748 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3749 default:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3750 purple_debug_error("yahoo", "Unknown presence in yahoo_tooltip_text\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3751 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3752 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3753 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3754
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3755 if (status != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3756 escaped = g_markup_escape_text(status, strlen(status));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3757 purple_notify_user_info_add_pair(user_info, _("Status"), escaped);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3758 g_free(status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3759 g_free(escaped);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3760 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3761
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3762 if (presence != NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3763 purple_notify_user_info_add_pair(user_info, _("Presence"), presence);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3764 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3765
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3766 static void yahoo_addbuddyfrommenu_cb(PurpleBlistNode *node, gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3767 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3768 PurpleBuddy *buddy;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3769 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3770
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3771 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3772
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3773 buddy = (PurpleBuddy *) node;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3774 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3775
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3776 yahoo_add_buddy(gc, buddy, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3777 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3778
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3779
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3780 static void yahoo_chat_goto_menu(PurpleBlistNode *node, gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3781 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3782 PurpleBuddy *buddy;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3783 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3784
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3785 g_return_if_fail(PURPLE_BLIST_NODE_IS_BUDDY(node));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3786
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3787 buddy = (PurpleBuddy *) node;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3788 gc = purple_account_get_connection(purple_buddy_get_account(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3789
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3790 yahoo_chat_goto(gc, purple_buddy_get_name(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3791 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3792
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3793 static GList *build_presence_submenu(YahooFriend *f, PurpleConnection *gc) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3794 GList *m = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3795 PurpleMenuAction *act;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3796 struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3797
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3798 if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3799 if (f->presence != YAHOO_PRESENCE_ONLINE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3800 act = purple_menu_action_new(_("Appear Online"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3801 PURPLE_CALLBACK(yahoo_presence_settings),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3802 GINT_TO_POINTER(YAHOO_PRESENCE_ONLINE),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3803 NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3804 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3805 } else if (f->presence != YAHOO_PRESENCE_DEFAULT) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3806 act = purple_menu_action_new(_("Appear Offline"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3807 PURPLE_CALLBACK(yahoo_presence_settings),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3808 GINT_TO_POINTER(YAHOO_PRESENCE_DEFAULT),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3809 NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3810 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3811 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3812 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3813
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3814 if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3815 act = purple_menu_action_new(_("Don't Appear Permanently Offline"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3816 PURPLE_CALLBACK(yahoo_presence_settings),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3817 GINT_TO_POINTER(YAHOO_PRESENCE_DEFAULT),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3818 NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3819 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3820 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3821 act = purple_menu_action_new(_("Appear Permanently Offline"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3822 PURPLE_CALLBACK(yahoo_presence_settings),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3823 GINT_TO_POINTER(YAHOO_PRESENCE_PERM_OFFLINE),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3824 NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3825 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3826 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3827
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3828 return m;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3829 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3830
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3831 static void yahoo_doodle_blist_node(PurpleBlistNode *node, gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3832 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3833 PurpleBuddy *b = (PurpleBuddy *)node;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3834 PurpleAccount *account = purple_buddy_get_account(b);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3835 PurpleConnection *gc = purple_account_get_connection(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3836
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3837 yahoo_doodle_initiate(gc, purple_buddy_get_name(b));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3838 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3839
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3840 static GList *yahoo_buddy_menu(PurpleBuddy *buddy)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3841 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3842 GList *m = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3843 PurpleMenuAction *act;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3844
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3845 PurpleConnection *gc = purple_account_get_connection(purple_buddy_get_account(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3846 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3847 static char buf2[1024];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3848 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3849
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3850 f = yahoo_friend_find(gc, purple_buddy_get_name(buddy));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3851
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3852 if (!f && !yd->wm) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3853 act = purple_menu_action_new(_("Add Buddy"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3854 PURPLE_CALLBACK(yahoo_addbuddyfrommenu_cb),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3855 NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3856 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3857
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3858 return m;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3859
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3860 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3861
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3862 if (f && f->status != YAHOO_STATUS_OFFLINE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3863 if (!yd->wm) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3864 act = purple_menu_action_new(_("Join in Chat"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3865 PURPLE_CALLBACK(yahoo_chat_goto_menu),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3866 NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3867 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3868 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3869
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3870 act = purple_menu_action_new(_("Initiate Conference"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3871 PURPLE_CALLBACK(yahoo_initiate_conference),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3872 NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3873 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3874
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3875 if (yahoo_friend_get_game(f)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3876 const char *game = yahoo_friend_get_game(f);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3877 char *room;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3878 char *t;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3879
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3880 if ((room = strstr(game, "&follow="))) {/* skip ahead to the url */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3881 while (*room && *room != '\t') /* skip to the tab */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3882 room++;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3883 t = room++; /* room as now at the name */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3884 while (*t != '\n')
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3885 t++; /* replace the \n with a space */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3886 *t = ' ';
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3887 g_snprintf(buf2, sizeof buf2, "%s", room);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3888
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3889 act = purple_menu_action_new(buf2,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3890 PURPLE_CALLBACK(yahoo_game),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3891 NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3892 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3893 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3894 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3895 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3896
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3897 if (f) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3898 act = purple_menu_action_new(_("Presence Settings"), NULL, NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3899 build_presence_submenu(f, gc));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3900 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3901 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3902
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3903 if (f) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3904 act = purple_menu_action_new(_("Start Doodling"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3905 PURPLE_CALLBACK(yahoo_doodle_blist_node),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3906 NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3907 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3908 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3909
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3910 return m;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3911 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3912
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3913 static GList *yahoo_blist_node_menu(PurpleBlistNode *node)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3914 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3915 if(PURPLE_BLIST_NODE_IS_BUDDY(node)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3916 return yahoo_buddy_menu((PurpleBuddy *) node);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3917 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3918 return NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3919 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3920 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3921
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3922 static void yahoo_act_id(PurpleConnection *gc, PurpleRequestFields *fields)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3923 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3924 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3925 const char *name = yd->profiles[purple_request_fields_get_choice(fields, "id")];
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3926
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3927 struct yahoo_packet *pkt = yahoo_packet_new(YAHOO_SERVICE_IDACT, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3928 yahoo_packet_hash_str(pkt, 3, name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3929 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3930
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3931 purple_connection_set_display_name(gc, name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3932 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3933
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3934 static void
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3935 yahoo_get_inbox_token_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3936 const gchar *token, size_t len, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3937 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3938 PurpleConnection *gc = user_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3939 gboolean set_cookie = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3940 gchar *url;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3941 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3942
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3943 g_return_if_fail(PURPLE_CONNECTION_IS_VALID(gc));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3944
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3945 yd->url_datas = g_slist_remove(yd->url_datas, url_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3946
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3947 if (error_message != NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3948 purple_debug_error("yahoo", "Requesting mail login token failed: %s\n", error_message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3949 else if (len > 0 && token && *token) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3950 /* Should we not be hardcoding the rd url? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3951 url = g_strdup_printf(
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3952 "http://login.yahoo.com/config/reset_cookies_token?"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3953 ".token=%s"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3954 "&.done=http://us.rd.yahoo.com/messenger/client/%%3fhttp://mail.yahoo.com/",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3955 token);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3956 set_cookie = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3957 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3958
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3959 if (!set_cookie) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3960 purple_debug_error("yahoo", "No mail login token; forwarding to login screen.\n");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3961 url = g_strdup(yd->jp ? YAHOOJP_MAIL_URL : YAHOO_MAIL_URL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3962 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3963
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3964 /* Open the mailbox with the parsed url data */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3965 purple_notify_uri(gc, url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3966
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3967 g_free(url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3968 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3969
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3970
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3971 static void yahoo_show_inbox(PurplePluginAction *action)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3972 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3973 /* Setup a cookie that can be used by the browser */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3974 /* XXX I have no idea how this will work with Yahoo! Japan. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3975
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3976 PurpleConnection *gc = action->context;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3977 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3978
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3979 PurpleUtilFetchUrlData *url_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3980 const char* base_url = "http://login.yahoo.com";
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3981 /* use whole URL if using HTTP Proxy */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3982 gboolean use_whole_url = yahoo_account_use_http_proxy(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3983 gchar *request = g_strdup_printf(
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3984 "POST %s/config/cookie_token HTTP/1.0\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3985 "Cookie: T=%s; path=/; domain=.yahoo.com; Y=%s;\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3986 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3987 "Host: login.yahoo.com\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3988 "Content-Length: 0\r\n\r\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3989 use_whole_url ? base_url : "",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3990 yd->cookie_t, yd->cookie_y);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3991
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3992 url_data = purple_util_fetch_url_request_len_with_account(
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3993 purple_connection_get_account(gc), base_url, use_whole_url,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3994 YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3995 yahoo_get_inbox_token_cb, gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3996
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3997 g_free(request);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3998
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
3999 if (url_data != NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4000 yd->url_datas = g_slist_prepend(yd->url_datas, url_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4001 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4002 const char *yahoo_mail_url = (yd->jp ? YAHOOJP_MAIL_URL : YAHOO_MAIL_URL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4003 purple_debug_error("yahoo",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4004 "Unable to request mail login token; forwarding to login screen.");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4005 purple_notify_uri(gc, yahoo_mail_url);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4006 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4007
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4008 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4009
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4010
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4011 static void yahoo_show_act_id(PurplePluginAction *action)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4012 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4013 PurpleRequestFields *fields;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4014 PurpleRequestFieldGroup *group;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4015 PurpleRequestField *field;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4016 PurpleConnection *gc = (PurpleConnection *) action->context;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4017 struct yahoo_data *yd = purple_connection_get_protocol_data(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4018 const char *name = purple_connection_get_display_name(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4019 int iter;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4020
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4021 fields = purple_request_fields_new();
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4022 group = purple_request_field_group_new(NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4023 purple_request_fields_add_group(fields, group);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4024 field = purple_request_field_choice_new("id", "Activate which ID?", 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4025 purple_request_field_group_add_field(group, field);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4026
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4027 for (iter = 0; yd->profiles[iter]; iter++) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4028 purple_request_field_choice_add(field, yd->profiles[iter]);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4029 if (purple_strequal(yd->profiles[iter], name))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4030 purple_request_field_choice_set_default_value(field, iter);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4031 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4032
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4033 purple_request_fields(gc, NULL, _("Select the ID you want to activate"), NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4034 fields,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4035 _("OK"), G_CALLBACK(yahoo_act_id),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4036 _("Cancel"), NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4037 purple_connection_get_account(gc), NULL, NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4038 gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4039 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4040
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4041 static void yahoo_show_chat_goto(PurplePluginAction *action)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4042 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4043 PurpleConnection *gc = (PurpleConnection *) action->context;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4044 purple_request_input(gc, NULL, _("Join whom in chat?"), NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4045 "", FALSE, FALSE, NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4046 _("OK"), G_CALLBACK(yahoo_chat_goto),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4047 _("Cancel"), NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4048 purple_connection_get_account(gc), NULL, NULL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4049 gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4050 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4051
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4052 static GList *yahoo_actions(PurplePlugin *plugin, gpointer context) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4053 GList *m = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4054 PurplePluginAction *act;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4055
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4056 act = purple_plugin_action_new(_("Activate ID..."),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4057 yahoo_show_act_id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4058 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4059
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4060 act = purple_plugin_action_new(_("Join User in Chat..."),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4061 yahoo_show_chat_goto);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4062 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4063
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4064 m = g_list_append(m, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4065 act = purple_plugin_action_new(_("Open Inbox"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4066 yahoo_show_inbox);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4067 m = g_list_append(m, act);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4068
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4069 return m;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4070 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4071
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4072 struct yahoo_sms_carrier_cb_data {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4073 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4074 char *who;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4075 char *what;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4076 };
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4077
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4078 static int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4079
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4080 static void yahoo_get_sms_carrier_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4081 const gchar *webdata, size_t len, const gchar *error_message)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4082 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4083 struct yahoo_sms_carrier_cb_data *sms_cb_data = user_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4084 PurpleConnection *gc = sms_cb_data->gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4085 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4086 char *mobile_no = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4087 char *status = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4088 char *carrier = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4089 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4090 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4091
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4092 if (error_message != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4093 purple_conversation_write(conv, NULL, "Cant send SMS, Unable to obtain mobile carrier", PURPLE_MESSAGE_SYSTEM, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4094
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4095 g_free(sms_cb_data->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4096 g_free(sms_cb_data->what);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4097 g_free(sms_cb_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4098 return ;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4099 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4100 else if (len > 0 && webdata && *webdata) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4101 xmlnode *validate_data_root = xmlnode_from_str(webdata, -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4102 xmlnode *validate_data_child = xmlnode_get_child(validate_data_root, "mobile_no");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4103 mobile_no = (char *)xmlnode_get_attrib(validate_data_child, "msisdn");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4104
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4105 validate_data_root = xmlnode_copy(validate_data_child);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4106 validate_data_child = xmlnode_get_child(validate_data_root, "status");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4107 status = xmlnode_get_data(validate_data_child);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4108
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4109 validate_data_child = xmlnode_get_child(validate_data_root, "carrier");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4110 carrier = xmlnode_get_data(validate_data_child);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4111
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4112 purple_debug_info("yahoo","SMS validate data: Mobile:%s, Status:%s, Carrier:%s\n", mobile_no, status, carrier);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4113
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4114 if( strcmp(status, "Valid") == 0) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4115 g_hash_table_insert(yd->sms_carrier, g_strdup_printf("+%s", mobile_no), g_strdup(carrier));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4116 yahoo_send_im(sms_cb_data->gc, sms_cb_data->who, sms_cb_data->what, PURPLE_MESSAGE_SEND);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4117 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4118 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4119 g_hash_table_insert(yd->sms_carrier, g_strdup_printf("+%s", mobile_no), g_strdup("Unknown"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4120 purple_conversation_write(conv, NULL, "Cant send SMS, Unknown mobile carrier", PURPLE_MESSAGE_SYSTEM, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4121 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4122
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4123 xmlnode_free(validate_data_child);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4124 xmlnode_free(validate_data_root);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4125 g_free(sms_cb_data->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4126 g_free(sms_cb_data->what);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4127 g_free(sms_cb_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4128 g_free(mobile_no);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4129 g_free(status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4130 g_free(carrier);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4131 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4132 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4133
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4134 static void yahoo_get_sms_carrier(PurpleConnection *gc, gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4135 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4136 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4137 PurpleUtilFetchUrlData *url_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4138 struct yahoo_sms_carrier_cb_data *sms_cb_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4139 char *validate_request_str = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4140 char *request = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4141 gboolean use_whole_url = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4142 xmlnode *validate_request_root = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4143 xmlnode *validate_request_child = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4144
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4145 if(!(sms_cb_data = data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4146 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4147
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4148 validate_request_root = xmlnode_new("validate");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4149 xmlnode_set_attrib(validate_request_root, "intl", "us");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4150 xmlnode_set_attrib(validate_request_root, "version", YAHOO_CLIENT_VERSION);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4151 xmlnode_set_attrib(validate_request_root, "qos", "0");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4152
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4153 validate_request_child = xmlnode_new_child(validate_request_root, "mobile_no");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4154 xmlnode_set_attrib(validate_request_child, "msisdn", sms_cb_data->who + 1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4155
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4156 validate_request_str = xmlnode_to_str(validate_request_root, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4157
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4158 xmlnode_free(validate_request_child);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4159 xmlnode_free(validate_request_root);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4160
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4161 request = g_strdup_printf(
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4162 "POST /mobileno?intl=us&version=%s HTTP/1.1\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4163 "Cookie: T=%s; path=/; domain=.yahoo.com; Y=%s; path=/; domain=.yahoo.com;\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4164 "User-Agent: " YAHOO_CLIENT_USERAGENT "\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4165 "Host: validate.msg.yahoo.com\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4166 "Content-Length: %" G_GSIZE_FORMAT "\r\n"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4167 "Cache-Control: no-cache\r\n\r\n%s",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4168 YAHOO_CLIENT_VERSION, yd->cookie_t, yd->cookie_y, strlen(validate_request_str), validate_request_str);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4169
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4170 /* use whole URL if using HTTP Proxy */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4171 if ((gc->account->proxy_info) && (gc->account->proxy_info->type == PURPLE_PROXY_HTTP))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4172 use_whole_url = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4173
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4174 url_data = purple_util_fetch_url_request_len_with_account(
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4175 purple_connection_get_account(gc), YAHOO_SMS_CARRIER_URL, use_whole_url,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4176 YAHOO_CLIENT_USERAGENT, TRUE, request, FALSE, -1,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4177 yahoo_get_sms_carrier_cb, data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4178
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4179 g_free(request);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4180 g_free(validate_request_str);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4181
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4182 if (!url_data) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4183 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4184 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, sms_cb_data->who, account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4185 purple_conversation_write(conv, NULL, "Cant send SMS, Unable to obtain mobile carrier", PURPLE_MESSAGE_SYSTEM, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4186 g_free(sms_cb_data->who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4187 g_free(sms_cb_data->what);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4188 g_free(sms_cb_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4189 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4190 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4191
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4192 static int yahoo_send_im(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4193 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4194 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4195 struct yahoo_packet *pkt = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4196 char *msg = yahoo_html_to_codes(what);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4197 char *msg2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4198 gboolean utf8 = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4199 PurpleWhiteboard *wb;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4200 int ret = 1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4201 YahooFriend *f = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4202 gsize lenb = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4203 glong lenc = 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4204 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4205 gboolean msn = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4206 msg2 = yahoo_string_encode(gc, msg, &utf8);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4207
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4208 if(msg2) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4209 lenb = strlen(msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4210 lenc = g_utf8_strlen(msg2, -1);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4211
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4212 if(lenb > YAHOO_MAX_MESSAGE_LENGTH_BYTES || lenc > YAHOO_MAX_MESSAGE_LENGTH_CHARS) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4213 purple_debug_info("yahoo", "Message too big. Length is %" G_GSIZE_FORMAT
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4214 " bytes, %ld characters. Max is %d bytes, %d chars."
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4215 " Message is '%s'.\n", lenb, lenc, YAHOO_MAX_MESSAGE_LENGTH_BYTES,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4216 YAHOO_MAX_MESSAGE_LENGTH_CHARS, msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4217 g_free(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4218 g_free(msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4219 return -E2BIG;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4220 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4221 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4222
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4223 msn = !g_strncasecmp(who, "msn/", 4);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4224
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4225 if( strncmp(who, "+", 1) == 0 ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4226 /* we have an sms to be sent */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4227 gchar *carrier = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4228 const char *alias = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4229 PurpleAccount *account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4230 PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, who, account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4231
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4232 carrier = g_hash_table_lookup(yd->sms_carrier, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4233 if (!carrier) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4234 struct yahoo_sms_carrier_cb_data *sms_cb_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4235 sms_cb_data = g_malloc(sizeof(struct yahoo_sms_carrier_cb_data));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4236 sms_cb_data->gc = gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4237 sms_cb_data->who = g_strdup(who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4238 sms_cb_data->what = g_strdup(what);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4239
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4240 purple_conversation_write(conv, NULL, "Getting mobile carrier to send the sms", PURPLE_MESSAGE_SYSTEM, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4241
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4242 yahoo_get_sms_carrier(gc, sms_cb_data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4243
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4244 g_free(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4245 g_free(msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4246 return ret;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4247 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4248 else if( strcmp(carrier,"Unknown") == 0 ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4249 purple_conversation_write(conv, NULL, "Cant send SMS, Unknown mobile carrier", PURPLE_MESSAGE_SYSTEM, time(NULL));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4250
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4251 g_free(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4252 g_free(msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4253 return -1;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4254 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4255
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4256 alias = purple_account_get_alias(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4257 pkt = yahoo_packet_new(YAHOO_SERVICE_SMS_MSG, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4258 yahoo_packet_hash(pkt, "sssss",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4259 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4260 69, alias,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4261 5, who + 1,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4262 68, carrier,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4263 14, msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4264 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4265
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4266 g_free(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4267 g_free(msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4268
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4269 return ret;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4270 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4271
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4272 pkt = yahoo_packet_new(YAHOO_SERVICE_MESSAGE, YAHOO_STATUS_OFFLINE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4273 if(msn) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4274 yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who+4);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4275 yahoo_packet_hash_int(pkt, 241, 2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4276 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4277 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4278 yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4279 if ((f = yahoo_friend_find(gc, who)) && f->protocol)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4280 yahoo_packet_hash_int(pkt, 241, f->protocol);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4281 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4282
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4283 if (utf8)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4284 yahoo_packet_hash_str(pkt, 97, "1");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4285 yahoo_packet_hash_str(pkt, 14, msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4286
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4287 /*
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4288 * IMVironment.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4289 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4290 * If this message is to a user who is also Doodling with the local user,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4291 * format the chat packet with the correct IMV information (thanks Yahoo!)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4292 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4293 * Otherwise attempt to use the same IMVironment as the remote user,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4294 * just so that we don't inadvertantly reset their IMVironment back
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4295 * to nothing.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4296 *
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4297 * If they have no set an IMVironment, then use the default.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4298 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4299 wb = purple_whiteboard_get_session(gc->account, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4300 if (wb)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4301 yahoo_packet_hash_str(pkt, 63, DOODLE_IMV_KEY);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4302 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4303 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4304 const char *imv;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4305 imv = g_hash_table_lookup(yd->imvironments, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4306 if (imv != NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4307 yahoo_packet_hash_str(pkt, 63, imv);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4308 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4309 yahoo_packet_hash_str(pkt, 63, ";0");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4310 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4311
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4312 yahoo_packet_hash_str(pkt, 64, "0"); /* no idea */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4313 yahoo_packet_hash_str(pkt, 1002, "1"); /* no idea, Yahoo 6 or later only it seems */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4314 if (!yd->picture_url)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4315 yahoo_packet_hash_str(pkt, 206, "0"); /* 0 = no picture, 2 = picture, maybe 1 = avatar? */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4316 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4317 yahoo_packet_hash_str(pkt, 206, "2");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4318
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4319 /* We may need to not send any packets over 2000 bytes, but I'm not sure yet. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4320 if ((YAHOO_PACKET_HDRLEN + yahoo_packet_length(pkt)) <= 2000) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4321 /* if p2p link exists, send through it. To-do: key 15, time value to be sent in case of p2p */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4322 if( (p2p_data = g_hash_table_lookup(yd->peers, who)) && !msn ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4323 yahoo_packet_hash_int(pkt, 11, p2p_data->session_id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4324 yahoo_p2p_write_pkt(p2p_data->source, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4325 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4326 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4327 yahoo_packet_send(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4328 if(!msn)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4329 yahoo_send_p2p_pkt(gc, who, 0); /* send p2p packet, with val_13=0 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4330 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4331 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4332 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4333 ret = -E2BIG;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4334
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4335 yahoo_packet_free(pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4336
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4337 g_free(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4338 g_free(msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4339
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4340 return ret;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4341 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4342
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4343 static unsigned int yahoo_send_typing(PurpleConnection *gc, const char *who, PurpleTypingState state)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4344 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4345 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4346 struct yahoo_p2p_data *p2p_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4347 gboolean msn = !g_strncasecmp(who, "msn/", 4);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4348 struct yahoo_packet *pkt = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4349
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4350 /* Don't do anything if sms is being typed */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4351 if( strncmp(who, "+", 1) == 0 )
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4352 return 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4353
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4354 pkt = yahoo_packet_new(YAHOO_SERVICE_NOTIFY, YAHOO_STATUS_TYPING, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4355
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4356 /* check to see if p2p link exists, send through it */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4357 if( (p2p_data = g_hash_table_lookup(yd->peers, who)) && !msn ) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4358 yahoo_packet_hash(pkt, "sssssis", 49, "TYPING", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4359 14, " ", 13, state == PURPLE_TYPING ? "1" : "0",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4360 5, who, 11, p2p_data->session_id, 1002, "1"); /* To-do: key 15 to be sent in case of p2p */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4361 yahoo_p2p_write_pkt(p2p_data->source, pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4362 yahoo_packet_free(pkt);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4363 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4364 else { /* send through yahoo server */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4365 if(msn)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4366 yahoo_packet_hash(pkt, "sssssss", 49, "TYPING", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4367 14, " ", 13, state == PURPLE_TYPING ? "1" : "0",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4368 5, who+4, 1002, "1", 241, "2");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4369 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4370 yahoo_packet_hash(pkt, "ssssss", 49, "TYPING", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4371 14, " ", 13, state == PURPLE_TYPING ? "1" : "0",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4372 5, who+4, 1002, "1");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4373 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4374 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4375
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4376 return 0;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4377 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4378
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4379 static void yahoo_session_presence_remove(gpointer key, gpointer value, gpointer data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4380 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4381 YahooFriend *f = value;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4382 if (f && f->presence == YAHOO_PRESENCE_ONLINE)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4383 f->presence = YAHOO_PRESENCE_DEFAULT;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4384 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4385
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4386 static void yahoo_set_status(PurpleAccount *account, PurpleStatus *status)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4387 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4388 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4389 PurplePresence *presence;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4390 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4391 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4392 int old_status;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4393 const char *msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4394 char *tmp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4395 char *conv_msg = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4396 gboolean utf8 = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4397
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4398 if (!purple_status_is_active(status))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4399 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4400
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4401 gc = purple_account_get_connection(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4402 presence = purple_status_get_presence(status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4403 yd = (struct yahoo_data *)gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4404 old_status = yd->current_status;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4405
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4406 yd->current_status = get_yahoo_status_from_purple_status(status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4407
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4408 if (yd->current_status == YAHOO_STATUS_CUSTOM)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4409 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4410 msg = purple_status_get_attr_string(status, "message");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4411
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4412 if (purple_status_is_available(status)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4413 tmp = yahoo_string_encode(gc, msg, &utf8);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4414 conv_msg = purple_markup_strip_html(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4415 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4416 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4417 if ((msg == NULL) || (*msg == '\0'))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4418 msg = _("Away");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4419 tmp = yahoo_string_encode(gc, msg, &utf8);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4420 conv_msg = purple_markup_strip_html(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4421 g_free(tmp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4422 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4423 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4424
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4425 if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4426 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4427 yahoo_packet_hash_str(pkt, 13, "2");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4428 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4429
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4430 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4431 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4432
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4433 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4434 yahoo_packet_hash_int(pkt, 10, yd->current_status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4435
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4436 if (yd->current_status == YAHOO_STATUS_CUSTOM) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4437 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4438 yahoo_packet_hash_str(pkt, 19, conv_msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4439 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4440 yahoo_packet_hash_str(pkt, 19, "");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4441 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4442
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4443 g_free(conv_msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4444
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4445 if (purple_presence_is_idle(presence))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4446 yahoo_packet_hash_str(pkt, 47, "2");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4447 else if (!purple_status_is_available(status))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4448 yahoo_packet_hash_str(pkt, 47, "1");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4449
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4450 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4451
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4452 if (old_status == YAHOO_STATUS_INVISIBLE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4453 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_VISIBLE_TOGGLE, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4454 yahoo_packet_hash_str(pkt, 13, "1");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4455 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4456
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4457 /* Any per-session presence settings are removed */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4458 g_hash_table_foreach(yd->friends, yahoo_session_presence_remove, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4459
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4460 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4461 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4462
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4463 static void yahoo_set_idle(PurpleConnection *gc, int idle)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4464 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4465 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4466 struct yahoo_packet *pkt = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4467 char *msg = NULL, *msg2 = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4468 PurpleStatus *status = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4469
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4470 if (idle && yd->current_status != YAHOO_STATUS_CUSTOM)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4471 yd->current_status = YAHOO_STATUS_IDLE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4472 else if (!idle && yd->current_status == YAHOO_STATUS_IDLE) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4473 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc)));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4474 yd->current_status = get_yahoo_status_from_purple_status(status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4475 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4476
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4477 pkt = yahoo_packet_new(YAHOO_SERVICE_Y6_STATUS_UPDATE, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4478
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4479 yahoo_packet_hash_int(pkt, 10, yd->current_status);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4480 if (yd->current_status == YAHOO_STATUS_CUSTOM) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4481 const char *tmp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4482 if (status == NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4483 status = purple_presence_get_active_status(purple_account_get_presence(purple_connection_get_account(gc)));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4484 tmp = purple_status_get_attr_string(status, "message");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4485 if (tmp != NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4486 gboolean utf8 = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4487 msg = yahoo_string_encode(gc, tmp, &utf8);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4488 msg2 = purple_markup_strip_html(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4489 yahoo_packet_hash_str(pkt, 97, utf8 ? "1" : 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4490 yahoo_packet_hash_str(pkt, 19, msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4491 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4492 /* get_yahoo_status_from_purple_status() returns YAHOO_STATUS_CUSTOM for
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4493 * the generic away state (YAHOO_STATUS_TYPE_AWAY) with no message */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4494 yahoo_packet_hash_str(pkt, 19, _("Away"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4495 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4496 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4497 yahoo_packet_hash_str(pkt, 19, "");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4498 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4499
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4500 if (idle)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4501 yahoo_packet_hash_str(pkt, 47, "2");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4502 else if (!purple_presence_is_available(purple_account_get_presence(purple_connection_get_account(gc))))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4503 yahoo_packet_hash_str(pkt, 47, "1");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4504
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4505 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4506
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4507 g_free(msg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4508 g_free(msg2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4509 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4510
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4511 static GList *yahoo_status_types(PurpleAccount *account)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4512 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4513 PurpleStatusType *type;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4514 GList *types = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4515
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4516 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE, YAHOO_STATUS_TYPE_AVAILABLE,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4517 NULL, TRUE, TRUE, FALSE,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4518 "message", _("Message"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4519 purple_value_new(PURPLE_TYPE_STRING), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4520 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4521
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4522 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_AWAY,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4523 NULL, TRUE, TRUE, FALSE,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4524 "message", _("Message"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4525 purple_value_new(PURPLE_TYPE_STRING), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4526 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4527
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4528 type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_BRB, _("Be Right Back"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4529 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4530
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4531 type = purple_status_type_new(PURPLE_STATUS_UNAVAILABLE, YAHOO_STATUS_TYPE_BUSY, _("Busy"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4532 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4533
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4534 type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTATHOME, _("Not at Home"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4535 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4536
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4537 type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTATDESK, _("Not at Desk"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4538 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4539
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4540 type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_NOTINOFFICE, _("Not in Office"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4541 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4542
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4543 type = purple_status_type_new(PURPLE_STATUS_UNAVAILABLE, YAHOO_STATUS_TYPE_ONPHONE, _("On the Phone"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4544 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4545
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4546 type = purple_status_type_new(PURPLE_STATUS_EXTENDED_AWAY, YAHOO_STATUS_TYPE_ONVACATION, _("On Vacation"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4547 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4548
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4549 type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_OUTTOLUNCH, _("Out to Lunch"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4550 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4551
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4552 type = purple_status_type_new(PURPLE_STATUS_AWAY, YAHOO_STATUS_TYPE_STEPPEDOUT, _("Stepped Out"), TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4553 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4554
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4555
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4556 type = purple_status_type_new(PURPLE_STATUS_INVISIBLE, YAHOO_STATUS_TYPE_INVISIBLE, NULL, TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4557 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4558
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4559 type = purple_status_type_new(PURPLE_STATUS_OFFLINE, YAHOO_STATUS_TYPE_OFFLINE, NULL, TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4560 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4561
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4562 type = purple_status_type_new_full(PURPLE_STATUS_MOBILE, YAHOO_STATUS_TYPE_MOBILE, NULL, FALSE, FALSE, TRUE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4563 types = g_list_append(types, type);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4564
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4565 return types;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4566 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4567
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4568 static void yahoo_keepalive(PurpleConnection *gc)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4569 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4570 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4571 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4572 time_t now = time(NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4573
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4574 /* We're only allowed to send a ping once an hour or the servers will boot us */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4575 if ((now - yd->last_ping) >= PING_TIMEOUT) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4576 yd->last_ping = now;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4577
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4578 /* The native client will only send PING or CHATPING */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4579 if (yd->chat_online) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4580 if (yd->wm) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4581 ycht_chat_send_keepalive(yd->ycht);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4582 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4583 pkt = yahoo_packet_new(YAHOO_SERVICE_CHATPING, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4584 yahoo_packet_hash_str(pkt, 109, purple_connection_get_display_name(gc));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4585 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4586 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4587 } else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4588 pkt = yahoo_packet_new(YAHOO_SERVICE_PING, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4589 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4590 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4591 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4592
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4593 if ((now - yd->last_keepalive) >= KEEPALIVE_TIMEOUT) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4594 yd->last_keepalive = now;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4595 pkt = yahoo_packet_new(YAHOO_SERVICE_KEEPALIVE, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4596 yahoo_packet_hash_str(pkt, 0, purple_connection_get_display_name(gc));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4597 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4598 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4599
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4600 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4601
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4602 static void yahoo_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *g)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4603 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4604 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4605 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4606 const char *group = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4607 char *group2;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4608 YahooFriend *f;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4609 const char *bname;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4610 gboolean msn = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4611
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4612 if (!yd->logged_in)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4613 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4614
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4615 bname = purple_buddy_get_name(buddy);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4616 if (!purple_privacy_check(purple_connection_get_account(gc), bname))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4617 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4618
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4619 f = yahoo_friend_find(gc, bname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4620 msn = !g_strncasecmp(bname, "msn/", 4);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4621
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4622 g = purple_buddy_get_group(buddy);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4623 if (g)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4624 group = purple_group_get_name(g);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4625 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4626 group = "Buddies";
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4627
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4628 group2 = yahoo_string_encode(gc, group, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4629 pkt = yahoo_packet_new(YAHOO_SERVICE_ADDBUDDY, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4630 if(msn) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4631 yahoo_packet_hash(pkt, "sssssssssss",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4632 14, "",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4633 65, group2,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4634 97, "1",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4635 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4636 302, "319",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4637 300, "319",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4638 7, bname + 4,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4639 241, "2",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4640 334, "0",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4641 301, "319",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4642 303, "319"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4643 );
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4644 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4645 else {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4646 yahoo_packet_hash(pkt, "ssssssssss",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4647 14, "",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4648 65, group2,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4649 97, "1",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4650 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4651 302, "319",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4652 300, "319",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4653 7, bname,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4654 334, "0",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4655 301, "319",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4656 303, "319"
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4657 );
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4658 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4659 if (f && f->protocol && !msn)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4660 yahoo_packet_hash_int(pkt, 241, f->protocol);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4661
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4662 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4663 g_free(group2);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4664 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4665
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4666 static void yahoo_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4667 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4668 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4669 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4670 GSList *buddies, *l;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4671 PurpleGroup *g;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4672 gboolean remove = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4673 char *cg;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4674 const char *bname, *gname;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4675 YahooFriend *f = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4676 gboolean msn = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4677
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4678 bname = purple_buddy_get_name(buddy);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4679 f = yahoo_friend_find(gc, bname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4680 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4681 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4682
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4683 gname = purple_group_get_name(group);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4684 buddies = purple_find_buddies(purple_connection_get_account(gc), bname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4685 if(f->protocol == 2)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4686 msn = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4687 for (l = buddies; l; l = l->next) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4688 g = purple_buddy_get_group(l->data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4689 if (purple_utf8_strcasecmp(gname, purple_group_get_name(g))) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4690 remove = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4691 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4692 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4693 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4694
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4695 g_slist_free(buddies);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4696
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4697 if (remove)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4698 g_hash_table_remove(yd->friends, bname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4699
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4700 cg = yahoo_string_encode(gc, gname, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4701 pkt = yahoo_packet_new(YAHOO_SERVICE_REMBUDDY, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4702
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4703 if(msn)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4704 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4705 7, bname+4, 65, cg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4706 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4707 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4708 7, bname, 65, cg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4709 if(f->protocol)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4710 yahoo_packet_hash_int(pkt, 241, f->protocol);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4711 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4712 g_free(cg);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4713 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4714
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4715 static void yahoo_add_deny(PurpleConnection *gc, const char *who) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4716 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4717 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4718
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4719 if (!yd->logged_in)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4720 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4721
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4722 if (!who || who[0] == '\0')
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4723 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4724
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4725 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4726 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4727 7, who, 13, "1");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4728 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4729 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4730
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4731 static void yahoo_rem_deny(PurpleConnection *gc, const char *who) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4732 struct yahoo_data *yd = (struct yahoo_data *)gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4733 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4734
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4735 if (!yd->logged_in)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4736 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4737
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4738 if (!who || who[0] == '\0')
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4739 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4740
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4741 pkt = yahoo_packet_new(YAHOO_SERVICE_IGNORECONTACT, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4742 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc), 7, who, 13, "2");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4743 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4744 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4745
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4746 static void yahoo_set_permit_deny(PurpleConnection *gc)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4747 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4748 PurpleAccount *account;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4749 GSList *deny;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4750
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4751 account = purple_connection_get_account(gc);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4752
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4753 switch (account->perm_deny)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4754 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4755 case PURPLE_PRIVACY_ALLOW_ALL:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4756 for (deny = account->deny; deny; deny = deny->next)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4757 yahoo_rem_deny(gc, deny->data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4758 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4759
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4760 case PURPLE_PRIVACY_ALLOW_BUDDYLIST:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4761 case PURPLE_PRIVACY_ALLOW_USERS:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4762 case PURPLE_PRIVACY_DENY_USERS:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4763 case PURPLE_PRIVACY_DENY_ALL:
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4764 for (deny = account->deny; deny; deny = deny->next)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4765 yahoo_add_deny(gc, deny->data);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4766 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4767 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4768 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4769
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4770 static gboolean yahoo_unload_plugin(PurplePlugin *plugin)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4771 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4772 yahoo_dest_colorht();
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4773
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4774 return TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4775 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4776
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4777 static void yahoo_change_buddys_group(PurpleConnection *gc, const char *who,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4778 const char *old_group, const char *new_group)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4779 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4780 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4781 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4782 char *gpn, *gpo;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4783 YahooFriend *f = yahoo_friend_find(gc, who);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4784 gboolean msn = FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4785 const char *temp = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4786
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4787 /* Step 0: If they aren't on the server list anyway,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4788 * don't bother letting the server know.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4789 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4790 if (!f)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4791 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4792
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4793 if(f->protocol == 2) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4794 msn = TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4795 temp = who+4;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4796 } else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4797 temp = who;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4798
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4799 /* If old and new are the same, we would probably
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4800 * end up deleting the buddy, which would be bad.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4801 * This might happen because of the charset conversation.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4802 */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4803 gpn = yahoo_string_encode(gc, new_group, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4804 gpo = yahoo_string_encode(gc, old_group, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4805 if (!strcmp(gpn, gpo)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4806 g_free(gpn);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4807 g_free(gpo);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4808 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4809 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4810
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4811 pkt = yahoo_packet_new(YAHOO_SERVICE_CHGRP_15, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4812 if(f->protocol)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4813 yahoo_packet_hash(pkt, "ssssissss", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4814 302, "240", 300, "240", 7, temp, 241, f->protocol, 224, gpo, 264, gpn, 301,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4815 "240", 303, "240");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4816 else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4817 yahoo_packet_hash(pkt, "ssssssss", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4818 302, "240", 300, "240", 7, temp, 224, gpo, 264, gpn, 301,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4819 "240", 303, "240");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4820 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4821
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4822 g_free(gpn);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4823 g_free(gpo);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4824 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4825
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4826 static void yahoo_rename_group(PurpleConnection *gc, const char *old_name,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4827 PurpleGroup *group, GList *moved_buddies)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4828 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4829 struct yahoo_data *yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4830 struct yahoo_packet *pkt;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4831 char *gpn, *gpo;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4832
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4833 gpn = yahoo_string_encode(gc, purple_group_get_name(group), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4834 gpo = yahoo_string_encode(gc, old_name, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4835 if (!strcmp(gpn, gpo)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4836 g_free(gpn);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4837 g_free(gpo);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4838 return;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4839 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4840
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4841 pkt = yahoo_packet_new(YAHOO_SERVICE_GROUPRENAME, YAHOO_STATUS_AVAILABLE, 0);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4842 yahoo_packet_hash(pkt, "sss", 1, purple_connection_get_display_name(gc),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4843 65, gpo, 67, gpn);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4844 yahoo_packet_send_and_free(pkt, yd);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4845 g_free(gpn);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4846 g_free(gpo);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4847 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4848
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4849 /********************************* Commands **********************************/
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4850
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4851 static PurpleCmdRet
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4852 yahoopurple_cmd_buzz(PurpleConversation *c, const gchar *cmd, gchar **args, gchar **error, void *data) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4853 PurpleAccount *account = purple_conversation_get_account(c);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4854
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4855 if (*args && args[0])
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4856 return PURPLE_CMD_RET_FAILED;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4857
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4858 purple_prpl_send_attention(account->gc, c->name, YAHOO_BUZZ);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4859
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4860 return PURPLE_CMD_RET_OK;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4861 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4862
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4863 static PurplePlugin *my_protocol = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4864
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4865 static PurpleCmdRet
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4866 yahoopurple_cmd_chat_join(PurpleConversation *conv, const char *cmd,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4867 char **args, char **error, void *data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4868 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4869 GHashTable *comp;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4870 PurpleConnection *gc;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4871 struct yahoo_data *yd;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4872 int id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4873
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4874 if (!args || !args[0])
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4875 return PURPLE_CMD_RET_FAILED;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4876
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4877 gc = purple_conversation_get_gc(conv);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4878 yd = gc->proto_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4879 id = yd->conf_id;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4880 purple_debug_info("yahoo", "Trying to join %s \n", args[0]);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4881
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4882 comp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4883 g_hash_table_replace(comp, g_strdup("room"), g_ascii_strdown(args[0], -1));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4884 g_hash_table_replace(comp, g_strdup("type"), g_strdup("Chat"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4885
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4886 yahoo_c_join(gc, comp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4887
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4888 g_hash_table_destroy(comp);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4889 return PURPLE_CMD_RET_OK;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4890 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4891
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4892 static PurpleCmdRet
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4893 yahoopurple_cmd_chat_list(PurpleConversation *conv, const char *cmd,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4894 char **args, char **error, void *data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4895 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4896 PurpleAccount *account = purple_conversation_get_account(conv);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4897 if (*args && args[0])
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4898 return PURPLE_CMD_RET_FAILED;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4899 purple_roomlist_show_with_account(account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4900 return PURPLE_CMD_RET_OK;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4901 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4902
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4903 static gboolean yahoo_offline_message(const PurpleBuddy *buddy)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4904 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4905 return TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4906 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4907
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4908 gboolean yahoo_send_attention(PurpleConnection *gc, const char *username, guint type)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4909 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4910 PurpleConversation *c;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4911
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4912 c = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4913 username, gc->account);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4914
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4915 g_return_val_if_fail(c != NULL, FALSE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4916
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4917 purple_debug_info("yahoo", "Sending <ding> on account %s to buddy %s.\n",
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4918 username, c->name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4919 purple_conv_im_send_with_flags(PURPLE_CONV_IM(c), "<ding>", PURPLE_MESSAGE_INVISIBLE);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4920
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4921 return TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4922 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4923
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4924 GList *yahoo_attention_types(PurpleAccount *account)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4925 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4926 static GList *list = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4927
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4928 if (!list) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4929 /* Yahoo only supports one attention command: the 'buzz'. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4930 /* This is index number YAHOO_BUZZ. */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4931 list = g_list_append(list, purple_attention_type_new("Buzz", _("Buzz"),
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4932 _("%s has buzzed you!"), _("Buzzing %s...")));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4933 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4934
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4935 return list;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4936 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4937
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4938 /************************** Plugin Initialization ****************************/
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4939 static void
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4940 yahoopurple_register_commands(void)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4941 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4942 purple_cmd_register("join", "s", PURPLE_CMD_P_PRPL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4943 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT |
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4944 PURPLE_CMD_FLAG_PRPL_ONLY,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4945 "prpl-yahoo", yahoopurple_cmd_chat_join,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4946 _("join &lt;room&gt;: Join a chat room on the Yahoo network"), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4947 purple_cmd_register("list", "", PURPLE_CMD_P_PRPL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4948 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT |
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4949 PURPLE_CMD_FLAG_PRPL_ONLY,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4950 "prpl-yahoo", yahoopurple_cmd_chat_list,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4951 _("list: List rooms on the Yahoo network"), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4952 purple_cmd_register("buzz", "", PURPLE_CMD_P_PRPL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4953 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4954 "prpl-yahoo", yahoopurple_cmd_buzz,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4955 _("buzz: Buzz a user to get their attention"), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4956 purple_cmd_register("doodle", "", PURPLE_CMD_P_PRPL,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4957 PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_PRPL_ONLY,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4958 "prpl-yahoo", yahoo_doodle_purple_cmd_start,
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4959 _("doodle: Request user to start a Doodle session"), NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4960 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4961
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4962 static PurpleAccount *find_acct(const char *prpl, const char *acct_id)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4963 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4964 PurpleAccount *acct = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4965
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4966 /* If we have a specific acct, use it */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4967 if (acct_id) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4968 acct = purple_accounts_find(acct_id, prpl);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4969 if (acct && !purple_account_is_connected(acct))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4970 acct = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4971 } else { /* Otherwise find an active account for the protocol */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4972 GList *l = purple_accounts_get_all();
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4973 while (l) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4974 if (!strcmp(prpl, purple_account_get_protocol_id(l->data))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4975 && purple_account_is_connected(l->data)) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4976 acct = l->data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4977 break;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4978 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4979 l = l->next;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4980 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4981 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4982
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4983 return acct;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4984 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4985
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4986 /* This may not be the best way to do this, but we find the first key w/o a value
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4987 * and assume it is the buddy name */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4988 static void yahoo_find_uri_novalue_param(gpointer key, gpointer value, gpointer user_data)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4989 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4990 char **retval = user_data;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4991
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4992 if (value == NULL && *retval == NULL) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4993 *retval = key;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4994 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4995 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4996
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4997 static gboolean yahoo_uri_handler(const char *proto, const char *cmd, GHashTable *params)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4998 {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
4999 char *acct_id = g_hash_table_lookup(params, "account");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5000 PurpleAccount *acct;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5001
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5002 if (g_ascii_strcasecmp(proto, "ymsgr"))
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5003 return FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5004
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5005 acct = find_acct(purple_plugin_get_id(my_protocol), acct_id);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5006
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5007 if (!acct)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5008 return FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5009
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5010 /* ymsgr:SendIM?screename&m=The+Message */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5011 if (!g_ascii_strcasecmp(cmd, "SendIM")) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5012 char *sname = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5013 g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &sname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5014 if (sname) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5015 char *message = g_hash_table_lookup(params, "m");
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5016
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5017 PurpleConversation *conv = purple_find_conversation_with_account(
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5018 PURPLE_CONV_TYPE_IM, sname, acct);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5019 if (conv == NULL)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5020 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, acct, sname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5021 purple_conversation_present(conv);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5022
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5023 if (message) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5024 /* Spaces are encoded as '+' */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5025 g_strdelimit(message, "+", ' ');
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5026 purple_conv_send_confirm(conv, message);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5027 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5028 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5029 /* else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5030 **If pidgindialogs_im() was in the core, we could use it here.
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5031 * It is all purple_request_* based, but I'm not sure it really belongs in the core
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5032 pidgindialogs_im(); */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5033
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5034 return TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5035 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5036 /* ymsgr:Chat?roomname */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5037 else if (!g_ascii_strcasecmp(cmd, "Chat")) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5038 char *rname = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5039 g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &rname);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5040 if (rname) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5041 /* This is somewhat hacky, but the params aren't useful after this command */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5042 g_hash_table_insert(params, g_strdup("room"), g_strdup(rname));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5043 g_hash_table_insert(params, g_strdup("type"), g_strdup("Chat"));
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5044 serv_join_chat(purple_account_get_connection(acct), params);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5045 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5046 /* else
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5047 ** Same as above (except that this would have to be re-written using purple_request_*)
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5048 pidgin_blist_joinchat_show(); */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5049
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5050 return TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5051 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5052 /* ymsgr:AddFriend?name */
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5053 else if (!g_ascii_strcasecmp(cmd, "AddFriend")) {
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5054 char *name = NULL;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5055 g_hash_table_foreach(params, yahoo_find_uri_novalue_param, &name);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5056 purple_blist_request_add_buddy(acct, name, NULL, NULL);
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5057 return TRUE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5058 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5059
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5060 return FALSE;
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5061 }
16ef6a9e7acd Start of splitting yahoo into two separate prpls. Not sure if this even comes
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
diff changeset
5062