annotate src/protocols/yahoo/yahoo_friend.c @ 12370:0d4484b7a46a

[gaim-migrate @ 14674] Changing the prototypes here broke FreeBSD. Looking at what was changed, I think reverting the changes for this file is best. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 06 Dec 2005 07:59:07 +0000
parents b41b75f709e4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
1 /*
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
2 * gaim
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
3 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
4 * Gaim is the legal property of its developers, whose names are too numerous
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
5 * to list here. Please refer to the COPYRIGHT file distributed with this
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
6 * source distribution.
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
7 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
9 * it under the terms of the GNU General Public License as published by
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
11 * (at your option) any later version.
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
12 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
16 * GNU General Public License for more details.
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
17 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
21 *
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
22 */
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
23
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
24 #include "internal.h"
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
25 #include "prpl.h"
9279
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
26 #include "util.h"
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
27 #include "debug.h"
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
28
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
29 #include "yahoo_friend.h"
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
30
9283
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
31 static YahooFriend *yahoo_friend_new(void)
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
32 {
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
33 YahooFriend *ret;
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
34
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
35 ret = g_new0(YahooFriend, 1);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
36 ret->status = YAHOO_STATUS_OFFLINE;
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
37 ret->presence = YAHOO_PRESENCE_DEFAULT;
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
38
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
39 return ret;
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
40 }
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
41
9279
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
42 YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name)
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
43 {
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
44 struct yahoo_data *yd;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
45 const char *norm;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
46
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
47 g_return_val_if_fail(gc != NULL, NULL);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
48 g_return_val_if_fail(gc->proto_data != NULL, NULL);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
49
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
50 yd = gc->proto_data;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
51 norm = gaim_normalize(gaim_connection_get_account(gc), name);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
52
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
53 return g_hash_table_lookup(yd->friends, norm);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
54 }
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
55
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
56 YahooFriend *yahoo_friend_find_or_new(GaimConnection *gc, const char *name)
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
57 {
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
58 YahooFriend *f;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
59 struct yahoo_data *yd;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
60 const char *norm;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
61
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
62 g_return_val_if_fail(gc != NULL, NULL);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
63 g_return_val_if_fail(gc->proto_data != NULL, NULL);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
64
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
65 yd = gc->proto_data;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
66 norm = gaim_normalize(gaim_connection_get_account(gc), name);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
67
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
68 f = g_hash_table_lookup(yd->friends, norm);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
69 if (!f) {
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
70 f = yahoo_friend_new();
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
71 g_hash_table_insert(yd->friends, g_strdup(norm), f);
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
72 }
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
73
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
74 return f;
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
75 }
1eaa4d8dcf26 [gaim-migrate @ 10082]
Tim Ringenbach <marv@pidgin.im>
parents: 9278
diff changeset
76
9281
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
77 void yahoo_friend_set_ip(YahooFriend *f, const char *ip)
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
78 {
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
79 if (f->ip)
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
80 g_free(f->ip);
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
81 f->ip = g_strdup(ip);
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
82 }
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
83
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
84 const char *yahoo_friend_get_ip(YahooFriend *f)
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
85 {
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
86 return f->ip;
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
87 }
adde46ad65e9 [gaim-migrate @ 10084]
Tim Ringenbach <marv@pidgin.im>
parents: 9279
diff changeset
88
9283
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
89 void yahoo_friend_set_game(YahooFriend *f, const char *game)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
90 {
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
91 if (f->game)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
92 g_free(f->game);
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
93
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
94 if (game)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
95 f->game = g_strdup(game);
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
96 else
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
97 f->game = NULL;
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
98 }
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
99
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
100 const char *yahoo_friend_get_game(YahooFriend *f)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
101 {
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
102 return f->game;
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
103 }
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
104
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
105 void yahoo_friend_set_status_message(YahooFriend *f, char *msg)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
106 {
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
107 if (f->msg)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
108 g_free(f->msg);
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
109
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
110 f->msg = msg;
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
111 }
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
112
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
113 const char *yahoo_friend_get_status_message(YahooFriend *f)
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
114 {
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
115 return f->msg;
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
116 }
66ff39319900 [gaim-migrate @ 10086]
Tim Ringenbach <marv@pidgin.im>
parents: 9282
diff changeset
117
9284
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
118 void yahoo_friend_set_buddy_icon_need_request(YahooFriend *f, gboolean needs)
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
119 {
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
120 f->bicon_sent_request = !needs;
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
121 }
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
122
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
123 gboolean yahoo_friend_get_buddy_icon_need_request(YahooFriend *f)
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
124 {
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
125 return !f->bicon_sent_request;
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
126 }
fe0291162312 [gaim-migrate @ 10087]
Tim Ringenbach <marv@pidgin.im>
parents: 9283
diff changeset
127
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
128 void yahoo_friend_free(gpointer p)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
129 {
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
130 YahooFriend *f = p;
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
131 if (f->msg)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
132 g_free(f->msg);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
133 if (f->game)
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
134 g_free(f->game);
9282
fe7db2ea4a1e [gaim-migrate @ 10085]
Tim Ringenbach <marv@pidgin.im>
parents: 9281
diff changeset
135 if (f->ip)
fe7db2ea4a1e [gaim-migrate @ 10085]
Tim Ringenbach <marv@pidgin.im>
parents: 9281
diff changeset
136 g_free(f->ip);
9278
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
137 g_free(f);
2401a9ef74a0 [gaim-migrate @ 10081]
Tim Ringenbach <marv@pidgin.im>
parents:
diff changeset
138 }
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
139
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
140 void yahoo_process_presence(GaimConnection *gc, struct yahoo_packet *pkt)
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
141 {
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
142 GSList *l = pkt->hash;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
143 YahooFriend *f;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
144 char *who = NULL;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
145 int value = 0;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
146
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
147 while (l) {
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
148 struct yahoo_pair *pair = l->data;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
149
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
150 switch (pair->key) {
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
151 case 7:
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
152 who = pair->value;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
153 break;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
154 case 31:
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
155 value = strtol(pair->value, NULL, 10);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
156 break;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
157 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
158
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
159 l = l->next;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
160 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
161
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
162 if (value != 1 && value != 2) {
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
163 gaim_debug_error("yahoo", "Received unknown value for presence key: %d\n", value);
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
164 return;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
165 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
166
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
167 g_return_if_fail(who != NULL);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
168
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
169 f = yahoo_friend_find(gc, who);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
170 if (!f)
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
171 return;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
172
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
173 if (pkt->service == YAHOO_SERVICE_PRESENCE_PERM) {
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
174 gaim_debug_info("yahoo", "Setting permanent presence for %s to %d.\n", who, (value == 1));
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
175 /* If setting from perm offline to online when in invisible status,
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
176 * this has already been taken care of (when the temp status changed) */
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
177 if (value == 2 && f->presence == YAHOO_PRESENCE_ONLINE) {
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
178 } else {
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
179 if (value == 1) /* Setting Perm offline */
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
180 f->presence = YAHOO_PRESENCE_PERM_OFFLINE;
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
181 else
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
182 f->presence = YAHOO_PRESENCE_DEFAULT;
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
183 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
184 } else {
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
185 gaim_debug_info("yahoo", "Setting session presence for %s to %d.\n", who, (value == 1));
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
186 if (value == 1)
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
187 f->presence = YAHOO_PRESENCE_ONLINE;
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
188 else
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
189 f->presence = YAHOO_PRESENCE_DEFAULT;
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
190 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
191 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
192
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
193 void yahoo_friend_update_presence(GaimConnection *gc, const char *name,
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
194 YahooPresenceVisibility presence)
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
195 {
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
196 struct yahoo_data *yd = gc->proto_data;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
197 struct yahoo_packet *pkt = NULL;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
198 YahooFriend *f;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
199
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
200 if (!yd->logged_in)
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
201 return;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
202
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
203 f = yahoo_friend_find(gc, name);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
204 if (!f)
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
205 return;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
206
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
207 /* No need to change the value if it is already correct */
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
208 if (f->presence == presence) {
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
209 gaim_debug_info("yahoo", "Not setting presence because there are no changes.\n");
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
210 return;
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
211 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
212
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
213 if (presence == YAHOO_PRESENCE_PERM_OFFLINE) {
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
214 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM,
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
215 YAHOO_STATUS_AVAILABLE, yd->session_id);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
216
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
217 yahoo_packet_hash(pkt, "ssss",
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
218 1, gaim_connection_get_display_name(gc),
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
219 31, "1", 13, "2", 7, name);
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
220 } else if (presence == YAHOO_PRESENCE_DEFAULT) {
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
221 if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) {
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
222 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM,
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
223 YAHOO_STATUS_AVAILABLE, yd->session_id);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
224
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
225 yahoo_packet_hash(pkt, "ssss",
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
226 1, gaim_connection_get_display_name(gc),
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
227 31, "2", 13, "2", 7, name);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
228 } else if (yd->current_status == YAHOO_STATUS_INVISIBLE) {
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
229 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_SESSION,
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
230 YAHOO_STATUS_AVAILABLE, yd->session_id);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
231 yahoo_packet_hash(pkt, "ssss",
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
232 1, gaim_connection_get_display_name(gc),
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
233 31, "2", 13, "1", 7, name);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
234 }
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
235 } else if (presence == YAHOO_PRESENCE_ONLINE) {
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
236 if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) {
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
237 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM,
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
238 YAHOO_STATUS_AVAILABLE, yd->session_id);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
239 yahoo_packet_hash(pkt, "ssss",
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
240 1, gaim_connection_get_display_name(gc),
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
241 31, "2", 13, "2", 7, name);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
242 yahoo_packet_send_and_free(pkt, yd);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
243 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
244
12010
b41b75f709e4 [gaim-migrate @ 14303]
Mark Doliner <mark@kingant.net>
parents: 11644
diff changeset
245 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_SESSION,
10989
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
246 YAHOO_STATUS_AVAILABLE, yd->session_id);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
247 yahoo_packet_hash(pkt, "ssss",
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
248 1, gaim_connection_get_display_name(gc),
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
249 31, "1", 13, "1", 7, name);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
250 }
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
251
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
252 if (pkt)
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
253 yahoo_packet_send_and_free(pkt, yd);
b4919e8c634c [gaim-migrate @ 12827]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 9284
diff changeset
254 }