Mercurial > pidgin
comparison libpurple/protocols/yahoo/yahoo_friend.c @ 15822:32c366eeeb99
sed -ie 's/gaim/purple/g'
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 19 Mar 2007 07:01:17 +0000 |
parents | 5fe8042783c1 |
children | f0c4b4fdbd16 |
comparison
equal
deleted
inserted
replaced
15821:84b0f9b23ede | 15822:32c366eeeb99 |
---|---|
1 /* | 1 /* |
2 * gaim | 2 * purple |
3 * | 3 * |
4 * Gaim is the legal property of its developers, whose names are too numerous | 4 * Purple is the legal property of its developers, whose names are too numerous |
5 * to list here. Please refer to the COPYRIGHT file distributed with this | 5 * to list here. Please refer to the COPYRIGHT file distributed with this |
6 * source distribution. | 6 * source distribution. |
7 * | 7 * |
8 * This program is free software; you can redistribute it and/or modify | 8 * This program is free software; you can redistribute it and/or modify |
9 * it under the terms of the GNU General Public License as published by | 9 * it under the terms of the GNU General Public License as published by |
37 ret->presence = YAHOO_PRESENCE_DEFAULT; | 37 ret->presence = YAHOO_PRESENCE_DEFAULT; |
38 | 38 |
39 return ret; | 39 return ret; |
40 } | 40 } |
41 | 41 |
42 YahooFriend *yahoo_friend_find(GaimConnection *gc, const char *name) | 42 YahooFriend *yahoo_friend_find(PurpleConnection *gc, const char *name) |
43 { | 43 { |
44 struct yahoo_data *yd; | 44 struct yahoo_data *yd; |
45 const char *norm; | 45 const char *norm; |
46 | 46 |
47 g_return_val_if_fail(gc != NULL, NULL); | 47 g_return_val_if_fail(gc != NULL, NULL); |
48 g_return_val_if_fail(gc->proto_data != NULL, NULL); | 48 g_return_val_if_fail(gc->proto_data != NULL, NULL); |
49 | 49 |
50 yd = gc->proto_data; | 50 yd = gc->proto_data; |
51 norm = gaim_normalize(gaim_connection_get_account(gc), name); | 51 norm = purple_normalize(purple_connection_get_account(gc), name); |
52 | 52 |
53 return g_hash_table_lookup(yd->friends, norm); | 53 return g_hash_table_lookup(yd->friends, norm); |
54 } | 54 } |
55 | 55 |
56 YahooFriend *yahoo_friend_find_or_new(GaimConnection *gc, const char *name) | 56 YahooFriend *yahoo_friend_find_or_new(PurpleConnection *gc, const char *name) |
57 { | 57 { |
58 YahooFriend *f; | 58 YahooFriend *f; |
59 struct yahoo_data *yd; | 59 struct yahoo_data *yd; |
60 const char *norm; | 60 const char *norm; |
61 | 61 |
62 g_return_val_if_fail(gc != NULL, NULL); | 62 g_return_val_if_fail(gc != NULL, NULL); |
63 g_return_val_if_fail(gc->proto_data != NULL, NULL); | 63 g_return_val_if_fail(gc->proto_data != NULL, NULL); |
64 | 64 |
65 yd = gc->proto_data; | 65 yd = gc->proto_data; |
66 norm = gaim_normalize(gaim_connection_get_account(gc), name); | 66 norm = purple_normalize(purple_connection_get_account(gc), name); |
67 | 67 |
68 f = g_hash_table_lookup(yd->friends, norm); | 68 f = g_hash_table_lookup(yd->friends, norm); |
69 if (!f) { | 69 if (!f) { |
70 f = yahoo_friend_new(); | 70 f = yahoo_friend_new(); |
71 g_hash_table_insert(yd->friends, g_strdup(norm), f); | 71 g_hash_table_insert(yd->friends, g_strdup(norm), f); |
135 if (f->ip) | 135 if (f->ip) |
136 g_free(f->ip); | 136 g_free(f->ip); |
137 g_free(f); | 137 g_free(f); |
138 } | 138 } |
139 | 139 |
140 void yahoo_process_presence(GaimConnection *gc, struct yahoo_packet *pkt) | 140 void yahoo_process_presence(PurpleConnection *gc, struct yahoo_packet *pkt) |
141 { | 141 { |
142 GSList *l = pkt->hash; | 142 GSList *l = pkt->hash; |
143 YahooFriend *f; | 143 YahooFriend *f; |
144 char *who = NULL; | 144 char *who = NULL; |
145 int value = 0; | 145 int value = 0; |
158 | 158 |
159 l = l->next; | 159 l = l->next; |
160 } | 160 } |
161 | 161 |
162 if (value != 1 && value != 2) { | 162 if (value != 1 && value != 2) { |
163 gaim_debug_error("yahoo", "Received unknown value for presence key: %d\n", value); | 163 purple_debug_error("yahoo", "Received unknown value for presence key: %d\n", value); |
164 return; | 164 return; |
165 } | 165 } |
166 | 166 |
167 g_return_if_fail(who != NULL); | 167 g_return_if_fail(who != NULL); |
168 | 168 |
169 f = yahoo_friend_find(gc, who); | 169 f = yahoo_friend_find(gc, who); |
170 if (!f) | 170 if (!f) |
171 return; | 171 return; |
172 | 172 |
173 if (pkt->service == YAHOO_SERVICE_PRESENCE_PERM) { | 173 if (pkt->service == YAHOO_SERVICE_PRESENCE_PERM) { |
174 gaim_debug_info("yahoo", "Setting permanent presence for %s to %d.\n", who, (value == 1)); | 174 purple_debug_info("yahoo", "Setting permanent presence for %s to %d.\n", who, (value == 1)); |
175 /* If setting from perm offline to online when in invisible status, | 175 /* If setting from perm offline to online when in invisible status, |
176 * this has already been taken care of (when the temp status changed) */ | 176 * this has already been taken care of (when the temp status changed) */ |
177 if (value == 2 && f->presence == YAHOO_PRESENCE_ONLINE) { | 177 if (value == 2 && f->presence == YAHOO_PRESENCE_ONLINE) { |
178 } else { | 178 } else { |
179 if (value == 1) /* Setting Perm offline */ | 179 if (value == 1) /* Setting Perm offline */ |
180 f->presence = YAHOO_PRESENCE_PERM_OFFLINE; | 180 f->presence = YAHOO_PRESENCE_PERM_OFFLINE; |
181 else | 181 else |
182 f->presence = YAHOO_PRESENCE_DEFAULT; | 182 f->presence = YAHOO_PRESENCE_DEFAULT; |
183 } | 183 } |
184 } else { | 184 } else { |
185 gaim_debug_info("yahoo", "Setting session presence for %s to %d.\n", who, (value == 1)); | 185 purple_debug_info("yahoo", "Setting session presence for %s to %d.\n", who, (value == 1)); |
186 if (value == 1) | 186 if (value == 1) |
187 f->presence = YAHOO_PRESENCE_ONLINE; | 187 f->presence = YAHOO_PRESENCE_ONLINE; |
188 else | 188 else |
189 f->presence = YAHOO_PRESENCE_DEFAULT; | 189 f->presence = YAHOO_PRESENCE_DEFAULT; |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 void yahoo_friend_update_presence(GaimConnection *gc, const char *name, | 193 void yahoo_friend_update_presence(PurpleConnection *gc, const char *name, |
194 YahooPresenceVisibility presence) | 194 YahooPresenceVisibility presence) |
195 { | 195 { |
196 struct yahoo_data *yd = gc->proto_data; | 196 struct yahoo_data *yd = gc->proto_data; |
197 struct yahoo_packet *pkt = NULL; | 197 struct yahoo_packet *pkt = NULL; |
198 YahooFriend *f; | 198 YahooFriend *f; |
204 if (!f) | 204 if (!f) |
205 return; | 205 return; |
206 | 206 |
207 /* No need to change the value if it is already correct */ | 207 /* No need to change the value if it is already correct */ |
208 if (f->presence == presence) { | 208 if (f->presence == presence) { |
209 gaim_debug_info("yahoo", "Not setting presence because there are no changes.\n"); | 209 purple_debug_info("yahoo", "Not setting presence because there are no changes.\n"); |
210 return; | 210 return; |
211 } | 211 } |
212 | 212 |
213 if (presence == YAHOO_PRESENCE_PERM_OFFLINE) { | 213 if (presence == YAHOO_PRESENCE_PERM_OFFLINE) { |
214 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM, | 214 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM, |
215 YAHOO_STATUS_AVAILABLE, yd->session_id); | 215 YAHOO_STATUS_AVAILABLE, yd->session_id); |
216 | 216 |
217 yahoo_packet_hash(pkt, "ssss", | 217 yahoo_packet_hash(pkt, "ssss", |
218 1, gaim_connection_get_display_name(gc), | 218 1, purple_connection_get_display_name(gc), |
219 31, "1", 13, "2", 7, name); | 219 31, "1", 13, "2", 7, name); |
220 } else if (presence == YAHOO_PRESENCE_DEFAULT) { | 220 } else if (presence == YAHOO_PRESENCE_DEFAULT) { |
221 if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) { | 221 if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) { |
222 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM, | 222 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM, |
223 YAHOO_STATUS_AVAILABLE, yd->session_id); | 223 YAHOO_STATUS_AVAILABLE, yd->session_id); |
224 | 224 |
225 yahoo_packet_hash(pkt, "ssss", | 225 yahoo_packet_hash(pkt, "ssss", |
226 1, gaim_connection_get_display_name(gc), | 226 1, purple_connection_get_display_name(gc), |
227 31, "2", 13, "2", 7, name); | 227 31, "2", 13, "2", 7, name); |
228 } else if (yd->current_status == YAHOO_STATUS_INVISIBLE) { | 228 } else if (yd->current_status == YAHOO_STATUS_INVISIBLE) { |
229 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_SESSION, | 229 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_SESSION, |
230 YAHOO_STATUS_AVAILABLE, yd->session_id); | 230 YAHOO_STATUS_AVAILABLE, yd->session_id); |
231 yahoo_packet_hash(pkt, "ssss", | 231 yahoo_packet_hash(pkt, "ssss", |
232 1, gaim_connection_get_display_name(gc), | 232 1, purple_connection_get_display_name(gc), |
233 31, "2", 13, "1", 7, name); | 233 31, "2", 13, "1", 7, name); |
234 } | 234 } |
235 } else if (presence == YAHOO_PRESENCE_ONLINE) { | 235 } else if (presence == YAHOO_PRESENCE_ONLINE) { |
236 if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) { | 236 if (f->presence == YAHOO_PRESENCE_PERM_OFFLINE) { |
237 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM, | 237 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_PERM, |
238 YAHOO_STATUS_AVAILABLE, yd->session_id); | 238 YAHOO_STATUS_AVAILABLE, yd->session_id); |
239 yahoo_packet_hash(pkt, "ssss", | 239 yahoo_packet_hash(pkt, "ssss", |
240 1, gaim_connection_get_display_name(gc), | 240 1, purple_connection_get_display_name(gc), |
241 31, "2", 13, "2", 7, name); | 241 31, "2", 13, "2", 7, name); |
242 yahoo_packet_send_and_free(pkt, yd); | 242 yahoo_packet_send_and_free(pkt, yd); |
243 } | 243 } |
244 | 244 |
245 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_SESSION, | 245 pkt = yahoo_packet_new(YAHOO_SERVICE_PRESENCE_SESSION, |
246 YAHOO_STATUS_AVAILABLE, yd->session_id); | 246 YAHOO_STATUS_AVAILABLE, yd->session_id); |
247 yahoo_packet_hash(pkt, "ssss", | 247 yahoo_packet_hash(pkt, "ssss", |
248 1, gaim_connection_get_display_name(gc), | 248 1, purple_connection_get_display_name(gc), |
249 31, "1", 13, "1", 7, name); | 249 31, "1", 13, "1", 7, name); |
250 } | 250 } |
251 | 251 |
252 if (pkt) | 252 if (pkt) |
253 yahoo_packet_send_and_free(pkt, yd); | 253 yahoo_packet_send_and_free(pkt, yd); |