comparison finch/gntblist.c @ 22212:6bb29f94862c

Add API so Finch doesn't need to touch the internals of PurpleBlistNode.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Sat, 26 Jan 2008 20:32:26 +0000
parents 1e103e1b845f
children 16ff37f64e29
comparison
equal deleted inserted replaced
22211:eddcf0f2da51 22212:6bb29f94862c
2156 } 2156 }
2157 2157
2158 static int 2158 static int
2159 blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2) 2159 blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2)
2160 { 2160 {
2161 while ((n1 = n1->prev) != NULL) 2161 while ((n1 = purple_blist_node_get_sibling_prev(n1)) != NULL)
2162 if (n1 == n2) 2162 if (n1 == n2)
2163 return 1; 2163 return 1;
2164 return -1; 2164 return -1;
2165 } 2165 }
2166 2166
2169 { 2169 {
2170 const char *s1, *s2; 2170 const char *s1, *s2;
2171 char *us1, *us2; 2171 char *us1, *us2;
2172 int ret; 2172 int ret;
2173 2173
2174 if (n1->type != n2->type) 2174 if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2))
2175 return blist_node_compare_position(n1, n2); 2175 return blist_node_compare_position(n1, n2);
2176 2176
2177 switch (n1->type) 2177 switch (purple_blist_node_get_type(n1))
2178 { 2178 {
2179 case PURPLE_BLIST_CHAT_NODE: 2179 case PURPLE_BLIST_CHAT_NODE:
2180 s1 = purple_chat_get_name((PurpleChat*)n1); 2180 s1 = purple_chat_get_name((PurpleChat*)n1);
2181 s2 = purple_chat_get_name((PurpleChat*)n2); 2181 s2 = purple_chat_get_name((PurpleChat*)n2);
2182 break; 2182 break;
2204 static int 2204 static int
2205 blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2) 2205 blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2)
2206 { 2206 {
2207 int ret; 2207 int ret;
2208 2208
2209 if (n1->type != n2->type) 2209 if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2))
2210 return blist_node_compare_position(n1, n2); 2210 return blist_node_compare_position(n1, n2);
2211 2211
2212 switch (n1->type) { 2212 switch (purple_blist_node_get_type(n1)) {
2213 case PURPLE_BLIST_CONTACT_NODE: 2213 case PURPLE_BLIST_CONTACT_NODE:
2214 n1 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n1); 2214 n1 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n1);
2215 n2 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n2); 2215 n2 = (PurpleBlistNode*)purple_contact_get_priority_buddy((PurpleContact*)n2);
2216 /* now compare the presence of the priority buddies */ 2216 /* now compare the presence of the priority buddies */
2217 case PURPLE_BLIST_BUDDY_NODE: 2217 case PURPLE_BLIST_BUDDY_NODE:
2249 blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2) 2249 blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2)
2250 { 2250 {
2251 int ret; 2251 int ret;
2252 PurpleBuddy *b1, *b2; 2252 PurpleBuddy *b1, *b2;
2253 2253
2254 if (n1->type != n2->type) 2254 if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2))
2255 return blist_node_compare_position(n1, n2); 2255 return blist_node_compare_position(n1, n2);
2256 2256
2257 switch (n1->type) { 2257 switch (purple_blist_node_get_type(n1)) {
2258 case PURPLE_BLIST_BUDDY_NODE: 2258 case PURPLE_BLIST_BUDDY_NODE:
2259 b1 = (PurpleBuddy*)n1; 2259 b1 = (PurpleBuddy*)n1;
2260 b2 = (PurpleBuddy*)n2; 2260 b2 = (PurpleBuddy*)n2;
2261 ret = purple_log_get_total_size(PURPLE_LOG_IM, b2->name, b2->account) - 2261 ret = purple_log_get_total_size(PURPLE_LOG_IM, b2->name, b2->account) -
2262 purple_log_get_total_size(PURPLE_LOG_IM, b1->name, b1->account); 2262 purple_log_get_total_size(PURPLE_LOG_IM, b1->name, b1->account);