Changeset 038d17f for protocols/jabber/jabber.c
- Timestamp:
- 2006-10-08T16:11:16Z (18 years ago)
- Branches:
- master
- Children:
- 861c199
- Parents:
- 36e9f62
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
r36e9f62 r038d17f 79 79 jd->server ++; 80 80 81 jd->node_cache = xt_new_node( "cache", NULL, NULL);81 jd->node_cache = g_hash_table_new_full( g_str_hash, g_str_equal, NULL, jabber_cache_entry_free ); 82 82 83 83 /* Figure out the hostname to connect to. */ … … 125 125 g_free( jd->txq ); 126 126 127 xt_free_node( jd->node_cache ); 127 g_hash_table_destroy( jd->node_cache ); 128 128 129 xt_free( jd->xt ); 129 130 … … 164 165 165 166 return l; 167 } 168 169 static void jabber_get_info( struct gaim_connection *gc, char *who ) 170 { 171 struct xt_node *node; 172 173 node = xt_new_node( "query", NULL, NULL ); 174 xt_add_attr( node, "xmlns", "http://jabber.org/protocol/disco#info" ); 175 node = jabber_make_packet( "iq", "get", who, node ); 176 jabber_cache_add( gc, node ); 177 178 jabber_write_packet( gc, node ); 166 179 } 167 180 … … 194 207 static void jabber_keepalive( struct gaim_connection *gc ) 195 208 { 196 struct jabber_data *jd = gc->proto_data;197 struct xt_node *c, *tmp;198 199 209 /* Just any whitespace character is enough as a keepalive for XMPP sessions. */ 200 210 jabber_write( gc, "\n", 1 ); 201 211 202 /* Let's abuse this keepalive for garbage collection of the node cache too. 203 It runs every minute, so let's mark every node with a special flag the 204 first time we see it, and clean it up the second time (clean up all 205 packets with the flag set). 206 207 node->flags is normally only used by xmltree itself for parsing/handling, 208 so it should be safe to use the variable for gc. */ 209 210 /* This horrible loop is explained in xmltree.c. Makes me wonder if maybe I 211 didn't choose the perfect data structure... */ 212 for( c = jd->node_cache->children; c; c = c->next ) 213 if( !( c->flags & XT_SEEN ) ) 214 break; 215 216 /* Now c points at the first unflagged node (or at NULL). Clean up 217 everything until that point. */ 218 while( jd->node_cache->children != c ) 219 { 220 /* 221 printf( "Cleaning up:\n" ); 222 xt_print( jd->node_cache->children ); 223 */ 224 225 tmp = jd->node_cache->children->next; 226 xt_free_node( jd->node_cache->children ); 227 jd->node_cache->children = tmp; 228 } 229 230 /* Now flag the ones that were still unflagged. */ 231 for( c = jd->node_cache->children; c; c = c->next ) 232 { 233 /* 234 printf( "Flagged:\n" ); 235 xt_print( c ); 236 */ 237 238 c->flags |= XT_SEEN; 239 } 212 /* This runs the garbage collection every minute, which means every packet 213 is in the cache for about a minute (which should be enough AFAIK). */ 214 jabber_cache_clean( gc ); 240 215 } 241 216 … … 253 228 ret->set_away = jabber_set_away; 254 229 // ret->set_info = jabber_set_info; 255 //ret->get_info = jabber_get_info;230 ret->get_info = jabber_get_info; 256 231 ret->add_buddy = jabber_add_buddy; 257 232 ret->remove_buddy = jabber_remove_buddy;
Note: See TracChangeset
for help on using the changeset viewer.