Mercurial > pidgin.yaz
comparison src/blist.c @ 9949:ced29c7b396c
[gaim-migrate @ 10845]
(00:25:10) LSchiere: datallah: commit message?
(00:25:40) datallah: LSchiere: nah.. nothing comes to me
datallah undertook the heroic effort of merging in all the .rejs and fixing
things up from the unclean merge of the status rewrite
committer: Tailor Script <tailor@pidgin.im>
author | Luke Schierer <lschiere@pidgin.im> |
---|---|
date | Sat, 04 Sep 2004 04:27:05 +0000 |
parents | e4a27c9aec4c |
children | cc2e6dd43613 |
comparison
equal
deleted
inserted
replaced
9948:b13013595c08 | 9949:ced29c7b396c |
---|---|
119 } | 119 } |
120 } | 120 } |
121 } | 121 } |
122 } | 122 } |
123 | 123 |
124 static void gaim_contact_compute_priority_buddy(GaimContact *contact) | 124 void gaim_contact_compute_priority_buddy(GaimContact *contact) |
125 { | 125 { |
126 GaimBlistNode *bnode; | 126 GaimBlistNode *bnode; |
127 int contact_score = INT_MAX; | 127 GaimBuddy *new_priority = NULL; |
128 | 128 |
129 g_return_if_fail(contact != NULL); | 129 g_return_if_fail(contact != NULL); |
130 | 130 |
131 contact->priority = NULL; | 131 contact->priority = NULL; |
132 for (bnode = ((GaimBlistNode*)contact)->child; bnode; bnode = bnode->next) { | 132 for (bnode = ((GaimBlistNode*)contact)->child; |
133 bnode != NULL; | |
134 bnode = bnode->next) | |
135 { | |
133 GaimBuddy *buddy; | 136 GaimBuddy *buddy; |
134 int score = 0; | 137 GaimPresence *presence; |
135 | 138 |
136 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | 139 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
137 continue; | 140 continue; |
141 | |
138 buddy = (GaimBuddy*)bnode; | 142 buddy = (GaimBuddy*)bnode; |
143 | |
139 if (!gaim_account_is_connected(buddy->account)) | 144 if (!gaim_account_is_connected(buddy->account)) |
140 continue; | 145 continue; |
141 | 146 if (new_priority == NULL) |
142 if (!GAIM_BUDDY_IS_ONLINE(buddy)) | 147 new_priority = buddy; |
143 score += gaim_prefs_get_int("/core/contact/offline_score"); | 148 else |
144 if (buddy->uc & UC_UNAVAILABLE) | 149 { |
145 score += gaim_prefs_get_int("/core/contact/away_score"); | 150 int cmp; |
146 if (buddy->idle) | 151 |
147 score += gaim_prefs_get_int("/core/contact/idle_score"); | 152 presence = gaim_buddy_get_presence(buddy); |
148 | 153 |
149 score += gaim_account_get_int(buddy->account, "score", 0); | 154 cmp = gaim_presence_compare(gaim_buddy_get_presence(new_priority), |
150 | 155 gaim_buddy_get_presence(buddy)); |
151 if (score < contact_score) { | 156 |
152 contact->priority = buddy; | 157 if (cmp > 0 || (cmp == 0 && |
153 contact_score = score; | 158 gaim_prefs_get_bool("/core/contact/last_match"))) |
154 } | 159 { |
155 if (gaim_prefs_get_bool("/core/contact/last_match")) | 160 new_priority = buddy; |
156 if (score == contact_score) | 161 } |
157 contact->priority = buddy; | 162 } |
158 } | 163 } |
164 | |
165 contact->priority = new_priority; | |
159 } | 166 } |
160 | 167 |
161 static gboolean blist_save_callback(gpointer data) | 168 static gboolean blist_save_callback(gpointer data) |
162 { | 169 { |
163 gaim_blist_sync(); | 170 gaim_blist_sync(); |
234 ops->set_visible(gaimbuddylist, show); | 241 ops->set_visible(gaimbuddylist, show); |
235 } | 242 } |
236 | 243 |
237 void gaim_blist_update_buddy_status(GaimBuddy *buddy, int status) | 244 void gaim_blist_update_buddy_status(GaimBuddy *buddy, int status) |
238 { | 245 { |
246 #if 0 | |
239 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 247 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
240 int old_status; | 248 int old_status; |
241 | 249 |
242 g_return_if_fail(buddy != NULL); | 250 g_return_if_fail(buddy != NULL); |
243 | 251 |
254 } | 262 } |
255 } | 263 } |
256 | 264 |
257 if (ops && ops->update) | 265 if (ops && ops->update) |
258 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); | 266 ops->update(gaimbuddylist, (GaimBlistNode*)buddy); |
267 #endif | |
259 } | 268 } |
260 | 269 |
261 static gboolean presence_update_timeout_cb(GaimBuddy *buddy) | 270 static gboolean presence_update_timeout_cb(GaimBuddy *buddy) |
262 { | 271 { |
263 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 272 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
338 | 347 |
339 if (ops && ops->update) | 348 if (ops && ops->update) |
340 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | 349 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); |
341 } | 350 } |
342 | 351 |
352 #if 0 | |
343 void gaim_blist_update_buddy_idle(GaimBuddy *buddy, int idle) | 353 void gaim_blist_update_buddy_idle(GaimBuddy *buddy, int idle) |
344 { | 354 { |
345 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 355 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
346 | 356 |
347 g_return_if_fail(buddy != NULL); | 357 g_return_if_fail(buddy != NULL); |
353 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); | 363 gaim_contact_compute_priority_buddy(gaim_buddy_get_contact(buddy)); |
354 | 364 |
355 if (ops && ops->update) | 365 if (ops && ops->update) |
356 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | 366 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); |
357 } | 367 } |
358 | 368 #endif |
359 void gaim_blist_update_buddy_evil(GaimBuddy *buddy, int warning) | |
360 { | |
361 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | |
362 | |
363 g_return_if_fail(buddy != NULL); | |
364 | |
365 if (buddy->evil == warning) | |
366 return; | |
367 | |
368 buddy->evil = warning; | |
369 | |
370 if (ops && ops->update) | |
371 ops->update(gaimbuddylist, (GaimBlistNode *)buddy); | |
372 } | |
373 | 369 |
374 void gaim_blist_update_buddy_icon(GaimBuddy *buddy) | 370 void gaim_blist_update_buddy_icon(GaimBuddy *buddy) |
375 { | 371 { |
376 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 372 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
377 | 373 |
622 | 618 |
623 g_return_val_if_fail(account != NULL, FALSE); | 619 g_return_val_if_fail(account != NULL, FALSE); |
624 g_return_val_if_fail(screenname != NULL, FALSE); | 620 g_return_val_if_fail(screenname != NULL, FALSE); |
625 | 621 |
626 buddy = g_new0(GaimBuddy, 1); | 622 buddy = g_new0(GaimBuddy, 1); |
627 buddy->account = account; | 623 buddy->account = account; |
628 buddy->name = g_strdup(screenname); | 624 buddy->name = g_strdup(screenname); |
629 buddy->alias = g_strdup(alias); | 625 buddy->alias = g_strdup(alias); |
626 buddy->presence = gaim_presence_new_for_buddy(buddy); | |
627 | |
630 gaim_blist_node_initialize_settings((GaimBlistNode *)buddy); | 628 gaim_blist_node_initialize_settings((GaimBlistNode *)buddy); |
631 ((GaimBlistNode *)buddy)->type = GAIM_BLIST_BUDDY_NODE; | 629 ((GaimBlistNode *)buddy)->type = GAIM_BLIST_BUDDY_NODE; |
632 | 630 |
633 if (ops && ops->new_node) | 631 if (ops && ops->new_node) |
634 ops->new_node((GaimBlistNode *)buddy); | 632 ops->new_node((GaimBlistNode *)buddy); |
1168 if (ops && ops->update) { | 1166 if (ops && ops->update) { |
1169 ops->update(gaimbuddylist, gnode); | 1167 ops->update(gaimbuddylist, gnode); |
1170 for (node = gnode->child; node; node = node->next) | 1168 for (node = gnode->child; node; node = node->next) |
1171 ops->update(gaimbuddylist, node); | 1169 ops->update(gaimbuddylist, node); |
1172 } | 1170 } |
1171 #endif | |
1173 } | 1172 } |
1174 | 1173 |
1175 void gaim_blist_remove_contact(GaimContact *contact) | 1174 void gaim_blist_remove_contact(GaimContact *contact) |
1176 { | 1175 { |
1177 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; | 1176 GaimBlistUiOps *ops = gaimbuddylist->ui_ops; |
1621 { | 1620 { |
1622 g_return_val_if_fail(buddy != NULL, NULL); | 1621 g_return_val_if_fail(buddy != NULL, NULL); |
1623 | 1622 |
1624 return (GaimContact*)((GaimBlistNode*)buddy)->parent; | 1623 return (GaimContact*)((GaimBlistNode*)buddy)->parent; |
1625 } | 1624 } |
1625 | |
1626 GaimPresence *gaim_buddy_get_presence(const GaimBuddy *buddy) | |
1627 { | |
1628 g_return_val_if_fail(buddy != NULL, NULL); | |
1629 return buddy->presence; | |
1630 } | |
1631 | |
1626 | 1632 |
1627 GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy) | 1633 GaimGroup *gaim_find_buddys_group(GaimBuddy *buddy) |
1628 { | 1634 { |
1629 g_return_val_if_fail(buddy != NULL, NULL); | 1635 g_return_val_if_fail(buddy != NULL, NULL); |
1630 | 1636 |