--- a/src/gf_display.c Mon Aug 24 00:19:59 2009 -0500
+++ b/src/gf_display.c Wed Sep 23 23:07:54 2009 -0400
@@ -930,79 +930,9 @@
-gf_display_condense_check_buddy(GfEventInfo *info1, GfEventInfo *info2) {
- PurpleAccount *account1 = NULL, *account2 = NULL;
- PurpleBuddy *buddy1 = NULL, *buddy2 = NULL;
- const gchar *name1 = NULL, *name2 = NULL;
- buddy1 = gf_event_info_get_buddy(info1);
- buddy2 = gf_event_info_get_buddy(info2);
- /* if we don't have any buddies, we can't do anything, so bail */
- name1 = purple_buddy_get_name(buddy1);
- name2 = purple_buddy_get_name(buddy2);
- account1 = purple_buddy_get_account(buddy1);
- account2 = purple_buddy_get_account(buddy2);
- return (!g_utf8_collate(name1, name2) && account1 == account2);
-gf_display_condense_check_contact(GfEventInfo *info1, GfEventInfo *info2) {
- PurpleBuddy *buddy1 = NULL, *buddy2 = NULL;
- PurpleContact *contact1 = NULL, *contact2 = NULL;
- buddy1 = gf_event_info_get_buddy(info1);
- buddy2 = gf_event_info_get_buddy(info2);
- /* if we don't have any buddies, we can't do anything, so bail */
- contact1 = purple_buddy_get_contact(buddy1);
- contact2 = purple_buddy_get_contact(buddy2);
- return (contact1 == contact2);
-gf_display_condense_check_target(GfEventInfo *info1, GfEventInfo *info2) {
- PurpleConversation *conv1 = NULL, *conv2 = NULL;
- const gchar *target1 = NULL, *target2 = NULL;
- conv1 = gf_event_info_get_conversation(info1);
- conv2 = gf_event_info_get_conversation(info2);
- /* if we don't have any conversations, we can't do anythin, so bail */
- target1 = gf_event_info_get_target(info1);
- target2 = gf_event_info_get_target(info2);
- return (!g_utf8_collate(target1, target2));
-#define GF_DISPLAY_CHECK_PRIORITY G_STMT_START { \
- if(priority1 >= priority2) { \
- gf_display_destroy(display); \
-/* Yes this big ugly function... isn't so big and ugly anymore...
+/* Yes this big ugly function has a purpose... * It checks for existing notification from the same buddy, or conv with
- * with the same target, and condenses contacts by the use of helper funcs.
+ * with the same target, and condenses contacts. * It returns TRUE if the new notification/event should be destroyed because
* theres a matching notification that has a higher priority than the new
@@ -1013,28 +943,104 @@
GfDisplay *display = NULL;
GfEvent *event1 = NULL, *event2 = NULL;
GfEventPriority priority1, priority2;
+ PurpleBuddy *buddy1 = NULL, *buddy2 = NULL; + PurpleContact *contact1 = NULL, *contact2 = NULL; + PurpleConversation *conv1 = NULL, *conv2 = NULL; GList *l = NULL, *ll = NULL;
+ gchar *ck1 = NULL, *ck2 = NULL; + const gchar *target1 = NULL, *target2 = NULL; event1 = gf_event_info_get_event(info);
priority1 = gf_event_get_priority(event1);
+ buddy1 = gf_event_info_get_buddy(info); + conv1 = gf_event_info_get_conversation(info); + target1 = gf_event_info_get_target(info); + contact1 = purple_buddy_get_contact(buddy1); + ck1 = g_utf8_collate_key(target1, -1); for(l = displays; l; l = ll) {
display = GF_DISPLAY(l->data);
+ event2 = gf_event_info_get_event(display->info); priority2 = gf_event_get_priority(event2);
- if(gf_display_condense_check_buddy(info, display->info))
- GF_DISPLAY_CHECK_PRIORITY;
+ conv2 = gf_event_info_get_conversation(display->info); + buddy2 = gf_event_info_get_buddy(display->info); + contact2 = purple_buddy_get_contact(buddy2); + if(contact1 && contact1 == contact2) { + ck2 = g_utf8_collate_key(buddy2->name, -1); + if(!(buddy1->account == buddy2->account && + if(priority1 >= priority2) { + gf_event_info_set_is_contact(info, TRUE); + gf_display_destroy(display); - if(gf_display_condense_check_contact(info, display->info))
- GF_DISPLAY_CHECK_PRIORITY;
+ /* check for duplicate buddies */ + if(priority1 >= priority2) { + gf_display_destroy(display); + /* check for duplicate targets from the same conv */ + if(ck1 && conv1 && conv1 == conv2) { + target2 = gf_event_info_get_target(display->info); + ck2 = g_utf8_collate_key(target2, -1); - if(gf_display_condense_check_target(info, display->info))
- GF_DISPLAY_CHECK_PRIORITY;
+ if(ck2 && !strcmp(ck1, ck2)) { + if(priority1 >= priority2) { + gf_display_destroy(display); /* we only check the stack count if ret is true, because that means one
* has been removed, so we have space.